Lang5 – A Stack Based Array Language(lang5.sourceforge.net)
lang5.sourceforge.net
Lang5 – A Stack Based Array Language
http://lang5.sourceforge.net/tiki-index.php
8 comments
Stack is cool as long as it's the top element or two that you care about. Anything more complex, and you want (well, I do) some sort of a binding syntax, so that it is possible to refer to the value symbolically. I find all those swaps and dups impossible to reason about.
I've found that there can be some cool stack combinators (like Factor's dip), but binding in stack based languages is nice in that it lets you effectively turn off having to think about the stack in depth, which frees up mental resources for thinking about the problem at hand.
Dup and Swap are all about the two top values though.
Otherwise I strongly agree, I like to use bindings for anything non-obvious.
In my own designs [0] I tend to add named arguments [1] as well, which helps a lot.
[0] https://github.com/codr7/gfoo
[1] https://github.com/codr7/gfoo#methods
Otherwise I strongly agree, I like to use bindings for anything non-obvious.
In my own designs [0] I tend to add named arguments [1] as well, which helps a lot.
[0] https://github.com/codr7/gfoo
[1] https://github.com/codr7/gfoo#methods
Kinda neat, but it breaks the APL convention of reading right to left. J version of their example:
+/ 1+ i.100
Interesting that it was developed for the HP48:
http://archive.vector.org.uk/art10500710
+/ 1+ i.100
Interesting that it was developed for the HP48:
http://archive.vector.org.uk/art10500710
Being Forth-inspired, you might expect left-to-right...? It’s more of Forth-with-arrays than APL-with-stacks.
Given that I read left to right usually, I think that this is a good change
Pretty sure you don't do that in coding. I do in R sometimes because it has ->, but generally speaking, coding is actually done right to left, just like K and Hebrew.
Uh? No I write code (C++) left to right most of the time, and when I have to do a right to left update, the IDE's stupid autocomplete (vscode but other IDE are the same) keeps making annoying unneeded changes.
Literally everyone writes J or K from left to right also: it's not read that way any more than C is.
Love it aesthetics!
Not sure if it has its niche though. I mean, "stack based" is not really a feature on its own, and we have tons of options to do tensor processing in conventional languages; but the conception is awesome.
Not sure if it has its niche though. I mean, "stack based" is not really a feature on its own, and we have tons of options to do tensor processing in conventional languages; but the conception is awesome.
Related from 2018: https://news.ycombinator.com/item?id=17286754
While I like its 'style', I'm not sure about the Perl5 implementation, is the speed 'good enough'?
It should evaluate from right to left, like all other array languages. Looks neat though!
This is a mistake perpetuated from old array languages.
Evaluation from left to right is more natural to people using latin alphabet.
It's totally arbitrary anyways. I suspect the only reason why there is right to left evaluation in APL family is to support assignment like this:
Evaluation from left to right is more natural to people using latin alphabet.
It's totally arbitrary anyways. I suspect the only reason why there is right to left evaluation in APL family is to support assignment like this:
x: 1 + 2 + 3
which would have to be the following in left to right 1 + 2 + 3 :xI think most people would agree that 'a:f g h x' is easier to read than 'x h g f:a'. This may be an artifact from familiarity from math or something else, but I think the point still stands. I've personally never found RPN languages easy to read.
A different APL in Forth: http://www.cosy.com/CoSy/
LessDmesg(1)
Stack based languages replace "dealing with the computer" with "dealing with the stack". Except the stack is always invisible, because it's a runtime artifact and not a code artifact. Their front-page example neatly dodges this, but their examples on the about page make this much more visible. For instance, here's their prime finder: