Hacker News new | past | comments | ask | show | jobs | submit login

Many of Ruby's standard higher order functions came from Smalltalk, such as collect, detect, inject, select, and so on. I expect to see fewer for-loops than in JavaScript, but I'd be more forgiving than with Ruby due to having less familiarity with the language.

For-loops and if-statements have their place, but too many of them (especially after a couple levels of nesting) makes code hard to read. Different languages have their own answers for this. In Ruby you'd use polymorphism and higher order functions, while C++ would use polymorphism and iterators.

Mind you, all of this is based on your self-professed experience with a language. If you tell me you're an expert in Ruby and proceed to write for-loops all over the place then I'll be severely unimpressed. If you tell me you're mostly a Java developer, but you're going to do the interview questions in Ruby because it's easier to whiteboard with (and more applicable to the work you'd be doing at my company) then I'd be a lot more forgiving.

Come to think of it, I think this may explain the perception that older developers have a hard time finding work. I get very excited when I see 20+ years of experience on someone's résumé. I assume they're going to know all sorts of programming paradigms, algorithms, data structures, languages, techniques, and so on. The problem is that the human brain discards information if it goes unused for too long. As a result, a lot of older devs have a fantastic grasp of the fundamentals because they use them every day, a solid understanding of the one or two languages they use now, and a hazy remembering of a bunch of things they used 5+ years ago. In other words, they're a lot like a developer with 5-10 years of experience, except they're marginally more well-rounded and have better war stories. That would normally be someone I'd really want to hire, but it falls so far short of the unrealistic demigods I'd imagined them to be.




Sorry, that was a trick question: in Smalltalk, the for-loop is just a block/higher order function applied to a collection, except that the collection is an Interval defined by its start, end and optional step that only generates its contents on-demand, for example when iterating:

    (1 to: 10) do: [ :i | ... ].
So (1 to: 10) creates an Interval, and then `do:` iterates that Interval. There's a shortcut convenience `to:do:` in Number that allows you to avoid the brackets.

The point being that the dichotomy "for-loop vs. higher order functions" is a false one. And usefully so, for example you can adjust methods in Interval to iterate in parallel (or you use a different kind of Interval) without having to touch the language or most iteration code.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: