3 ms·
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(): f
by copx 12y ago
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.
- 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.