Is C obsolete?

Started by
41 comments, last by daviangel 16 years, 3 months ago
Just wondering, I thought C++ is C and more, so why do people still use C?
Advertisement
I would think that a lot of OS and driver development still uses C (rather than C++). And, back in the Visual Studio 6 days, all Microsoft IDEs and Office products were developed using C (and straight Win32). That may have changed.

C is also still used in the low speed CPU world (PIC, 8051, z-80, etc.)

Check out Super Play, the SNES inspired Game Engine: http://www.superplay.info

I use C all the time for microcontrollers and also for some of the stuff I do with robotics. Many of the microcontroller and robotics folks are working on going to C++ but just like everything else it takes time.

theTroll
Like TheTroll mentioned, lots of embedded systems end up requiring you to use C. There's a simple reason for this. C has been around for well...a long time now -- because of this, it's been ported to a bajillion architectures. When you make a new kind of processor architecture, or even a complicated microcontroller...and you plan on letting people write programs for it; you have to give them some way to write programs that removes the need to speak processor language (can you imagine having to write in x86 machine code? ugh...).

C, because it's been around a while, because lots of people are familiar with it, and because its standards are more or less fixed -- is a decent choice for a language to implement a compiler for. I'm not saying writing a compiler for C is -easy- (for from it...), but because so many people have done it before, it makes things a -bit- easier :)

~Shiny

p.s. Lots of people are trying to move things to C++ -- I have worked on embedded systems that use C++ lately, unfortunately because someone had to make their own implementation of standard library stuff for this particular hardware -- sometimes the standard library stuff does not work as expected :'(
------------'C makes it easy to shoot yourself in the foot. C++ makes it harder, but when you do, it blows away your whole leg.' -Bjarne Stroustrup
No language is ever really "obsolete". The platform it runs on can become obsolete, but that's different.

C runs on virtually everything. Unix and Linux were written almost purely in C. A lot of robotics and embedded solutions run C.

I don't like C++. It has a lot of things I don't want/need, and there's not really anything it can do that C can't.

Not to mention, a C compiler exists for pretty much every operating system out there... The same can't be said for a lot of other languages.
Oh, I forgot to mention, a properly programmed C program is FAST.
Quote:Oh, I forgot to mention, a properly programmed C program is FAST.

Sorry to rebuke but this comment stuck out at me.

A properly programmed C program does the same thing any properly programmed software does in any language... perform a task to spec.
My point was that if you write a program in C, and then write one in Java, the one in C is going to run faster.

I see what you're trying to say though, my bad.
All of the reasons stated so far are valid, but I'm always surprised in these threads that one particular item never seems to come up, yet for me it is THE reason why C is still not only used but of vast importance to the development community:

Binary compatibility.

Standard compliant C compilers are required to output their structures and function entry points into the final binary a certain way, and no one really deviates from it. What this means, practically, is that I can take a C library compiled with a Microsoft compiler (like the Win32 lib) and call it's functions and use its structures from, say, a compiler from GCC or Borland or Intel or anywhere and KNOW that it will work. You simply CANNOT do that with today's C++ compilers. Heck, even different versions of the same C++ compiler may be binary-incompatible.

This is why a great many plugin setups (Maya comes to mind, but there are many, MANY others) are in C, as are a great many standard libraries like OpenGL, as well as why most tutorials on DLL usage have you wrap everything exposed to the outside world in a "C" declaration. Everything can read it! Most other languages also include a method for calling C functions from a lib or DLL (Python, D, .NET, etc.) for the same reason. AND it's why COM is built around many many layers of awkward C code. Have I beat the dead horse enough yet, because I'll go on if I have to :)

Now C isn't the only language out there that does this. .NET actually has a nice setup for "binary" compatibility, but C has the advantages of cross-platform compatibility and native compilation (read: speed). Other languages that conform to a specific binary format usually have the simple disadvantage that they aren't as well known as C.

The list goes on and on, but what it all boils down to is that when interoperability and speed are an absolute must C is generally the way to go!
Quote:Original post by Tom9729
My point was that if you write a program in C, and then write one in Java, the one in C is going to run faster.


Except when it doesn't. 'Java is slow' is an urban legend.

This topic is closed to new replies.

Advertisement