May the Forth be with you

If the software on the Death Star were written in anything, it was likely Forth. Forth is an interesting language. Firstly the languages mechanism is based entirely on a stack. That’s right, a STACK.

So being an interpreted environment, adding 6 and 23 together can be done in the following manner:

6 23 + . <enter> 29 ok

Forth interprets 6 and 23 as numbers and pushes them onto the stack. Both “+” and “.” are considered pre-defined words, and therefore are identified and applied. The “+” adds 6 and 23 and leaves the answer, 29, on the stack. The word “.” removes 29 from the stack and prints it to standard output.

In many respects, Forth is NOTHING like a traditional compiler. It’s environment is interpreted, and is more akin to an operating system in how it works.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s