Blzut3
Member
Posts: 375
Registered: 06-04 |
Maes said:
It's not unusual to be able to make a more lightweight version of e.g. a Stack or ArrayList class than the built-in one, even for a novice programmer, especially if limited to a single data type. What such re-implementations often "lose" are some frills like thread safety, generics (but not always), implementation of some exotic interfaces, serialization, etc. and of course having to prove from the ground up that they are correct.
While this may be true, one thing most other languages don't have to put up with is binary bloat from using their standard templates. In Java generics are basically a way of having the compiler handle Object casts for you and don't really exist at run time. I'm not familiar with all the implementation details of ArrayList, but I can't imagine where it would perform significantly poorly from another implementation. I can see making specialized containers for primitives, but that's about it.
C++ templates generate code at compile time, which has many benefits, but it does mean that heavy template usage (as seen in the STL) can bring the binary size up dramatically. I'm sure having all that code duplication (and I reiterate that it usually isn't a small file size difference) doesn't help with CPU caching, but I'm not an expert here.
|