Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am a C# programmer, and most of my development is for websites along with a few Windows application. As far as C goes, I haven't used it in a long time, as there was no need to. It came to me as a surprise when one of my friends said that she needs to learn C for testing jobs, while I was helping her learn C#.

I figured that someone would only learn C for testing only if there is development done in C. In my knowledge, all the development related to COM and hardware design are also done in C++. Therefore, learning C doesn't make sense if you need to use C++. I also don't believe in historic significance, so why waste time and money in learning C?

Is C is still used in any kind of new software development or anything else?

share|improve this question
Have you ever seen a C++ compiler for PICs? – SK-logic Aug 26 '11 at 12:33
Am I the only who is sad that somebody would equate learning with wasting time and money? – Jetti Aug 26 '11 at 14:59
This is a joke, right? – Ed S. Aug 26 '11 at 18:46
"In my knowledge, all the development related to COM and hardware design are also done in C++" - Sounds to me like you don't actually do any hardware interface design. – Ed S. Aug 26 '11 at 18:47
People forget that the fancy higher level languages that we all love are often implemented in C. – David Cowden Jan 15 '13 at 22:03

13 Answers 13

up vote 161 down vote accepted

C has the advantage that it is a relatively small language, which makes it easy to implement a C compiler (whereas a C++ compiler is a monster to write), and makes it easier to learn the language. Also see the TIOBE index, according to which C still is far ahead of C++.

In (IMO) decreasing order of justification, C is still used a lot for

  • Embedded stuff
    It's way easier to port a C compiler to a small platform than it is to port a C++ compiler. Also, C advocates claim that C++ "does too much behind their backs". However, IMO that's FUD.

  • Systems programming
    Again, that's usually due to claims that it is easier to "know what the compiler is doing". However, many embedded programs would benefit from, e.g., templates and other C++ key features.

  • Open source software
    That's mostly an attitude problem, though: OSS has always preferred C over C++ (whereas it's the opposite in large parts of the industry). Torvalds' irrational hatred might actually be the most important reason for this on Linux.

share|improve this answer
It's more history than attitude. Many of what you might consider the "core" open source packages were originally developed when C++ wasn't as widely available as it is now and resources were still scarce. – Blrfl Aug 26 '11 at 14:07
The TIOBE index is a joke. Search engine hits are meaningless. – DeadMG Aug 27 '11 at 11:08
@Sedate: That templates generally cause code bloat is a myth, coming from the times of ancient C++ compilers. Modern compilers will fold identical template instances. OTOH, templates allow template meta-programming, which executes code at compile-time, rather than run-time, resulting in less code being generated. Also, they make for much safer programs (less casting), something that's often very important in the embedded domain. EC++ has been bashed to death by C++ experts over (among other things) the sheer stupidity of throwing out templates. – sbi Aug 29 '11 at 6:25
@James: You mean things like efficient abstractions, generic programming and type-safety? Yeah, who'd want that. – Xeo Nov 4 '12 at 21:34
@JesperE As it happens, I have changed jobs since I wrote that, and I am now programming for embedded devices. We're using C++, and it's remarkable what the STL and template meta-programming can do for you when you have weak hardware and hard realtime constraints as well as reliability necessities. (We're doing power plants.) Yes, you have to know whether you should use a std::vector or an std::map for a certain piece of code — but you do not have to implement it yourself, but can rely on well-tested, highly performant, and dependable library implementations offering high abstractions. – sbi Mar 3 '13 at 21:21

C is used a lot in embedded hardware programming where resources are scarce.

Linux kernel is written in C because, according to Linus Torvalds, C++ is a horrible language.

share|improve this answer
I think large part of Windows kernel is also C. And a lot of legacy systems. – Coder Aug 26 '11 at 12:38
To be complete, Linus did give a try to C++ in the kernel. That was more an issue than a plus. Anyway, kernel devellopement is a really specific topic, that doesn't means C++ is bad in general. – deadalnix Aug 26 '11 at 12:40
According to others, Linus' argumentation is horrible. – sbi Aug 26 '11 at 12:41
Linus's arguments may or may not be valid, but Linux kernel is still written in plain C :-) – Joonas Pulakka Aug 26 '11 at 12:51
As a side note: BEOS was written in C++ and superior to other OS of its time failing mainly due to the politics of the day. As an indication that the OS need not be written in C. – Loki Astari Aug 26 '11 at 13:00

All of the modern languages I have seen may interact with C:

  • C++
  • Java
  • Golang
  • C#
  • Python
  • Haskell
  • Objective C

The need to interact with C derives from:

  • C having a simple ABI
  • C being around for a long time

It means that since those languages can communicate with C, they can:

  • leverage its libraries
  • communicate with each other through C (for example, Clang is written in C++ but offers Python Bindings hooked on its C interface).

And I would bet that all of them rely on C for their runtimes (unless they went full assembly ? dubious).

C is the Lingua Franca of the programming languages and one of the simplest (ABI-wise) not tied to a specific architecture (like assembly is), it'll take a major shift to get rid of it.

share|improve this answer
"All of the modern languages I have seen may interact with C". And these two interact with C#: 1).. 2).. . ;)) – mlvljr Sep 20 '11 at 20:12
Lingua Franca? If you say something someone already said, you should quote him. – Isaac Kleinman Jan 8 '13 at 15:37
@IsaacKleinman: Lingua Franca is a regular term, no copyright or authorship that I know of. I was not even aware this had been said by Joel Spolsky, and I am certainly not sure he was the first ever to say it about C... so I'll refrain from quoting him for now ;) – Matthieu M. Jan 8 '13 at 16:00
@MatthieuM: Excuse my false accusation; couldn't help recalling Joel's article when I saw you refer to C that way. :) – Isaac Kleinman Jan 8 '13 at 16:43
@IsaacKleinman: No problem, in general I am all for quoting; it's always good to replace things in their context. – Matthieu M. Jan 8 '13 at 18:49

