I am a C# programmer, and most of my development is for websites along with a few Windows applications. 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 if there is development being done in C. From my knowledge, all development related to COM and hardware design is 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 still used in any kind of new software development or anything else?

  • 44
    Have you ever seen a C++ compiler for PICs? – SK-logic Aug 26 '11 at 12:33
  • 190
    Am I the only who is sad that somebody would equate learning with wasting time and money? – Jetti Aug 26 '11 at 14:59
  • 37
    "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
  • 30
    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
  • 12
    @ThomasEding Dead language? You certainly have a very limited knowledge of programming languages if you consider C a dead language. – JesperE Mar 3 '13 at 14:57

14 Answers 14

up vote 209 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 slightly 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.

  • 14
    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
  • 62
    The TIOBE index is a joke. Search engine hits are meaningless. – DeadMG Aug 27 '11 at 11:08
  • 27
    @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
  • 17
    @James: You mean things like efficient abstractions, generic programming and type-safety? Yeah, who'd want that. – Xeo Nov 4 '12 at 21:34
  • 11
    @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.

  • 14
    I think large part of Windows kernel is also C. And a lot of legacy systems. – Coder Aug 26 '11 at 12:38
  • 14
    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
  • 74
    According to others, Linus' argumentation is horrible. – sbi Aug 26 '11 at 12:41
  • 35
    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
  • 13
    Linus is a git. – ubiyubix Aug 26 '11 at 22: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.

  • "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
  • 20
    @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
  • 2
    @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 its use. Different languages definitely have their niches. But asking about C! I am sure fewer people use C# than C on a daily basis (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:

http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
http://langpop.com/

Even looking at SO ratio of question on tags:
https://stackoverflow.com/tags

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

So C is 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).

  • 1
    This answer confuses me...you 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
  • 3
    @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. – Martin York 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
  • 4
    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
  • 4
    @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. – Martin York 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.

  • 4
    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
  • 7
    @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
  • 2
    re C in the embedded field, see also this question and answers: programmers.stackexchange.com/questions/84514/… – tcrosley Aug 26 '11 at 17:00
  • 6
    You never actually need OOP capabilities, it simply works well in some scenarios. – Ed S. Aug 26 '11 at 19:41
  • 2
    @Jose Faeti: My boss would agree because my boss is an experienced, rational guy. He doesn't buy into programming religion. – Ed S. Aug 29 '11 at 16:54

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.

  • 6
    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
  • 5
    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
  • I agree in voting for clarification of that fact, not all valid C programs are valid C++ programs, i.e. C++ is not a superset of C. However, it is a superset of how C was at the point of making the decision for it to be a superset, as Donal Fellows mentioned. It simply doesn't make sense to say that it is anymore, when it's no longer true however. – Joshua Hedges May 25 '17 at 19:18

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++).

  • 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 langpop.com, 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.

  • 3
    DON'T OPEN this URL! The website does not exist anymore and the URL redirects to some annoying spammy pages. – Nikolay Suvandzhiev Jan 18 at 12:59

I use it almost every day developing for iPad/iPhone. 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)

  • 2
    "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.

  • 2nd Place (after Java). – Martin York Aug 26 '11 at 13:06
  • 7
    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

Portability.

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.

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.

Oh yes, it is used. I work in the field of network packet processing. I have been at two different companies where we process network packets. So, we are operating at the Ethernet or IP level, not at the level above TCP.

Interestingly, in both companies C was chosen over C++. In one of the companies, one of the two products was built on top of Linux kernel, whereas the other product was built in Linux userspace. The kernel product obviously used C as Linux kernel is programmed in C, but they chose to use C for the userspace product as well. Both products were developed starting from about year 2000 (the kernel product a bit before 2000 and the userspace product a bit after 2000).

In the company where I went after that, the product was built on C, not on C++. It is actually a continuation of a project from the mid-1990s, although due to recent performance improvement demands, it was decided that essentially everything will be rewritten. We had an option to select C++ due to this rewrite, but didn't do so.

In the field of network packet processing, performance counts a lot. So, I want to implement my own hash table having higher performance than existing hash tables. I, not the hash table author, am who selects what hash function is to be used. Perhaps I want performance and go for MurMurHash3. Perhaps I want security and go for SipHash. Memory allocators are obviously custom. In fact, all the important data structures we use have been custom-implemented for the highest possible performance.

While there is nothing that would prevent the use of C++, it is usually a bad idea. A single thrown exception per packet will drop the packet processing rate to unacceptable levels! So, we cannot use C++'s exceptions. Way too slow. We are already using kind-of object-oriented C code by implementing data structures as structs and then implementing functions operating on those structs. C++ would allow having virtual functions, but then again virtual function calls would kill performance if used everywhere. So, it's better to be explicit and have a function pointer if virtual function calls are needed.

C++ will do a lot of things behind your back: memory allocation, etc. On the other hand, in C that usually doesn't happen. You can write a function that allocates memory, but usually it is apparent from the interface of the function that allocation is happening.

As example of the kind of micro-optimizations that you can do when programming in C, take a look at the container_of macro in the Linux kernel. Sure, you could use container_of in C++ code, but who does that? I mean, it is entirely acceptable in most C programs, but typical C++ programmers would immediately propose something else, such as a linked list that allocates the link nodes as separate blocks. We don't want that because every allocated memory block is bad for performance.

Perhaps the only thing that would benefit us in C++ is that C++ allows template metaprogramming, meaning you can sometimes avoid virtual function calls while still having a function parameter, and allow the compiler to inline the functions. But template metaprogramming is complicated, and we have managed to fulfill all requirements in C, so the benefit of this feature in C++ is not so critical.

In one of the companies, we actually had a custom compiled language where part of the features were implemented in. Guess which was the target language of the compiler? Assembly? No, we had to support both 32-bit and 64-bit architectures. C++? Surely you jest. Obviously, it was C with GCC's computed goto. So, the custom language was compiled to C (or actually the gcc variant of C that supported computed goto), and the C compiler produced assembly.

I still use C on a daily basis and one of the primary reasons is because of interop with other languages and an SDK designed to be used by plugins built by all kinds of compilers in various languages.

I can't write a C++ API that uses classes with constructors and destructors and vtables, function overloading, throws exceptions, etc. that can be used from Lua, C#, Python, C, etc. let alone a C++ plugin written using different compilers and settings from our own.

I can't write a C# SDK that can be called from Python, e.g., or a Python SDK that can be called from C#.

C is the only language here that allows me to create an API that can be called from any of these languages. That said I often use C++ to implement these C interfaces (though I sometimes just implement them in C).

Besides that, I sometimes find C the easiest language to work with for things like low-level data structures and memory allocators. All the extra type safety you gain in C++ doesn't help if you're writing a memory allocator designed to pool aligned bits and bytes. And against C++'s rich type system and exception-handling, it's not easy to roll your own data structures -- just look at how much effort it takes to write a data structure as trivial as std::vector if you want to make it exception-safe and avoid invoking ctors and dtors on elements you didn't insert to the container (I'm speaking as one who has implemented the entire C++ standard library). When just a growable array is very difficult to implement well, then imagine the work required to implement a production-quality BVH.

I prefer C++ over C when I want to use existing data structures or implement higher-level ones by using existing ones, but if I'm going to be implementing a low-level data structure at the core of an engine that has no use for existing data structures, C definitely makes that a lot easier to do with its uber simplistic type system that lets you just memcpy things here and memmove things there, malloc a contiguous block and realloc it there, without worrying about constructors, destructors, and exceptions being thrown.

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.