News for hackers. Stuff that matters.
Re:Is C++ the Language of the Future? by demallien on Friday March 23, 2012 @11:58AM (#3745717)
Ahhh, He started talking about needing concurrency to be able to make use of multicode CPUs, and his solution is C++ ??? The number of cores is multiplying with Moore's Law. It doesn't take many multiplications before a language able to easily make use of those multicores efficiently will blow past C++ in performance.
Re:Is C++ the Language of the Future? by mrich on Friday March 23, 2012 @12:13PM (#3745796)
Modern C++ code is multithreaded, threading is now finally part of the standard. While C++ is showing its age, and the refusal to cut any old features at all sure is no advantage, it is still the language to beat for performance and especially memory usage.
Re:Is C++ the Language of the Future? by rbanffy on Friday March 23, 2012 @01:07PM (#3746095)
The problem is not the ability to start threads - it's enabling the programmer to express the problems in concurrent form.
Re:Is C++ the Language of the Future? by angersock on Friday March 23, 2012 @12:05PM (#3745757)
So, before you rush off to dismiss C++, note a very important thing:

With reference-counted smart pointers, you can guarantee that objects immediately go away once they leave scope, and that you can pass them around between threads without worrying too much about a thread forgetting to delete them. No other language has such easy support for doing something like that without relying on a background memory-management mechanism (at least that I'm aware of--I'd like to hear about it if you know one!).

Re:Is C++ the Language of the Future? by ootachi on Friday March 23, 2012 @12:13PM (#3745794)
Well, you have to make sure that you use atomic reference counting in this case. Using regular reference counting will lead to subtle and hard-to-diagnose bugs.

Also, to answer your query, Rust uses unique pointers (the equivalent of std::unique_ptr in C++0x) for inter-thread communication. When the unique pointer goes out of scope, its memory is immediately freed (since it was the only owner of the data). And since the data has only one owner, it's data-race-free.

Re:Is C++ the Language of the Future? by angersock on Friday March 23, 2012 @12:20PM (#3745829)
Yeah, one of the first things we fixed in our smart pointer implementation was to use atomic ops for the ref counters. This had the unfortunate side effect of excluding the smart pointer classes from our STL replacement (as it introduces a dependency on our low-level ops library), but in projects using both all is well.

Cool on Rust, though! Thanks for the info!

Re:Is C++ the Language of the Future? by pmjordan on Friday March 23, 2012 @12:18PM (#3745817)
Reference counting is nothing new. Visual Basic used it before the transition to .NET. Python uses it, if I remember correctly (with occasional GC to avoid leaks due to cycles). There are probably countless other examples.

Reference counting is also not even that great for shared memory multithreading. The (atomic) increment/decrement operations typically cause lots of cache invalidation, so you'll get a slowdown even for immutable objects.

Re:Is C++ the Language of the Future? by ootachi on Friday March 23, 2012 @12:25PM (#3745870)
Yeah, atomic RC hurts a lot (5x-10x slower, based on the measurements I've seen -- Hans Boehm of Boehm GC fame did a presentation on this that you can find if you're interested). (This is a problem with Objective-C reference counting -- they use atomic ops for all reference counting I believe.) There's some work on mitigating its cost with per-thread reference counts arranged in a tree or whatever, but it's still tough.

The alternatives are either (a) avoiding shared state; (b) strong lifetime management such that you make sure one parent thread owns all of the data that its child threads are going to use; (c) concurrent GC; (d) pretending it's not a problem like Go does and doing stop-the-world GC.

Re:Is C++ the Language of the Future? by angersock on Friday March 23, 2012 @12:35PM (#3745931)
Hm... interesting. Looks like we might want to expand our library to have RC with and without atomic ops--that way we can get some of the cleanness of scoped destruction when appropriate without having to go whole-hog ATOMIC RC INVALIDATE ALL THE THINGS when we can getaway with it.

Thanks again folks!

Re:Is C++ the Language of the Future? by angersock on Friday March 23, 2012 @12:25PM (#3745865)
Ref counting by itself is nothing new, agreed. The fact that I can reliably say when things go out of scope in C++, though, combined with ref counting, is quite handy.

Interesting point about the cache invalidation, though. I wonder if we'll see chip vendors going out of their way to improve performance and invalidation when using atomic ops.

Re:Is C++ the Language of the Future? by pmjordan on Friday March 23, 2012 @01:38PM (#3746232)
I wonder if we'll see chip vendors going out of their way to improve performance and invalidation when using atomic ops.

They already put a lot of effort into making this stuff as efficient as possible - the fact that Intel is going in the direction of hardware transactional memory indicates to me that they don't think the bus locking/cache snooping approach scales, and I can't say I'm surprised.

Re:Is C++ the Language of the Future? by mrich on Friday March 23, 2012 @12:11PM (#3745782)
Objective-C with ARC comes pretty close.
Re:Is C++ the Language of the Future? by angersock on Friday March 23, 2012 @12:14PM (#3745806)
Out of curiosity, when does the GC happen there? Does Objective-C have strict enforcement of destruction-on-scope exiting?

(not a Objective-C dev, so don't know)

Re:Is C++ the Language of the Future? by ootachi on Friday March 23, 2012 @12:16PM (#3745814)
Yes, Objective-C will reclaim your retained objects promptly (unless you use the deprecated Objective-C garbage collection, which few do and never worked on iOS).

The exception is the autorelease pool, which gets dumped at the end of every turn of the event loop. You can promote or demote objects from the autorelease pool at will.

Anyway, the biggest problems with Obj-C memory management are (a) you can't allocate objects on the stack, so you're forced into using the autorelease pool for stuff, and (b) you can promote or demote objects from the autorelease pool at will, which means that even the autorelease pool has to malloc, thus you don't get the nice benefits of super-cheap bump allocation that C++ arenas (or a generational GC's nursery) buy you.

Re:Is C++ the Language of the Future? by angersock on Friday March 23, 2012 @12:21PM (#3745837)
I'm still a little puzzled by the phrase "promptly"--you mean as soon as it goes out of scope, right? Like, immediately?

Anyways, thank you for the information!

Re:Is C++ the Language of the Future? by ootachi on Friday March 23, 2012 @12:23PM (#3745852)
Right, as soon as it goes out of scope. (Or when you call release to drop the last reference on it, if you aren't using ARC.)
Re:Is C++ the Language of the Future? by bediger4000 on Friday March 23, 2012 @02:18PM (#3746423)
First, why C++? Given that you can't truly do threading via a library (http://lambda-the-ultimate.org/node/950 Lambda-the-ultimate thread for context, and pointers to various versions), it would seem that C++ is not a good choice.

Second, why not assembly of some sort, or something very close to assembly? It's hard to break things out into threads and not incur performance problems due to platooning or thundering herds or contention for critical section(s). You want to maximize each individual CPU's work even in a massively multi-processor environment. Assembly gets you performance, guaranteed atomic operations, guaranteed memory barriers. and precise locations of those things.

I smell a return to the "semantic gap" and highly orthogonal ISAs.

Re:Is C++ the Language of the Future? by qdog on Friday March 23, 2012 @12:25PM (#3745871)
No mention of several other languages, like Erlang, which more or less scales up with available hardware threads.

However, it doesn't even mention that just having multiple cores on a chip isn't the same thing as having 2 chips, you still have shared memory and the bus, so having 2 cores is not going to be as fast as having 2 chips and 2 sets of memory in most cases, so adding cores is never going to be a linear increase. I believe right now that intel's hyperthreading needs to be turned off for some compile scenarios, as the collisions are too high either for memory or something else (at least 2 people I know who have to do huge compiles disable some of the hyperthreads).

In short, I don't believe it's easy to just scale up on multi-core systems, regardless of language. Threads are a pretty dangerous way to do things, processes are much safer, but not all problems fall easily into a parallel model.

Re:Is C++ the Language of the Future? by ootachi on Friday March 23, 2012 @11:56AM (#3745709)
No Scala or Rust? Especially Rust seems like it fits the author's wishlist.
Re:Is C++ the Language of the Future? by espeed on Friday March 23, 2012 @12:01PM (#3745727)
Go is a strong candidate because of its concurrency model.
Re:Is C++ the Language of the Future? by aninteger on Friday March 23, 2012 @12:34PM (#3745926)
Why would the language of the future be any one specific language? Many languages can make use of multiple cores through threading/open-mp like libraries.
Re:Is C++ the Language of the Future? by tomp on Friday March 23, 2012 @02:21PM (#3746443)
Whenever I read such an article, I'm amused at how the authors seem to forget that there exist multiple areas of programming: web programming, application programming, industrial programming, real-time programming (finance), ...

C/C++ is popular only in the application programming and possibly industrial programming category. I believe that the latter category will become increasingly popular/important in the future (robotics, space travel, even consumer gadgets are becoming "smarter"), and C is a really bad language for any kind of life-critical software, mainly because it cannot be statically analysed (without significantly restricting the language features). Another thing is, in embedded systems, there's much less legacy code, so a new language for that field could very easily win over any existing ones.

Re:Is C++ the Language of the Future? by rbanffy on Friday March 23, 2012 @06:10PM (#3747611)
I can't see why being able to statically analyze the code brings it any closer to correctness - all it says is that you got your types right. In fact, switching to a lower-level language (as in "more detached from the problem you are trying to solve" such as C or C++) seriously harms your ability to even produce correct code.

Anyone who has chased a time-sensitive bug caused by data structures that mutate unexpectedly (be it by conflicting threads, be it by hardware changing it) can tell you that getting the types right won't help you a bit with making code that runs correctly on multi-core machines.

Re:Is C++ the Language of the Future? by pork on Friday March 23, 2012 @02:41PM (#3746528)
Sorry, which (widely used) language out there can be statically analyzed without restricting language features? And being difficult to statically analyze is hardly a reason to switch to C++.
Re:Is C++ the Language of the Future? by lopatin on Friday March 23, 2012 @12:21PM (#3745839)
What are the chances a coffeescript-like language for c++ being adopted? I would think that a python like syntax, with utility methods and such, that compiles to c++ would be a huge help if c++ really is going to be adopted more and more in the future.
Re:Is C++ the Language of the Future? by phamilton on Friday March 23, 2012 @12:28PM (#3745890)
Why compile to c++?

Compiling to javascript makes sense because javascript is the lowest common denominator for browsers.

Compiling to c++ wouldn't make any sense when you can compile directly to assembly/bytecode.

It would be like writing a python like language that compiled to coffeescript. It would be silly not to compile it directly to javascript.

Re:Is C++ the Language of the Future? by eco on Friday March 23, 2012 @04:54PM (#3747230)
Interestingly, the original C++ compilers were like CoffeeScript in that they'd compile to C source code. Walter Bright (now of D fame) wrote the first C++ compiler that compiled to machine code. I don't really see this as the approach going forward though. There isn't much to gain from compiling to C++ code over C code.
Re:Is C++ the Language of the Future? by rbanffy on Friday March 23, 2012 @06:01PM (#3747564)
Why not go the rpython or Cython route? Both have the Python syntax and compile to C.

Not very readable C, of course, but not significantly worse than what the first C++ preprocessors did (yes, kids, C++ started its life as a compiler that compiled C++ code into horribly mangled C).

Re:Is C++ the Language of the Future? by qdog on Friday March 23, 2012 @12:29PM (#3745894)
I would think compiling to llvm is probably a better road to go down than compiling to c++, as long as llvm can target the platform you are interested in. C++ could link against your library then. And you could probably do it right now.
Re:Is C++ the Language of the Future? by angersock on Friday March 23, 2012 @12:02PM (#3745734)
(the inclusion of Ada and the dismissal of go as "not having objects" makes me question the author's wisdom)

C++ is likely to be the language of the future, as it is getting to the point where you can pick a subset of the language and emulate your favorite other programming language and paradigms.

This is not a good thing.

Re:Is C++ the Language of the Future? by wicknicks on Friday March 23, 2012 @12:26PM (#3745876)
Exactly! This has been my concern too. Everybody has their pet subset of the language. With the amount of native features growing with every standard, large C++ codebases look more polyglot than ever.
Re:Is C++ the Language of the Future? by rbanffy on Friday March 23, 2012 @06:12PM (#3747617)
Indeed. There are probably a dozen people in the planet that understand C++ completely. They all maintain compilers.
Re:Is C++ the Language of the Future? by j_baker on Friday March 23, 2012 @12:13PM (#3745799)
I think this post is a non-sequiter. I think the observations the author is making are accurate, but I don't think that any of them but #2 really make a strong case for C++. And even that one is debatable.
Re:Is C++ the Language of the Future? by drucken on Friday March 23, 2012 @04:04PM (#3746964)
Languages of the future will be written to VMs.

The languages on top of the VMs will evolve fast while the VMs become progressively broader in scope.

It has already happened for many languages and is already a route companies like Apple have and are investing heavily into, e.g. Clang.

Bleeding edge examples include Rust (http://www.rust-lang.org/) and Clay (http://claylabs.com/clay/) both on the LLVM.

Re:Is C++ the Language of the Future? by rbanffy on Friday March 23, 2012 @01:16PM (#3746129)
> (Note: I define "serious development" as rock solid, enterprise quality software)

This guy must be right. I don't see why my opinions should matter because, according to him, I haven't done any rock solid enterprise quality software since 2002 or so. I sure must warn my clients my software isn't up to the current standards of quality, for they rely on my "lesser" solutions.

Am I the only one who is sick of this kind of arrogance?

Re:Is C++ the Language of the Future? by numeromancer on Friday March 23, 2012 @12:11PM (#3745781)
(Note: I define "serious development" as rock solid, enterprise quality software)

This guy must be good; I've been looking for the source code for the systems of the U.S.S Enterprise for months now on The Pirate Bay, and still haven't found it.

ALSO: I didn't know that this was an Object Oriented world! Ya lern sumthin new evry day.

Squirrel!

Re:Is C++ the Language of the Future? by olaf on Friday March 23, 2012 @12:37PM (#3745955)
I think, the question is wrong, because of Browsers/Javascript. Not much C++ in sight there, for scripting Browsers/DOM. Even Stroustrup mentioned JS as one of the programming languages programmers should know.
Re:Is C++ the Language of the Future? by krisc on Friday March 23, 2012 @12:23PM (#3745858)
If the JVM persists into the future, I see Clojure as a strong candidate.
Re:Is C++ the Language of the Future? by icefox on Friday March 23, 2012 @11:52AM (#3745682)
No
Re:Is C++ the Language of the Future? by Smudge on Friday March 23, 2012 @01:34PM (#3746205)
That was my reaction too. I like your brevity.