In my opinion this is a very short sighted question akin to "My friends and I listen to Reggae. Does anybody really still listen to Rap?".

Every language out there has it use. Different languages definitely have their niches. But asking about C!! I am sure less people use C# than use C on a daily bases (from the totally biased view point of working in a shop where nobody uses C#).

Quick google looking on the relative popularity of languages.
I am sure none of this is authoritative but we can use it to see trends:

Even looking at SO ratio of question on tags:

  • C#: 209845
  • 16 other tags
  • C: 38790

So C is like the 18 most popular topic on SO (and there are a lot of other languages there).

Note: The TIOBE index above has been constantly updated for over a decade (and has some data going back 3 decades) is supposed to measure engineers working in each language (though I have no idea how accurate that is). Of the top 10 languages except Java/Visual Basic it reflects what people in my shop know (though our ratios will be slightly different as we have a much smaller sample size).

share|improve this answer
This answer confuses go on about C# and then show SO question tags but none of that has anything really do to with C being used. Popularity (especially on langpop, where they use search engine queries to determine popularity) doesn't really show the modern day usage of a language, just modern day searches on a language. You must take into account, for searches, that C is used frequently in Universities for the lower level classes so that can increase the number of queries and also SO posts. – Jetti Aug 26 '11 at 14:58
@Jetti: Thats why I explicitly say: I am sure none of this is authoritative but we can use it to see trends But I disagree with your second statement; C is no longer the major language taught at institutes of higher learning (if it was then the new batch of graduates would not be as useless). People tend to be learning Java/C# sharp nowadays. Also the Tiobe report is about jobs not queries. – Loki Astari Aug 26 '11 at 16:57
Looking back, there seems to be a poor word choice on my part. I didn't mean the low number classes (beginning classes), I meant the systems classes (computer architecture) is where C is used. – Jetti Aug 26 '11 at 17:48
SO tag count does not define language popularity in general, it simply shows language popularity between users of SO. – Ed S. Aug 26 '11 at 19:42
@Ed S. Obviously. But the question is not about popularity. Its about the existence of C as a language. The SO tag count shows us that it is definitely not a dead language. The fact that C is in the top 2 on the other sites does not make it the first/second most used language. But its existence in the top 10 is a significant marker that it is not dead. Of course none of this is proof just strong indicators that C is still being actively used. – Loki Astari Aug 26 '11 at 21:32

You may need to use C when you are low on resources and don't need object oriented capabilities.

Many softwares in use today are still written in C, not to mention hardware drivers.

According to Tiobe index, C is still the most used language.

As tcrosley suggested, you may want to take a look at this related question.

You should also check for some related articles on the differences between C and C++, like this wiki or this for example.

