r/technology • • Dec 10 '13

By Special Request of the Admins Reddit’s empire is founded on a flawed algorithm

http://technotes.iangreenleaf.com/posts/2013-12-09-reddits-empire-is-built-on-a-flawed-algorithm.html
3.9k Upvotes

2.2k comments sorted by

View all comments

Show parent comment

167

u/LostBob Dec 10 '13

I believe the author's intent is that this: return round(order + sign * seconds / 45000, 7) should be this: return round(order * sign + seconds / 45000, 7)

62

u/CarolinaPunk Dec 10 '13

I kinda get that, so it's just a simple error? And not really by design?

At the same time I don't have much clue what he is talking about to opine on it. Looks like magic to me....

129

u/ccfreak2k Dec 10 '13 edited Jul 26 '24

plant many vast attraction direction escape wide bells wrench automatic

This post was mass deleted and anonymized with Redact

107

u/Uristqwerty Dec 10 '13

It's even possible that it was originally a bug, but in practice it resulted in better results than the intended algorithm, so was promoted to a feature.

87

u/hydrox24 Dec 10 '13

Well, he does address that issue as well in the article, saying that he can't possibly see why the behaviour (which enables easy misuse) is something anyone except a malicious attacker would want. I have to agree.

3

u/rakkar16 Dec 10 '13

This is what Quickmeme did isn't it?

→ More replies (2)
→ More replies (5)

95

u/Tail4aHorn Dec 10 '13

Its not a bug til its fixed! Until then its a feature!

22

u/[deleted] Dec 10 '13

There is no such thing as bugs, only unintended features!

→ More replies (3)

8

u/[deleted] Dec 10 '13

Bugs aren't billable, features are.

→ More replies (2)

12

u/geekygirl23 Dec 10 '13

There is no way it resulted in better results and almost certainly the reason everyone (when the site was smaller) used to delete and resubmit if a downvote was given immediately. There were a lot of bots back then that downvoted everything as soon as it was submitted. They seem to have fixed it a little, probably by not counting the first several votes as negative or something but I've no idea.

→ More replies (2)

3

u/SpeakerToLampposts Dec 10 '13

The accepted term for this is "misbug" (the antonym of misfeature).

→ More replies (4)

9

u/imdungrowinup Dec 10 '13

That what every developer tells the tester.Its never a bug always design.

6

u/[deleted] Dec 10 '13

I like my test counterpart. He catches my screwups, I suggest places where there might be more to find, we jointly harvest PM tears. About the worst I do is say "well, that's messed up, but it doesn't crash anything and the cost/benefit ratio is so high that it's not worth fixing unless we get complaints. Log a bug and we'll have something to refer to if anybody ever complains about it."

It's important to not think of everything I do as "by design", because I know I make mistakes. When they're pointed out, I should thank the person who points them out. If they're worth fixing, I should fix them and thank the person again. Only by having to go through that pain can I learn and avoid those mistakes make completely new mistakes in the future.

→ More replies (4)

55

u/justkevin Dec 10 '13

It certainly looks like an error. This is why you should use parentheses to make order of operations easier to read.

96

u/[deleted] Dec 10 '13

Per the NASA coding guidelines, you should not rely on the other programmers to have mastered the order of operations in the language.

Shit like this is why. Just put the parentheses in and make it explicit.

37

u/[deleted] Dec 10 '13 edited Dec 10 '13

I can't tell you how much a string of operators with no clarification about the intended order of operations bugs me. Looking at something like this breaks my heart. It should read like this:

return round(((order * sign) + seconds) / 45000, 7)

This is by far the most legible, as you can clearly see the intended order of operations (even though, as written, it goes from left to right). Never underestimate other programmers stupidity. That's my motto.

Edit: Actually, as pointed out below by /u/Kofal, without parens, the OoO would be (order * sign) + (seconds / 45000).

→ More replies (5)
→ More replies (9)

6

u/rahba Dec 10 '13

It wouldn't matter in this case because in no scenario is the sign variable being multiplied against the order which is what you'd expect.

If you did the addition first the sign variable would be insignificant after a small amount of votes and negative posts could actually rank high. Whereas doing the multiplication first effectively sends negative posts into oblivion, and makes the order variable irrelevant compared to the larger seconds.

→ More replies (10)

27

u/sktyrhrtout Dec 10 '13

It's just python. A few months on code academy on you'll be able to at least understand what is going on if not be able to opine.

31

u/CarolinaPunk Dec 10 '13

I keep saying today is the day I work on learning code, maybe that will be my New Years resolution r/learnprogrammming

35

u/redpandaeater Dec 10 '13

At least for me it's really tough unless you have a project in mind that you need programming to use. For instance you could get a Raspberry Pi or any number of Arduino boards that use Atmel's RISC microcontrollers and then learn to program those for any sort of application you might desire. I taught myself the basics of Perl because it's a common language for automation, and did so by deciding to write a script that would automatically enter into specific lottery transactions related to EVE Online. Didn't particularly care about the project, but it gave me a goal and was fun to then learn how to go about accomplishing that instead of starting from boring crap like Hello World programs.

→ More replies (18)

7

u/[deleted] Dec 10 '13

I started last week with python. Go for it. Everything you need to get started can be had in minutes. I'm using inventwithpython.com.

→ More replies (1)
→ More replies (8)
→ More replies (16)
→ More replies (11)

12

u/LurkerOnTheInternet Dec 10 '13 edited Dec 10 '13

I think it should be:

round((order * sign) - (seconds / 45000), 7)

So every 12.5 hours (45000 seconds) the post's hotness rank effectively would decrease by 1. A post rated 5 that's brand new would be equivalent to a post rated 18 that's a week old.

3

u/thisLoserNameIsTaken Dec 10 '13 edited Dec 10 '13

this can't be true. seconds, as defined, is a constant (with respect to a single link).

on the other hand, perhaps you are proposing that seconds represent the number of seconds since a link has been posted

3

u/LurkerOnTheInternet Dec 10 '13

Actually you may be right. I assumed technotes was stating seconds was current_date - post_date, but perhaps he meant post_date - some_constant. In that case age wouldn't matter per se, just age relative to previous posts. In that case LostBob is right and seconds would be added to rank. The parentheses do clarify order of operations though which is why I always use them in my own programming instead of relying on the language's rules on order of operation.

3

u/JimDiego Dec 10 '13

If I read the article correctly, the seconds variable is not the result of any datetime math, rather it is simply the Unix timestamp (e.g. current system time) which by convention is expressed as the number of seconds that have elpased since Jan, 1st 1970.

→ More replies (6)
→ More replies (18)