r/shittyprogramming • • Dec 05 '14

Recursion 101

Post image
316 Upvotes

73 comments sorted by

View all comments

6

u/seiyria Dec 05 '14

What is recursion?

0

u/OrionBlastar Dec 05 '14

When a function calls itself.

Which is good for calculating Fibonacci numbers or Ackerman numbers, but you have to have a variable or variables that decrease over time to prevent infinite recursion that results in a stack overflow.

Here recursion is used to computer Ackermann numbers in C++:

https://github.com/orionblastar/ackermann0/blob/master/ackermann0.cpp

7

u/seiyria Dec 05 '14

shittyprogramming

taking me seriously

this sub should be called badprogramming, no one can ever act "shitty" :(

-3

u/OrionBlastar Dec 05 '14

Shitty programming is like this:

int worddata; printf(worddata);

Stuff where you forget to initialize a variable and it pulls data from a random location in memory where the variable is stored. Yet the compiler does not notice it, compiles the shitty code, and it prints some random number each time it runs.

Shitty programming is just not paying attention to what you are doing, not taking the time to look it over and debug. Not following directions and getting things confused.

A function that just calls itself with no way to terminate the recursion is just another example of an infinite loop.

Shitty programmers always shoot themselves in the foot and then blame someone else for their mistakes.

I used to work with a lot, had masters and PHDs in computer science and still were shitty programmers that I always had to debug their code to fix problems like that.

5

u/seiyria Dec 05 '14

Have you ever been on a shitty network subreddit? /r/shittyaskscience maybe? pls

-6

u/OrionBlastar Dec 05 '14

Nope it looks like circlejerk.

For a really shitty network subreddit try /r/kuro5hit it is run by Trolls from Kuro5hin when /r/kuro5hin locked them out. Kuro5hin is a troll website based on Scoop that started out as a Slashdot clone and ended up a Troll Paradise.

7

u/seiyria Dec 05 '14

Ok, then you don't get how the shitty network operates. Sorry, but the jokes (and most of this subreddit) will probably go over your head. Carry on.

-1

u/OrionBlastar Dec 05 '14

Bad code is not funny, it causes all kinds of problems.

3

u/seiyria Dec 05 '14

tl;dr you.doesNotKnowHowTo().take.thingsShittySeriously()