share|improve this answer
ahem !! thats a great point. I never gave a thought that "OOP capabilities actually add overhead for the language". Thanks for making this valid point clear. Now, i can understand, where C is ahead of others – Pankaj Upadhyay Aug 26 '11 at 12:54
Yes that's something you should consider when your program doesn't require particular OOP capabilities, it's just a waste and may be not as fast as a plain C implementation. – Jose Faeti Aug 26 '11 at 12:57
@Pankaj C++ generally doesn't necessarily add much run time overhead, a lot of the complexity of the language is the principle of "not paying for what you don't use" - if you don't use exceptions then exceptions don't slow down or add size to your code. The compiler is larger and more complex though – Martin Beckett Aug 26 '11 at 15:27
re C in the embedded field, see also this question and answers:… – tcrosley Aug 26 '11 at 17:00
You never actually need OOP capabilities, it simply works well in some scenarios. – Ed S. Aug 26 '11 at 19:41

It sounds like you are trying to convince yourself that C is useless and therefore can be ignored. Let's break your question down:

"I figured that someone would only learn C for testing only if there is development done in C."

No, there are many reasons to learn C. Even if you didn't know that I would still avoid using blanket statements like that, especially in conjunction with circular logic. Obviously one needs to know the language the code is written in to be able to properly test/fix it but that assumes that the langauge is still used as a given and is true for any language and not just C.

"In my knowledge, all the development related to COM and hardware design are also done in C++."

That is incorrect.

"Therefore, learning C doesn't make sense if you need to use C++. I also don't believe in historic significance, so why waste time and money in learning C?"

This is the most questionable logic of all. First of all, historic significance is something you should believe in, because if you did you'd know that C is a subset of C++ and, because of that, knowing C can help you be a better C++ programmer. Of course, C was also influential to most languages that came after it so the benefits don't stop there. In addition, because C is so important it can not be considered as having only historical significance. It is still widely used and thus cannot be relegated to a secondary position like that. You can argue that it's not a language that every programmer needs to use and have a thorough knowledge of and that would be right but please don't build your argument on saying that you don't believe something without examining its true merits first.

share|improve this answer
C is a subset of C++ , Is that what you meant ?? . C is not a Subset of C++; infact they are pretty different. Yes, C++ is an enhancement of C, or sometimes referred as C with classes and OOP, but to say C is a subset, doesn't justify – Pankaj Upadhyay Aug 31 '11 at 5:37
C++ is mostly a superset of an old version of C, and C's gone in a somewhat different direction since then. Some aspects of the languages have gone in largely parallel directions, but others have not (and C++ has a lot of other things besides). – Donal Fellows May 26 '12 at 14:22

In addition to embedded systems, most newer languages have some way to interface with C. When writing a library that you want to have an easy time using in all of those languages, C is an obvious choice. C++, while it can also interface with some languages (such as Python (CPython only)), C++ cannot interface with a greater number of languages due to some of its features (name mangling especially, but templates don't help the issue). The C ABI is one of the easiest to interface with (I know you can write C++ and use extern "C" for the interface. I don't care).

It also has the benefit that C and C++ are really the best languages for systems programming and the C compile times are much faster. C++ compile times are noticeably the worst of any language I've used.

Now while there are other languages that want to become the popular systems language out there (I know about D in particular), a far majority of software is written in C/C++. Languages like D require someone to create a wrapper around the C library instead of just using it directly (like you would from C++).

