4 ms·
Significant whitespace is a dealbreaker for me. I never tried Nim for this reason
by efilife 1y ago
Significant whitespace is a dealbreaker for me. I never tried Nim for this reason
- krupan 1y agoHello, Python Critic from the 1990's. Welcome to the future
- codr7 1y agoHello fellow programmer from the middle ages; we discovered long ago that significant whitespace is a dead end, the fact that it's popular with the wannabes changes nothing.
- xigoi 1y agoI have just the thing for you ;) https://github.com/xigoi/nimdenter https://github.com/xigoi/nimdenter
- archargelod 1y agoI 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!
- froobius 1y agoOn the other hand, I hate languages that are polluted with ugly bracket noise, so Nim is appealing to me for this reason
- vips7L 1y agoIt’s subjective, but this is also why I haven’t tried Nim or Crystal. If you like brackets, I’d say try Swift if you want to stay in the natively compiled + GC space.
- Philpax 1y agoI don't believe Crystal is whitespace significant?
- vips7L 1y agoIt uses do/end but parts of it are white space from what I can tell. loop do case message = gets when Nil break when "" puts "Please enter a message" else puts message.upcase end end
- etra0 1y agoIt is not whitespace sensitive afaik. This same version works as well loop do case message = gets when Nil break when "" puts "Please enter a message" else puts message.upcase end end (Scrambled on purpose).
- sigmonsays 1y agoSpaces don't copy n paste well and are hard to read/navigate
- HiPhish 1y agoI could never understand why people care this much about significant whitespace of all things. This seems like such a non-issue, it should be a minor annoyance at worst. Then again my favorite language is Lisp, so maybe I'm just too much beyond caring about syntax. The only annoying thing about significant whitespace is having to escape a new line sometimes. But significant whitespace has always made sense to me. You are going to indent your code anyway, so you might as well give the indentation some meaning. I write Python, JavaScript and Lua most of the time, and I never waste any thought on whitespace VS braces VS keyword delimiters.
- MrJohz 1y agoThe biggest advantage if you can avoid significant whitespace is that it's usually a lot easier to manipulate text if you don't have to worry about the whitespace being correct. For example, when I'm copying and pasting Javascript code from somewhere else into a file, I don't need to worry about getting the indentation right, I just paste it into the right location, press format, and it does what I want. This is often nontrivial in Python, where both the source and the destination may have existing (invisible) whitespace. Worse, leading whitespace characters are often trimmed on copy or select, which often makes the resulting paste even more chaotic. This is a minor inconvenience, and I still use Python regularly when it makes sense, but from a language design perspective, I think it's one of those decisions that makes your users' lives that slight bit harder with no real upside.
- mixmastamyk 1y agoSelect-lines-(shift)-tab when needed is quite easy. Often that’s not needed either because moving from one function to another is the same level. The benefit is not having to constantly read/write delimiters. Imagine a shell where all arguments had to be delimited by , or | chars instead of whitespace.
- MrJohz 1y agoIt's harder when the source or the destination isn't all indented in quite the same way, which happens often if you start a block, press enter and end up on an indented line, and then paste the code. I don't really get the readability argument - like the lisper I was replying to said, it's all much of a muchness. A shell where arguments are delimited by commas is a function call in most programming languages, and people don't struggle with readability there. If anything, I find having an explicit "close block" symbol a useful visual marker on the page, but I write Python fairly regularly and don't really notice much readability differences compared to any of the brace-using languages I work with.