|
|
|
|
|
by nerdponx
3096 days ago
|
|
What would the elegant Ruby version look like, and what was inelegant about the Python version? In Python I imagine you could just do something like this: from time import sleep
sleep_increment = 1
sleep_time = 0
success = False
while not success:
sleep(sleep_time)
success = try_thing()
sleep_time += sleep_increment
|
|
Personally I find the Python approach inelegant. Can it be composed? Why am I having to work with low-level looping constructs instead of higher level control flow constructs that map more closely to the task I’m actually trying to accomplish?
Same thing goes for any non-functional looping at this point. Why am I having to care about loop indices, incrementing counters, creating result arrays and inserting items into them, etc.? It’s (almost) 2018 and people are still writing low-level looping logic for the n-billionth time. Worse, people have to read it and parse it for the n-trillionth time to figure out which looping idiom is being used, instead of being able to see at a glance that something is being mapped, selected from, reduced, etc.