Linked by R_T_F_M on Thu 13th Sep 2012 21:19 UTC
FreeBSD "For the past several years we've been working towards migrating from GCC to Clang/LLVM as our default compiler. We intend to ship FreeBSD 10.0 with Clang as the default compiler on i386 and amd64 platforms. To this end, we will make WITH_CLANG_IS_CC the default on i386 and amd64 platforms on November 4th."
Permalink for comment 535115
To read all comments associated with this story, please click here.
RE[12]: C++
by boldingd on Fri 14th Sep 2012 21:45 UTC in reply to "RE[11]: C++"
boldingd
Member since:
2009-02-19

As for inheritance abuse in Java, it is true that a lot of people do it, but you can also have quite nice arquitectures using interfaces instead.


Java was initially designed around inheritance abuse. Inheritance is all over Java's oldest APIs; note for example that Java's original Vector class holds Objects (and not a specific type), which means that you can shove any java Object into them, and that you can't shove a bare scalar type into them (yes, I know that Integer is an object that just thinly wraps around an int). This makes these things extremely type-unsafe; if you want to constrain the types you put in a Java vector, you have to enforce those constraints yourself explicitly, in your code, and you always have to explicitly type-cast the things you get out before you use them. Essentially, Sun was trying to use polymorphism to provide a flexible, generic container without actually including generics in the language, and the result was a mess.

And while Java has proper generics now, that heritage is definitely still in the language. Java by design puts a lot of weight classes, objects and polymorphism.


I might also point out that, at least at my school, we actually teach in some of our courses that "inheritance is a functionality extension and code-reuse mechanism, and you should use the hell out of it." And while I think that's insane, I think that view is one of the fundamental assumptions that went into Java.


Sadly, many developers don't know any better, and you tend to be forced to abuse inheritance as soon as you start incorporating a lot of 3rd party libraries.

In C++ you can find such examples in ATL, MFC, OWL and TurboVision and most game engines.



OOP and inheritance is sometimes the right metaphor, but not always. It's great in game engines, because you often find yourself building large trees of heterogenious but semantically-related types (i.e. large trees of objects that are renderable, but have different render methods). Ditto for UI frameworks, where you find yourself adding lots of different types that are all widgets. But, "look, this technique is used a lot in C++, too!" is not the same as "look, C++ over-uses this technique!" OOP is Java's central organizing metaphor, whereas C++ is a multi-paradigm language that also supports imperative-style code and template meta-programming where those make more sense.

Reply Parent Score: 3