Jump to content
  • Advertisement
Sign in to follow this  
johnnyBravo

Why do people still use C ?

This topic is 5033 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I was quite curious why people still use C, if C++ is just as fast , has backwards compatibility and has OOP capabilities. As at my friend's uni, the are currently teaching them that, im not sure what course he's doing, ...forgot to ask. Also apart from updating existing c programs. Thanks

Share this post


Link to post
Share on other sites
Advertisement
Your friend is probably being taught that because C programs are programmed differently than OO C++ programs. It's best to have experience with a wide range of programming paradigms.

Share this post


Link to post
Share on other sites
Some reasons to use C are:
- Existing applications
- The platform you are developing for has no C++ compiler (embeded systems)
- You don't need te features of C++, since you need maximum speed. Low level code, like drivers, operating system stuff...

Share this post


Link to post
Share on other sites
Some people simply like C more than C++. They do usually use a modern C++ compiler to code with though, which is backwards compatible as you said.

If I'm writing a small program I usually code in classless C++, using just functions but making use of features of the C++ language like new/delete. If I'm writing a larger program I use OO code.

Share this post


Link to post
Share on other sites
I would say it's because no matter what platform you have to work on, there is most likely a C compiler for it. The C runtime library is small, fast, and relatively easy to implement compared to the C++ runtime library. Often times the first thing done for a new platform is writing a C compiler and runtime for it.

C is good to know so that one day when you have to work on platform XYZ that doesn't have a C++/"insert favorite language here" compiler, you can be pretty sure it has a C compiler.

Share this post


Link to post
Share on other sites
If you us ANSI C it is much easier to port your application to other platforms, because (as was said earlier) most platforms have a C compiler. Also some people (myself included) prefer structured programming as opposed to OO. At work I use C to program for an embedded system.

Share this post


Link to post
Share on other sites
C is not often used by new programmers or many hobbyists because it requires dicipline, and that's no fun! ;-)

But once writing code is about getting the code written, C is

1. Clean. Super clean. Diciplined C code is a dream to read.
2. Fast. It's C, after all.
3. Portable.
4. can be as abstract as necessary.

So basically, a lot of people look at what they want to write, decide that it need to be lean and mean, and so dismiss things like python, vb, c#, whatever, and then choose C by default.

Why not C++? Sure, it's fast ("only pay for what you use"). It's only somewhat less portable. But the abstraction and clean parts get messed up.

Huh? abstraction in an OOP languages being worse than a non-OOP language?

Yeah. OOP is sometimes a square peg for a round hole. Sure, C++ lets you solve those problems by using a different style, but suddenly you loose all that syntax sugar C++ has for OOP and you're left with horribly ugly code. Just look at some of the template functional programming garbage. Horrendously complex.

And it's not like you can't write OO code in C. and when you do, its style is more consistent with other programming styles.

Share this post


Link to post
Share on other sites
a lot of the OOP in C++ is done during pre-processing. Classes end up getting converted to regular C functions and structures during compile time. It's not like C++ is going to be faster. The real difference is that C++ may to some people feel more user friendly and they may like using it. C++ simply adds a *this pointer parameter to functions of classes and passes *this pointer for you ... This can be achieved in C just as well but will not look or act as pretty.

picture this:

c
rotate(theobject,x,y,z)

c++
theobject.rotate(x,y,z)
or
theobject->rotate(x,y,z)

Really their is no difference at the end of the day. If you are looking for a language that masks the underlying code from you to help you program better, then you should look into Java or .Net languages, because in general thats all they do.

Share this post


Link to post
Share on other sites
As it happens, I remember I've always liked using C libraries better than the C++ ones (OpenGL vs. DirectX, SDL vs. CDX, and others). The very same goes for my own modules.

Portability (between platforms and compilers) and compiling speed are some other advantages.

The biggest reward for not going C++ has been that it is vastly easier to connect a C program to other languages than it is for a C++ one. I try to move away from C as well, but C++ is not where I want to end up. I need a dynamically typed language, like Lua or Lisp. (Lua by the way is coded as a vanilla C library.)

Share this post


Link to post
Share on other sites

This topic is 5033 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!