Posted by : ANIMESH SHAW Saturday, 17 September 2011

One reason you might program in C is if you intend to read the generated assembly code. C++ does name-mangling, generates virtual tables for classes that use virtual functions, and other such things that will make the resulting assembly code harder to read (although I'm sure that doesn't scare some programmers). I'm a bit of an assembly noob and I sometimes write C code just to see what kind of assembly the compiler generates for the purpose of learning. This can also be a good way to research optimization strategies, for instance.

Another reason to stick with C is if you have a project or team where the advanced features of C++ are seen as a risk. Perhaps the project has a very straight-forward design and you don't want there to be any excuse for team members to get fancy with a complicated class hierarchy (this is more of a team management problem than a real tech problem, obviously). The decision to go with C may force project members to approach the problem in a simple way, although one hopes that such management trickery would never be needed in the first place.

Simucal made good comment on the above point in one of the other answers: "I know that the decision to code Git in C vs C++ was partly due to that. Linus was raving about the number of "bad" c++ programmers and how using C instead, he was keeping a huge amount of poor developers out." (link added)

Yet another reason I can think of to go with C is if you need to write a compiler for your target platform because there isn't a suitable one available. This is highly hypothetical, but if I found myself in a position of trying to bootstrap a software development pipeline for a hardware platform without existing compiler tools, I'd start by writing a C compiler because it's far easier to do so than to write, say, a C++ compiler.

One reason to learn C (but not necessarily use it) is to gain insight into the roots of programming. C was an extremely influential language that helped shape Unix culture as well as all of modern computer technology. One can better understand the design of C++, Unix, and even how assembly code works by having a detailed knowledge of C. It's yet another important puzzle piece in understanding how computer technology all fits together.

Popular Post

Blog Archive

Total Pageviews

Sign In

Follow by Email

Powered by Blogger.

Like Us on Facebook

Search This Blog

Loading...

Indian Coder

- Copyright © Programming Mania -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan -