Follow

In every programming language I've ever heard of, program control flows left→right and then top→bottom. That is, this psudo code:

{ print "1" } { print "a" }
{ print "2" } { print "b" }
{ print "3" } { print "c" }

would print 1a2b3c

Are there any languages (even eso-langs/DSLs) that invert that order, so that the above would print 123abc?

It occurs to me that a left-to-right control flow would be a good fit for a lot of "pipeline" type data work, and I'm curious if anyone has tried it

@codesections I guess in some lazy-language you could have evaluation done at a later time and so actually do this one reversed or even sorted

@codesections do-notation in most fp languages is
value <- op
for binding monadic computations
which is essentially right-to-left dataflow

@codesections the closest I can think of is something like a verilog fork/join where all the lines are executed logically in parallel ?

@codesections
There's one eso language that is all about paths in an ascii grid, but I don't remember the name

@codesections
As for the pipeline model, that's arguably how a lot of functional languages are written (f . g . h(x))

@pettter

> As for the pipeline model, that's arguably how a lot of functional languages are written (f . g . h(x))

Yeah, that's the sort of thing I was thinking of. Because that model loses some of it's left-to-right flow as the function names grow beyond one letter.

You end up with something like

some_list.map(|a_mapper|)
.filter(|filter_fn|)
.sort(|sort_fn|)

Which is still ok – good, even! – but not as left-to-right anymore

@pettter @codesections I think you may be thinking of Befunge or one of its derivatives?

@codesections Not exactly what you're asking, but the closest thing I can think of is that function composition in functional languages can often go both ways. For example, nested function calls like a(b(c(d(e(f))))) can be represented in Elm as:

e f |> d |> c |> b |> a

or:

a <| b <| c <| d <| e f

@ayo @codesections That also made me think of the difference between left associative and right associative operators in even e.g. C.

@codesections Look at Brainfuck and Befunge, which express their programs on a 2D surface, and where their program counters have the concept of a current direction.

@codesections Oops. Brainfuck is apparently one dimensional. Disregard that one.

@codesections
AFAIK, Forth would be so. And other RPN based languages, if there are any.

@rudolf @codesections codesection's example is going from "row major" to "column major", not reversal of the resulting total ordering, though. (Also, Factor, Postscript, Joy...)

@rudolf @codesections Thinking about it, RPN languages are just like conventional imperative languages in this regard; data is processed and declared from left to right, line by line, as opposed to top-down column by column.

@codesections There is the apl "family" of languages that go from right to left.
@codesections Just see this -> https://www.youtube.com/watch?v=_DTpQ4Kk2wA
In apl, data flows through procedures from right to left.

Some esolangs have 2d execution flow if you're interested.

@tequillaThirst @asterope

> APL is an underrated gem

Strong agree. In fact, despite my commitment to free software, I came within a hair of seriously committing to programming in Dyalog APL (a proprietary language) because it's just that good.

(But then I discovered which – despite taking a vastly different approach – gives me much of what I loved about APL while also being *extremely* open source)

@tequillaThirst @asterope

Also, if your comment that

> APL is an underrated gem

wasn't a reference to the classic comparison between Lisp and APL, it really should have been!

> APL is like a beautiful diamond – flawless, beautifully symmetrical. But you can't add anything to it. If you try to glue on another diamond, you don't get a bigger diamond. Lisp is like a ball of mud. Add more and it's still a ball of mud – it still looks like Lisp.

en.wikipedia.org/wiki/Big_ball

@codesections I've been working with the Chunks and Tasks programming model, see chunks-and-tasks.org/, where inside your function you register tasks for execution later. The order of execution can be restricted by data dependencies but is otherwise arbitrary. When two tasks can run in any order, they can also run in parallel. Your example has no deps. so the order would be arbitrary or all could run in parallel. However operations like "print" are forbidden, you can only output via return. 😉

@codesections I'm not sure if I already showed you this, but I spent a while last year experimenting with a postfix shell that I wanted to be more "horizontal" rather than vertical. Here's a couple of 2-minute demos:

archive.org/details/akkartik-2

archive.org/details/akkartik-2

archive.org/details/akkartik-2

@codesections I know (from a video on the subject, not personal experience) that the Sega Saturn had a video chip that would execute six assembly instructions in parallel and thus you would write code more or less like that with each column being its own quasi execution chain. Apparently it was *very* difficult to use properly and thus contributed to the system's downfall.

Sign in to participate in the conversation
Fosstodon

Fosstodon is an English speaking Mastodon instance that is open to anyone who is interested in technology; particularly free & open source software.