Re:Show HN: Code Words, a quarterly publication about progra...
by therealdrag0 on Friday December 05, 2014 @07:35PM
(#8707826)
I really like the approach taken in the introduction to functional programming article.
[ Parent
| on HN ]
Re:Show HN: Code Words, a quarterly publication about progra...
by mlangdon on Friday December 05, 2014 @10:50PM
(#8708283)
As 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.
Re:Show HN: Code Words, a quarterly publication about progra...
by thmcmahon on Saturday December 06, 2014 @03:17AM
(#8708702)
Yep great article. As a beginner programmer I find functional more intuitive than OOP, there just seems to be less abstract concepts and boilerplate.
Re:Show HN: Code Words, a quarterly publication about progra...
by splinterofchaos on Sunday December 07, 2014 @12:46AM
(#8711379)
There 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.
Re:Show HN: Code Words, a quarterly publication about progra...
by copx on Saturday December 06, 2014 @02:23PM
(#8709903)
Well 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.
Re:Show HN: Code Words, a quarterly publication about progra...
by splinterofchaos on Saturday December 06, 2014 @03:07PM
(#8710007)
How 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.