In other words the correct choice of algorithm and data structure can dramatically simplify a problem and the amount of code and time needed to solve it. It also means that having tools where you can quickly apply different techniques, ahem, composable functions, that you can search for more efficient solutions with a lot less effort. That doesn't solve the smartness problem but it makes it a lot more tractable.
Why GNU grep is fast (2010)
21–30 of 133 posts
Re: Why GNU grep is fast (2010)
#221) make it do less
2) make it do more at a time.
The first corresponds to using more efficient algorithms and data structures. The second is parallelism.
Re: Why GNU grep is fast (2010)
#23Earlier quoted context omitted.
The article references an article published in 1991. Does that need stating too?
If this story was just a blogspam saying "Hey look I found this article from 1991 which is still relevant" then yes, because the story would be worth nothing by itself. But this story is actually an email (from 2010) written by the guy WHO ORIGINALLY WROTE GREP, making it a pretty damn interesting source in its own right. In that sense, the 1991 article is very much an aside. In conclusion, no.
Just a pedantic remark: He (Mike Haertel) originally wrote GNU grep. Grep, on the other hand, was originally written by Ken Thompson.
Re: Why GNU grep is fast (2010)
#24This applies very well to optimization, too. There are only really two ways to optimize code: 1) make it do less 2) make it do more at a time. The first corresponds to using more efficient algorithms and data structures. The second is parallelism.
Yes, but less in a particular way. It's important to skip processing stuff that can't matter in the end. In this example, skipping over bytes that can't matter because the end doesn't match. In DBMS, it's important to skip over records/columns/values that can't contribute to the answer.
The surprising realization in optimization is that procrastination is a virtue. Lazy beats eager.
Re: Why GNU grep is fast (2010)
#25https://news.ycombinator.com/item?id=1626305, 1193 days ago, 115 comments
https://news.ycombinator.com/item?id=2393587, 972 days ago, 68 comments
https://news.ycombinator.com/item?id=2860759, 842 days ago, 43 comments
( ionelm also pointed out a previous submission: https://news.ycombinator.com/item?id=6814153 )
Also worth mentioning is "The Treacherous Optimization" ( http://ridiculousfish.com/blog/posts/old-age-and-treachery.h... ), although previous submissions of that provoked no discussion at all.
https://news.ycombinator.com/item?id=1624402
https://news.ycombinator.com/item?id=5257874
ADDED IN EDIT: More rigorous searching has turned up substantial discussion of the Treacherous Optimization: https://news.ycombinator.com/item?id=1627367
Re: Why GNU grep is fast (2010)
#26This applies very well to optimization, too. There are only really two ways to optimize code: 1) make it do less 2) make it do more at a time. The first corresponds to using more efficient algorithms and data structures. The second is parallelism.
Re: Why GNU grep is fast (2010)
#27Re: Why GNU grep is fast (2010)
#28By this logic you can write really fast programs in Haskell, because it avoids computing unused values (and therefore complete calltrees). (Unfortunately, the management of such calltrees -- thunks -- often has higher cost than outright computing them in the first place.) I try hard, but I'm not smart enough to write programs that do nothing. :)
Re: Why GNU grep is fast (2010)
#29I don't know who to attribute the quote to, but there is one the goes something along the lines of: "The fastest method to execute is an empty method."
> "The fastest method to execute is an empty method." The fastest method to execute is an empty method that was never called. The fastest method to execute is an empty method that was never called and never written. The fastest method to execute is an empty method that was never called and never written and never planned.
Re: Why GNU grep is fast (2010)
#30By this logic you can write really fast programs in Haskell, because it avoids computing unused values (and therefore complete calltrees). (Unfortunately, the management of such calltrees -- thunks -- often has higher cost than outright computing them in the first place.) I try hard, but I'm not smart enough to write programs that do nothing. :)
You can do that in any programming language by, well, not computing unused values.