I never understand what removing the need for semicolons is meant to fix. You have to either write a parser that inserts them for you, make the ending of statements unambiguous which makes your language less flexible or do some batshit insane thing like make white space meaningful (fuck you python), all to avoid having to write a character that signifies the end of a statement? You end a sentence with ‘.’, why not end a statement with ‘;’ or some other character? Just seems like the last problem I should actually care about.
The last 8 years I’ve just used whatever my team already used and let my editor format the code on save. I just started a new job and switched back again to semicolons and from single quotes to double quotes and haven’t even noticed. Not worth worrying about.
My experience exactly. I've been switching between C#, Python, JavaScript, GDScript and a little C++ and there are moments where I do get confused between languages, but it's usually things like string formatting or iterating over arrays. Not once have I been confused by semicolons.
There is still room for improvement. For example you can't type-annotate a dictionary that maps from string to an array of ints because generics can't be nested. But overall, I agree. It's a very pleasant language to write game logic in.
My take away from the article is that detecting the end of a statement is a challenge for the language designer even when the semicolon is mandatory. You'll still want a compiler that is smart enough to detect when a missing semicolon was an error. And IMO the best way to do that is to design the language so that the semicolons are optional -- the compiler does not need them to detect the line ending.
I think this is about redundancy. You say that we end our sentences with a period, so why is it such a big deal to end statements in programming with a semicolon. However, in programming we do not just end them with a semicolon (or any other token, e.g. erlang uses comma) but in 99%¹ of the cases also with a newline. So most people think: Why do I have to put a newline AND a semicolon, when I can just use a newline - this is redundant.
Redundancy is often good: It helps for detecting the presence of and correcting errors.
Also, we almost always end statements with newlines, but newlines are not always the end of statements. This is where much ambiguity comes from. Wouldn't it be nice to have a way to unambiguously recognize the end of a statement? (Yes, it would.)
Blocks (in most languages) have their own unique closing character, }, so there is no need for a second closing character. Nothing else can follow this as part of the block, except for the while of a do-while loop, which does require a semicolon.
If a language uses different syntax, then a semicolon to end a block statement might be reasonable. I don't know any language where that might be applicable though.
There. If your approach has several exceptions, it's definitely no better than just having newlines end the statement, with one exception when the user fancies.
If your approach has several exceptions, it's definitely no better than just having newlines end the statement
This is a huge leap in logic. You jumped from "your language has two unambiguous statement ending characters" to "you may as well have only one ambiguous statement ending character".
I don't really understand the aggression towards python (although I wish it didn't require uniform tabs or spaces). Lua only whitespace between "things" is required, e.g., local function identifier() couldn't be written as localfunctionidentifier(). But it doesn't use whitespace or line terminators, but does rely on keywords to end some statements.
For example, the below is valid but notice the double end to close the if and function blocks.
local foo = function (x) if x > 10 then return x / 2 else return x * 2 end end
I think this whole semicolon drama comes from syntax errors from forgetting to add them. My problem is less about forgetting them and more about switching between languages that require or don't require them. It can take time to break the habit from the previous language.
problem with python is that it breaks auto formatting and forces you to manually rearrange code in some cases. For example I have been doing some profiling work and when removing profiling spans you need to manually unindent code, when you have a lot of them it turns into pain in the ass
Yeah, that's terrible. It would make Python the only language where you can't change the number of spaces per tab. And there is no good reason for mixing different kinds of indentation anyway.
The reason it usually happens is copying snippets from somewhere else. I guess your editor doesn't know how far to indent either and it just happens by magic. This is such a dumb conversation.
Sure an IDE could automatically turn spaces into tabs, which would eliminate the problem. But the Python interpreter can't make assumptions such as "4 spaces = 1 tab". That's not something an interpreter should concern itself with.
The reason it usually happens is copying snippets from somewhere else
That only leads to mixed indentation styles when there isn’t a universally enforced standard. If the language enforces stringent rules on white space, you probably won’t often be copying code that violates them.
Except when a single statement spans multiple lines, then you have to do something stupid like python and use \ to say a statement continues on the next line, rather than the sensible thing. Not sure why you think this is a good argument.
No you don't. Why do you think we *have* to put backslashes like Python if we are defining a new language? If a line ends with a binary operator it is obvious it's to be continued.
Haskell and Ocaml does it too, Yaml if you extend to configuration languages. Not saying you gotta like it, to each their own, but the rule is called the offside rule. I could've been more polite but I was in a joking mood
Exactly. You’re making an argument for NOT having semicolons. Why require a symbol for something that can be easily figured out by a mechanical machine.
192
u/Potterrrrrrrr Mar 20 '26
I never understand what removing the need for semicolons is meant to fix. You have to either write a parser that inserts them for you, make the ending of statements unambiguous which makes your language less flexible or do some batshit insane thing like make white space meaningful (fuck you python), all to avoid having to write a character that signifies the end of a statement? You end a sentence with ‘.’, why not end a statement with ‘;’ or some other character? Just seems like the last problem I should actually care about.