Hacker News new | past | comments | ask | show | jobs | submit login

But who in their right mind would do the second one?

Obviously you can make code both less efficient and less readable. But starting with code that a competent programmer has written, I find it seldom makes it more readable when you make it more efficient.




  But who in their right mind would do the second one?
Oh abritishguy, I can assure you that the world is awash in such magical code snippets.


> competent programmer


It's amazing the sorts of things otherwise sharp programmers will write when they're tired, hurried, and devoting cycles to more interesting/complicated parts of an implementation.


> true scotsman


>>But who in their right mind would do the second one?

Surely you jest. I don't know who, but their handiwork is everywhere.


People using ORM can end up writing the second one without it being obvious.


i tend to agree. take dijkstra's algorith implemented with a fibonacci heap or something very simple like

for i = 1 to 100 if x = this do that and something with i else something else with i

easy to read, less efficient than: if x = this for i = 1 to 100 do that and something with i else for i = 1 to 100 do something else with i

from my experience, compilers usually dont hoist very well

edit: sorry, spaces didnt come out well




Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: