4 ms·
I hated significant whitespace when I tried Python first time. Years later I found Nim and indentation didn't bother me as much. Maybe we both just got bad fir
by archargelod 1y ago
I hated significant whitespace when I tried Python first time. Years later I found Nim and indentation didn't bother me as much.
Maybe we both just got bad first expression with most popular, but unfortunately not a good language? =)
- zahlman 1y agoI've really never understood where this aesthetic preference comes from. Back when most of my code was in C or C++ (or Java), I was told all the time, sure you can omit these braces for a single-statement block, but you shouldn't, you'll regret it later. You can leave all the code unindented or irregularly indented, it won't matter to the compiler, but you'll appreciate lining it up in the long run. And all that advice was correct; I was better off in the long run, and I saw others come to regret it all the time. But then, over time, I started to wonder why I had to scan past all these diagonal lines of close braces as I read the code. And I cursed that these languages made it too difficult to pull out the inner parts into separate functions, disentangle setup and teardown from the main loop etc. But I also cursed that after putting in the effort (even if was just "using a proper text editor") to make things line up beautifully and in agreement with the logical structure, I still had to take up vertical space with these redundant markers of the logical structure. Python was my first language using significant whitespace, and it was a breath of fresh air. That was a bit over 20 years ago, I think. I've learned several other programming languages since then, but I never "looked back" in any meaningful way.
- lostdog 1y agoEvery time I copy paste something in python I have to check the whitespace. Often there's a problem that needs fixing, like the first line indented differently, or everything is off. Sometimes I'm not paying perfect attention and get hard to catch bugs. I'm now certain that significant whitespace is simply wrong.
- Philpax 1y agoSignificant whitespace pushes a tooling problem (correct indentation) into the human domain. It might have made sense before autoformatters that run on save, but I agree with you that in today's languages, it's a net negative. As far as I'm aware, none of the new languages that have seen success in the last ten years (Go, Rust, Swift, Dart, Kotlin) rely on the author to format code correctly - instead, they do it for you. And that's good! That's one less thing the programmer has to worry about!
- zahlman 1y ago> Significant whitespace pushes a tooling problem (correct indentation) into the human domain. It might have made sense before autoformatters that run on save, but I agree with you that in today's languages, it's a net negative. Sorry, I don't follow. There's nothing preventing a tool from re-indenting code when it's pasted (i.e.: considering indentation within the pasted text relative to its first line, and then applying an indentation offset according to where it's pasted), and many already do. It's the same kind of logic that's used to auto-format code in braced languages; arguably simpler unless it's also validating the existing indentation of the pasted text. And actually, who even is relying on "autoformatters that run on save"? I want the code to look right as I'm writing it, not after. The tools you describe are, to me, about maintaining project standards when multiple people are involved, but fundamentally each person is still making the code look locally, personally right before saving (or committing, since these things are also often done with pre-commit hooks). I can't imagine just typing out whatever slop is syntactically correct and waiting to save the file to fix it. Not when I have a proper text editor that facilitates typing it out the way I want it, taking advantage of awareness of the language syntax. > none of the new languages that have seen success in the last ten years (Go, Rust, Swift, Dart, Kotlin) rely on the author to format code correctly - instead, they do it for you. Languages do not and cannot format code. Text editors (including the ones built into IDEs) do. If I type a } and the text changes position, it's not the programming language that did this. And this is also not better in braced languages. Just as I can input a } on a new line in Vim in a braced language and have it dedent, if I want to write more code in Python that's outside the block, I just press the backspace key and it removes an entire level of indentation. And then I start typing that code, and I don't have to input a newline because I'm already on the line where I want the code to be, because I'm not expected to have a } on a separate line from everything else.
- mixmastamyk 1y agoYes, optimize for the thing you do once in a great while over having to read/type redundant braces constantly. Wouldn’t want to have to pay attention and use the tab key! ;-)
- polotics 1y agoI've been certain that copy & pasting code is simply wrong for a long time, but if the ease of doing this is your yardstick for language design quality, then you are simply right.
- efilife 1y agoSometimes you copy and paste your own code as well!