STL and gcjx

gcjx is written in
C++ and uses the STL pervasively. It is in C++ as a compromise: it
isn’t C, and I thought I could convince the GCC maintainers to allow a
C++ front end. I felt that the Ada experience had probably soured
most of them on using a more esoteric language, like Java.

Bryce pointed out to me that the STL is not cheap. I already knew
that building STL-using programs took a long time — literally hours
to build gcjx on my wimpy laptop that hits swap whenever it builds a
big C++ program. That’s sort of an outlier, though, my desktop
machine builds it reasonably quickly. However, the result is also
huge:

$ ls -lh gcjx
-rwxr-xr-x    1 tromey   tromey       1.1M May 25 13:54 gcjx*

That’s after running strip, too.

Sigh. Perhaps we can replace our use of the STL with something
more light-weight — I left all the std:: tags scattered
all over the source for an eventuality like this (driven by my
perception of the GCC maintainers’ future requests, not any
engineering concern). I’m not even convinced this replacement would
help the size problem, though.

So, this is one identifiable advantage of Java’s otherwise goofy
erasure-based generics — there is only one implementation of any
given generic class, so you never have template-induced code bloat.

Be the first to leave a comment. Don’t be shy.

Join the Discussion

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.