Live data from Hacker News

Crafting Interpreters

craftinginterpreters.com

61–62 of 62 posts

Re: Crafting Interpreters

#61

Earlier quoted context omitted.

I don't really know what you mean by "worst-designed syntax". Do you mean that the design process was bad, or that the result is bad?

I meant exactly what the parent-comment pointed out - that C can't be parsed without a symbol table. Like the example on wikipedia: A * B; Which either represents a multiplication or a pointer of type A* to B, depending what the symbol table looks like. That means parsing C is impossible without these hacks, and you need to basically parse the whole file to build up this information. A lot text editors which only sup…

So you were criticizing the C language syntax, without considering the context which it was designed in.

Just to give this context a little bit more substance, Pascal was designed to work on a mainframe which could address up to 4MB of RAM, with a typical setup of around 1MB (it's actually not the real amounts: the CDC-6600 the values are 128Kwords, but it had 60 bits word). These machine were beasts designed for scientific computation.

The first C compiler was implemented on a PDP-11, which could handle up to 64KB of RAM, and had 16bits words.

I assume that these constraints had a heavy influence on how each language was designed and implemented.

Note that I wasn't aware of all these details before writing this comment, I had to check.

See: http://pascal.hansotten.com/niklaus-wirth/zurich-pascal-comp...

Regarding the C compiler, it is likely that the first version was written in assembly language, which was later "translated" to C.

An early version of the compiler can be found there: https://github.com/theunafraid/first_c_compiler and does look like assembly hand converted to (early) C.

Post reply on HN