What are the advantages to using white space?
Blocks easily identified by their indentation. It might take a little getting used to but I find it very pleasant.
Sure, you make it easier for the random onlooker to be prepared to always immediately understand what is going on, but at the same time, the programmer who writes for his own perusal or that of a small team of known others will find themselves restricted by a totalitarian scheme telling them what they can express and what they can't. The assumption that most code is written for most people to read is simply not true, and code that is intended for the masses has always been able to deal with the problem by imposing style guidelines.
Most projects/companies have indentation/style standards so that code can be communicated across individuals. Once you add in the indentation style, braces look redundant and are just extra noise and chances for error.
I must admit, though, totalitarian systems often help people work together :)
Enough with the bikeshedding! There are much more interesting things about Rust to discuss than this.
Significant indentation is the #1 thing keeping me at a distance from Haskell and Coffeescript.
Any decent editor lets you handle block indentation very simply, and it's typically easy to see what the indentation level should be.
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.
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.
That was supposed to be the compilers job. I am here to do mine.
No wonder so many people hate whitespace based parsing.
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.
Anyway, that's tab vs. space flamewar, best practices flame war, etc.
Long story short, I don't like spaces because editors do not make it as easy to navigate back/forward 4 (or 2) spaces as it is to navigate 1 tab. Most annoying instance of this: what combination of keypresses does it take to get from the middle of a line to the beginning of a line? In Notepad++ it's easy, but it Xcode its cmd-left-arrow then hit right-arrow for every space/tab you need to pass. (Or in general for a Mac text editor cmd-left-arrow, then opt-right arrow, then opt-left arrow, but that doesn't always work right. In TextWrangler it's cmd-left + opt-right, which is better but still slightly tricky hopping from cmd to opt key.)
If you assume that this is possible, and your eyes can get used to read code just by its blocking, then brackets are unnecessary, even superfluous.
As long as there are not too many newlines within blocks...
If all you know is {}, then other code is harder to read. Once you learn either a Lisp-like language or a Python-like language then you learn to see code blocks without {}. This is what happened for me. (I was forced into learning Scheme in school. Only after that did I decide that Python was an OK language after all.)
I'll grant, however, that the Python approach isn't quite as bad as I thought it would be, and that it can come close to matching the readability of "code with braces." But, for me at least, braces (and vertically aligned ones at that, dangit) absolutely make code more readable.
YMMV, IANAL, HTH, WTFBBQ, etc...
Let me ask you this, do you already indent your code? If not it is probably a tangled mess and I wouldn't want to continue the conversion with you. But, if you already indent your code, then why do you need brackets? You are wasting space and you are repeating yourself. It is like enforcing that every declaration of "int counter" to be followed by a comment saying "// declaration of counter as an int".
The only reason to use brackets is to minify a piece of code or to appeal to C++ or C programmers. So Javascript benefits from having brackets. I guess Rust does too because it is trying to appeal to C++ programmers.
I can't depend on having a "good" editor. I have 2 work machines, 2 home machines, ssh to a VPS, ssh to a bunch of machines at work, etc. So as often as not I have to use vim to do quick edits of code. I also am generally forced to use Apple's Xcode for Obj-C applications, but use other editors for anything else. Working on my own toys vs. working at work, vs. being in school instead of a commercial entity with nice software licenses also means I can't depend on having the same text editor available, other than free ones.
I'd prefer to use a programming language that was easy to read and write in just about any text editor. The only requirement I can't easily escape is that the editor must support auto-indent. (So MS Notepad is out.)
Actually you can apply that argument for whitespace only languages, because they produce code that is more consistent. So because the code is more consistent it is also easier to read and write (as opposed to say, dealing with someone's eccentric formatting).
Vim or emacs (the one I use) is available for any modern OS out there. It is free and has outstanding syntax highlighting and works through a terminal as far as I know.
In general it seems like this is a tail wagging the dog problem -- picking a language to work with (what seems to be a broken) editor.
I agree but in reverse. You're willing to give up a trivially parseable syntax just to avoid typing a few braces?
Minimalism for its own sake is an anti-pattern in language design. I will be very happy once this meme dies.
Incidentally, I'm the latter, and I'm very interested in Rust.
if(foo) { doSomething(); } else { doSomethingElse(); }
to be rather unreadable. My solution is to not write it that way.My observation is that code style is very important to Ruby and Python developers and less important to those from C-family backgrounds. That is, a lot of Ruby developers, for example, refuse to touch anything containing braces whereas few C-family developers require them.
I think the solution is that developers with a Python/Ruby background need to create a systems language, instead of expecting those with different backgrounds to be converted to the Python/Ruby-ists mindset. But in reality it seems that few Python/Ruby developers are all that interested in systems languages whereas those with C-family backgrounds are very interested (hence the situation that presently exists).
So, you can have a whitespace-based version of Rust easily.
The practical problem is that then you'd split the community between the two syntaxes since you couldn't copy-paste code examples from one syntax into the other. That could be problematic for building a large base of support. Take D for example where they had fragmentation problems with two standard libraries. Perhaps a split based on syntax would be less? (Since code written in one could be shared with the other.) But it would still cause problems in how the language is marketed to new developers.
Also besides semicolons don't cause any problem at the first place, so why eliminate them?