share|improve this answer
D can call C code directly, just like C++. All you need if the function prototype (again, just like C++). You just write extern(C) in D, whereas in C++ you write extern "C" – Peter Alexander Aug 27 '11 at 12:29
@Peter Alexander I'm aware of extern(C) in D. That's what I was referring to when I said wrapper file. You cannot directly include the C header (which you can do in C++, assuming the C header uses extern "C" and has the #ifdef __cplusplus blocks, which most do). There are then other incompatibilities among just using extern(C) (particularly how strings are handled. To my knowledge, they do not have a null terminator in D. So you have to specially change the array when passing it to C). – jsternberg Aug 27 '11 at 13:12

check out, especially the graphs from Freshmeat and Google Code. It shows that C still is way ahead.

C is still popular on systems where you need to be get close to the metal (ie embedded system) and performance hungry applications.

share|improve this answer

I use it almost every day developing for iPad/iPhone. Objective-C is yet young and many libraries are written in C and don't have an Objective-C equivalent. So yes, it is still used, and by one of the newest device on market.

With C, you can program lots of embedded systems, it's small and handy, and probably will be around for many years to come (aka you are not wasting time nor money learning it)

share|improve this answer
"Objective-C is yet young" it's actually from the mid 1980s, about as old as C++. Most people who use it didn't come across it until 2007, though. – user4051 May 26 '12 at 12:25
True, what I wanted to say is basically that there are many C libraries that don't have an equivalent in Objective-C for iOS. Indeed, the language itself, is not young at all (checked with Wiki). Thanks for pointing that out. – Valentin Radu May 26 '12 at 13:41

Generally for embedded system C is still widely used.

This question gives some other example.

The Tiobe index, which attempts to classify language by popularity / usage, consistently puts C in the first places.

share|improve this answer
2nd Place (after Java). – Loki Astari Aug 26 '11 at 13:06
Interesting that C++ and Java both seem to be both trending downwards in popularity over the last 10 years, while C remains more or less static. – Paul R Aug 26 '11 at 16:37


Do a list of every system you think will run C code and then a similar list for every other language you like.

If you came up with the same answer as me then the conclusion is yes.

share|improve this answer

Well I think C is the most powerful language Due to the following reasons!

1) AT first C , It's a systems language (which means it can be used to do low-level programming with minimal or no run-time).

2) Speed of the resulting application. C source code can be optimized much more than higher-level languages because the language set is relatively small and very efficient. It is about as close as you can get to programming in assembly language, without programming in assembly language. and you can even use assembly and C together!

3) C has which is its application in Firmware programming (hardware). That is due to its ability to use/work with assembly and communicate directly with controllers, processors and other devices.

4) C is a building block for many other currently known languages. Look up the history of C and you will find that it has been around for some time (as programming languages go anyway). Take a look at Python for example a fully Object-Oriented High-Level programming language. It is written in C (perhaps C++ too). That tells you if you ever want to know what is going on under the hood in other languages; understanding C and how it works is essential.

An applications language is used for high-level programming, e.g. writing a word processor or game. Examples of applications languages are Java, C#. The reason is because they contain garbage collection, automatic typing, run-time validation, etc. - where the focus is productivity.

A systems language is used for low-level programming. e.g. A micro-controller, a driver, and OS kernel. Examples include assembly, C. They require little or no runtime to run code directly on the hardware, and the focus is for the programmer to have direct control over the hardware.

Overall, it's declining as an applications language, but still holding strong as a systems language.

share|improve this answer

I think it is one of the best ways to write cross-platform game engine, that can then have a very thin ObjectiveC, Java or even JS/HTML wrapper and have less porting required

Ok, so for most programmers, there is always the dream of write once, run everywhere. Porting over your game to multiple platforms means more distribution, more sales, etc

However, rewriting that game engine code in different languages means you do take away a lot of the coding time, but not as much as you should. It also means learning a new language well enough to be able to avoid pitfalls and use the best-practices of that certain language/platform

As nice as that may seem, it is in reality a different matter. Re-writing code that was designed for one language/platform may not work so well in another. And there is a whole slew of design problems that may lead to worse performance, unmaintainable code and, not to mention, tons of new bugs. Like imagine trying to port a functional based code base to Java. You'll be just wrapping around classes that don't make sense, just to stick to java's everything is an object

On the other hand, C can be compiled to almost every platform. If you can have your core functionality written in C with a proper API that can delegate all boilerplate work (handling user input, creating graphics context, etc) then you can immediately have a couple of benefits

  • Handle User Input / interactions in the optimal way for the platform (touch commands in mobiles, keyboard & mouse in PCs, controllers in consoles, etc)
  • Maintain a single code base for the core functionality (bug fixes, patches, improvements) across all your deployment targets
  • Get pretty decent performance (C is usually as close to the metal as most people will ever get)
  • Maintain a pretty decent, platform independent design that works for your framework, and not just for the platform

I think the reason why most truly cross-platform game engines will be written in C/C++ (with most of the lower-level parts in C) with thin wrappers, and not have different 'ports' of the engine for every platform out there.

share|improve this answer

protected by maple_shaft Mar 3 '13 at 17:41

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.