LinuxQuestions.org
Review your favorite Linux distribution.
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


View Poll Results: Which is better?
C 24 34.78%
C++ 35 50.72%
C# 2 2.90%
Other/Don't Care/Huh? 8 11.59%
Voters: 69. You may not vote on this poll

Reply
  Search this Thread
Old 04-07-2003, 11:00 PM   #1
iHeru
Newbie
 
Registered: Apr 2003
Distribution: Slackware 9.0 and Debian 3.0
Posts: 26

Rep: Reputation: 15
Post C? C++? (c#?)


Okay, so I program C++ (don't know standalone C) and was wondering what you think is better. Some people I know love C++'s increased functionality, but others say that C++ is just C's ill formed bastard child. Or do you (gag) like C#? Whatever the case, come and discus...
 
Old 04-07-2003, 11:44 PM   #2
fatman
Member
 
Registered: Mar 2003
Location: PA
Distribution: Ubuntu (x2)
Posts: 158

Rep: Reputation: 30
As someone educated in C++ with minimal strict C experience, I am being forced into writing my graduation project in C (couldn't get the #@%^ mysql++ API working),

I can say I hate C (even though I'm such a moron I just accidentally voted for C in your poll). It does has the nice side effect of refreshing my grasp on the use and abuse of pointers, albeit through massive trial and error and lots of goofy little diagrams.

Overloading - good
string and stream objects - good
call by reference - good
member functions of classes - good
(if I can do any of those things in C please let me know)

That being said I am aware that C has its benefits and many areas is a better choice than C++.
 
Old 04-08-2003, 12:12 AM   #3
Palin
Member
 
Registered: Feb 2003
Location: A Meatlocker, well feels like one
Distribution: Gentoo
Posts: 292

Rep: Reputation: 30
Other than assembly I don't think you can beat compiled C code for speed. Pointers will extremely difficult to use and maintain are extremely powerful. I believe device drivers are written in C. Other languages do have benefits that make their use more deseriable in certain situations. I would say I prefer c/c++ over any other.
 
Old 04-08-2003, 01:18 AM   #4
GtkUser
Member
 
Registered: Sep 2002
Location: Canada
Distribution: Redhat 9.0
Posts: 637

Rep: Reputation: 30
Standard C is necessary for any system application because all enterprise platforms are implemented in C and have critical subsystems that use Standard C function interfaces.

Standard C++ is much nicer than Standard C to build systems, yet because you need to generalize when you build a system, you have to work with the limitations of a Standard C function interface. It would be much better if the platform were implemented in Standard C++. The system interface would use references and copies of objects rather than functions So in reality there is no such thing as Standard C++ that is indepentant of Standard C.

C# is not independant of a framework and a virtual machine. In large part, C# is an operating system, and so is Java. These middleware platforms are well suited for solution implementation and less so for system implementation. The developer specializes through vendor framework libraries (rather than generalizing toward the system interface). I've been studying Java and I find that the core language is cleaner with respect to syntax and related to common language features, however since the core language is less powerful, it fails to maintain that clean syntax when trying to implement generics or even inheritance. The same weaknesses hold true for C#.

I think that generally trying to compare C# with Standard C and Standard C++ is very clueless. This is like saying, which is better, a computer language or a framework written in that language.

Last edited by GtkUser; 04-08-2003 at 01:20 AM.
 
Old 04-08-2003, 07:31 AM   #5
wapcaplet
LQ Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Rep: Reputation: 48
Gotta say I prefer C++, for a number of reasons. My favorite feature (to date) is operator overloading (which, frankly, I don't see why this can't be added to the C standard as well, but I digress). I like objects, for the most part, since it modularizes and simplifies the programming process (at least conceptually - it seems like it'd be far easier to maintain an OOP program than a non-OOP one).

Though, then again, C++'s object-orientedness is kind of klugey and not nearly as elegant as something like Java. I've noticed that programs in strict C tend to compile to a smaller and faster binary. And certainly, programming in strict C once in a while gives you a good perspective on how well you really understand low-level programming concepts.

I don't think I'll ever touch C#, just on principle. I know next to nothing about it, aside from the obvious fact that since Microsoft invented it, it's quite likely there is an agenda attached to the language. One of my professors described the situation well:

Java is a single language that will work on many different platforms. Learn one language, and you can program for many different environments.

MS C#, VB, and other stuff in their .NET framework are multiple languages which (surprise) work on a single platform. Learn one environment (Microsoft's) and you get many different languages to choose from.

I'm probably missing some of the details, but that's the overall impression I get. Of course, Java's approach seems to make infinitely more sense from a programmer point of view - it means less work.

C/C++ is a pretty good happy medium for me, since it's relatively portable, and is not tied to any single company's agenda.
 
Old 04-08-2003, 08:12 AM   #6
macewan
Senior Member
 
Registered: Jan 2002
Distribution: Ubuntu, Debian
Posts: 1,055
Blog Entries: 1

Rep: Reputation: 45
seems everyone that i know that is in the know says c is the best and that i !must! learn it. they also rave about python. currently i'm teaching myself c++ and java just because they seem sexier (little python also).
 
Old 04-08-2003, 03:36 PM   #7
nakkaya
LQ Guru
 
Registered: Jan 2003
Location: Turkey&USA
Distribution: Emacs and linux is its device driver(Slackware,redhat)
Posts: 1,398

Rep: Reputation: 45
check out http://www.research.att.com/~bs/ Bjarne Stroustrup(creater of c++)
faq he states a c++ programs when compiled are smaller and faster if compiled in a good compiler some one said they were slower.
 
Old 04-08-2003, 04:17 PM   #8
wapcaplet
LQ Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Rep: Reputation: 48
Quote:
Originally posted by nakkaya
check out http://www.research.att.com/~bs/ Bjarne Stroustrup(creater of c++)
faq he states a c++ programs when compiled are smaller and faster if compiled in a good compiler some one said they were slower.
I didn't say they always did; I just said they tend to be smaller and faster. Obviously Bjarne Stroustrup is going to be a little bit biased In my experience, though, anything written in C compiles to a smaller binary. I haven't actually measured the speed myself, but there has to be a pretty good reason that almost all GNU-related development seems to be done in C, rather than C++.

Just now I tested it with a small program:

Code:
#include <stdio.h>
int main()
{
  printf("Hello, world\n");
  return 0;
}
Compiled it:


gcc hello.c -o helloc
g++ hello.c -o hellocpp
ls -l
-rw-rw-r-- 1 eric eric 75 Apr 8 17:12 hello.c
-rwxrwxr-x 1 eric eric 11346 Apr 8 17:17 helloc*
-rwxrwxr-x 1 eric eric 11450 Apr 8 17:17 hellocpp*


Trivial example, I know, but there ya go.
 
Old 04-08-2003, 05:37 PM   #9
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Try static linking ;)

gcc -static hello.c -o helloc
g++ -static hello.cc -o hellocpp

Oh, and I used cout instead of printf :} in C++

Code:
-rw-r--r--    1 tink   users          74 Apr  9 10:32 hello.c
-rw-r--r--    1 tink   users          84 Apr  9 10:33 hello.cc
-rwxr-xr-x    1 tink   users     1575113 Apr  9 10:34 helloc
-rwxr-xr-x    1 tink   users     1882559 Apr  9 10:34 hellocpp

Cheers,
Tink
 
Old 04-10-2003, 01:33 PM   #10
kenulla
LQ Newbie
 
Registered: Apr 2003
Posts: 13

Rep: Reputation: 0
c++ fo sure!
 
Old 04-11-2003, 11:47 AM   #11
GtkUser
Member
 
Registered: Sep 2002
Location: Canada
Distribution: Redhat 9.0
Posts: 637

Rep: Reputation: 30
One reason why systems are implemented in C rather than Standard C++ is that all enterprise platforms which all stemmed from the 1970 are implemented in C.

There is no such thing as a Standard C++ toolkit. It's all either object based C, or non standard C++ or just C++ wrappers of C toolkits. This is a very sad fact.

Middleware systems such as Java and .Net support OOP in a much more powerful way than any native toolkit, but they are watered down OOP languages. Their strength is in the OOP domain manufactured by the virtual machine and the famework that supports OOP useage. This rich development would be possible in native platforms if they were implemented in a language like Standard C++, but they are not, instead they are dinosaurs. Vendors have used middleware instead of rewriting the native platform.

Last edited by GtkUser; 04-11-2003 at 11:49 AM.
 
Old 04-11-2003, 01:23 PM   #12
GtkUser
Member
 
Registered: Sep 2002
Location: Canada
Distribution: Redhat 9.0
Posts: 637

Rep: Reputation: 30
I'm afraid that the choices are either to use Standard C and object based toolkits that support C very well such as GTK+. However you will not be able to take advantage of OOP such as inheriting and subclassing framework objects and you will have more obfusicated code and trouble handling complexity, or else use middleware, which carries bulk and is a watered down core OOP language with extensive and rich framework libraries. I don't see any clear choice, because both paths are weak. Yet there is a whole series of work arounds that can be suffered through to make things work.
 
Old 04-11-2003, 02:37 PM   #13
nakkaya
LQ Guru
 
Registered: Jan 2003
Location: Turkey&USA
Distribution: Emacs and linux is its device driver(Slackware,redhat)
Posts: 1,398

Rep: Reputation: 45
there is something called standart c++ check ansi/iso page if they were the same why another commiti
there is a lot of changes in bet ween c and c++ if you read the c++ programming language from the creator of c++(cant write his name) he explains it in detail. what can and cant be done diffrences standart libs in c and c++ are completely difrent.
 
Old 04-11-2003, 08:47 PM   #14
macewan
Senior Member
 
Registered: Jan 2002
Distribution: Ubuntu, Debian
Posts: 1,055
Blog Entries: 1

Rep: Reputation: 45
learning c++ is easy enough. quite fun. started with c but it's so freaking boring. c++ is more like setting a site up with php. funfun.
 
Old 04-12-2003, 01:24 AM   #15
jsimonelis
LQ Newbie
 
Registered: Apr 2003
Posts: 2

Rep: Reputation: 0
How is it that you can program in the superset of a language and not the base?

> Okay, so I program C++ (don't know standalone C) and was wondering
> what you think is better. Some people I know love C++'s increased
> unctionality, but others say that C++ is just C's ill formed bastard child. Or >do you (gag) like C#? Whatever the case, come and discus...
 
  


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 06:39 PM.

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