← Back to context

Comment by 01HNNWZ0MV43FF

1 year ago

Wikipedia says that came from Modula, but I can't find why Modula did it or why Lua decided to copy it.

I thought I read somewhere that Lua was meant for use by non-programmers, so the "end" would be easier to type and read than curly brackets.

Modula is based on pascal which is based on algol. The "end" thing is in the first version of algol from 1958. This is 14 years before C was invented.

Presumably they thought the more verbose syntax would be more readable.

  • Algol (and Pascal) originally did the same thing that C did, except that you used `begin` and `end` instead of `{` and `}` when you needed a compound statement as a branch etc.

    Modula changed it so that all structured constructs implicitly introduced a compound statement, and terminated one where appropriate (e.g. on `else`), but this still required some end marker for the last one.

    If the question is why `begin` and `end` and not `{` and `}` - for one thing, Algol was designed to be the language you'd write reference implementations of algorithms in for publication, so readability was more important than terseness. For another, it predates ASCII, and not all charsets in use at the time even had `{` and `}` as symbols.