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.
I am a little confused so please bear with me. I have recently switched from c++ to C. I have a couple of Questions though.
1) I am wanting to start getting involved more with the linux community and start contributing my share. So my question is If I want to start building device drivers did I choose to move to the right language or should I have stuck with C++?
2)Can C write more than just console applications? I am assuming it can which if thats the case where would I go next to further my knowledge in C and start designing these non console based programs?
I appreciate all the help I can get. This is starting to be frustrating switching back and forth wandering if I am making the right decision.
GTK is written in C. Unfortunately, there appears to be no totally cross platform ANSI C graphics toolkit that can use the native widgets and windowing systems of each platform. I consider this a major downside.
Most device drivers are written in C.
There's no need to switch back and forth, a good number of projects use both languages. I'm in the habit of writing the core of a progam in C and wrapping it in a C++ gui.
Originally posted by wasp
Most device drivers are written in C.
In the Linux world ALL device drivers should be written in C. There is no C++ runtime support in the linux kernel aside from a few hacks that aren't, and most likely will never be, in the standard kernel source.
As for gui programs, I'd use glib/gtk+ if you really want to write programs in C. If you want to be cross platform then I recomment using QT and either C++ or any other language it has bindings for. There is no law that says you can only program in one language... a good deveoper uses the best tool for the job they are trying to accomplish.
Thanks for the quick replies. I never knew or even thought about that. So I could learn C then go to C++ and use both languages. So I could build device drivers in C and use C++ for applications.
So if I learn C how much more would you say that I would need to learn in order to use C++?
Thanks Again guys. Your comments have been very helpful.
Originally posted by jstephens84 So if I learn C how much more would you say that I would need to learn in order to use C++?
I don't know C, but I do know some C++. There are probably lots of features that C++ has, that C does not, so you'd probably still have quite a bit to do. One of the most important things about C++ is that you can define your own types by using classes. I'd say that's certainly something you'd want to look at with C++ (and the two above would probably recommend other things, too).
>> So if I learn C how much more would you say that I would need to learn in order to use C++?
really not a whole lot as far as language semantics go.. there are some differences, but if you are already familiar with c, it will be nothing to learn c++ syntax.... however, the real power of c++ is OOP (obj oriented progn). if you are not familiar with object oriented design then I suggest you get acquainted before you jump into c++ too much.
as far as the other stuff, I have never gotten around to working on any device drivers.. it is on my list of things to do.... lol.. i would think that even with the code being written in c as jtshaw wrote, that there would be quite a bit of assembly tuning by hand that goes on.. ???? there is an oreilly book i have been looking at for years, linux device driver programming 3rd edition... anyone read it, any reviews?
Originally posted by xhi
as far as the other stuff, I have never gotten around to working on any device drivers.. it is on my list of things to do.... lol.. i would think that even with the code being written in c as jtshaw wrote, that there would be quite a bit of assembly tuning by hand that goes on.. ???? there is an oreilly book i have been looking at for years, linux device driver programming 3rd edition... anyone read it, any reviews?
Linux Device Drivers is a pretty good book. There are drivers out there that have inline assembly and such.. but quite honestly, it is hardly neccesary or really common practice to do things that way anymore.
Think of C++ as an object-oriented extension to C.
It has proven to be very convenient to use object-oriented constructs to describe the structure and behavior of many applications. Most modern languages provide a strong "class" concept, and the "strong typing" concepts, that were first pioneered in C++.
The advanced features of C++ are, by and large, provided by a substantial runtime library ... in addition to the normal runtime library environment used by C.
In the kernel environment, only a limited C-style runtime library is available within the kernel, and none of the C++ world is available at all. This is why you will not find C++ in the world of device-drivers and kernel modules.
You should learn both languages. You should familiarize yourself with as many languages as you can get your hands on ... and in Linux, that's a lot of them.
Originally posted by sundialsvcs Most modern languages provide a strong "class" concept, and the "strong typing" concepts, that were first pioneered in C++.
C++ is not a Strongly Typed language as it includes union types, which are not type checked.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.