5 ms·
Terrible article. Looks like it's written in 2004? I've been using Python 3+ for the past few years, never looked back. > Python decided it would be a fun ide
by tomp 6y ago
Terrible article.
Looks like it's written in 2004? I've been using Python 3+ for the past few years, never looked back.
> Python decided it would be a fun idea to govern blocks using whitespace, instead of wrapping everything in braces.
Yeah, because using braces was a stupid idea in the first place. Just because C++ / JavaScript etc. are stuck with backwards compatibility, doesn't mean that other languages can't move to something better.
> For instance, what is called an "Array" in pretty much every mainstream language, is instead called a "List" in Python. Key-Value stores that are usually called a "Map" or a "HashMap" are instead referred to as a "Dictionary".
Yeah, except in C++, where it's called "Vector" (which makes even less sense, from a mathematical point of view). Also, The problem with "Map" (the data structure) is that it conflicts with "map" (the function). I prefer what Python is doing.
> When creating a string in most mainstream languages you can usually just do something along the lines of var s = "string" or for a char you usually use single quotes var c = 'c'
And most mainstream languages are wrong. In practice, there's no meaningful difference between (Unicode multi-byte multi-codepoint) characters and strings; Python just makes it more obvious.
- bluGill 6y agoWhitespace is a terrible idea. I'm not saying languages need to use the one true brace (which every brace you care to argue for, they are all the same, at least for this point), but there needs to be a start and end block, and white space is one of the worst choices you can make. The problem with whitespace is in real programs you eventually realize (often because of a new requirement) that you need a new block and whitespace is the hardest to change. Whitespace is good for readability and important. It should be an error if the whitespace is wrong. However there needs to be a simple start/end block marker so that programs can fix the whitespace correctly.
- falcolas 6y ago> whitespace is hard to change What text editor are you using? Select region, Tab or Shift-Tab, and move on. > Whitespace is a terrible idea. That’s like, just your opinion man. The only time I’ve had issues with blocks and whitespace is when some monster mixed in tabs. Thankfully every decent editor can make whitespace characters visible, and a quick find/replace fixed the heinous action.
- mercer 6y ago> The only time I’ve had issues with blocks and whitespace is when some monster mixed in tabs. Thankfully every decent editor can make whitespace characters visible, and a quick find/replace fixed the heinous action. Sure, but in the non-Python languages that I use, that's not necessary, and in most cases, these days anyways, simply saving the file will fix indentation!
- falcolas 6y agoInstead, you have to insert a '{', move to the end of the block and insert a '}'. Or 'begin' and 'end' (or whatever delimiter is used). Some IDEs also support selecting the new block region and hitting a shortcut. None of these are any less onerous than selecting and hitting tab.
- mercer 6y agoI've had editors or git merges mess with whitespace. I've never had editors remove braces or begin..end blocks, and merges have rarely caused issues with begin..end blocks or braces. apples and oranges , in this case.
- D13Fd 6y agoThis makes no sense to me. The whitespace is controlling. There is no need to retroactively "fix" it because if it's wrong, the program won't work.
- apta 6y agoYou might be able to spot the bug if you're lucky. Otherwise, it might go on undetected until it decides to show up at the "best" time.
- bluGill 6y agoIn python the program may work wrong. I've removed an if before and when unindeting the nested blocks took something back one level too many. It still parsed as the levels were legal, but something that should have been in the nested loop was now outside of the loop.
- tomp 6y agoI disagree, but in any case this is a better criticism than what's written in the original article. First of all, whitespace is the reality. The only relevant choice is for the compiler to consider it, or ignore it. You're arguing "wrong whitespace is error" so I guess we agree there. My main job is Python, and there's not a lot of work I need to do to fix the whitespace. It's literally a few Tabs / Shift+Tabs away! IDEs help a lot, the worst are REPL-like tools (Python's command line interface, or Jupyter) that fail to automatically remove leading whitespace in copy-pasted lines. Python goes a long way to helping tools by having the `:` (colon) as "new block" signal. I personally think that's superfluous, and it should be done away with. The broader point is, there are (or should be) techniques that eliminate these problems altogether; copy-pasting text is the problem - we should be copy-pasting AST instead. Same issues would happen e.g. in C++ if you copy-paste on `{` too much or too little... Copying AST instead of text would solve that as well.
- mercer 6y agoIt's easy to argue in favor of something if you can use hypotheticals that are unlikely to every come to pass. I agree with you that significant whitespace in Python is much less of an issue than many make it out to be, but arguing that using braces (or def..end, or whatever) is a stupid idea is going a bit far in the other direction. For me, at least, my dislike of Python's significant whitespace does put a bit of weight on the scale when I choose my language. Not much, but something.
- threatofrain 6y agoIt's short enough on content that it looks like low-effort resume SEO.