Hacker News new | past | comments | ask | show | jobs | submit login
A tiny interpreter for a stack-based language (flowsnake.org)
29 points by JGM564 on Dec 21, 2008 | hide | past | favorite | 5 comments



Stack-based languages can be fun to play around with.

Way back when, I used Quartus Forth (http://www.quartus.net/products/forth/) to write a few small games for my Palm. Quartus is (was? looks dead...) an onboard Forth compiler -- Forth is a very compact language which is handy when you're writing code with a stylus.

The thing I remember most about it was that the actual coding was probably more fun than that playing the games I wrote. There's a kind of puzzle solving element to learning a stack-based language. I already knew how I'd write such-and-such function in a C-like language, it was all about arranging words in the most succinct, efficient manner possible to create the equivalent function.

I don't think I'd go back to Forth or another stack-based language for a project these days, but I'm glad for the time I spent playing with it.


The best thing about stack-based languages are that the parsers are usually dead simple. I did one in Haskell, never released, and the parser consisted of one standard-library function call: words.


his anonymous blocks ( 1 + ) look straight from false, http://wouter.fov120.com/false/ with different syntax, but the same idea: 2 [ 1 + ] ! leaves 3 as top of stack.


Joy, as well. (http://www.latrobe.edu.au/philosophy/phimvt/joy.html)

Putting words in a list is also a way to do quoting, so you get the lispy code-is-data property without necessarily needing Forth-style immediate words.


Nice tutorial thanks!




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: