[0674] There Are 10 Types Of Programmers
└ posted on Monday, 13 April 2015, by Novil
[Update: 13 April 2015]: I fixed a bug in the code.
- Jack: You need to chill, boss. I’m sure Melody’s not intentionally trying to piss you off.
- Richard: All right.
- Notification: Source code repository: Melody Crawford has changed the indent style of all your code.
- Richard: ?
- Jack: I can provide a perfect alibi for you on Saturday, from 4 p.m. to 6 p.m.
- Richard: I always knew I could count on you when it really mattered, Jack.
I prefer to code in the changed style. That said, it’s a really jerkish move to not adhere to someone’s formatting style in their own code.
I prefer the before indent style…
but for JavaScript you really have to go with the second due to some pretty stupid traits of the language…
not sure if strict mode would solve it so its easiest to just use that indent style…
and if your doing it with java you might as well get used to it…
there really isn’t a super big difference…
figuring out what what curly bracket matches what curly brackets might be easier with one style over the other… but then again most good IDEs will be able to highlight it for you…
(and by good IDE i mean Visual studio :p)
When I started with programming I used to work on a small laptop screen most of the time so the second style was a convenient way how to put much more lines of code on the screen.
Lookfar wrote:
But not the punchline?
The joke is actually “There are 10 kinds of people… those who know binary and those who don’t”
If you don’t understand binary, the joke makes no sense.
I didn’t even notice the title until I saw your comment.
all these people discussing computer code and not mentioning THIS Richard is about to join ANOTHER Richard in the other Richard’s favorite passtime… killing.
At a previous company we avoided this carnage by setting a coding standard of: “whatever unadulterated, unmodified ‘indent-region’ in emacs does”.
Thus were many lives spared and many code review sessions made useful.
These last few pages have just made my eyes glaze over. I have no idea what any of the references are, or why they’re upset with each other. I’m sure those who “get it” are enjoying the change of pace, but I’m looking forward to getting back to Sandra, Woo, and the rest of the kids.
1FBS?! BURN THE WITCH!
All-Purpose Guru wrote:
Either of the above styles will be handled properly by indent-region in emacs without modification. It just depends which line you type the “{” on.
Haven’t touched any coding since high school, yet surprised myself by being able to follow that code. That being said, you just don’t screw with someone else’s code like that, unless that’s what you’ve been hired to do.
Gotta admit, I prefer Richards indent style, less likely to forget to close off a part ( Yeesh, I’ve spent more time now outta school than I did in, I forget what the proper term is )
PURE EVIL
Formedras wrote:
IIRC, K&R-style indent used to be the guideline for Java, but I heard they since switched to Allman.
On Melody’s choice, it could be worse, much worse: She could have set it to that horrid GNU indent style…
@ Lookfar:
“tintypes” of programmers? 🙂
Why?! WHY WOULD YOU DO THAT?! I’m with Richard on this one. I didn’t wanna pick a side, but now I have to. :<
Follow your codebase’s style standards pls. D:
Oh good gracious! Nightmares about spaghetti code!
He’s against the one and only way of indenting? the K&R way? Shame on him 😉
This comic is so absurdly fantastic…..
Oh, hell no. I am absolutely with Richard on this one. His indentation style is absolutely the best way to do it.
@ Vidad:
Good man. My reaction wasn’t unlike Richard’s when I saw what she did. It’s just… immoral. The Harpy must pay.
richard’s way of programing looks way better than melody it is easyer to follow with some space. that is from a guy who know jack about programing
I presume that Richard’s code actually conforms to company guidelines. In which case, that behavior (changing the code style like that) is really unprofessional. Not cool.
Trimutius wrote:
I think that hate and love are opposites. Hate is to love like -5 is to +5 and indifference would be 0.
I have no idea what any of the humor in today’s strip (sans the title) actually references. I get that coding styles are diverse, but in order to understand the nuance I think I’d need to be a programmer myself.
Don’t get me wrong, I’m glad I’ll be taking some programming courses soon, but in all honesty raw code just looks gross to me right now. Like an ocean of indiscernible, tiny sea creatures that probably are carrying invasive bacteria.
Melody’s change is an improvement, but it doesn’t go far enough….
If you’re using indentation to show the code’s structure, then what’s the point of braces? Just get rid of them, like in Python, or Scheme when using “SRFI 49” I-expressions. Why use braces to describe structure a second time (for compilers) when compilers can already see structure from when it was written the first time (for programmers) with indentation?
You think that’s bad? This is my code.
We should really have a poll for which of the two options people here prefer.
I personally am fan of crawfords way. Specially in java.
Java is already taking up so much visual space, that i have no need to waste more on that linebreak for each bracket.
Ghag the vile witch, anyone who puts a new line before an opening brace is evil!
What? No! There are 01 types of programmers! Little-endiannes FTW!
@ Trimutius:
If I am remembering correctly the way Javascript is parsed requires Melody’s format. The parser automatically insert semicolons (;) at the end of each line, which can lead to unexpected bugs when formatting it the way Richard has it.
Since this is probably Java I prefer Richard’s original formatting as I find it better marks the beginning and ending of functions.
Haha I can’t believe it took me some time to realize “10” was binary. It even puzzled me ><
“Good lord, she even replaced spaces for tabs. This is a war declaration right there.”
I don’t really see why Richard doesn’t just revert all the code to its previous incarnation and voids Melody’s password. The last bit omly until she gets the message and realizes her place in the food chain, of course.
@ Steven:
me neither. could someone PLEASE explain it for non-code-monkeys?
Please, guys, JavaScript does *not* require Melody’s style at all.
> The parser automatically insert semicolons (;) at the end of each line
No, the parser automatically inserts a semicolon between two lines *if and only if* it fails to parse the second line without the semicolon.
Oops, I forgot about the “Quote” link.
Why would she bother? That’s 3 seconds she could be using to do more programming.
Good on Melody for fixing Richard’s clearly defective style. He’ll become a better programmer now.
(There’s no real debate on styles. There’s the One True Brace Style, as given to us by the prophets Kernighan and Ritchie, and there are people who are wrong.)
As for comments: comments at the top of a file explaining the design are fine. Comments on data explaining how it’s used are fine. Comments at the top of a function explaining your assumptions going in are fine. Comments in the code explaining the code are not fine. They’re a sign that you failed to make the code simple enough or failed to choose good enough names. If the code needs commenting, then change the code.
(Some code is hard to read because it solves genuinely hairy problems with tight constraints. In that case you should be writing several pages explaining what’s going on and which approaches have been tried and didn’t work.)
@ Richard Braakman:
So… one line meaning “this chunk of code does this thing described on top” and another line meaning “up to here” is something that’s bad? Now that’s what I call edgy.
And you think writing several pages won’t have a side effect called tl;dr.
If you think it makes the code clearer and you can do it, then do it; personal preference for what’s best in specific contexts FTW. Writing down overly general coding commandments is stupid.
I find it incredible as most of the posts have no comments, but suddenly there’s one about code indentation… and everyone goes kaboom.
Whitesmith FTW, BTW.
GO GO INDENTATION WARS!!!
Not being familiar with programming, but if he’s anything like the programmer I know they better have a third friend who knows forensics.
If you work in a company, just use Checkstyle (Java) or StyleCop (.net)
Even if you might not agree with a certain coding style, tools like this will tell you what is expected in that company and noncompliance will result in a warning.
At least she didn’t do the intent style change and a functional change in the same commit.
@ Trimutius:
Since when does pre-increment work faster than post increment? How does that even work, especially in a for loop?
I ask out of genuine curiosity because in all my 28 years of C/C++ programming, and as one of the senior engineers with the most knowledge of optimisation etc. (although to be honest compilers make it so that it’s hardly worth trying to optimise code any more) I have never heard that one before.
Also, it is presumably specific to certain instruction set(s)?
@ Trimutius:
Maybe it is in Hexa: those who indent like Richard and F with the rest.
@ Jontom Xire:
x++ is equal to
int temp = x;
x = x + 1;
return temp;
++x is equal to
x = x + 1;
return x;
I think you can see why ++x is (very slightly) faster.
However, when you don’t use the return value, most compilers optimize both to
x = x + 1
so you shouldn’t have to care.
Some years ago I coded like “before”, after that I started working with sources provided by Mozilla aaaaaand… “now” since then
Personally, I prefer the way Richard wrote it. Makes it easier to spot where the indentations actually are. Melody’s edit turns it into a big block of text.
Saturday, 5 p.m. – Richard kicked off the door… – Melody, waiting in sexy Lilith cosplay: “What took you so long?”
@ Lookfar:
I’m of the school that it doesn’t matter what style you use, so long as you have one and use it consistently.
Heretic.
There is Allman style, or there is one-foot-into-the-abyss style (maybe two feet).
Next you’ll be suggesting that tabs vs. spaces is irrelevant! Or that decades of an unseen holy war, conducted company-by-company, programmer-by-programmer is only about indentation instead of a war for the very soul of computation itself!!
@ Jontom Xire:
Since when does pre-increment work faster than post increment? How does that even work, especially in a for loop?
My strong suspicion, if it’s like similar advice I’ve received over my career, is that it was true for one particular processor or compiler and it’s been mistakenly assumed to be general advice for decades.
What’s amazing is when you get young programmers who’ve learned a rule that was obsolete *before they were born*. Old traditions, passed from programmer to programmer, die hard.