473,326 Members | 2,588 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Can C++ be used for system programming such as OS & DB?

Maybe it's a stupid question, but I really couldn't figure it out. C++
is expected to be a better C, provides compatibility with C, and is
able to do all that C can do. however, the number of projects in
sf.net written by C++ is always smaller than that of C, many people
directly turn to Java or C# after they learned C. Now that C++ is a
system programming language, it should have the capability to replace
C in many cases. We all know that the most important Operating Systems
are all written by C (the core part), and in my memory the DB engine
of Oracle is written by C (what about DB2 & sybase?). Why not use C++
to program these projects, since the management of C++ projects is
easier?

And another question. What about the runtime efficiency of C++
compared to that of C? because of the added OO features, C++ may be a
little slower. but if use C to simulate and implement the OO features
as C++ can do, will C be less efficient than C++? Can we use C++ for
the huge projects mentioned above? or those projects didn't require
any modern features, e.g. Polymorphism? (that sounds terrible)

Mar 29 '07 #1
9 2107
* Royt:
Maybe it's a stupid question, but I really couldn't figure it out. C++
is expected to be a better C, provides compatibility with C, and is
able to do all that C can do. however, the number of projects in
sf.net written by C++ is always smaller than that of C, many people
directly turn to Java or C# after they learned C. Now that C++ is a
system programming language, it should have the capability to replace
C in many cases.
Yes.

We all know that the most important Operating Systems
are all written by C (the core part), and in my memory the DB engine
of Oracle is written by C (what about DB2 & sybase?). Why not use C++
to program these projects, since the management of C++ projects is
easier?
An operating system is /not/ written in a single language. There's some
assembler at the innermost portions, some C, some C++ (large portions of
Windows are apparently written in C++), and even script languages. C++
has too much baggage for some parts of an operating system (mainly the
parts written in assembler), and it's too low-level for other parts
(such as those written in scripting languages), and fits quite well for
many parts in between.

And another question. What about the runtime efficiency of C++
compared to that of C? because of the added OO features, C++ may be a
little slower. but if use C to simulate and implement the OO features
as C++ can do, will C be less efficient than C++? Can we use C++ for
the huge projects mentioned above? or those projects didn't require
any modern features, e.g. Polymorphism? (that sounds terrible)
As you seem to note, if you restrict C++ to C-style, then you have the
runtime efficiency of C. If on the other hand you use C for typical C++
tasks, then you're unlikely to obtain the runtime-efficiency of C++.
Anyway, in both cases you're most likely using the wrong language for
the task: it's extremely difficult to restrict oneself to the pure C
subset of C++ (the compiler won't help), and emulating OO or template
things in C yields extremely large, complex and brittle code.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Mar 29 '07 #2
On Mar 29, 7:12 am, "Royt" <raoyi...@gmail.comwrote:
Maybe it's a stupid question, but I really couldn't figure it out. C++
is expected to be a better C, provides compatibility with C, and is
able to do all that C can do. however, the number of projects in
sf.net written by C++ is always smaller than that of C, many people
directly turn to Java or C# after they learned C. Now that C++ is a
system programming language, it should have the capability to replace
C in many cases. We all know that the most important Operating Systems
are all written by C (the core part), and in my memory the DB engine
of Oracle is written by C (what about DB2 & sybase?). Why not use C++
to program these projects, since the management of C++ projects is
easier?

And another question. What about the runtime efficiency of C++
compared to that of C? because of the added OO features, C++ may be a
little slower. but if use C to simulate and implement the OO features
as C++ can do, will C be less efficient than C++? Can we use C++ for
the huge projects mentioned above? or those projects didn't require
any modern features, e.g. Polymorphism? (that sounds terrible)
>From what I remember it has been said that the C++ compilers are buggy
in order to use them for something like OS kernel..
But it was a few years ago, maybe the statement is not true anymore.

Mar 29 '07 #3
On Mar 29, 7:12 am, "Royt" <raoyi...@gmail.comwrote:
Maybe it's a stupid question, but I really couldn't figure it out. C++
is expected to be a better C, provides compatibility with C, and is
able to do all that C can do. however, the number of projects in
sf.net written by C++ is always smaller than that of C, many people
directly turn to Java or C# after they learned C. Now that C++ is a
system programming language, it should have the capability to replace
C in many cases.
I can't imagine starting a new project in C, when C++ exists.
We all know that the most important Operating Systems
are all written by C (the core part),
Well, except maybe for Windows, most of the mainframes, and
significant parts of many Unixes.

Some parts of systems like Solaris are still written in C,
because they were written 15 or 20 years ago. (Other parts of
Solaris are written in C++.)
and in my memory the DB engine
of Oracle is written by C (what about DB2 & sybase?). Why not use C++
to program these projects, since the management of C++ projects is
easier?
Until recently, portability was a problem. And of course, a
company like Oracle isn't going to rewrite their entire
application just because it becomes possible to use a new
language.
And another question. What about the runtime efficiency of C++
compared to that of C?
I've not seen any difference. Typically, the two compilers
share a common back end, and when used to do the same thing,
generate exactly the same machine code. In fact, the presence
of inline functions (now supported in C as well) sometimes means
that the C++ code can be faster.
because of the added OO features, C++ may be a
little slower.
Only if you use them.

The big difference between C and C++ is that in C, you define a
struct and a set of functions to manipulate it, and you cross
your fingers that no one manipulates it otherwise. In C++, you
make the data members of the struct private, the set of
functions members, and the compiler ensures that no one
manipulates it otherwise.

Beyond that, of course, C++ supports a number of other idioms,
which may or may not be appropriate in any given application.
But the encapsulation is always appropriate, has no added
run-time cost, and justifies in itself using C++ rather than C,
even if you don't need run-time polymorphism, templates,
exceptions and all the rest.
but if use C to simulate and implement the OO features
as C++ can do, will C be less efficient than C++?
For the programmers, certainly. Probably in terms of execution
run-time as well.
Can we use C++ for
the huge projects mentioned above? or those projects didn't require
any modern features, e.g. Polymorphism? (that sounds terrible)
C++ is definitly usable, and is being used in many places, for
such things. As always, you don't have to use everything the
language offers. Only what's appropriate. (Note however that
every OS uses dynamic polymorphism at some point. A call to
read() results in significantly different code being executed if
the file descriptor designates a keyboard than when it
designates a file on disk.)

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Mar 29 '07 #4
James Kanze wrote:
On Mar 29, 7:12 am, "Royt" <raoyi...@gmail.comwrote:
>>We all know that the most important Operating Systems
are all written by C (the core part),

