If you’ve spent much time with cljs, you probably know that cljs uses the Closure Compiler for code compilation. The Closure Compiler provides significant features such as dead code removal and minimization. (For more details, check out Luke VanderHart’s old but relevant post. Also make sure to check out Maria Neise’s awesome blog about her cljs compiler work through Google’s Summer of Code).
One other well-known, though often forgotten, benefit from Google Closure is the Closure Library. The Closure Library provides a huge set of functionality for free.
By all accounts, the code is high quality and covers lots of edge cases that would be difficult and painful to find. For example, what’s the regular expression to determine if a string is all whitespace? If, like me, you said
^[\s]*$… Well, thanks for playing, because that’s not 100% correct. Here’s what you want:
Good luck figuring out that IE’s handling of
0xa0 is broken before you get to production. And you get a nice little performance optimization thrown in for free.
The Closure Library is large, and I’ve only used a small portion of it. As I’ve suggested before, we could find worse ways to spend time than reading through the Closure api to get a feel for what’s available.