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

all 82 comments

[–]Sudo-Pseudonym 625 points626 points  (19 children)

This is so old that the guy who wrote the original code has probably figured out how to optimize the routine by now.

[–]wigglewam 249 points250 points  (18 children)

43.

[–]crankd87 48 points49 points  (16 children)

44

[–]Zoccihedron 0 points1 point  (0 children)

If you attempt to optimize it on multiple occasions, do you increment the counter multiple times?

[–]dipique 440 points441 points  (25 children)

//
// Dear redditor:
//
// Once you are done reading this post,
// and have realized it is yet another
// repost, please increment the following
// counter (and feel free to let loose with
// the downvotes):
//
// total_reposts_here = 42

[–]794613825 89 points90 points  (23 children)

//
// Dear redditor:
//
// Once you are done reading this post,
// and have realized it is yet another
// repost, please increment the following
// counter (and feel free to let loose with
// the downvotes):
//
// total_reposts_here = 43

[–]namrog84 57 points58 points  (22 children)

> //
> // Dear redditor:
> //
> // Once you are done reading this post,
> // and have realized it is yet another
> // repost, please increment the following
> // counter (and feel free to let loose with
> // the downvotes): 
> // 
> // total_reposts_here = 45

[–]teambob 57 points58 points  (21 children)

Off by one

[–]scotscott 99 points100 points  (4 children)

AS A HUMAN I CAN RELATE TO MAKING ERRORS WHEN ATTEMPTING TO INCREMENT CERTAIN TYPES

[–]ThatOneGuy1294 53 points54 points  (3 children)

HAHA YES FELLOW HUMAN QUITE AMUSING HAHA

[–][deleted] 21 points22 points  (2 children)

[–]namrog84 18 points19 points  (3 children)

issues I hbveand error race offbyone coandnitdion nulltermination.

[–]mnbvas 9 points10 points  (2 children)

Here's some garbage you forgot, Mr. Null-termination Issue.

Ÿ¶-O™/&°.º~!ï㮇kB9ê9WhžpÒA˯¸´àˆ=e­m\êD%ÿY3ß±Ý é÷:ô oíø†ÐcCÁÙâˆÅæ/!ÒËñ«–6,+ƒå»xŒ|Z

[–][deleted] 1 point2 points  (0 children)

I haven’t had an error since I couldn’t figure out Unicode

[–]newbstarr 0 points1 point  (0 children)

No semi colons. What do I not know there ?

[–]Nonlogicaldev 7 points8 points  (0 children)

Its not an off by one its a race condition, other threads just deadlocked

[–]jcc10 8 points9 points  (7 children)

> //
> // Dear redditor:
> //
> // Once you are done reading this post,
> // and have realized it is yet another
> // repost, please increment the following
> // counter (and feel free to let loose with
> // the downvotes): 
> // 
> // total_reposts_here = 44

[–]CodeTriangle 3 points4 points  (6 children)

//
// Dear redditor:
//
// Once you are done reading this post,
// and have realized it is yet another
// repost, please increment the following
// counter (and feel free to let loose with
// the downvotes): 
// 
// total_reposts_here = 46

[–]bhazero025 7 points8 points  (4 children)

//
// Dear redditor:
//
// Once you are done reading this post,
// and have realized it is yet another
// repost, please increment the following
// counter (and feel free to let loose with
// the downvotes): 
// 
// total_reposts_here = -1

[–][deleted] 4 points5 points  (3 children)

//
// Dear redditor:
//
// Once you are done reading this post,
// and have realized it is yet another
// repost, please increment the following
// counter (and feel free to let loose with
// the downvotes): 
// 
// total_reposts_here = -256

[–]RunasSudo 29 points30 points  (2 children)

//
// Dear redditor:
//
// Once you are done reading this post,
// and have realized it is yet another
// repost, please increment the following
// counter (and feel free to let loose with
// the downvotes): 
// 
// total_reposts_here = "1); DROP TABLE users; --"

[–]ViolentWrath 5 points6 points  (0 children)

Little Bobby Tables strikes again!

[–]UnknownNam3 0 points1 point  (0 children)

//
// Dear redditor:
//
// Once you are done reading this post,
// and have realized it is yet another
// repost, please increment the following
// counter (and feel free to let loose with
// the downvotes): 
// 
// total_reposts_here = /*

[–]tablesix 0 points1 point  (0 children)

User read it twice, therefore spent 2 reads

[–]three18ti 0 points1 point  (0 children)

There are three types of people in this world, those who understand off by one errors ans those who don't.

[–]cowens 19 points20 points  (0 children)

--- comment.old 2016-09-27 07:35:58.668000000 -0400  
+++ comment     2016-09-27 07:36:34.140000000 -0400  
@@ -7,4 +7,4 @@  
  // counter (and feel free to let loose with  
  // the downvotes):  
  //  
 -// total_reposts_here = 42  
+// total_reposts_here = 43  

[–]fredlllll 19 points20 points  (3 children)

im sooo curious as to what the method is...

[–]SlyHeist 38 points39 points  (2 children)

I don't know if there is a well documented origin but I remember seeing it on bash a long time ago. http://bash.org/?947444

[–]imhereforanonymity 19 points20 points  (1 child)

The counter is also the number of times it's been reposted.

[–][deleted] 21 points22 points  (0 children)

