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.
hi everybody..
It's my first post in this forum, and I'm wonder -just an curiosity, why I see much more code in C than in C++
under linux..
If C++ got classes and all that 'advantages'.. why it isn't so used like C ?
regards.
If a project as large and complex as the Linux kernel can be implemented as successfully as it has been in C, it makes me wonder if there's any real merit in coding in C++ in the first place. After all, the whole point of coding in an Object Orientated style is to make large, complex projects manageable.
Just a thought.
On the other hand, I know Not Much At All about kernel hacking, so maybe writing operating systems doesn't lend itself to OO programming.
It should be noted that I learned to program in Ada and Java, so I'm in no way a Procedural Language zealot, and I generally prefer programming in terms of objects.
Other languages (perl, java, python, PHP) have more advantages so they are used instead of c++.
Quality of the gcc c++ compiler used to be much worse than the c compiler. This probably isn't the case anymore, but many old projects use C because of it.
Writing portable c++ code is hard because every compiler (including different versions of gcc) supports different version of the language standard and different set of features.
Quote:
If a project as large and complex as the Linux kernel can be implemented as successfully as it has been in C, it makes me wonder if there's any real merit in coding in C++ in the first place. After all, the whole point of coding in an Object Orientated style is to make large, complex projects manageable.
Open source developers like to modularize their projects at higher level, splitting a complex project to multiple sub-projects. For example, in the Linux kernel each driver is a sub-project. This reduces complexity the same way as using OO.
GNOME is written in C, KDE uses C++. GNOME is considering to adopt a higher-level language for their project though.
IMHO C++ makes more sense for complex desktop applications, allowing programmers to think about more complex situations instead of worrying about low-level stuff. Background processes (think apache, sshd) perform many low-level tasks, C is a nice choice. For desktop appliations, problems like "how can I make two parts of my problem interact nicely?" arrise. C++ gives an answer for this. In effect, many users are able to create new kde applications, building on the development platform created by KDE.
KDE did suffer from the bad performance of C++ in the past, but they've also tracked the problems down to issues with GNU "ld" and "gcc". Improving the GNU stuff would fix many "C++ is slow" issues too. (gcc-3.4 already gives KDE more performance)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.