2 ms·
Is there a reason why programming languages use semicolons instead of dots as terminators?
by k__ 7y ago
Is there a reason why programming languages use semicolons instead of dots as terminators?
- randiantech 7y agoI guess because benefits of 'dot notation' vastly overpass the ones of eol-with-dot.
- muricula 7y agoI always figured its position on the querty keyboard had something to do with it, but would love to know the actual history.
- drivers99 7y agoA lot of programming languages are descendants of ALGOL [1], where the ; is the separator, not a terminator (you don't have to use it on the last statement of a block of code). Pascal (being based on algol) is the same, and the final "end." statement of the program, which is the main program, has a period/full stop. See end of this sample: [2] A begin / end block is one statement so they end like so "end;" unless it's the last one in a procedure, in which case you don't need the semi-colon. C was similar, except they made ; a terminator instead of separator, but you don't have to put it at the end of being/end blocks. C just uses { } to make it clear. But then, in C++ I always forget to put ; at the end of a class definition. I get why it's there, but it looks more like a function definition to me which doesn't need a semicolon at the end. Many languages are also from C or at least the Algol family tree (but usually C), like C++, Java, Javascript, etc. More about ALGOL: https://en.wikipedia.org/wiki/ALGOL https://en.wikipedia.org/wiki/ALGOL [1] Algol sample: http://sandbox.mc.edu/~bennet/cs404/doc/primes_alg.html http://sandbox.mc.edu/~bennet/cs404/doc/primes_alg.html [2] Pascal sample: http://courses.washington.edu/css448/zander/Code/array.p http://courses.washington.edu/css448/zander/Code/array.p
- reallydude 7y agosome languages (eg Erlang) do use dots as terminators. Dots are harder to see and verify. Imagine: A = something+"some string.".
- equalunique 7y agoErlang and prolog use dots in this way.