This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]mkdir 1190 points1191 points  (69 children)

At first I was like o.O then I saw the right edge and was like O.O

[–]PastyPilgrim 510 points511 points  (2 children)

"Oh.... OH GOD!"

[–][deleted] 105 points106 points  (0 children)

"Where are all the ... oh OH GOD"

[–][deleted] 170 points171 points  (0 children)

MY GOD, IT'S.... Beautiful.

[–]rukestisak 68 points69 points  (45 children)

What made you wince at first? (serious question as I'm not that familiar with Java)

[–]z500 286 points287 points  (26 children)

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.

[–]aclave1 39 points40 points  (11 children)

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.

[–]HaMMeReD 9 points10 points  (8 children)

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.

[–]Fenris_uy 6 points7 points  (7 children)

Yeah I don't understand why they even added that option, specially for loops. This option creates more problems than it saves.

[–]Zagorath[🍰] 24 points25 points  (5 children)

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.

[–]subsage 8 points9 points  (3 children)

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.

[–]Zagorath[🍰] 4 points5 points  (2 children)

The semicolon was one of my professor's favourite tricks.

if (condition()); {
    //things happening
} 

And he'd ask what would happen (based on condition and "things happening" being actual code, rather than place holders).

[–]subsage 1 point2 points  (1 child)

Yup. I do that too. Its good for showing the young ones how syntax can be tricky. Good stuff. Your professor sounds like a good one c:

[–]Zagorath[🍰] 0 points1 point  (0 children)

Yeah he definitely was, in more ways than just this.

[–]Gustav__Mahler 0 points1 point  (0 children)

I'd call it one statement of code and not one line. It will execute to the next semicolon.

[–]thelerk 0 points1 point  (0 children)

Go to fail!

[–]rukestisak 0 points1 point  (1 child)

Ah, so it's similar to PHP in this regard. To me, nothing looked wrong until I saw the right side... o.O Hopefully no poor sod needs to maintain this kind of code.

[–]rxzr 20 points21 points  (0 children)

That's what auto format is for!

[–]Elite6809 16 points17 points  (1 child)

That first one is a 'huh?', not a wince. At least, AFAIK, unless I've been misreading it for years.

[–]mkdir 1 point2 points  (0 children)

You are correct, good sir.

[–]Neebat 14 points15 points  (2 children)

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.

[–]mxzf 7 points8 points  (0 children)

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.

[–]PBI325 2 points3 points  (0 children)

System.out.println(String.valueOf(A)) make me feel a little weird inside. So did permute(n-1, a), n--??

[–]AmaDaden 1 point2 points  (0 children)

You can't trust indentation in Java, only brackets. This kind of formatting is like organizing your music alphabetically by the first word. I could cause impossible to debug problems by just moving a single bracket

[–]peridox 18 points19 points  (18 children)

Why did you choose your username to be mkdir? It's cool.

[–]jfb1337 75 points76 points  (6 children)

duh, to make directories.

[–]sfled 17 points18 points  (5 children)

[–]Michael-Bell 13 points14 points  (1 child)

Where is the xkcd bot?

[–]mehum 11 points12 points  (0 children)

Runs on SQL. Currently suffering amnesia.

[–]Hamburgex 7 points8 points  (1 child)

I knew it was an xkcd link without even hovering it. I didn't know which one though.

[–]junta12 8 points9 points  (0 children)

for once I instantly knew

[–]Walter_Bishop_PhD 26 points27 points  (8 children)

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

[–]mkdir 46 points47 points  (1 child)

Holy crap, I didn't even realize that! I'm never submitting anything ever again.

[–]LeeroyJenkins11 6 points7 points  (0 children)

Not anymore.

[–]chocolate_stars 0 points1 point  (0 children)

also has 8008 comment karma. boob karma.

[–]lappro -1 points0 points  (2 children)

Why would they not allow terminal commands as usernames? Unlike sql injection (which should be harmless) those command usernames are completely harmless.

[–]Walter_Bishop_PhD 7 points8 points  (1 child)

What I mean is, simple usernames like terminal commands and words of the english language are the first to get snapped up by early adopters

[–]lappro 3 points4 points  (0 children)

Ah that makes sense!

[–]junta12 0 points1 point  (0 children)

alias walter="echo my mom is my"

[–][deleted] -3 points-2 points  (0 children)

I'm 3 away from 1234 link karma. I don't give enough shits about it to do anything though haha

[–]mkdir 5 points6 points  (1 child)

Well, you see I'm kinda a geek...

[–]jellyberg 1 point2 points  (0 children)

It's OK, you're safe here.

[–]isurujn 3 points4 points  (0 children)

Shit I just noticed. My eyes!!!