Hacker News new | ask | show | jobs
by stackghost 17 days ago
Semantic indentation is fundamentally an insane design. And I don't mean "insane" as a colloquialism for "dumb". I mean it is literally not a sane choice to make.

English would make a horrid programming language, so being close to it is not a plus.

5 comments

In the age of auto-formatters, I have less and less sympathy for this point of view.

Any widely used formatter indents along semantics anyway, so why clutter your code with curly braces everywhere if stucture is clear from indentation? Might as well make it semantic.

Before auto-formatters, there was the occasional case where you could argue that some quick hack made something more readable, at the expense of less consistency and wasted time arguing about this in code reviews. But that ship has sailed, arguably rightfully so.

And that doesn't even bring the LLM angle. If code is generated by a machine anyway and you just review it, if even that, why still bash indentation as a semantic construct?

If you have to run your source code through a formatter to make sure it doesn’t have mixed tabs and spaces that is not the flex you seem to think it is.

If you’re going to just have an LLM write all the code anyway why bother with a slow janky mess like python at all? Just make it write rust or java or go or literally anything.

Imagine having a magical machine that can write code in any programming language ever conceived, and you ask it to pick the language whose community thinks virtualenvs are a reasonable solution as opposed to a mark of profound shame. Couldn’t be me.

> Just make it write rust or java or go or literally anything.

Not literally anything. Just go the full distance and have it directly output binary. No need for any intermediate code at all.

I think it makes a lot of sense.

Nearly everybody agrees that a neat formatting style is better and more readable than a messy inconsistent one. So while designing a programing language intended to be highly readable we jump two steps ahead. mandatory linting, make the neat format part of the syntax, remove the parts of the syntax now superfluous due to the mandatory neat format, and you have python.

> Semantic indentation is fundamentally an insane design

That is a common complaint against Python, and tbh it also made me uneasy at first.

But honest question: Do you write any Python yourself?

I ask because I’ve only heard this objection from people who do not write Python at all.

IME, people soften up on it after some use. I find that this is the case for many (visual) aspects of syntax.

Considering the endless arguments over C syntax I really don't see what is so weird about Python indentation. It has the nice effect of making code look a lot more consistent.
> English would make a horrid programming language, [...]

We now have definitive proof that this is incorrect: LLMs make using English - and any other natural language - very straight-forward to instruct machines. Similar to how the compilers and interpreters make the bastardized subset of natural language that we formalize into "programming languages" translatable into machine language. Ultimately the goal is identical: human-machine communication.