LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 01-08-2004, 09:04 PM   #1
fr0zen
Member
 
Registered: Nov 2003
Location: 127.0.0.1
Distribution: xubuntu
Posts: 217

Rep: Reputation: 30
Question Applications seem favor C over C++, why?


I've programmed in both C and C++. I don't mind either language, each has its special quirks.

What I don't understand is, if C++ offers the same functionality as C, but in a more OOP manner, why do most developers choose C over C++?

Is it because they don't understand OOP? Choose not to use it? Old code, and porting would take too long? Pointless? Or is there something I'm missing...?

Thanks.
 
Old 01-08-2004, 09:22 PM   #2
h/w
Senior Member
 
Registered: Mar 2003
Location: New York, NY
Distribution: Debian Testing
Posts: 1,286

Rep: Reputation: 45
i think one of the main reasons is "using a hammer to go after a fly".
 
Old 01-08-2004, 09:45 PM   #3
mr_segfault
Member
 
Registered: Oct 2003
Location: Australia
Distribution: Redhat 9
Posts: 95

Rep: Reputation: 15
Without even taking all the other factors into consideration, in my experience, all non trivial programs use containers of some sort (linked lists, arrays etc) in C this is a pain since there are no standard container (ADT like linked lists) types in the language spec (other than arrays).

And for every C program I have worked on a large portion of the development effort is spent developing ADT (abstract data types)... Now with C++ we have them all at our finger tips..

If you dont like C++ I'd suggest using a C++ compiler even if it is just for the std containers..

Just my 2 cents...

Cheers.
 
Old 01-08-2004, 10:10 PM   #4
fr0zen
Member
 
Registered: Nov 2003
Location: 127.0.0.1
Distribution: xubuntu
Posts: 217

Original Poster
Rep: Reputation: 30
Well I do like C++, and C. I was just curious as to why C is favored more. I suppose I do see the logic behind the "using a hammer to go after a fly" analogy, but if that's true, then C++ was a waste of time to develop. If C++ is a hammer, what is C? A rock?

Most of what I code uses C++, mostly because of the STD containers. I just started noticing (after having had to make changes in source files for several applications) that not many production level applications appear to make use of them.

Oh well.
 
Old 01-08-2004, 10:36 PM   #5
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 58
I much prefer C over C++. Part of the reason is because the executable is usually a bit bigger for C++ programs. Another reason is uhh...I don't know. I learned C first and there's nothing I can't do in C that C++ would let me do I guess Maybe my brain just doesn't think OOP very well. :P
 
Old 01-08-2004, 10:38 PM   #6
mr_segfault
Member
 
Registered: Oct 2003
Location: Australia
Distribution: Redhat 9
Posts: 95

Rep: Reputation: 15
Hey fr0zen, I like your desktop screen shots
 
Old 01-08-2004, 10:42 PM   #7
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 66
I am not going to start a discussion on C vs. C++ because that could easily start a holy war. I will say that compilers is the total reason why most things linux are in C.

GCC, the free (as in beer) compiler used for most things linux, started out as a C compiler (GCC used to stand for Gnu C Compiler if I am not mistaken). It's support for C has, and still is, better then it's support for C++. They have messed around with the C++ part of it so much they even broke compatibility going from 3.0 to 3.1. As a result many people utilizing these tools have tended to go toward C because the C compiler is more stable, and more heavily tested over the last 27 years.

The kernel itself is C probably because way back in the 1991 gcc was still mostly just a C compiler and Object Orientation and Abstraction, while logically very efficient, doesn't lend itself to code that is as fast or as memory friendly as function code with only simple data types.
 
Old 01-09-2004, 10:42 AM   #8
fr0zen
Member
 
Registered: Nov 2003
Location: 127.0.0.1
Distribution: xubuntu
Posts: 217

Original Poster
Rep: Reputation: 30
Quote:
Originally posted by mr_segfault
Hey fr0zen, I like your desktop screen shots
Heh. Thanks. :P

Quote:
Originally posted by jtshaw
I am not going to start a discussion on C vs. C++ because that could easily start a holy war. I will say that compilers is the total reason why most things linux are in C.

GCC, the free (as in beer) compiler used for most things linux, started out as a C compiler (GCC used to stand for Gnu C Compiler if I am not mistaken). It's support for C has, and still is, better then it's support for C++. They have messed around with the C++ part of it so much they even broke compatibility going from 3.0 to 3.1. As a result many people utilizing these tools have tended to go toward C because the C compiler is more stable, and more heavily tested over the last 27 years.

The kernel itself is C probably because way back in the 1991 gcc was still mostly just a C compiler and Object Orientation and Abstraction, while logically very efficient, doesn't lend itself to code that is as fast or as memory friendly as function code with only simple data types.

I was careful in choosing the wording for my question as I too have no interest in sparking a C & C++ jihad. Your explanation for the reasons behind the usage of C in preference to C++ is sufficient for me. The main reason I like C++ is because I use the STD containers.

Are there any C oriented STD-like containers available?

Last edited by fr0zen; 01-09-2004 at 10:44 AM.
 
Old 01-09-2004, 11:47 AM   #9
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
Quote:
Originally posted by fr0zen
Well I do like C++, and C. I was just curious as to why C is favored more. I suppose I do see the logic behind the "using a hammer to go after a fly" analogy, but if that's true, then C++ was a waste of time to develop. If C++ is a hammer, what is C? A rock?
not a rock, more like a fly swatter.
 
Old 01-09-2004, 12:04 PM   #10
h/w
Senior Member
 
Registered: Mar 2003
Location: New York, NY
Distribution: Debian Testing
Posts: 1,286

Rep: Reputation: 45
that's a beautiful screenshot, frozen. sure woke me up.
 
Old 01-09-2004, 12:25 PM   #11
Strike
Member
 
Registered: Jun 2001
Location: Houston, TX, USA
Distribution: Debian
Posts: 569

Rep: Reputation: 31
I'd say the hammer analogy is misguided. If anything, C is the hammer simply because it is a "heavier" tool in that you have to do so much with it, and it can be considered more powerful in that you can do ANYTHING in it that can be done on a machine that it compiles/runs on, basically.

Also, why do you say more people choose C? What kind of apps are we talking about here anyway?

In an ideal world, the language used would reflect the problem's domain. Of course, in this ideal world C would be used only for things that are speed-critical, basically. But, people use C instead of C++ a lot of times because C is just easier to hack together and using C++ requires more design and planning to get it done right. Ideally, many of the "utility" apps that use C++ would be written in a higher level language like Python because it would solve their problems better. Note: by "utility" I don't mean larger-scale apps where response time is critically important.
 
Old 01-09-2004, 01:00 PM   #12
h/w
Senior Member
 
Registered: Mar 2003
Location: New York, NY
Distribution: Debian Testing
Posts: 1,286

Rep: Reputation: 45
if you were to write something that does not require obj-oriented design, would you choose C/C++?
 
Old 01-09-2004, 01:38 PM   #13
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 66
I would choose C if I was writing someting that didn't require obj-oriented design. But that is probably because I am most comfortable with C and I use it the most out of all the different programming languages.
 
Old 01-09-2004, 02:29 PM   #14
h/w
Senior Member
 
Registered: Mar 2003
Location: New York, NY
Distribution: Debian Testing
Posts: 1,286

Rep: Reputation: 45
http://www.artima.com

i think i had seen the hammer-fly analogy there. there are a few nice interviews with stroustrup on the index page itself. excellent read if you don't already know what he's talking about.
 
Old 01-09-2004, 04:29 PM   #15
Mega Man X
Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 63
I've been programming only in C++ for quite a long time(hobby) now, because it was, and still is, the only choice for courses around here and most of tutorials on the net are about it, and so are the books. I've read huge books about it, I've done a lot of small projects and now we (at the school) are starting out with Java (one month programming with Java now) which is purely OO and guess what? I still cannot see a good reason for using OO... at least not in my applications. A gui program would require more OO, as defining a class Window and buttons and so on... but other then that, I still don't know why or when I'm supposed to use OO. You could tell me that it makes the code more usable, more easy to update it and everything that is on the books I know . I don't understand the concept of OO in "practice". Everything in theory is beautiful though... Any ideas about it? Because I code in C++, using a C style if you know what I mean... (sounds dumb, but I mean C++ syntaxes)

Last edited by Mega Man X; 01-09-2004 at 06:33 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can do me a favor? lifetaster Linux - Security 1 03-11-2005 09:01 AM
Can someone do me a favor? TerminalPhreak Linux - Newbie 3 02-27-2003 03:10 PM
can anyone do me a favor? I need... C++freak Linux - Distributions 4 09-22-2002 11:16 AM
What FS do you favor? NSKL Slackware 14 05-30-2002 01:02 AM
Squid favor... sancho5 Linux - Networking 1 09-24-2001 12:41 AM


All times are GMT -5. The time now is 11:36 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration