4 ms·
I 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
by HiPhish 1y ago
I 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.
- mixmastamyk 1y agoI configure my basic editor to remove trailing whitespace on save, not specifically for that reason but it does mitigate it. The point was that whitespace was always significant. People like to pretend it isn’t for some reason. Perhaps because it has a minimum though not a maximum. There’s a reason Python is considered very readable and “executable pseudocode.” Less delimiter and sigil noise is the main reason.
- efilife 1y agoIt's harder to tell where code blocks end just by looking 2, I sometimes want to fuck up the indentation on purpose, if I'm just quickly pasting some code to test if it even works or to mark it as "look at it in 5 minutes from now". Also I can mix spaces and tabs quick edits it notepad/vim/whatever become painful also converting tabs to spaces or vice-versa is tiring. A language shouldn't force me to a particular code style
- Sohcahtoa82 1y ago> It's harder to tell where code blocks end just by looking This is always puzzling to me. I've always felt that the indentation is what told me a code block ended, not a closing brace. It's graphical rather than textual. Maybe that's why Python feels more natural to me. The indentation tells me a code block ended, and the closing brace used by other languages is just a redundancy. Languages that use things like "endif/endfor/etc" end up looking downright cluttered. > also converting tabs to spaces or vice-versa is tiring. Get a better IDE. I've never had this be an issue in PyCharm.
- darthrupert 1y ago> You are going to indent your code anyway, so you might as well give the indentation some meaning. Autoformatters came and fixed that problem. Nobody (except python, haskell and nim coders probably) wastes time indenting code anymore, you save and your code is indented. Nowadays, code that relies on whitespace and has no ending delimiters (like nim and python) gets awkward because the formatters have less information to go on. If your rust or typescript code formats to bad indent or none at all, you have an error.
- mixmastamyk 1y agoEditors already auto indent. I find reading/writing Python easier than rust/javascript.
- teo_zero 1y agoI can count multiple reasons why someone might dislike significant whitespace. The most evident is that whitespace is... not evident at all! By definition, it's a transparent character: it's extremely difficult to directly count spaces; they can be indirectly counted by comparison with text in the surrounding area. The same principle why we add commas or apostrophes or spaces every 3 digits in big numbers. As of the "you're going to indent your code anyway" claim, this seems to completely ignore one-liners, either embedded in other documents (onClick=...) or fed to the shell as a quick way to get some work done without spawning new tools.
- mixmastamyk 1y agoI turned on indentation guides on my basic editor twenty years ago and never looked back. Show whitespace in a pinch once a year? Or shift arrow select. Not a significant problem. They can also be shown always in a very muted color if having frequent problems, for some reason.