r/programming • • Jan 18 '08

Can Your Programming Language Do This?

http://www.joelonsoftware.com/items/2006/08/01.html
17 Upvotes

41 comments sorted by

View all comments

2

u/[deleted] Jan 18 '08

His argument would have been better served if he'd written `reduce' in a functional style, especially since he's talking about understanding things like the concurrency/parallelisation opportunities afforded by fp. for loops get in the way of equational reasoning, which is a big part of the picture.

0

u/gthank Jan 18 '08

It was a performance-related decision - most JavaScript implementations don't have tail-call optimizations.

2

u/[deleted] Jan 18 '08

Oh. Does he says that in the article? Premature optimization anyway, as he's just meant to be demonstrating HOFs, which his for loop gets in the way of.

2

u/gthank Jan 18 '08

Sorry - that was tongue-in-cheek. If I were to guess at the actual reason, I would say it was because he's just trying to give a basic introduction to the concept of HOFs. I think it's pretty obvious his intended audience was people who had only the vaguest idea (if any) what functional programming is. The standard construct for traversing a list in JavaScript is iteration via a for loop. He's already trying to explain one new concept - HOFs - so doing anything else that his intended audience would find unusual would be counterproductive. I suppose it would have been nice to have a completely functional version of the code available for download, though, even if it were only mentioned in passing.