Friday, April 11, 2008

Which Languages Handle Packages and Libraries Best?

In the post Why Do We Use C++, I made the following statement.

Another, often forgotten strength of C++ and of many traditional modular and modular-turned-OO languages is linking, or more generally, we might say 'package management'. C++ innately offers build-time linking and runtime 'linking' is also usually available (i.e., DLLs). This allows graceful scaling. Tool support for this in C++ is strong and reasonably robust because C++ is so frequently used to build enormous projects. It's possible to build massive projects in pieces in ways that are awkward or impossible in many functional or logic languages.

Simon wrote,

C++ good at linking and package management??? That's the most ridiculous thing I've heard all week. This is one of the weakest aspects of C++. Where to start:
* no standard ABI for compiled code. ("Don't mix compilers")
* no standard for managing namespaces and packages like in Java.
* Very hard to evolve a class and keep binary compatibility. Lots of obscure compiler depend rules need to be followed to do this. ("Change a .h file, rebuild everything that uses it")
* dynamically loading code modules has to be done manually. Java, Python and other languages load classes on demand.
* C++ code can call C code, but any other kind of mixed language development is a nightmare.
* easy to break features like dynamic_cast when loading share libraries. (My fun debugging adventure this last week...)

I think Simon makes some excellent points here. So I'd like to ask the community.

What is the best language (and what are the best language features) for linking/loading and package and library management?

4 comments:

michaelw said...

I always liked ML's Functors (see, e.g., Designing a Generic Graph Library using ML Functors), however, I haven't done anything with it that really stretches it to the limits.

Tom Finnigan said...

My company is in the process of taking a c++ codebase and making it available as a library. c++ does have some serious issues when being used as a library, since iostream implementations are generally not binary compatible, and the runtime compiled against matters in other various ways.

Some of our library users have suggested providing C bindings, because it would alleviate a lot of the problems.

Other than C, languages that are interpreted all seem to do pretty well. But if you give the c++ source, you can also get very good compatibility, so that's not really apples to apples. Java has paid a lot of attention to the problem, and do well.

The best I've seen is a dependency resolution system such as perl's CPAN. This isn't a language feature per se, but greatly enhances the usability of libraries, even the compiled modules.

Anonymous said...

C#. (<-- period)

You don't ever have to think about moving things out in separate dlls, and it's very easy to add links to e.g. c-dlls.

And via reflection you can access any dll you'd like. It's heaven ;)

Joshua Smith said...

Thank you for the nice info. It was easy to read, but I'd like to add that if your software company needs to be updated try software development service.