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?

17 Answers
17

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.

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.
–
BlrflAug 26 '11 at 14:07

@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.
–
sbiAug 29 '11 at 6:25

@James: Might I kindly point you at this comment, where there's a link to a posting in which someone earnestly takes Linus' rant as if it was something intelligible, and takes it apart sentence by sentence. Write a reply to that that's at least half as intelligent as that one and post the link here. Or go back to the cave you came from, and keep cargo-culting.
–
sbiNov 4 '12 at 21:38

I think large part of Windows kernel is also C. And a lot of legacy systems.
–
CoderAug 26 '11 at 12:38

11

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.
–
deadalnixAug 26 '11 at 12:40

56

According to others, Linus' argumentation is horrible.
–
sbiAug 26 '11 at 12:41

29

Linus's arguments may or may not be valid, but Linux kernel is still written in plain C :-)
–
Joonas PulakkaAug 26 '11 at 12:51

12

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 AstariAug 26 '11 at 13:00

@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

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:

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

@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 AstariAug 26 '11 at 16:57

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.
–
Loki AstariAug 26 '11 at 21:32

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 UpadhyayAug 26 '11 at 12:54

1

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 FaetiAug 26 '11 at 12:57

4

@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 BeckettAug 26 '11 at 15:27

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.

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 UpadhyayAug 31 '11 at 5:37

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

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)

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.

Most drivers on most operating systems are written in C. Linux device drivers including kernel 2.4 n 2.6 and above 3 are coded in C language. Most digital sound processing DSP algorithms are written in C.

C shouldn't be used in embedded devices. It should be Assembly.
C++ shouldn't be used to create operating systems. It should be C.
Assembly is a bad choice to create application software. It should be C, or if you're lazy, it's Java or C++.

My view is that Linux and GNU stuff are in C because both needed to work on different machines. Assembly is unique for each machine.

Microsoft Windows is partially written in C++. I think C++ was used to create those application software that came along with the OS. Windows is still C at it's core level.

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.

I am a very beginner programmer and I was totally "lost" inside the jungle of languages for about 6 months, knowing "nothing about how/where to start from zero".

Then I found this nice site (this is not an ad, just my experience) which teachs programming languages from the very beginning in a funny and not-tedious way. Well, they begin with this first language:

C.

Why?

Because C is the mother of mostly all popular languages that came after C. Sometimes C is the only mother, sometimes languages have many fathers, but whatever... I mean, almost every language, including modern ones, like JAVA, behaves to C++, which came directly from C.

With pre(or post?) C -knowledge, I can tell you by my experience, you can really learn fast and easier other languages. Also you now know what is going on the underground when you run some "nice" command on a higher level language(like a GC), and this will probably make you a better programmer in almost all languages, with a better view of the entire process, since knowledge doesn't hurts.

Another advantage is you can control with more details things like, for example, a garbage colection, (more work, but maybe you need this), and you are really, really at bare metal. I guess more than this only with assembly, but this is nuts!

Ferraris doesn't have ABS.

C is one of the most fast languages in run time. (there is why is common to see C in drivers and anything that need speed = PERFORMANCE X [Some more job to write code].)

Pure C is still used, and run anywhere. It's just a matter of choice. You just have more options today, and thanks C for this. =P

I usually thanks C for anything new that I learn in another languages.