Hacker News new | ask | show | jobs
by samuel 6203 days ago
The less the programmer says, the more flexibility the compiler has to speed things up.

I seriously doubt it. The more the compiler knows, the more it can optimize things.

What it's "daily" in this example? It could be anything. The only thing the compiler knows at compile time is that it should generate some lookups searching and calling the functions "__iter__", "__slice__", etc... Put that line into a function which receives daily as a parameter and it could mean something different at every single invocation. Human beings, looking that code think know what it does, while in fact don't have a clue. The equivalent code in clojure someone has wrote only is really equivalent under some very specific assumptions.

I know, I know, at runtime you could gather all kinds of interesting data to optimize things. But, that's not easy nor cheap and, sometimes, iterating over an array, it's just iterating over an array.

1 comments

Also... The more the runtime knows, the more it can optimize away (JIT).