Herb Sutter - Why C++? [now known as rapidcoder's dumb ass comparison with java]

Pages: 12
I agree on modularity, especially dynamic. C++ has fundamental problems with it.

Templates are not an optimization technique. They are the basic language concept that enables static polymorphism, generic programming, and metaprogramming, things that make C++ a unique language (combined with OOP, of course). If you find yourself doing something "as you would in Java", you're using the wrong language.

Google and especially Mozilla are terrible examples as far as C++ goes, even if you've misrepresented their guidelines.
Most programmers by "readable code" uderstands pure OOP code, using virtual calls, and no templates (except maybe using standard STL containers and std::string)


When I started C++ three years ago (with the help of this forum), I jumped directly into using templates.

I couldn't write pure OOP (nor do I understand what it means), nor did I understand virtual calls. I had no problems grasping templates from day 1. I have been using templates heavily without any major readability issues for the last 3 years, and have had to convert usual classes to templated classes at least 10 times.
Last edited on
Now we need voices from developers who do development in different realms. Embedded devices OS can use Java? Embedded devices apps can use Java? Device drivers can use Java? etc etc

E.g
Compass,GPS etc internally should run some code isn't it? Are those done in Java?

I know Java has a set of API to target embedded devices but seems not yet strike a confidence vote from those embedded device manufacturers isn't it? How about device driver also?

Now until the day Java can take over this realm, I believe such software will still be dominated by C/C++.

Templates are not an optimization technique.


Ok, you are right. They should not be. But because substandard OOP performance in C++, templates are often used as an optimisation technique. Because the compiler is not intelligent enough to remove the dynamism overhead, the programmer has to make things more static to help it. Therefore if you designed sorting library in an OOP way, instead of using templates, you would get much worse performance than in Java.


I know Java has a set of API to target embedded devices but seems not yet strike a confidence vote from those embedded device manufacturers isn't it?


BlueRay, TV and GSM SIM card manufacturers would strongly disagree with you.
Last edited on
Because the compiler is not intelligent enough to remove the dynamism overhead, the programmer has to make things more static to help it

If the programmer finds himself having to alter the best-fit model to fit the compiler or language limitation, he may be using the wrong compiler or language. If the best-fit model is some sort of class-based OOP with dynamic dispatch, Java may indeed be more suitable. OOP is not the answer to everything, especially not in C++, where it's only one of many tools available.


Topic archived. No new replies allowed.
Pages: 12