3 ms·
I really like the approach taken in the introduction to functional programming article.
by therealdrag0 12y ago
I really like the approach taken in the introduction to functional programming article.
- mlangdon 12y agoAs somebody who can still only grow a neck beard, I've been trying to get into functional for a while now. Maybe it's because the examples are in python (a non-crazy looking language I've written a lot of lines in), but this is the first time I've read an FP article and thought I might enjoy explicitly using this stuff. I've been low-side effect and anti global for a while, but filter() is sexy.
- thmcmahon 12y agoYep great article. As a beginner programmer I find functional more intuitive than OOP, there just seems to be less abstract concepts and boilerplate.
- splinterofchaos 12y agoThere do exist object-oriented functional languages (Ocaml). Functional vs OOP is a false dichotomy, though a very common one. I prefer to use functional techniques in imperative languages with simple objects.
- copx 12y agoWell I only noticed how much less efficient the "functional" code is, downright wasteful even. And nobody is going to tell me that this: def move_cars(): for i, _ in enumerate(car_positions): if random() > 0.3: car_positions[i] += 1 ..is not way more readable and clear than this: def move_cars(car_positions): return map(lambda x: x + 1 if random() > 0.3 else x, car_positions) If you ask me the article makes a good argument against functional programming.
- splinterofchaos 12y agoHow about: def move_pos(x): if random() > 0.3: return x + 1 return x def move_cars(positions): return map(move_pos, positions) I do not believe that functional programming benefits from brevity, except at the top layer. Unfortunately, functional programmers often expand their equations which, having examined them thoroughly, they understand implicitly, but can give too much information to the reader all at once. Though, I have to agree, the FP community really hasn't been able to demonstrate how to do it without losing efficiency, and yet many proponents claim we should abandon all other paradigms. All of these articles seem very biassed towards FP. I enjoy functional programming, but I prefer to work in imperative languages where I have a choice between paradigms.