LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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 02-19-2004, 10:56 PM   #1
gr33ndata
Member
 
Registered: Aug 2003
Location: DMZ
Distribution: Ubuntu
Posts: 144

Rep: Reputation: 15
Exclamation Guru = C & Lame = C++


Hi

Thi may seem to be a silly question, but I am thinking about if since a while
I have been wondering why all - most of - the programmes written on *nix are written in C not C++
Also linux gurus do not mension C++, Classes, new, delete etc. and insted use handlers (alternative to classes somehow) etc.
So what is so special about C and not in C++ ??
 
Old 02-19-2004, 11:02 PM   #2
KptnKrill
Member
 
Registered: Apr 2003
Location: US, MA
Distribution: Nandu-0.ab, Arch 0.7.2
Posts: 229

Rep: Reputation: 30
I am in no means qualified to answer this question but perhaps it's because unix was originally written in c, and most programs don't *need* oo. ?
Just a guess

edit: spelling
 
Old 02-20-2004, 04:06 AM   #3
PSIplus
Member
 
Registered: Feb 2004
Location: Vienna/Austria
Distribution: Debian Unstable
Posts: 36

Rep: Reputation: 15
Hmmm... What do you know about C, C++ or ObjC? Use the program lang YOU like!
And: There are many C++ apps for UNIX Environment (For example the KDE Project!)

The most significant difference between both is the different programming-style... For newbes, both look like the same, but for pros each language contains it special abilities!

Have Fun
Martin
 
Old 02-20-2004, 04:14 AM   #4
moeminhtun
Member
 
Registered: Dec 2002
Location: Singapore
Distribution: Fedora Core 6
Posts: 647

Rep: Reputation: 30
You know why Linux kernel is written in C?
Because that time "Linus" was still a kid (20 something) and he didn't know how to program in C++ yet.
 
Old 02-20-2004, 04:58 AM   #5
andzerger
Member
 
Registered: Feb 2004
Location: denver
Distribution: slackware && freeBSD && rh9
Posts: 92

Rep: Reputation: 15
heh i got blacklisted at college for pestering one of my instructors about how C and C++ had so much in common (loops, data, pre. proc., structs) .. he kept saying "but C++ has classes, its object oriented" well.. i think many CS students (especially at that school) can go a whole 4 years without being taught exactly what the point of object oriented programming is .. im sure I dont know ..
will someone please take a shot at explaining it to me .. ?
 
Old 02-20-2004, 05:42 AM   #6
codedv
Member
 
Registered: Nov 2003
Location: Slough, UK
Distribution: Debian
Posts: 146

Rep: Reputation: 15
I'm not sure this is right and it probably isn't, but the way I understand it OOP gives you away of modeling and structuring your code in a way that represents the real world problem you are trying to solve.

For example you may want to write a program which will be embedded into a kettle microchip. In C++ you may choose to have a kettle object. The kettle object will have a set of things it can do - like boil and stop boiling. It should also be able to communicate its state - e.g temperature of the water and whether or not its on or off.

From your point of view what goes on inside the kettle is of no relevance to you. All you need to to is fill it with water and have the ability to turn it on to boil the water and also be able to see when the kettle has boiled.

So the kettle is an object which encapsulates some code. The object has a user interface, such as a switch and the exact workings of the kettle are hidden in the casing and should never have to be changed.

I hope I havn't completely confused you.
 
Old 02-20-2004, 06:41 AM   #7
andzerger
Member
 
Registered: Feb 2004
Location: denver
Distribution: slackware && freeBSD && rh9
Posts: 92

Rep: Reputation: 15
thats not confusing, except that it sounds so easy that i doubt my sanity
 
Old 02-20-2004, 06:52 AM   #8
codedv
Member
 
Registered: Nov 2003
Location: Slough, UK
Distribution: Debian
Posts: 146

Rep: Reputation: 15
That's the problem with OOP - it just confues the hell out of me. I understand the concepts but find it a lot easier to use the old fashioned modular approach.
 
Old 02-20-2004, 07:37 AM   #9
andzerger
Member
 
Registered: Feb 2004
Location: denver
Distribution: slackware && freeBSD && rh9
Posts: 92

Rep: Reputation: 15
if youv compiled a program that uses 'cin>>' and cout<< .. have you also compiled all the code required for 'cout<<setw(9)<<' ??
 
Old 02-20-2004, 08:21 AM   #10
PSIplus
Member
 
Registered: Feb 2004
Location: Vienna/Austria
Distribution: Debian Unstable
Posts: 36

Rep: Reputation: 15
Quote:
Originally posted by moeminhtun
You know why Linux kernel is written in C?
Because that time "Linus" was still a kid (20 something) and he didn't know how to program in C++ yet.
The Kernel is coded in C, because it makes sense in this low level! If you want to code low-level code, C++ makes no sense (Think about it - NeXT created Objective-C to do objective things in low levels, C++ itself is not for these purposes)

