Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why would someone use C instead of C++? [duplicate]

Tags:

c++

c

Possible Duplicate:
Why artificially limit your code to C?

I started off with learning C, but then jumped straight into C++ simply because it supports OO and was also required for subsequent work. However, some companies insist on employing people with particularly strong C experience - and I've noticed this applies especially to hardware driver development companies.

like image 700
Nick Bolton Avatar asked Feb 24 '10 15:02

Nick Bolton


3 Answers

C string handling is very different than C++ typical string code. Certainly I wouldn't want any C++ string near my drivers!

More specifically, in good, modern C++ you don't really have to understand pointers and handle buffers at low level; but these are basic and crucial skills in device driver code.

Yes, it's possible to write good drivers in C++; but that C++ would really look like C with a few extra features. Most of the C++ library has no place in deviceland.

like image 190
Javier Avatar answered Nov 09 '22 02:11

Javier


It could simply be that they do not have a C++ compiler for the platform they are working with... Personally I would always use C++ in preference to C.

like image 39
Martin Milan Avatar answered Nov 09 '22 03:11

Martin Milan


C is much more portable - under the current level of standardization of C++, it simply can't be used when portability is important. It is also very hard for C++ code to be integrated (in a reliable and portable manner) into a C environment.

like image 44
Ofir Avatar answered Nov 09 '22 03:11

Ofir