The Compiler is Your Friend
I’ve been coding exclusively in Java for the last few weeks. However, when I needed to write a quick program to crunch some numbers the other day, I decided to write it in C++ for the change. Since I’ve also been working exclusively within Eclipse, I decided to use a simple text editor for this and gcc from the command line.
The experience made me reflect a little on the importance of good tools.
In Contributing to Eclipse, Kent Beck and Erich Gamma speak of the compiler moving from being a separate tool to “air - something vital that’s always around”. While using the JDT, the compiler is constantly running in the background, warning you of potential errors as you type each line of code. The IDE also makes suggestions for fixes that save much typing. In this collaborative model, the compiler/editor is like a helpful colleague looking over your shoulder and making gentle suggestions from time to time. By contrast, the model of finishing the code, trying to compile it and working through the often opaque error warnings thrown by a c++ compiler is more like facing a difficult interview. The rhythm of work is completely different.
Doug Schaefer, project lead for the Eclipse CDT, explains in this Callisto podcast (direct link to mp3) that the simplicity of Java makes the JDT experience possible but that it would be prohibitively expensive to do the same with CDT.
Another thing I missed was JUnit. At the moment, I frequently work outside my comfort zone, learning through discovery and error and unit testing gives me the confidence to do this and to refactor. The task at hand was so brief it wasn’t worth investing the time to explore the xUnit variants for C++ but I intend to do so the moment I need to write more substantial code in that language.
February 26th, 2008 at 12:11 pm
I’ve had a similar experience with the two languages .. there seems to be no proper IDE for C++ while there are a number for Java. The basic problem is that the concept of macros makes it impossible to build a parse tree in the general case (since they may be arbitrarily complex or even Turing undecidable). This is the C legacy of C++ which is killing the language, just like radio killed the radio star ..
March 8th, 2008 at 7:02 pm
Thanks for the comment. Not entirely sure that I’d agree that it’s killing the language, but it definitely makes it harder to work with than, say, Java.