C++ is as bad as they say it is. It is horrible, it is the worst language in the world ... except for all the other (a la Winston Churchill and democracy).
The horrifical complexifications of C++ are just terrible, yet every one of them has a reason behind it. And also, the horrifical complexities are a bit more optional than the horrifical complexities of, say, Java.
There isn't another language that has both the large-scale modularization given by OO and low-level efficiency of direct pointer manipulation and other C features. You get a vast library of available free code and a huge number of available tools to boot.
There is no other language for crafting large-scale, high performance tools. Java and C# can be just as fast but even fast Java has even greater verbosity overhead. And the scripting languages are great yet their resource overhead makes up for their compactness.
C++ is definitely a language of "big design". "Thinking in C++" is a mistake. You should think in your design and implement in C++. Unlike C, C++ seduces people to take the code for the design.
In any case, however flawed, the thing occupies a niche no other language can. I'm sorry.
Well, we can agree to disagree here, but my belief is that OO is a impedence mismatch for writing "low-level efficiency of direct pointer manipulation and other C features". It's kind of like saying, "There is no 16 wheel semi truck that can win the Tour De France." Maybe you shouldn't be using a 16 wheel truck.
If you cut a couple wheels off of an 18-wheeler, you could travel the 3642 km of the Tour de France in about 36 hours of driving, which would be about 3 days on a leisurely, safe schedule. The bicyclists take 22 days to do the same thing.
So, there are really only a couple of problems:
• if you're Zed Shaw, you apparently want to cut two wheels off an 18-wheeler, and if you're Zed Shaw, you're likely to screw up and choose the drive wheels for your demented sacrifice. You do that, the sucker won't even roll.
• the stupid hatas who judge the race won't acknowledge your achievement. Something about the allowed types of bicycle. Is that analogous to how you can't run Ruby on a microcontroller with 1024 bytes of RAM, maybe? Because you can sure as fuck run C++ on it.
Anyway, direct pointer manipulation has been part of OO environments since the beginning. The purest current incarnation might be SqueakNOS (ever seen an IDE driver written in Smalltalk?) or SBCL's alien, but the most practical one is probably C++. Rust, Golang, and ATS seem like up-and-coming contenders.
Edit: oh, I forgot D. D's been an up-and-coming contender for more than ten years now.
If we're both posting, we agree that we disagree... (along with agreeing that Paris is the capital of France..)
Anyway, C++ is more like a construction system which can be used to make a bicycle, a semi, or a six-person tandem which could win the Tour De France.
Which is to say it's pretty clunky for a lot of things. But there are still things where both large scale organization and particular low-calls need to coexist - Databases, large graphics programs, etc. It's not impossible to write these in C or Java obviously but I'd still say C++ is cleaner.
> The horrifical complexifications of C++ are just terrible, yet every one of them has a reason behind it.
Many of the reasons are legacy issues though like using dumb linkers and using the C preprocessor rather than a real module system. Templates are just a huge hack: manipulating the text of the source code to simulate generics and then abusing that feature to get meta programming.
One of the great mysteries of life is why there isn't another language that "has both the large-scale modularization given by OO and low-level efficiency of direct pointer manipulation and other C features" yet doesn't make the same mistakes as C++.
"There isn't another language that has both the large-scale modularization given by OO and low-level efficiency of direct pointer manipulation and other C features."
Arguably this might be true, however if you add another requirement to the list Joe posted it isn't. Cross platform code is important to many people. I work on large scale, performance intensive, cross platform applications. Microsoft tells me I should be doing everything in C#. Apple tells me I should be doing everything in Objective C. I just get on with it and use something that works. A language that gives me the ability to combine high level design with low level efficiency and run on multiple platforms.
I often use a paraphrase of the Winston Churchill quote as well. There are probably many better languages for many other applications, however for high performance, cross platform large scale apps C++ is still the only game in town.
Joe's point that all the complexities have reasons behind them is a really good one. I'd suggest reading Stroustrup's "The Design and Evolution of C++" for more information.
Ironically, the whole iphone apps goldrush seems to have contributed in a big way to increase its mindshare. Obj-C is very beautifully designed, I especially like how it adds message passing OOP to C with very minimal syntax additions. But then calling objc_msgSend for every message send, does have a small performance penalty attached, which mostly static languages like C++ don't have to pay.
vtables in C++ aren't free, but C++ has a couple of advantages here:
• If you're calling a nonvirtual method, you don't have to pay the vtable cost at all, just the cost of passing this. And most methods in C++ are nonvirtual.
• A call through a vtable is typically a couple of indexed fetches and an indirect jump. Objective-C's mechanism involves a hash-table lookup, which is a bit slower.
There is no other language for crafting large-scale, high performance tools is demonstrably false. There are high-volume low latency world-class financial systems written totally in Java.
The seriously complex and high-performance ITA system is written in Lisp.
And if you read Coders at Work, some of the criticisms of C++ suggest that the reason behind many of the C++ features is that Bjarne didn't want to say NO.
And I am happy to leave that particular niche of badness to C++ its own self.
I guess, if you set your mind to it, you could probably make Forth do a nice mixture of low and high-level stuff, too.
But why do people insist on being able to do low and high level stuff in the same language? What's wrong with, say, using Python for high level stuff, and calling into C for low level tasks? C+Python is probably more convenient than C++.
Actually Boost::Python makes python and c++ mix beautifully. I just started playing with it a few days ago and am seriously impressed. I'm planning on using it to write a WSGI gateway to put in front of my bottle.py apps.
I should have said "there is no other language which gives you the latitude for crafting high performance tools". You can indeed create serious high performance systems in a number of languages. The thing about most languages other than C and C++ is that things written in them tend to inherit their qualities - A system written in Java generally use Java's garbage collector. That works great for a number of things but it's still a constraint.
More of C++'s "modularization" features are optional than in the other languages so you have more latitude for creating your tools than anywhere else.
The seriously complex and high-performance ITA system is written in Lisp
Have you worked on it? Do you know this? Is it all written in Lisp, or are the parts that need high-performance and predictability written in C or C++?
There's a lot of language FUD out there. I say this as someone who owns OnLisp, and has spent a lot of time learning Lisp.
Until there's a single, stable, not-on-the-way-to-be-obsoleted version of D, with standard standard library, I'm not inclined to invest too much time in it.
I wish that D1 was oficially killed, and a stable strict subset of D2 ("D1.5") was chosen as a recommended future-proof version.
What you say about Java's verbosity is sort of flawed in the same way that attacks on C++ about its template metaprogramming madness are flawed. Don't confuse a language with what people write in it.
There is a point though. C++ encourages obscure "too clever" constructs, and Java encourages excessive verbosity. But in both cases you can decide not to go there.
As far as I know, there's a lot more to Java that isn't optional: everything must be inside a class definition, everything must use the garbage collector.
In C++, you don't have to declare a single class or create a single template.
C++ is as bad as they say it is. It is horrible, it is the worst language in the world ... except for all the other (a la Winston Churchill and democracy). The horrifical complexifications of C++ are just terrible, yet every one of them has a reason behind it. And also, the horrifical complexities are a bit more optional than the horrifical complexities of, say, Java. There isn't another language that has both the large-scale modularization given by OO and low-level efficiency of direct pointer manipulation and other C features. You get a vast library of available free code and a huge number of available tools to boot.
There is no other language for crafting large-scale, high performance tools. Java and C# can be just as fast but even fast Java has even greater verbosity overhead. And the scripting languages are great yet their resource overhead makes up for their compactness.
C++ is definitely a language of "big design". "Thinking in C++" is a mistake. You should think in your design and implement in C++. Unlike C, C++ seduces people to take the code for the design.
In any case, however flawed, the thing occupies a niche no other language can. I'm sorry.