LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-05-2008, 04:40 AM   #16
Agrouf
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,596

Rep: Reputation: 80

C is more efficient than C++
You can do C++ code as efficient as C code, but you have to take much care, because much processing is hidden when you use C++.
The kernel talks to the hardware directly and C is the best language for that.
You could try java, but the result would be an Os that need a JVM to run and another OS to run the JVM.
You could try awk, but the OS would only be able to parse big text files and wuoldn't be that useful.
You could try spanish, but the processor would not understand the OS.
Believe me, I've tryed to write OSes in many languages and C is the most reasonable solution.
 
Old 06-05-2008, 04:51 AM   #17
raedbenz
Member
 
Registered: Dec 2007
Posts: 93

Original Poster
Rep: Reputation: 15
HI
as Agrouf said C++ and other OO languages have many hidden processing, because they have inheritance and polymorphism which increase CPU overheads. although the efficiency of the code depends on programmer but generally C language is much efficient..
 
Old 06-06-2008, 07:59 AM   #18
amitabhishek
Member
 
Registered: Jul 2006
Location: Bombay, India
Distribution: Ubuntu (Hardy Heron)
Posts: 118

Rep: Reputation: 15
Because C++ was too boring to code and probably didn't existed when AT&T guys decided to code Unix.

Last edited by amitabhishek; 06-06-2008 at 08:02 AM.
 
Old 06-06-2008, 08:16 AM   #19
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by amitabhishek View Post
Because C++ was too boring to code and probably didn't existed when AT&T guys decided to code Unix.
But the question was about the Linux kernel, not Unix. AND, when Unix was first written, there was no C.

AND----coding in C is not boring?
 
Old 06-06-2008, 08:30 AM   #20
amitabhishek
Member
 
Registered: Jul 2006
Location: Bombay, India
Distribution: Ubuntu (Hardy Heron)
Posts: 118

Rep: Reputation: 15
Quote:
Originally Posted by pixellany View Post
But the question was about the Linux kernel, not Unix. AND, when Unix was first written, there was no C.

AND----coding in C is not boring?
apologies, my oversight.Agreed Unix was not first written in C but then later the entire OS was re-written in C.

At least its better than C++ and assembly language.
 
Old 06-06-2008, 08:49 PM   #21
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
It's simple, really simple: you code, you decide. You don't code: you don't complain (at least, not until you make a port using your favourite language :P ).

Each programmer has his/her own tastes, and each language is better suited for a particular task. When you are talking about low level tasks, OO programming is not going to do you particularly any good at all. It wouldn't even be faster to code (which is one of the things why I prefer C++ to C for graphic interfaces) because an OO language is not a natural thing for a low level task.

On another matter, I don't think asm would be any better for such a big thing, instead it would just make out for a very low quality product, or, at most, a product that could only be run on x86. Linux, on the contrary, being written in C for the most part, can be run on a wide range of architectures. That's a big advantage of C as well.

C is a good language, like it or not. And it's particularly good for this task. As a bonus, it's easy to find good C programmers with a wide experience, which is a guarantee that, when you eventually leave or you can't continue with your project alone, you will find enough human force to continue the work for or with you.
 
Old 06-07-2008, 10:20 AM   #22
nuxrl
Member
 
Registered: Jun 2006
Location: NY, USA
Distribution: Slackware, Arch
Posts: 176

Rep: Reputation: 35
C is best suited for developing an OS because it's powerful and efficient to access low level hardware like registers.

OO is a way to resolve problems. It's a method, not a language. If you take a look at Linux kernel code (and BSD kernel code), you will see that OO method is used in VM, VFS, ...etc. If C can bring the benefits of OO on the table, why bother to introduce overhead built in other OO-featured languages, for example, C++?
 
Old 06-08-2008, 10:41 PM   #23
iwasapenguin
Member
 
Registered: Jul 2007
Posts: 110

Rep: Reputation: 15
Question*: Did Linus have a C++ compiler? Also I know that at the time Linux was an overblown rsh reimplementation that was really just made so that he could better understand assembler on the 386.

*That was not rhetorical.
 
Old 06-09-2008, 07:30 AM   #24
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
Quote:
Originally Posted by iwasapenguin View Post
Question*: Did Linus have a C++ compiler? Also I know that at the time Linux was an overblown rsh reimplementation that was really just made so that he could better understand assembler on the 386.

