Tuesday, March 11, 2008

Statically Typed Foreword

Robbie asked me to write a foreword for his upcoming Guice book. Having never written a foreword before, I Googled, "how to write a foreword," which brought me to two helpful posts from Muse Ink: Foreword Thinking and Foreword March.

Here's what I came up with:

I created Guice in the midst of one of the biggest projects of my career. When you have hundreds of engineers touching millions of lines of code, you come to appreciate the benefits of static type checking. Static types aren't just about compiler errors. In fact, I rarely see Java compiler errors nowadays. Thanks to all that great, formalized Java type information, my IDE helps me write correct code in the first place.

Writing your application in a nearly 100 percent type safe manner, like Guice enables and Robbie advocates in this book, opens the door to a new level of maintainability. You can effortlessly navigate unfamiliar code, jumping from interfaces to their implementation and from methods to their callers. As you master your Java tools, you realize that deceptively simple atomic refactorings combine to form molecular tools, which you can reliably apply to companywide swaths of code, accomplishing refactorings you'd never even consider trying by hand. In the long run, it's much cheaper to ward off bit rot through heavy reuse and constant refactoring than by nuking the world with a rewrite every couple years.

Having experienced Guice's benefits on a number of projects, we at Google knew we couldn't keep it to ourselves and decided to make it open source. Readying Guice for the outside world felt like it took an order of magnitude more work than writing that first internal version, but community contributors like Robbie who fuel the forums, help polish rough edges, and generate excellent documentation like this book pay back that effort tenfold. You'll find that Robbie's brevity and conversational tone suit Guice well. I like my books like I like my APIs: with high power-to-weight ratios.

I focused on static typing because I've gotten a lot of questions about it lately. There's a lot of misinformation out there. For example, some people incorrectly conflate static typing with compiler errors, and, based on that false foundation, they claim that unit testing is an adequate substitute for static typing.

Static typing and unit tests are orthogonal. Static typing doesn't replace unit tests. Unit tests don't replace static typing. In fact, static typing can make maintaining unit tests much easier, especially when paired with the right mocking framework. I certainly believe that scripting languages have their place; beware anyone who tells you that static typing doesn't.

Monday, March 10, 2008

Thanks for the Jolt!

Jolt

Guice took home the Jolt, a.k.a. the geek Oscar, at an award ceremony hosted by Bob Cringely during SDWest:

The Jolt Awards recognize those products, books, and websites that have "jolted" the industry in the past year. Winners are selected by a panel of judges consisting of industry insiders, columnists, and technology leaders.

I started reading Dr. Dobb's Journal back when I was 12. I regularly bought it off the newsstand at Oxford books in Atlanta and was lucky to understand one article in the entire magazine. I learned much of what I know by reading instead of going to college, so DDJ has been an invaluable resource for me. I remember greatly admiring the Jolt winners each year. I hardly imagined myself among them, especially so soon.

The judges picked three productivity winners and one overall Jolt winner from a pool of six finalists in each category. Guice had some stiff competition; other finalists in the Libraries, Frameworks and Components category included the Eclipse Modeling Project, JasperReports, Qt Jambi, the Spring Framework, and the Zend Framework. Congratulations to the productivity winners: Eclipse, Zend and JasperReports.

Kevin and I had the pleasure of accepting the award on stage, but the truth is, Guice 1.0 is heavily indebted to a lot of people. I can't name you all, but I would like to thank:

  • My wife Krista and daughter Dagny for their support
  • The Jolt judges for recognizing our hard work
  • Kevin Thompson, our manager at the time who gave me the latitude to work on Guice full time
  • My mentors Josh Bloch and Neal Gafter
  • Cedric and Hani for their treatment of Guice in Next Generation Testing
  • The early adopters and contributers who helped steer Guice to 1.0, in random order: Jesse Wilson, Zorzella, Laura Werner, Peter Epstein, Don Brown (Struts 2), Cliff Biffle, Arthur Gleckler
  • Brian Slesinsky, for his apt analogies, Eric Burke, for his cartoons, and all the other bloggers who helped popularize Guice
  • Robbie for writing a Guice book
  • Dhanji for writing a Guice book, and integrating Guice with Hibernate and JPA in Warp Persist
  • My parents for instilling a strong sense of type safety at an early age (Thanks for the reminder, kebernet.)

And finally, I'd like to thank Google for its unparalleled commitment to open source. If you haven't tried Guice yet, now is the time.