Remix.run Logo
troupo 2 days ago

Wirth was obsessed with the idea of creating the absolutely minimal useful language, and many of his languages' warts come from that.

Variables are at the top because:

- you immediately see them (so, perhaps, easier to reason about a function? I dunno)

- the compiler is significantly simplified (all of Wirths' languages compile superfast and, if I'm not mistaken, all are single-pass compilers)

However, I feel that Wirth was overly dogmatic on his approaches. And "variables must always be at the top" is one of those.

gingerBill a day ago | parent | next [-]

This has nothing to do with "dogma" and something simpler. It has nothing to do with "immediately see them".

Hint: This about this from a single pass compiler basis and how much memory needs to be reserved from the procedure's stack frame.

troupo a day ago | parent [-]

"This is nothing to do with something simpler" and "this is from a single pass compiler".

Are you sure you actually read my second bullet point?

If you read texts and papers by Wirth you'll see a single theme emerge: simplicity. Everything he didn't consider simple was thrown away and derided.

NuclearPM a day ago | parent | prev [-]

Lua is single pass too and doesn’t have the same restrictions.

troupo 16 hours ago | parent [-]

Wirth is also from a time when resources were incredibly constrained. So it was a combination of his ideas for what a PL should be: easy to understand, easy to learn, powerful enough to do everything he needed. And the compiler for the language also needed to be the same.

Unfortunately he got kinda stuck in that, and you can see it in all the Oberon flavors: he was clearly fighting against the limitations he imposed, but couldn't break out if them.