The article is fine, but I have one serious concern.
How on earth do you prefer tabs to curly brackets?!?!
Readability? It is crucial for indicating which code belongs to specific blocks to help the compiler/interpreter and humans alike. There are primarily two methods for structuring code to achieve this: rigid indentation rules, as seen in Python, or the use of brackets. Elixir and Ruby use end blocks, which essentially serve as a substitute for curly braces.
Similarly, when considering JSON versus YAML or TOML for human readability, the same principles apply. Personally, I find indented code more readable, but this can be easily attained in most languages with universal code formatting rules and intelligent code editors that highlight different elements to improve readability.
It’s crazy that we have totally opposite views here.
I find code block which are delineated by brackets so much more readable than ones delineated by invisible characters. Especially at a glance
I don’t love do..end either, but still prefer them to arguing with Python about the level of indenting not being correct or that spaces were used somewhere somehow.
> this can be easily attained in most languages with universal code formatting rules and intelligent code editors that highlight different elements to improve readability.
Ofc, none of this is a practical issue, but that’s what makes it a fun topic of discussion ;)
My biggest issue with tabs over curly braces is that it makes copy / pasting code insanely difficult. That alone makes tabs a bad choice.
Why not both? Approximately no one uses braces without indentation, and that's trivially enforceable with a code formatter. But I personally find that the redundant signal of the braces makes things much more readable than in the languages that lack that redundancy!
Every human communication mechanism includes deliberate redundancy to ensure that the meaning gets through even in suboptimal situations. Programming languages are somewhat unique in having a strong movement towards eliminating all redundancy.
Gotta love that this comment has the most replies :D
I don't understand how people prefer curly braces, a character that is almost always has other meanings within the same language, instead of something like `end`. To that (ahem) end I don't understand how people prefer `end` to the exceptionally clear `endif`. Turns out different people have different preferences :D
It’s always a fun little, largely meaningless, bike shed. ;)
I don’t understand how people prefer invisible characters which change sized depending on the editor to visible ones which are consistent and easy to scan for.
Oh boy there is a whoooooole fun thing on that here: https://github.com/prettier/prettier/issues/7475
And ya I also don't appreciate having to care about formatting for my code to compile and not being able to put debug statements at column 1 so they stick out like a sore thumb, though I suppose the solution to the latter is to stop being a puts/print debugger but, like... no :)
It’s quicker to move code around with whitespace because you can just tab it in and out, move lines etc.
The best solution is to ban tabs entirely from the syntax - only allow spaces in multiples of 2.
I can’t agree with that.
Curly bracket blocks are obviously visible at a glance. If I incorrectly move one around it’s obvious.
If I shift tab a section of python code around, I may be breaking an if state without noticing if I didn’t pay attention to a specific colon on one line.
Imo s-expressions are the easiest to move around, but have the same issue of being hard to scan as tabs.
Whitespace works better in the context of statically typed functional programming, I’ll give you that!
It's easier and quicker to move code around with braces when you're using vim. Vim has motions for selecting, editing, copying, etc everything between two braces. Without the braces, it makes moving that code around much more difficult, and error prone.
Although I agree in general you can configure capture and move to be whitespace sensitive, for example by relying on tree-sitter.
I like to structure my code as an outline.
Helps readability, quick visual hint of structure and i don't have to keep track of open-end brackets.
Though i much prefer spaces to tabs.
> How on earth do you prefer tabs to curly brackets?!?!
In general, how is significant whitespace both a thing, and popular?
i don't mind as long as it's simple and regular (python is ok for instance)
Personally, I think using invisible, editor dependent characters is neither simple nor regular.
i kinda agree but in practice it stopped being an issue 25 years ago
It didn't stop being an issue 25 years ago.
Python of course still has invisible issues like silent invalid identations in `if` clauses, for example. Well, you could fix those with copious amounts of tests, of course.
Same goes for YAML where invalid identation can will still be easily valid YAML.
the honest amount of time I had syntactic issues with python in 10 years was 1.5 (my emacs removes whitespace between methods which made an admin unable to binpaste it directly on a remote machine)
never once did we (and I have some bad apples at work) hit a problematic indentation in conditionals or other structs
i'm honestly surprised
Yeah we’re just bike shedding here ;)
This same discussion was had a long time ago when python was being more commonly used. I figure people just get used to it, and now we're in the inverse.
"Get used to it" doesn't mean "like it" or "prefer it".
I've gotten used to a lot of things that I'd rather not have to deal with.
> people just get used to it
it's not just a matter of preference -- "no-curly-brace" dogma means it's impossible to do multiline lambdas in python
This doesn't seemed to have affected pythons growth and popularity.
Isn’t python currently the most popular programming language?
JavaScript (and variants) is
Python is slightly above it on the StackOverflow 2024 developer survey.
https://survey.stackoverflow.co/2024/technology#2-programmin...
The "admired and desired" chart has nothing to do with actual use.
According to this chart[0] higher on the same survey report, JavaScript is the #1 most used, and Python is #3.
But, I don't see this as a contest... being "the most popular" programming language doesn't automatically make it the best choice for a given task.
[0]: https://survey.stackoverflow.co/2024/technology#most-popular...
you forgot to add TS and JS together
While not the be all end all, TIOBE disagrees.
https://www.tiobe.com/tiobe-index/
I think since the AI boom, Python took over.
I'm not here to take a stance on Python vs Javascript, but I am here to remind people that TIOBE is utter nonsense with no informational value whatsoever. Please stop linking it.
It has exactly as much value as discussing whether Python or JavaScript is more popular.
Which is to say, very little.