5 ms·
Being someone who has only ever programmed in languages that use whitespace or parens, I really, really don't get the curly braces thing. :) White space is very
by mattdeboard 15y ago
Being someone who has only ever programmed in languages that use whitespace or parens, I really, really don't get the curly braces thing. :) White space is very readable and just as obvious a discernment of codeblocks as curly braces.
- ntkachov 15y agoAs someone who uses both constantly, Whitespace languages and curly braces are the same. For a good programmer, she can take out the curly brace and it should look like a whitespace language. Likewise, a whitespace language would just have braces inserted everywhere there would be an indent change. '{' for forward indent and '}' for backwards indent.
- nickknw 15y agoExactly, I agree. Enough with the bikeshedding! There are much more interesting things about Rust to discuss than this.
- cageface 15y agoThe problem with significant whitespace is that it makes routine tasks like copy & paste and shifting blocks around a tedious and error prone exercise instead of a trivial editor task. Give me instead a syntax that lets my editor completely and correctly reformat an entire file with a keypress. Significant indentation is the #1 thing keeping me at a distance from Haskell and Coffeescript.
- mattdeboard 15y agoWell, I dunno, I've never really had issues with it but, like I say, vast majority of my code has been in Python and Clojure. I'm not arguing against braces, btw, it's just another delimiter like whitespace. It's all just about what kinds of things you're willing to train your brain to do, IMO.
- falcolas 15y agoI've heard this before, and after working in a 250k loc Python codebase for 4 years, I can't say that this has actually ever been an issue. Any decent editor lets you handle block indentation very simply, and it's typically easy to see what the indentation level should be.
- webjprgm 15y agoI find that significant white space is a problem mainly when going between editors, and also mainly because of space vs. tab problems. E.g. if I copy-paste from vim in Terminal into TextWrangler (free BBEdit) then all the tabs have become spaces, which python will throw a fit about. Similarly if I copy-paste code from a website or blog entry. In languages with () or {} I can hit a key to reformat copy-pasted code. In Python I have to do it manually. When it comes to moving blocks of Python code around inside one source file, then it's a simple matter to hit the plus/minus indent hotkey.
- falcolas 15y agoUsing tabs instead of spaces is not a recommended practice for Python, or most white space orientated languages that I'm aware of. Adopting that best-practice would seem to alleviate most of your concerns that you've listed here. Most editors even let you handle that on a filetype basis, so you can use 4 spaces for Python, and tabs for your C files.
- kamaal 15y agoWhy should I even waste my time worrying about supplying spaces or tabs every time I go to a new line while programming. That was supposed to be the compilers job. I am here to do mine. No wonder so many people hate whitespace based parsing.
- Bjartr 15y ago>Why should I even waste my time worrying about supplying spaces or tabs every time I go to a new line while programming. What are you talking about? Why wouldn't you have your editor just insert the correct number of spaces when you press the tab key? It's worked fine for all my python work.
- yumraj 15y agoIMvHO: Curly braces are like punctuation marks in a language, in that they very clearly mark the beginning, end and so and so forth. But, yes, it is a very style issue, but to me code without curly braces feels very naked.