
Fif, a stack-based scripting language - tosh
http://benzaporzan.me/blog/2018/5/28/fif__an_introduction/
======
haolez
For anyone out there with an interest in stack-based languages, I highly
recommend the book "Thinking Forth" ([http://thinking-
forth.sourceforge.net/](http://thinking-forth.sourceforge.net/)). It is free
and "open source".

It is a short read and it attacks some of our dogmas as programmers, such as
the high level/low level abstractions. I'm not saying it is right in its
claims, but it is a very provoking read and will make you aware of your own
dogmas.

~~~
terminalcommand
Thanks for the recommendation, when I was in high school I had followed a
different tutorial and even spent a whole summer holiday trying to build a
cargo-cult Forth interpreter in JS to convince my friends to try Forth. But
then I lost interest.

Now that I'm much older I think I will take my shot at reading a more advanced
book on Forth.

------
j-walker
Relevant Chappelle's Show clip?

[https://youtu.be/HeOVbeh2yr0?t=318](https://youtu.be/HeOVbeh2yr0?t=318)

------
camtarn
Does anybody else find the mix of prefix and postfix slightly odd?

For instance, in the repl functions, why is it "see <function name>" not
"<function name> see"?

Most of the repls I've used use the same function invocation syntax for built
in repl functions as for language ones, although obviously this doesn't _have_
to be the case.

~~~
Avshalom
Because _functionname_ first would cause it to execute the function on
whatever is on top of the stack.

Most stack languages i've seen have the occasional bit of prefix hanging
around things like definitions or flow control.

~~~
camtarn
Ah, interesting. And I guess it's easier to make it prefix than to require the
function name be a string or symbol.

Yeah, I noticed that Fif uses prefix for function defs, but I figured that
might be a pragmatic decision.

~~~
Avshalom
Yeah, Forth for instance has

: Function (comment) function body ;

The colon, name and stack comment are all in prefix position. But in an
interpreted environment you could maybe swap the semicolon to prefix and the
name to postfix but you're still stuck with _some_ prefix token to prevent
execution.

Forth also has

 _Bool_ if _code_ else _code_ which is essentially prefix. But it boils down
to the same reason, you need some prefix to delay execution anyway.

From a sort of conceptual level this is all fine anyway. A big part of stack
languages is how they lead to a data flow sort of programming rather than some
fundamentalist belief in postfix syntax. So when there is a language construct
that doesn't benefit-from/contribute-to that data flow style people choose
syntax they find comfortable or readable which is sometimes prefix or even
infix.

