Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Forth Interpreter in Java

Here I found a Simple Forth Interpreter implemented in Java.
However I don't understand the significance of it if I want to use it?

What could be the advantage of the Forth Interpreter:

  • If the final compiled code to be executed by the JVM is still "Byte code" what would we the Forth Interpreter be doing?
  • Will it help in writing efficient/tight programs?
  • Will I be writing my code in Forth and the interpreter will convert it to Java?

Your thoughts...

like image 385
Kevin Boyd Avatar asked Sep 12 '09 19:09

Kevin Boyd


1 Answers

The author on the page describes at as implementing a subset of FORTH and being suitable for incorporationg in other applications; presumably it is intended to provide a scripting capability for an application. It's fairly unlikely that the system works by spitting out java or JVM byte codes; it almostly certainly uses an interpreter written in Java.

Traditionally, a FORTH interpreter can be implemented in a very small memory footprint. I know someone that implemented one on a COSMAC and the core interpreter was 30 bytes long. The stack oriented byte code was also very compact as it did not need to specify the location of operands - it just read from the stack and deposited the result on the top of the stack. This made it popular in embedded systems circles where the small overhead of the interpreter was more than offset by the compact representation of the program logic.

These days it's less important as machines tend to be much larger, although digitalross makes a good point about other situations where FORTH is still used.

like image 180
ConcernedOfTunbridgeWells Avatar answered Sep 28 '22 04:09

ConcernedOfTunbridgeWells