*That was not rhetorical.
That's besides the point in any case. Maybe he did not even know C++. Which is also besides the point.

No programmer can own a compiler for every language, and no programmer can know every single language over the sun.

So, each programmer chooses the tools s/he thinks it's the best for the purpose, amongst these that are available to him (in both senses of owning a compiler and having the knowledge about it).

As I said (and the license permits it) no one is stopping you or anyone else from porting it to any other language, if you feel brave enough. So far, no one has ever thought about that, probably because there's absolutely no benefit in doing it (in my humble opinion, that's it).
 
Old 06-09-2008, 07:55 AM   #25
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018
Quote:
Originally Posted by pixellany View Post
Why is everyone writing in XML?
Now, that is a valid question. As far as I can tell it just makes things 3-4 times larger than they need to be and harder to read.

I really don't see what advantages it brings over stanza based or field delimited files.
 
Old 06-09-2008, 12:02 PM   #26
proc
Member
 
Registered: Jul 2007
Location: /dev/urandom
Posts: 70

Rep: Reputation: 15
Quote:
Originally Posted by lazareth1 View Post
But which came first? The chicken or the egg?
The T-Rex

http://www.livescience.com/animals/0...o_tissues.html


The the first compiler was made either in hex or with binary...lol

Last edited by proc; 06-09-2008 at 12:03 PM.
 
Old 06-09-2008, 12:55 PM   #27
Agrouf
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,596

Rep: Reputation: 80
Quote:
Originally Posted by pixellany View Post
Why is everyone writing in XML?
There are some good things about XML.
Some people use it where they shouldn't, but it has some advantages.
It can be hand written and translated easily. Also, there are many tools for validating and for parsing XML. And it can be described with DTD or XSD, enforcing some logical rules that prevent misuse of the XML. Also, it is extensible, so you don't have to reinvent the world when you want to decline your own format, and you can use subset of another format, like it is done for SVG.
It is important to have a good standard because applications are more and more interconnected. For instance, you can put some svg imported from inkscape inside open office document and keep the format simple.
You can make your own format but usually it is not a good idea because you forget a lot of things.
For simple things, a simple key-value pair file is usually sufficient, but when things become complicated, XML is a good choice.
For very large data, binary is better but it requires more work.
The good balance for medium-sized data is to use zipped XML, like SVGZ.

Last edited by Agrouf; 06-09-2008 at 12:57 PM.
 
Old 06-09-2008, 01:45 PM   #28
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,647
Blog Entries: 4

Rep: Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933
Quote:
Originally Posted by raedbenz View Post
why Kernel is written in C not other O-O language(like C++)??
"An operating-system kernel," which creates the warm and fuzzy environment that every application-program has come to expect, actually has to live in a much more complicated environment: "the actual hardware."

In this environment, speed is sometimes critically-important. Being able to know exactly what will happen when a particular piece of code runs, and exactly what set of machine-instructions will be produced, is sometimes essential. This is the major reason why different coding-strategies are used.

Languages like C++ strive to produce an environment in which application development is easy and in which the resulting applications can run reliably. The so-called "runtime environment" provided by such languages (and upon which all programs written in the language utterly depend...) is rich and powerful. In so-called user-land, such attributes are highly desirable. But kernel-land neither requires them nor particularly benefits from them.

"The kernel," critical though it may be, is actually a very small part of the operational software that makes up a computer system. In fact, efforts are constantly being made to make it smaller: to move "more stuff" into user-land. The kernel is the foundation: the building is built on top of it, and when all is said and done, "the building is really what's important." We can afford to use different coding-practices when building the kernel.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert a user written .c program in kernel 2.4.20-8 jayeshleo Linux - Newbie 2 12-07-2007 12:42 AM
Compiling routing algo written for 2.4 kernel, with 2.6 kernel rvenkatesh25 Linux - Networking 1 08-28-2007 02:19 PM
Compiling a program written for 2.4 kernel, with 2.6 kernel rvenkatesh25 Programming 0 08-28-2007 09:31 AM
Is not all C++ written eqaul? Fingel Programming 12 02-23-2003 12:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:56 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
Open Source Consulting | Domain Registration