C++ pointer question

And Windows 8 is being written to aim at… C++. Smartphones keep having C++ or ObjectiveC APIs for the good stuff. Games are written in C++. I live in embedded land. JVM? What’s that (yes, ok, Dalvik, but again, what are the good APIs for Android in?).

People have been sounding the deathknell for C++ for a decade. It’s still here, and major new platforms keep using it!

You should probably read the updates to the article since you last bookmarked it:


Language 	           Time per iteration (microseconds)
Java 	                   1.6
C++ (original)             3
C++ (updated)             ~0

I don’t know if “approximately zero” means 0.9 us or 0.001us or what, but since he could resolve the Java time/iter down to 0.1us, we can probably assume it means < 0.1us, so we can set a lower bound of C++ being 16x faster than Java (for this one random benchmark.) This goes to Miramon’s point about it being easy to screw up performance in C++ (though note the optimization was apparently the same one that had been done for the Java version.)

And Windows 8 is being written to aim at… C++.

How is the C++ stuf handled in Win8? Is it going to be set up to run with .NET on the CLR?

I don’t know if “approximately zero” means 0.9 us or 0.001us or what, but since he could resolve the Java time/iter down to 0.1us, we can probably assume it means < 0.1us, so we can set a lower bound of C++ being 16x faster than Java (for this one random benchmark.) This goes to Miramon’s point about it being easy to screw up performance in C++ (though note the optimization was apparently the same one that had been done for the Java version.)

Yes, it illustrates a point pretty clearly, that you CAN make C++ faster… on the right compiler, if you take the time to deal with the micromanagement of things.

But most people don’t do that anyway. They end up writing C++ code that runs slower than Java code, while also being harder to write.

I agree with the idea that lower level languages have value in certain specific applications. But, in the grand scheme of things, most applications benefit heavily from higher level languages.

Also, from Alberto’s own page, it doesn’t appear to be 0… not sure where that number comes from. His numbers cite:

On my machine, making a loop of 10000000 iterations:
java version: 26922 milliseconds
c++ version: 21422 milliseconds

Certainly not a trivial difference, but we’re talking a difference of around 20%.
And doing so required a 30% increase in the amount of code written.

Again, it’s an illustration of the kind of tradeoffs you’re making. If you really roll up your sleeves and get under the hood, you can tune it to be faster… But if you’re just writing applications at a higher level, then you’re not likely to get much benefit from a lower level language. You’ll just get the painful aspects of it.

The benefit of using a managed language like Java is that you benefit from the fact that the guys at Sun handled most of the low level crap… and, the vast majority of the time, they probably did it much better than we can. :)

The bulk of my career has been in embedded and networking work, so I still do a huge amount of pure C. Using C++, as a “C with better string handling” or “C with some abstract data types,” is a big win in that realm, and there will always be a need for it.

And that’s where I will agree with you completely. The ability to write low level code and reach up to the higher levels of abstraction where needed is great.

I don’t recommend C++ for most things. In fact, there are very few times I’d recommend using C++ on Windows over C# (or, ok, Java), but it has its uses.

Totally. Or Haskell, or Python. Same goes for other platforms, too. We aren’t running on 4.77MHz 16-bit CPUs any more, basically. :)

You’re listening to Chris Nahr too much. For Metro in Win8, C++, .NET, and Javascript are all basically co-equal. In fact, given Microsoft’s historic Windows platform standards (i.e., all C++ with a sparse cover of some .NET), it’s more accurate to say that Win8 represents a shift away from C++, toward .NET, and massively and revolutionarily toward Javascript.

Almost exactly the same here. I’m responsible for a 3D UI framework that ships on millions of devices in the embedded space and C++ still reigns king for both performance and memory.

Should the majority of people work in C/C++? No, but calling the language a dinosaur is a bit of a false statement.

More of a shark: Powerful, dangerous, and unquestionably primitive.

For what it’s worth, there’s a long running survey on relative language usage. C, C++, and Java dominate. Same story here.

Ooo, I like that metaphor.

Lisp, stilling hanging in with 1% woot!

It makes a lot of the “talked about” lists for the perfectly good reason that it is the language toward which all other languages are slowly evolving, though.

I think it’s sort of amazing how Javascript, for instance, gets lumped as a “C-like” language when by any reasonable evaluation (including the ability to DO evaluation), it’s about a zillion miles closer to Lisp than C. If you’d gone back to 1980 and told people that a memory-managed, dynamically-typed language with first class functions and closures was more like C than Lisp, I can’t imagine you would have met with much agreement.

But apparently curly braces and (even optional) semicolons qualify you for C-lineage these days…

LMAO… Perfect!

My former employer (ITA->Google) is contributing most of that I think :)

Well, weren’t you the guy who was saying, in the Dart thread, that syntax is like the UI of a language?