Hacker News new | ask | show | jobs
by pothibo 4738 days ago
I'll reply at all the above here.

When you have load/concurrency that needs you to move to C++ there's no doubt C++ is right.

When you reach that level though, you will usually have the resource to build infrastructure specifically designed to your need, dismissing any "general" purpose C++ framework.

All the example mentioned here are using in-house products for the most part.

1 comments

I am not sure it is ever true that there are no doubts about C++ being "right." It might be "good enough," but it is a generally bad language that would not be my first choice for anything (I would sooner use C, but even that's not my top choice).
And I would sooner use modern C++, it is personal preference and experience.
It's not about experience, it is about the language. Modern C++ is basically a motorized stone hand-ax. Even experienced C++ programmers are surprised by undefined behavior and unexpected semantics.
A significant amount of undefined (and unexpected) behavior in C++ is inherited from C, for compatibility. You'd sooner use C, and fall into undefined behavior quickly as well.

C++ is large and hard to master, but I don't think UB is the best reason to choose C over it.

C++11 is years ahead of Java. http://herbsutter.com/elements-of-modern-c-style/

I especially like the fact that you can specify which variables are captured by the closure: http://www.cprogramming.com/c++11/c++11-lambda-closures.html

I use both C++ and Scala on daily basis and there are just a few things I wish C++ had from Scala. On the other hand it is a huge time saver not having to worry about the JVM GC freeze.

"C++11 is years ahead of Java"

OK but so what? It is also years ahead of BF.

C++11 has a few nice features, but it is really dragged down by low level issues. You talk about garbage collection like it is a problem, but C++ still does not even offer good garbage collection (not even optional garbage collection) for those situations where it makes sense. At least with Java you do not need to manually break cyclic references to prevent memory leaks.

As for closures, why would I want to specify which variables are captured? If I reference a variable from the enclosing environment, I capture it. If I mask the variable, I do not capture it. What point is there in explicitly declaring this? Frankly, the entire C++11 approach to closures is insane. Why add the extra syntax to explicitly declare how variables are captured, when capture by value covers all cases?

I stand by what I said. C++ is an awful language.

Since it has deterministic destructor and RAII is easy to implement, garbage collector is not needed. It works not only with memory allocation, but any other resource you need to release: mutex, serial port, window handle, file handle etc. Also move schematics really helps with performance: create, copy & destroy can be avoided altogether. No garbage, nothing to collect. :)

BTW, Normally you should avoid "new" and "delete", only very special use cases need it.

Specifying the closure variables is optional and it is both for performance and encapsulation. You can specify "nothing", "everything by reference", "everything with copy", just some by copy or reference - mix & match. If this is too much to start with then just copy everything with [=] and clean it up later if it turns out to be a bottleneck. The point is: you can save on cycles if you want to/have to.

If you think C++ is not a match for you, that's OK, there are plenty other languages. You don't need performance all the time - some are OK with 400 queries/sec, others want 7,000 on the same server: http://www.techempower.com/benchmarks/#section=data-r6&hw=i7...

> not having to worry about the JVM GC freeze

Bad engineers blame their tools.

Android: http://www.war-worlds.com/blog/2012/06/on-android-garbage-co...

C#: http://conversations.nokia.com/2012/06/01/interview-with-mat...

Ruby: https://blog.twitter.com/2011/building-faster-ruby-garbage-c... (It was not good enough, they dumped Ruby)

Accepted answer? "Manual tracking of objects" http://stackoverflow.com/questions/2484079/how-can-i-avoid-g...

Google has 14 million web pages about Garbage Collector issues...

Good engineers start with good tools and avoid wasting time.

See section 9 http://www.joelonsoftware.com/articles/fog0000000043.html

Well, I might have over-emphasize on what is "right". Blame this on the language barrier :)