Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think C++ has greatly made C obsolete in many fields, I'd rather see people embracing C++ than C when it comes to learning and using either. For example almost everything C teaches about "low-level" and "how things work" is learned by C++ too, while giving possibility to remain at higher level of abstraction most of the time - if so desired.


The majority of good, and reusable code is in libraries - as it should be. If you write a library in C++, you're limiting potential users of said library to only using C++, because there's no ABI compatibility with other languages.

C on the other hand, has almost global compatibility with other general purpose languages. It should therefore be everyone's effort to write good C libraries and promote code reuse.

Of course, there's no harm in writing your library in C++ and exposing a C interface to it - but that's not necessarily as simple as it might sound. The better approach is to design your API in C and then figure out how to implement it in C++.

As for writing the actual applications (non-reusable part), there are obvious advantages to using C++ over C.


C++ is awesome, no doubt about it. However it's a superset of C and the entry cost is much, much higher. Learning C is good for your culture, learning C++ is useful only if you plan on using it.


>However it's a superset of C

This isn't 100% true: http://en.wikipedia.org/wiki/C%2B%2B#With_C


gcc itself is switching to C++ by default in 4.8.

Source: http://gcc.gnu.org/ml/gcc/2012-04/msg00054.html


What the hell is g++ for? This is a stupid idea IMO.


The post is about building GCC itself with a C++ compiler, which is already possible on most(?) platforms: Basically, the default of the --enable-build-with-cxx configuration option will change, which does not affect the default input language of the gcc executable (which is chosen by file extension anyway).


Ah, okay. That I'm fine with. :)


For compiling C++ code. Which gcc will start using. This is just a way to make compiling gcc take 20 times longer.


Agree but kinda Disagree

C++ is built on C. You need to know C (but maybe not the C library) to know C++. Like pointers


"Built on C" seems like the wrong phrase to me. "Extension of C" is a better fit.


> You need to know C

Learning C before C++ is a very bad idea, as it will make you try to use language patterns that are considered bad ideas in C++, as there are safer alternatives.


I think that in order to be proficient in C++, you also need to understand what separates C++ from C and how C++'s features (classes, overloaded functions, templates) map to C.




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

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

Search: