LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 04-11-2010, 07:10 PM   #1
Super TWiT
Member
 
Registered: Oct 2009
Location: Cyberville
Distribution: Debian
Posts: 132

Rep: Reputation: 16
C vs C++


I am sure many of you have heard about Linus Torvald's Rant on C++. At first, I thought he was crazy, but a lot of people agree with him that I've seen after looking at various comments on websites that journal tech news. I am looking to learn a language and am currently swayed towards C++, but I DO respect torvalds and it leads me to wonder... Many small programs are written in c. I have heard that c++ really isn't different than c as far as efficiency (I HATE bloated applications). I don't want to start a flamewar, but am looking for a balanced disscussion of c vs c++. What are the main differences?
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 04-11-2010, 07:18 PM   #2
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Personally I really don't like C++.

(And I have read Linus's rant before).
 
Old 04-11-2010, 08:10 PM   #3
Dan04
Member
 
Registered: Jun 2006
Location: Texas
Distribution: Ubuntu
Posts: 207

Rep: Reputation: 37
The C++ FQA is a good description of what's wrong with C++.
 
2 members found this post helpful.
Old 04-11-2010, 08:15 PM   #4
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Rep: Reputation: 231Reputation: 231Reputation: 231
C++ has some disadvantages e.g.: WTF style virtual/template/vector
and advantages e.g.: Functions that adapt to the type required and auto freeing pointers.
 
Old 04-11-2010, 08:38 PM   #5
cola
Senior Member
 
Registered: Sep 2007
Posts: 1,045

Rep: Reputation: 65
Quote:
Originally Posted by Super TWiT View Post
I am sure many of you have heard about Linus Torvald's Rant on C++. At first, I thought he was crazy, but a lot of people agree with him that I've seen after looking at various comments on websites that journal tech news. I am looking to learn a language and am currently swayed towards C++, but I DO respect torvalds and it leads me to wonder... Many small programs are written in c. I have heard that c++ really isn't different than c as far as efficiency (I HATE bloated applications). I don't want to start a flamewar, but am looking for a balanced disscussion of c vs c++. What are the main differences?
Programming in C++ can be easier because it has a lot of built in function/algorithm.
 
Old 04-11-2010, 08:43 PM   #6
MrCode
Member
 
Registered: Aug 2009
Location: Oregon, USA
Distribution: Arch
Posts: 864
Blog Entries: 31

Rep: Reputation: 148Reputation: 148
I personally don't use C++'s "special features" that much, as I really have no need for them as of yet. The only things I've done in C++ are usually little Arduino AVR programming experiments (the Arduino API is in C++), and a small console application I wrote that does little more than calculate a facing vector between two others (I was thinking I'd use this in a future game engine). You would give three parameters on the command line (the X, Y, and Z values of the first position), and it would spit out an X and Y angle that makes the first position "face" the other. Yeah, nothing all that speical, but it was in C++, utilizing object orientation.

Last edited by MrCode; 04-11-2010 at 08:46 PM.
 
Old 04-11-2010, 08:50 PM   #7
Super TWiT
Member
 
Registered: Oct 2009
Location: Cyberville
Distribution: Debian
Posts: 132

Original Poster
Rep: Reputation: 16
Does C offer more control?

Last edited by Super TWiT; 04-11-2010 at 09:01 PM.
 
Old 04-11-2010, 09:23 PM   #8
Dan04
Member
 
Registered: Jun 2006
Location: Texas
Distribution: Ubuntu
Posts: 207

Rep: Reputation: 37
Quote:
Originally Posted by Super TWiT View Post
Does C offer more control?
No. Every C program is a valid C++ program if you add enough typecasting.
 
Old 04-11-2010, 10:24 PM   #9
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
C++ has been a software disaster of biblical proportions.

IMHO

PS:
Quote of the day:
Quote:
"I invented the term object-oriented, and I can tell you that C++ wasn't what I had in mind".

Last edited by paulsm4; 04-11-2010 at 10:29 PM.
 
Old 04-12-2010, 12:51 AM   #10
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by Dan04 View Post
No. Every C program is a valid C++ program if you add enough typecasting.
Almost every.
 
Old 04-12-2010, 04:13 AM   #11
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
To say that "It's [C++ is] made more horrible by the fact that a lot of substandard programmers use it" is really quite a feeble argument. C++ is arguably over complex and many of the feature are used without really understanding them. For example there is confusion for some programmers when to select inheritance, association and templates. The fire two are O-O issues (often known as the "is a" versus "has a" problem) the third element is part of the generic paradigm in C++. Having all of this in one language can be confusing and can lead to bad design decisions, but having it in a language doesn't mean that all design decisions will be bad. The key is to know when to use them.

C is a great language, particularly for system and low level programming; it can also be used for high level applications but for the higher level applications I prefer other languages. I really like C++, but I don't use all of its features in every program that I write, that's for sure. I would rather maintain a well designed well written C++ program over a well designed well maintained C program, but that is a personal choice, and I know that others in this forum would come to the opposite conclusion.

Why do I like C++ over C. I like the O-O support, it's not the best but it is good enough for what I do. I like the options to have templates but I have learnt that these should not used with extreme caution. I like the exception handling, inline functions and static variables. C++ has it's flaws but so does every language.

Last edited by graemef; 04-12-2010 at 04:31 AM.
 
Old 04-12-2010, 04:27 AM   #12
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
well, any rant with foul language can't really be taken as reasoned argument.
no matter who says it.
Linus seems to be up his own quite a lot lately. Like he's the overarching god of software.

in my extensive experience the whole of IT works in a generally sub standard
way, from an engineering point of view. An awful lot of it is ad-hoc and held together
with tape and wire. It's nothing to do with the languages.
It's to do with the people.

Last edited by bigearsbilly; 04-12-2010 at 04:29 AM.
 
Old 04-12-2010, 04:59 AM   #13
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Sergei Steshenko

With respect to your post 10, could you kindly give me an example where a C program cannot be considered a C++ program ! because I also used to think that every C program is a C++ program..
 
Old 04-12-2010, 05:53 AM   #14
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by anishakaul View Post
Sergei Steshenko

With respect to your post 10, could you kindly give me an example where a C program cannot be considered a C++ program ! because I also used to think that every C program is a C++ program..
http://www.linuxquestions.org/questi...-and-c-800768/ ->
http://www.linuxquestions.org/questi...8/#post3928626
 
1 members found this post helpful.
Old 04-12-2010, 06:14 AM   #15
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Sergei

Thanks for the enlightenment !
 
  


Reply



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



LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:13 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration