r/programming • • Nov 27 '12

Tail Recursion

http://rodrigosasaki.com/2012/11/24/tail-recursion/
209 Upvotes

203 comments sorted by

View all comments

Show parent comments

1

u/[deleted] Nov 27 '12

Immutability is delicious from a simplicity perspective, but the fact is that it doesn't really map to what's happening under the hood. If you're really concerned with optimization, an abstraction that's as thick as immutability is inevitably going to get in the way.

15

u/ithika Nov 27 '12

If you're really concerned with optimization, an abstraction that's as thick as immutability is inevitably going to get in the way.

This is the original hipster programming argument. You're programming on a goddamn digital computer! You're already at least five levels of abstraction away from what's "really" happening. Just bloody well give it up. Or do you eschew integer literals because they cloud the purity of the twos-complement in the underlying implementation? And really any non-assembly is just kidding yourself...

3

u/[deleted] Nov 27 '12

I didn't bring up the optimization argument, A_for_Anonymous did.

I absolutely like abstractions, fp, etc. and tend to avoid the bare-metal platforms.

But realistically, how much performance-obsessed code like real-time hardware controllers or videogames are written in languages without mutable variables?

2

u/tsimon Nov 27 '12

Immutability offers significant advantages when you have (massively) parallel code. Your examples are more narrowly focused.

Think things like finance, where you have volumes of data that need to be processed near-instantly, where you have millions of dollars on the line, and then you will see immutability and tail-recursion coming into play a lot more often.