Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I could comprehend the first piece of code in about 20 seconds and the final result in a couple minutes. It's pulled apart nicely, but it's not as simple any more.

The end result might look better in something like Lisp or Ruby, but I don't think it's a great tradeoff in Python.



There is a price for new vocabulary involved, which is some learning curve.

By the way, first piece of code can become much more hairy with time.


It depends on what you consider simple. I don't consider the earlier code simple, just crude. Testing it, or adding features (e.g., tacking caching) would increasingly make it messier, plus the code mixes error handling and low-level concerns with business logic.

The final result is broke up in nicely referentially transparent functions, making testing or refactoring more trivial. Also, the main body reads as a DSL, a programmer can pick this code and more easily figure out what it does, which is easier to reason about.




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

Search: