I have trouble accepting that 'the compiler knows better'

I started as a software engineer in 1978, so I’m a bit ‘set in my ways’. That being said, I was very intrigued by the GO language, but quickly found a distaste for the way the compiler forces a restriction on me:

func main() {
}

compiles just fine, but:

func main()
{
}

gives a syntax error. I did some reading on this, and found that the problem is that the compiler has “automatic semicolon insertion”, where the compiler will put in semicolons where it THINKS they need to be.

No problem, I thought. I’ll just end the first line with a line continuation character, and that will make the compiler happy. But wait! There is no line continuation character. Why? Because the language designers insist that it isn’t needed.

I understand that Ken Thompson had much to do with the design of the language, and I would never imply that I know more about language design than he. That being said, I have written a number of parsers for various languages over the years and a line continuation character is very simple to implement.

I do not like to accept the idea that ‘they know better’. I have this problem with cars with automatic transmissions, Windows 11, and now this. Someone please help me to understand why this behavior by the compiler is ‘a good thing’ - with details, not just ‘because’.

Google the go proverb “Gofmt’s style is no one’s favorite, yet gofmt is everyone’s favorite”. The point of it is: it might not be exactly how you want to format your code, and it might not be how the original creator of Go wants to format the code (because it was argued about by many people). But it being opinionated is the entire point and the value it brings to the table. It’s not that anybody “knows better”.

Go has great tooling, one of the best stdlibs I’ve ever experienced, a mature ecosystem for things that fall outside the stdlib, and a great community (in my opinion of course!). It can be jarring at first because it’s very different. But if any of that sounds appealing to you, stick with it and you might just end up loving it. I have gotten a lot of use out of it in my career and I really enjoy it for building web APIs and CLI-ish projects.

1 Like