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

The key to making programs fast is to make them do practically nothing.

This is the Ultimate Truth of optimizing computer programs, and it seems so few people understand it.

"Why can't you make Python faster!?" Because Python does a lot of stuff without you asking.



It might be the Ultimate Truth, but it also begs the question. Of course you need to make programs do less, the question is how you actually do it...


He didn't say it was the Complete Ultimate Truth, did he?


It's just a truism. You make things faster by making them faster.


No, you don't make things faster by making them faster. You can't make your computer do things faster.

You can only make it do less.


It's not just a truism. It's like a koan. It's meant to make you think about what you really need.


I have to disagree, and I could actually use Boyer-Moore as an example on this:

Split the string you're searching into four roughly equal pieces, with an overlap so that potential matches is guaranteed to be found. Then do a Boyer-Moore on those in parallel. E.g. if you look after FOO, you'd have to split the string like this (pipes are the start/end of the piece exclusive, i.e. piece 1 does not contain the last O)

    piece 1 here|
  ...7890abcdeFOOghijk
             |piece 2 here
Now, what we know is that in the worst cases, this would require more operations: The O may be detected by piece 1, and it will check if the character in front is an O as well. Piece 2 will also check the same O, so there's redundant computation going on. However, this is theoretically faster (I'd guess it is practically faster for large files) even though this requires more operations.


Another way of putting this was from an nVidia developer deck I once read: the fastest triangle you can render is the one you don't render at all.


I thought the Ultimate Truth of optimizing computer programs was: Premature optimization is the root of all evil.


If you're doing it right, then by the time you've decided to optimize, it's no longer premature.


Isn't that the same as what I said above?


http://www.jwz.org/doc/easter-eggs.html

Mozilla is not big because it's full of useless crap. Mozilla is big because your needs are big. Your needs are big because the Internet is big. There are lots of small, lean web browsers out there that, incidentally, do almost nothing useful


Which browsers? uzbl? midori? seamonkey? lynx?




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

Search: