⇐ MY QUORA-INDEX QUORA - my answered Questions

QUORA - my answered Questions

Q016: What makes Forth more powerful than Lisp?

It is not easy to compare these two languages. They are pearls in the universe of programming languages.

I?m biased with Forth and have some experience with Lisp. I try to point out what I think is an advantage over Lisp (letting out the opposite).

How much smaller is Forth (some k) compared to lisp (some megabytes) (or any other language) and what does that mean?:

One person can easily hold full control over the whole Forth system. I mean the interpreter, compiler, storage, debugger, editor, etc. It?s not a big deal for a system so small to change the compiler for different needs or different targets (metacompiler). For example, to run Forth on or with OpenCL.

There's another feature in Forth which is almost unique: the compiler for definitions (or words) is not a single program, which handles parsing, control structures, statements and so on; it's split up into a simple loop which does parsing, and Forth words which are responsible for control structures. There is no difference between Forth system words, and user defined words, thus you can write your own control structures which act as a compiler.

Lisp and most other languages protect the programmer to access memory directly. This leads to slow and expensive serialization of objects for crossing the application borders. it is not a trivial task to save objects to disk or send and receive objects from network or save the whole memory to disk and resume later. In Forth this becomes one simple write of the memory segment.

Lisp and most other languages protect the programmer to access the return and data stack. With Forth one can build really easy (and cheap in terms of CPU resources) some kind of multitasking, cooperative or preemptive or to build co routines. Compared to Lisps expensive continuations.

There is another thing which I dislike about almost every language. The infix or prefix notation. This is not the way we are thinking and is not the way the computer is working. To write code from left to right is natural for me and the computer, so why not doing it this way?

The way Forth programs are written don?t impose the need of a garbage collector. Even memory management could be very easy (no need for malloc/free). There are other solutions, load a small application execute it and forget it. No need for memory management at all. Useful results are stored in a database.

In a language with direct memory access, writing a persistent manager is almost no work (some lines of code).

One can easily write Forth code with a dumb editor. because there are almost no syntax rules, and no syntax checks are needed. Slime and Emacs are not needed for a comfortable interactive development experience.

Plain Forth doesn't have many abilities. It's always much work to get a complicated job done. However, Forth is the ultimate language for building extensions. Programming in Forth is generating higher levels of abstractions, until you have a language well fitted to solve your problem. The simplicity of the underlying system allows it to rely on it.

The art of programming is to reduce or eliminate complexity. I think that we have lost this ability and are doing the opposite. Forth imposes this kind of programming (simplicity) while Lisp does not.

I have many more arguments (how simple could it be to build a massive parallel Forth system? On cheap processors?), but I think I set my point - simplicity rules.