News for hackers. Stuff that matters.
Re:Pascal in Forth (1983) by sph on Sunday December 31, 2023 @06:37AM (#38823348)
What is a compiler? This actually parses a subset of Pascal and translates it into another representation. Perhaps you can call it an interpreter.

Compiler = parse + codegen — Later, the OS executes.

Interpreter = parse + execute

On metaprogrammable languages like Forth, what is the point of compiling to disk, if the final goal is to execute it anyway? ;)

Re:Pascal in Forth (1983) by astrobe_ on Sunday December 31, 2023 @12:09PM (#38825526)
> This actually parses a subset of Pascal and translates it into another representation. Perhaps you can call it an interpreter.

I didn't read TFA thoroughly, but traditionally a compiler that translates not to machine code but into another language (source level) is called a "transpiler".

> On metaprogrammable languages like Forth, what is the point of compiling to disk, if the final goal is to execute it anyway? ;)

Lua and probably other languages do have a "pre-compiler", something that parses and compiles to bytecode. This reminds of image-based systems, except it is only one half of them (the other half being the value of variables, stack state, etc.).

It must be much more rare for Forth dialects, as the parsing step is really simple - almost trivial. It has nothing to do with metaprogramming, though - actually, it adds a tiny bot of complexity (must check the "immediate" flag when compiling).