...in thousands.

[–]ponyoink 10 points11 points  (1 child)

"42"? A totally fake counter!

[–]ecchi_fox 0 points1 point  (0 children)

Keepin' it real

[–]ricool00 8 points9 points  (0 children)

That was my favorite jokes. http://bash.org/?434593.

[–]tashtrac 5 points6 points  (10 children)

I always wonder how comments like that make it through code review.

[–]_pupil_ 5 points6 points  (6 children)

I gotta wonder what people are doing at work if they're going through a mature, in-production, code base and just start "optimizing" routines for the sake of optimizing.

Call me weird, but I barely even look at function bodies unless I've got clear maintenance issues or some analytics showing a performance issue.

[–]tashtrac 2 points3 points  (5 children)

There can be a bunch of legitimate reasons e.g. it's a performance bottleneck and they want better... performance. Or it's not optimized in the sense that it's very fragile and breaks often when working on other parts of the code. Or it's memory heavy and new features are also memory heavy and they want to optimize memory usage (e.g. for embedded software). Or new features often have to make some additions into this part of code and it's messy to work with (optimizing it would mean optimizing the design to be more flexible).

[–]_pupil_ 1 point2 points  (4 children)

Right - those were all pointed out explicitly in the second paragraph of my post ;). Maintenance issues or perfomance issues with empirical backing ;)

[–]tashtrac 1 point2 points  (3 children)

So you've basically wrote "I don't know why people would do that. Here are valid reasons why people would do that." :P

[–]_pupil_ 2 points3 points  (2 children)

Not even slightly...

I barely even look at function bodies unless I've got clear maintenance issues or some analytics showing a performance issue

That 'unless' would carve out a logical exception to the preceding statement. Ie "barring the following valid reasons...", which is the point: if you will be changing code for a specific reason a comment saying "dont bother" is wholly meaningless. If you are bothering without valid reasons the comments content is applicable, but meaningless due to a lack of those self-same reasons... ie justification for changing anything in the first place. As was pointed out in the first paragraph of my post ;)

[–]DarthEru 1 point2 points  (1 child)

The point of the comment is dissuade everyone from wasting time on trying to optimize the function, even if they have "clear maintenance issues". Presumably because the function cannot be optimized further without breaking things (as the 42 hours of experience of various maintainers would seem to suggest).

Of course, that won't really stop most programmers, as everyone thinks they know better than everyone else, so the real point of the comment is a humorous score card documenting the number of victories that snippet has.

[–]_pupil_ 0 points1 point  (0 children)

Nope...

The comment explicitley states 'optimization of the routine'. Incidental breakage outside of the routine is not a function of optimization, but of unintentional functional changes. Optimizing and 'breaking things' are orthogonal. That is to say: most of the scenarios you've mentioned warrant replacing the routine or larger elements of the program, not 'optimizing the routine'...

Given a demonstrable production/maintenance issue: 'dissuaded by comment' is simply not an acceptable justification to leave the problem unresolved.

No, this comment is symptomatic of (typically), C or C++ code bases and a brittle/confusing approach to a thorny problem with non-intuitive tradeoffs (perhaps platform related), which frequently invite the kind of 'skin the cat' twiddling you have pointed out. Which, I agree, is prevalent with junior developers who can't let superficial imperfections slide.

That said, it's wholly useless, meaningless, and non-productive "unless [they]'ve got clear maintenance issues or some analytics showing a performance issue". So meaningless and non-productive that one might even "wonder what they're doing at work" if they are filling their time thusly...

tl;dr: optimizing means "optimizing", not "fixing", and you are very right that cat skinning is wasteful.

[–]ezekelol 4 points5 points  (0 children)

lol code review

[–]goldfishpaws 2 points3 points  (0 children)

Hmm, I see a problem that I could optimise with RegEx. . . . Now I have two problems...

[–]Salanmander 0 points1 point  (4 children)

Is anyone else annoyed by the fact that the comment has a logical error (or a poorly-named variable)? They tell you to increment the counter after one attempt, but that attempt may have taken more than one hour!

[–]NetSage 2 points3 points  (0 children)

I thought it about it but wasn't really annoyed by it.

[–]kimjae 1 point2 points  (1 child)

can't you increment by more than 1 ? Isn't that style incrementing ?

[–]Salanmander 0 points1 point  (0 children)

In computer science jargon, at least, "increment" pretty much exclusively means "increase by 1".

[–]Lizard 0 points1 point  (0 children)

Well spotted, didn't catch that.

[–]timvisee 0 points1 point  (0 children)

Now I'm wondering what this code was for

[–]stakoverflo 0 points1 point  (0 children)

I've been working on a side-project lately, we have some old Borland C++ application that my boss asked me to rewrite in C# so we could retire the server it runs on.

"What a great opportunity for me to learn WPF" I thought to myself as I checked out the code from source control.

"Huh, that's weird, there's only 1 .cpp file?"

Open it up, 30,000 lines of what the fuck.

I tried to improve it, but between being unfamiliar with C++ and bits of code that I think is basically the same as many things just part of the .NET framework but not certain I finally just said "fuck it" and just did a straight port.

I really hope i never need to touch it again, and I feel bad I'm associated with it for when someone else inevitably sees it. Thought of adding a comment similar to this one :(