ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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...
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++.
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.
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.
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.
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).
Distribution: Emacs and linux is its device driver(Slackware,redhat)
Posts: 1,398
Rep:
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.
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*
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.
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.
Distribution: Emacs and linux is its device driver(Slackware,redhat)
Posts: 1,398
Rep:
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.
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...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.