Hacker News new | past | comments | ask | show | jobs | submit login

I am not a programmer by trade... but I'm a little confused as to why you would say Go can replace java but not c++? Is it just a speed thing?



C++ gives you an insane amount of control, is exceedingly manual, hard to use, hard to learn, and you can easily screw yourself over by using it - but it gives you so much performance that it's worth the necessary expertise.

Go tries to be safer and more automatic, like Java. While it's more organized and prescriptive than C or C++, it's less religious than Java about everything being a class. So it encourages the pragmatism and low-levelness of closer-to-the-metal languages while also abstracting out a lot of the details which get in the way of just writing systems.


I still can't grok why people pick C++. Is it just a Windows specific thing? If someone wanted speed of execution, why not use Ansi C? If someone wanted object oriented programming, why not the myriad other languages? (Java comes to mind) What does C++ do better than all the languages?


> If someone wanted speed of execution, why not use Ansi C? If someone wanted object oriented programming, why not the myriad other languages?

Because they want both speed and OO programming? :)

C++ is a multi-paradigm language. It has more abstractions than C, while retaining the ability to get down to the metal when you need to. Arguably, these higher level features are desirable when working on larger code bases. C++ also has features that make it easier to write clean and correct code (such as RAII). Templates and operator overloading makes for writing expressive libraries. I remember reading and article that compared C and C++ in the context of a matrix library. The C++ code was much more concise and readable, and was easier to get right compared to C, mainly due to those two features.

Furthermore, C++ can actually be faster than C. The canonical example is the templated std::sort() vs C's quicksort(). The C++ compiler is able to inline the comparator argument to the former, whereas qsort() takes a function pointer.


While I don't have personal experience with it myself, things like games lend themselves well to a limited use of OOP but also require performance-critical code and tight control over the language. With static analysis tools, I bet that C++ could be audited more comprehensive through automated tests than C could be.


So the answer to the question is that C++ is just much more performant than Go in general?


It's principally about control, performance is a side effect related to control and abstractions.


Rob Pike wrote a post about the curious phenomena of most Go coming from high-level languages and not from C++:

http://commandcenter.blogspot.fi/2012/06/less-is-exponential...

Apparently the remaining C++ users are really fixated on something called zero cost abstractions, and it's not a goal of Go: "Zero cost isn't a goal, at least not zero CPU cost. Go's claim is that minimizing programmer effort is a more important consideration."

(though I don't think C++ succeeds in "zero cost abstractions")




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: