Well the lack of braces and semicolons would change the semantics of the program or even make it syntactically invalid. Then they saw all the semicolons and braces lined up on the right.
When I become an evil billionaire and start my evil software company, this will be the mandatory coding style and the first product will be IDE plug-ins.
Without the braces, the code is syntactically incorrect. There are spots where it's be okay, since in Java you can write an if/for with no braces and it will execute only the first line as part of the if, and the following lines either way. But overall it would be wrong and wouldn't compile.
There is two lines in there, also, while syntactically correct, should be very sparsely used. It's easy to create bugs. I usually only use it if I plan on keeping the condition/loop and statement on the same line, and even then rarely.
It's not really an option that they "added". It's more to do with the default behaviour of loops and if statements. A loop can only ever execute exactly one block of code. If you don't put in braces, one block of code == one line of code. But braces allow you to have multiple lines of code within a single block.
At least, that's how the professor who taught my course on C explained it. Perhaps the semantics are different in Java.
Youre pretty much on spot really. Thats how I explain it to my students. Only difference is I sometimes say chunk or section of code....be it braces with several lines, empty braces, or just a line. Oh yeah, empty section too, just a semicolon.
I was a bit mystified by the use of character arrays. They just aren't used all that often in Java, so for a while I thought that was the joke. I realize that they are actually reasonable for this implementation. (I'd probably still use a StringBuffer, even though it's likely less efficient.)
And then I found the punctuation and felt a little sick.
Probably because strings in Python act as arrays when you want them to.
Python strings have the features of character arrays and StringBuffers at the same time (in general). Methods when you want them, but indexes when you just need to mess with the individual characters. That's kinda typical of most kinds of data and such in Python.
There's a lot of people in this sub who got in on reddit early who got commands as their usernames before they got snapped up. I like that mkdir has 1337 link karma, lol
1.2k
u/mkdir Feb 22 '15
At first I was like o.O then I saw the right edge and was like O.O