Classpath trouble

Java programmers are haunted by inferiority complexes. Before the functional programming wave, a much ink had been spilled debating the benefits of dynamic languages such as Python and Ruby. While the discussion focused mostly on syntax and the pros and cons of dynamic typing, it recently struck me that the major reason something like Python feels so much more easy to experiment with than Java is that the interpreter manages to import most installed third-party libraries automatically. The popular dynamic languages all have standard package managers (cpan, gem, setuptools) that can install third-party libraries from a standard location on the Net to a standard location on your filesystem. Once this has been taken care of, you can just specify which modules you want to use at the top of your program files, and you’re good to go.

Because Java is language of the Web era, where open source libraries have proliferated, a typical Java program relies on many more external dependencies than a C or C++ program, but since it came of age so early, it did not develop tools as sophisticated as those available for the scripting languages. Hence the endless artifact hunting and path setting.

Of course, there are Java solutions to the problem. More or less standard classpaths have been defined for Java: it’s one of the features of things like JEE containers. But this goes only half-way: these conventions are only environment specific (and in fact, even vendor specific). There is no standard location to use for that experiment we might want to write to test a technique or a library.

Hence the existence of Maven and more recent competitors like Gradle, which create a common location for all your application dependencies and take care of downloading the stuff from the Web. Although this an improvement over passing options to javac and java, each tool behaves slightly differently and you still need to define a build file for every new project. In Perl, Python and Ruby, once a library has been installed globally, it is automaticaly available in all programs. Of course, global libraries have their own problems, but they are so practical for fooling around! Which is how you start learning everything.