C++ is good for large Applications - classes and namespaces are very usefull for object-based applications (like KDE or others) - The GTK-based programming can be very complicated, because you need the GObject-Model and other memory sharing/protection and so on...

Have Fun!
Martin
 
Old 02-20-2004, 08:39 AM   #11
moeminhtun
Member
 
Registered: Dec 2002
Location: Singapore
Distribution: Fedora Core 6
Posts: 647

Rep: Reputation: 30
Quote:
Originally posted by PSIplus
The Kernel is coded in C, because it makes sense in this low level! If you want to code low-level code, C++ makes no sense (Think about it - NeXT created Objective-C to do objective things in low levels, C++ itself is not for these purposes)

C++ is good for large Applications - classes and namespaces are very usefull for object-based applications (like KDE or others) - The GTK-based programming can be very complicated, because you need the GObject-Model and other memory sharing/protection and so on...

Have Fun!
Martin
The kernel can be written in C++ and it would turn out to be a very very good designed and fool-proof kernel. For example, have you heard about "symbian" OS? The OS used by high end mobile phones like, nokia 3650, 7250, etc.. The symbian OS is 100% written in C++ and everybody who program on that platform before will have to admin that the OS is very very well-designed, and extremely stable.

Last edited by moeminhtun; 02-20-2004 at 08:41 AM.
 
Old 02-20-2004, 09:33 AM   #12
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 66
As I have stated before on C vs. C++ threads.... Back in 1991 the C++ support in GCC was pretty primative (compared to now anyway). That fact, and the fact that C was created specifically to build the UNIX operating system were probably the compeling reasons that Linux was built in C and not C++.

C++ certainly could be used for writing a complete OS kernel. But it certainly wasn't made for that (C++ was designed for higher level applications) and the choice of language has nothing to do with the design or stability of the software. I assure you C as a language is just as stable (and way more mature) then C++.
 
Old 02-20-2004, 09:34 AM   #13
sNicker
Member
 
Registered: Oct 2003
Location: Italy
Distribution: Slackware 9.1, Slackware 10
Posts: 33

Rep: Reputation: 15
Oh well, C and C++ share a very similar sintax but are completely different languages and refer to totally different programming models. There's no point on which is better. A lot of good applications are made in C, a lot of good applications are made in C++. A HUGE amount of bad applications are made in C and in C++ as well.

They are both powerful and quick. If you need low level programming maybe you will choose C, for high-level programming (say GUIs or modular systems) you will choose C++.

I repeat, if you are a good programmer you will be able to take the best from both, and use the right language based on your needs.

C vs C++ it's a silly problem...
 
Old 02-20-2004, 11:06 AM   #14
PSIplus
Member
 
Registered: Feb 2004
Location: Vienna/Austria
Distribution: Debian Unstable
Posts: 36

Rep: Reputation: 15
Quote:
Originally posted by moeminhtun
The kernel can be written in C++ and it would turn out to be a very very good designed and fool-proof kernel. For example, have you heard about "symbian" OS? The OS used by high end mobile phones like, nokia 3650, 7250, etc.. The symbian OS is 100% written in C++ and everybody who program on that platform before will have to admin that the OS is very very well-designed, and extremely stable.
Can be written... But what would it cause? It makes sense in some case, but there is neary nothing wich requires C++! It would cause many problems: mutexes and classes, first level memory protection, object registration. Yeah, module-handling would be much easyer and the structures would become much more clean. And it would make preemptivity much more complicated!

But: Linux is a UNIX-Like operating system, using C++ coding it would require new abstracts with syscalls - they have to be exported in C-Style (not really a problem, but it would cause many-many incompatiblities since, if i'm not wrong, any existing POSIX-Like OS is coded in C or ObjC ... Even MSWin is, except of parts of the GDI, coded in C!)

Symbian is not a UNIX-Like multi-purpose operating system, Symbian is an Embedded OS! It was designed to be coded in C++, it is structured for it and it is implemented in C++ (but as far as I know with many parts in C-Style code...)... You cann't compare Linux with Symbian, it's totally different.
 
Old 02-20-2004, 11:53 AM   #15
chewysplace
Member
 
Registered: Sep 2003
Distribution: Slackware 10 w/ Kernel 2.6.8
Posts: 176

Rep: Reputation: 30
PSIplus:

the code only sucks as bad as teh coder can program. language realy doesnt matter.
 
  


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
ALAC & Lame Script Soulful93 Programming 6 04-15-2009 08:24 PM
Japanese canna won't work : Warning: &#12363;&#12394;&#28450;&#23383;&#22793;&am OrganicOrange84 Debian 3 06-30-2005 03:28 PM
Ph&#7909;c h&#7891;i d&#7919; li&#7879;u b&#7883; m&#7845;t???, c&#7913; pollsite General 1 06-27-2005 01:39 PM
Abit Guru & hardware monitoring progs for AN7 mobo Alien42 Linux - Hardware 2 04-26-2004 06:02 PM
Welcome new guru! MasterC General 17 05-20-2003 01:50 PM


All times are GMT -5. The time now is 05:03 PM.

Main Menu
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