Well, except maybe for Windows, most of the mainframes, and
significant parts of many Unixes.

Some parts of systems like Solaris are still written in C,
because they were written 15 or 20 years ago. (Other parts of
Solaris are written in C++.)
Only a very tiny part of the core:

cd onnv-gate/usr
find . -name "*.cc" | wc -l
65
find . -name "*.c" | wc -l
13178

About 0.5%....

--
Ian Collins.
Mar 29 '07 #5
On Mar 29, 1:12 am, "Royt" <raoyi...@gmail.comwrote:
We all know that the most important Operating Systems
are all written by C (the core part), and in my memory the DB engine
of Oracle is written by C (what about DB2 & sybase?). Why not use C++
to program these projects, since the management of C++ projects is
easier?
For historical reasons - they were started before C++ existed or at
least before it was widespread. On the other hand, BeOS was written
mostly with C++, and most of the Windows (at least user-space mode)
code is apparently written with C++, not C.

Mar 29 '07 #6
I can imagine a completely new OS kernel written in C++, But I don't
know why Java virtual machine, interpreter of Ruby and Python are all
written by C, these things appeared in 1990s, in that time C++ has
come to maturity.

Mar 29 '07 #7
On Mar 29, 10:25 am, "Royt" <raoyi...@gmail.comwrote:
But I don't
know why Java virtual machine, interpreter of Ruby and Python are all
written by C, these things appeared in 1990s, in that time C++ has
come to maturity.
AFAIK, the Java HotSpot is written with C++ : http://en.wikipedia.org/wiki/HotSpot

Mar 29 '07 #8
On Mar 29, 3:25 pm, "Royt" <raoyi...@gmail.comwrote:
I can imagine a completely new OS kernel written in C++, But I don't
know why Java virtual machine, interpreter of Ruby and Python are all
written by C, these things appeared in 1990s, in that time C++ has
come to maturity.
At that time ANSI C would have been a much more mature standard than
C++. Different ANSI C compilers would be more compatible and ANSI C
would be available on a wider range of hardware than C++.

- Paddy.

Apr 6 '07 #9
In article <11**********************@e65g2000hsc.googlegroups .com>,
Paddy3118 <pa*******@googlemail.comwrote:
>On Mar 29, 3:25 pm, "Royt" <raoyi...@gmail.comwrote:
>I can imagine a completely new OS kernel written in C++, But I don't
know why Java virtual machine, interpreter of Ruby and Python are all
written by C, these things appeared in 1990s, in that time C++ has
come to maturity.

At that time ANSI C would have been a much more mature standard than
C++. Different ANSI C compilers would be more compatible and ANSI C
would be available on a wider range of hardware than C++.
For only but a sampling, see:

http://www.research.att.com/~bs/applications.html
--
Greg Comeau / 4.3.9 with C++0xisms now in beta!
Comeau C/C++ ONLINE == http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
Apr 6 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Carlos Ribeiro | last post by:
Hi, A friend of mine passed me some links about a great concept (not new in fact, only new to me): -- http://www.jpaulmorrison.com/fbp/ -- http://c2.com/cgi/wiki?FlowBasedProgramming I...
3
by: fabio de francesco | last post by:
Hello, I have a couple of years of experience with C++. I started studying C++ syntax, then I read the B.Stroustrup's book, and eventually I went through the N.Josuttis' book on how to program...
61
by: Steven T. Hatton | last post by:
Stroustrup's view on classes, for the most part, seems to be centered around the notion of invariants. After a bit of adjusting to the use of yamt (yet another math term) in computer science, I...
80
by: Bibby | last post by:
Hi, I'm interested in getting started in the programming world. I've dabbled in C, C++ and VB6. Which would be the best language to focus my attention to regarding the following considerations: ...
4
by: maricel | last post by:
Could someone confirm which tablespace is being used when running ALTER & CREATE INDEX. Is it the tempspace or the tablespace where the table resides? Many thanks, maricel
11
by: Robert Schuldenfrei | last post by:
I am an older person trying to learn C# just for the fun of it. I am a veteran of older style languages (COBOL, FORTRAN, etc.) and I want to learn an Object Orientated language. Currently working...
0
by: WhiteWizard | last post by:
Here’s the situation: I am writing a C# Windows application using VS 2003. I have built a user control, and it has a Tab Control on it with (currently) 2 tab pages, and the whole thing sits...
11
by: arnuld | last post by:
hello all, 1st of all, i searched last 12 years archives of comp.lang.c++ because i have some problems. i got some help but not satisfied as i did not get solution specific to my problem. In the...
0
by: Adam Salisbury | last post by:
**To members of microsoft.public.dotnet.framework, apologies for the crosspost. I originally posted this message into that group however have since realised this may have been a better...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.