LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
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



Reply
 
Search this Thread
Old 11-15-2005, 10:49 PM   #1
jstephens84
Senior Member
 
Registered: Sep 2004
Distribution: (Home)Opensolaris, Ubuntu, CentOS, (Work - AIX, HP-UX, Red Hat)
Posts: 2,056

Rep: Reputation: 94
Switched to C


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.
 
Old 11-15-2005, 10:55 PM   #2
wasp
LQ Newbie
 
Registered: Mar 2005
Posts: 9

Rep: Reputation: 0
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.
 
Old 11-16-2005, 06:45 AM   #3
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 66
Quote:
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.
 
Old 11-16-2005, 07:00 AM   #4
wasp
LQ Newbie
 
Registered: Mar 2005
Posts: 9

Rep: Reputation: 0
I wasn't speaking purely of Linux device drivers, but you are correct. I've seen some interesting x86/SPARC asm drivers in my time, too.
 
Old 11-16-2005, 10:55 AM   #5
jstephens84
Senior Member
 
Registered: Sep 2004
Distribution: (Home)Opensolaris, Ubuntu, CentOS, (Work - AIX, HP-UX, Red Hat)
Posts: 2,056

Original Poster
Rep: Reputation: 94
Never knew

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.
 
Old 11-16-2005, 11:01 AM   #6
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Re: Never knew

Quote:
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).
 
Old 11-16-2005, 06:14 PM   #7
xhi
Senior Member
 
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065

Rep: Reputation: 45
>> 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?
 
Old 11-16-2005, 06:43 PM   #8
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 66
Quote:
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.
 
Old 11-16-2005, 06:53 PM   #9
xhi
Senior Member
 
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065

Rep: Reputation: 45
hey thanks for the link! I never realized that it was an open book...

here if anyone cares are also are a few freebies
http://www.oreilly.com/openbook/
 
Old 11-17-2005, 01:36 PM   #10
sundialsvcs
Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 5,455

Rep: Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172
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.
 
Old 11-18-2005, 08:15 AM   #11
koodoo
Member
 
Registered: Aug 2004
Location: a small village faraway in the mountains
Distribution: Fedora Core 1, Slackware 10.0 | 2.4.26 | custom 2.6.14.2, Slackware 10.2 | 11.0, Slackware64-13
Posts: 345

Rep: Reputation: 32
Quote:
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Just switched from Windows.... tperzanowski Suse/Novell 6 02-27-2005 08:48 AM
Switched to Fedora C1 fedora2004 Fedora 4 03-17-2004 02:20 AM
I finally switched and need some help nny0000 Slackware 5 12-02-2003 10:48 PM
Just switched from Windows XP Brother Michael Linux - Newbie 2 08-18-2003 11:48 AM
Just switched LinuzRulz Linux - Distributions 0 05-12-2002 10:31 AM


All times are GMT -5. The time now is 08:42 AM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration