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 all,
I'm about to embark on a programming tutorial involving C. And...I was wondering...since I understand the concepts of OOP (Java)...should'nt I just learn C++ instead?
The software has to run on a Linux system and pretty dep down in the layers too...at the DE level, in fact...
So..C or C++?
Is (for example) XFCE written in C or in C++?
Thanks
Melissa
If you're thinking of writing Gnome/GTK apps (XFCE uses GTK), then C.
If you want to get all historic and investigate the native X11 libraries: libXaw, libXt, libX11/xcb, those are also C.
Ultimately, the choice will depend on what your end goal is. Besides, no reason not to learn both C and C++.
If the tutorial is in C, then you should consider sticking with C. That is if I understand that point correctly, which is that you're going to follow a programming tutorial that already has been worked out? If so, then whatever language they use, you should continue with.
Yes, some DE's use C++, like Qt and FLTK, I guess GTK uses C, from seen above, I do not know.
But hey ... if you know Java, and more pointedly OOP, then I feel you know C++.
You can't go wrong by learning C, and C++ is a superset above it.
Hi, I'm an ignorant but for me the answer is: "both and much more"; c and c++ always on the desk, it and it's history it's philosophy and it's people push up you to the intellectual glory.
For your programs, I recommend writing largely in C style, but compiling with C++. This will let you selectively use the C++ features that improve upon C.
A C++ program can call C libraries as though nothing had changed.
Ed
"Should I learn C?" Yes. "Should I learn C++?" Yes. (And I'd go on to say: "Should I learn ____?" Yes. Languages are, after all, "the tools of your trade." Studying new languages is a bit of a "nerd hobby" for me.
The C language was designed to be "better than assembler." The original Unix operating system was mostly written in it, and that's why it was invented in the first place. (Of course, so was Linux.)
C++ was originally implemented as a preprocessor which emitted C source code. The language implements many useful object-oriented features, but by doing so it "steps away from assembler." This for example is why the Linux kernel is not written in it. But, if I needed to write a binary program today, C++ is most likely to be the trusty hammer that I'd reach for, and recommend.
So, go ahead and take that course in "C." Next, take a similar course in "C++."
Last edited by sundialsvcs; 07-19-2021 at 11:25 AM.
C++ programs, like most programs, are very dependent on a "runtime library" for their successful operation, and many of C++'s goodies are implemented using it. The language implementation also tacitly assumes that it is "running in userland."
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.