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

Just finished reading Osborne's actual write up, and it's one of the better tutorials I've read on how to optimize code. Write things in the simplest way, measure, then optimize the bottle necks. We've all heard that, but here is a very concrete example of how to do it in practice. He puts in type annotations and fiddles with the underlying Java bits only where necessary, and wraps it in a way that the code calling the optimized code is mostly idiomatic Clojure.

It also reflects well on the pragmatism behind Clojure's design. The type annotations and dropping into Java, while not as pretty as pure Clojure, are still prettier than regular Java and can be isolated to the performance hot spots.

I appreciated this little bit of editorializing:

"The -> and doto macros save us from having to name each intermediate step and from the unreadable nesting you’d get if you tried to do the same thing in a typical curly-brace language.

    BufferedReader reader = new BufferedReader(new InputStreamReader(new BufferedInputStream(
                          new FileInputStream(filename).skip(startByte), 131072), "US-ASCII"));
Oops, FileInputStream.skip() returns a long, so that doesn’t even work. Now who was complaining about Lisp syntax (looking (like (this)))?"

Nicely done. An informative, enjoyable read. Two thumbs up.



Consider applying for YC's Summer 2026 batch! Applications are open till May 4

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

Search: