Call stack Memes

Posts tagged with Call stack

Fuck Haskell Long Live Java Script

Fuck Haskell Long Live Java Script
So someone decided to implement functional programming in JavaScript by... literally just calling functions recursively and pretending they're doing Haskell. The isEven function checks if a number equals zero (true) or one (false), then recursively calls isOdd with n-1. The isOdd function just... calls isEven back. This is the programming equivalent of asking your roommate if they're hungry, and they respond by asking if YOU'RE hungry, and this continues until someone starves or the call stack explodes. Instead of using the modulo operator like a normal human being ( n % 2 === 0 ), this genius decided to torture the JavaScript engine with mutual recursion. The irony? Haskell would actually handle this elegantly with tail call optimization. JavaScript? It'll blow up your stack faster than you can say "Maximum call stack size exceeded." So yeah, "long live JavaScript" indeed—until you try to check if 10000 is even.

There Is Arecursion Under My Bed

There Is Arecursion Under My Bed
This is what happens when you don't implement a proper base case! The kid yells about recursion under the bed, then we see the dad looking under the bed... only to find another kid yelling about recursion under that bed. It's recursion all the way down! The programmer's equivalent of the monster under your bed is just an infinite stack overflow waiting to happen. Sweet dreams, hope your call stack doesn't explode before morning!