8

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.

Community
  • 1
  • 1
Nick Bolton
  • 38,276
  • 70
  • 174
  • 242
  • http://stackoverflow.com/questions/649789/why-artificially-limit-your-code-to-c –  Feb 24 '10 at 15:07
  • 17
    Why would someone use a knife instead of a food processor? – William Pursell Feb 24 '10 at 15:07
  • @Neil Butterworth Cool, thanks. – Nick Bolton Feb 24 '10 at 15:08
  • My question seems to be a duplicate of: http://stackoverflow.com/questions/482574/whats-the-advantage-of-using-c-over-c-or-is-there-one – Nick Bolton Feb 24 '10 at 15:10
  • 1
    C is easier to implement and to "glue" with legacy libraries. Other languages also usually have a C interface. Some environments are also restricted to C; for instance, to develop a Linux device driver. A more convoluted approach is possible (a small C driver talking to a C++ or even Java, Python, whatever user-mode daemon), but implies a performance hit and there's always the C module. A C++ runtime is also harder to develop, so for embedded devices for instance it's way easier to port some C compiler than a C++ compiler. – Joao da Silva Feb 24 '10 at 15:11
  • Is that "string" or "strong"? – RichN Feb 24 '10 at 15:12
  • 3
    Note that you can program in an Object Oriented manner in C. – Bill Feb 24 '10 at 15:19

5 Answers5

4

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.

Javier
  • 60,510
  • 8
  • 78
  • 126
3

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.

Martin Milan
  • 6,346
  • 2
  • 32
  • 44
3

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.

Ofir
  • 8,194
  • 2
  • 29
  • 44
1

A lot of embedded systems such as microcontrollers, PLCs, etc use C and not C++ because they don't need to have classes just one giant loop with some functions sprinkled about. Nothing fancy but enough to get the job done in a higher-level language. Since C is more familiar to people than assembly, it works well in ~98% of cases.

-1

I think that the reason is fairly simple, a lot of companies want efficient readable code. C is a fairly easy language to understand and grasp, and for many uses there is no reason to complicate development and code continuity by adding whole new concepts (classes, polymorphism, inheritance, etc) that OO languages make possible but may not be needed.

Hortinstein
  • 2,667
  • 1
  • 22
  • 22