
Lang5 – A Stack Based Array Language - doener
http://lang5.sourceforge.net/tiki-index.php
======
jdmichal
> Obviously this program [in C] contains a lot of things that deal with the
> computer and not the problem of calculating a sum.

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:

    
    
        : prime_list
          1 - iota 2 +  dup dup dup
          '* outer  swap in not  select
        ;
    
        100 prime_list .

~~~
eequah9L
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.

~~~
yumaikas
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.

------
scottlocklin
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](http://archive.vector.org.uk/art10500710)

~~~
renox
Given that I read left to right usually, I think that this is a _good_ change

~~~
scottlocklin
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.

~~~
renox
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.

~~~
scottlocklin
Literally everyone writes J or K from left to right also: it's not read that
way any more than C is.

------
okaleniuk
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.

------
dang
Related from 2018:
[https://news.ycombinator.com/item?id=17286754](https://news.ycombinator.com/item?id=17286754)

------
renox
While I like its 'style', I'm not sure about the Perl5 implementation, is the
speed 'good enough'?

------
smabie
It should evaluate from right to left, like all other array languages. Looks
neat though!

~~~
snidane
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:

    
    
      x: 1 + 2 + 3
    

which would have to be the following in left to right

    
    
      1 + 2 + 3 :x

~~~
smabie
I 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.

------
5-
A different APL in Forth:
[http://www.cosy.com/CoSy/](http://www.cosy.com/CoSy/)

