473,395 Members | 1,756 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,395 software developers and data experts.

Why ! C++

Hi all,
We mostly use C for system programming.
Why not C++?
Since c++ is superset of C.
we can combine both if needed...
do we have any file system written in C++.
Thx.

Mar 1 '07 #1
27 1783
On Mar 1, 8:38 pm, "lakshmi" <lakshmipath...@gmail.comwrote:
Hi all,
We mostly use C for system programming.
Why not C++?
Since c++ is superset of C.
we can combine both if needed...
do we have any file system written in C++.
Thx.
Why we can't develop a file system in C++. I think it is possible even
if I dint implement the same.
C++ really comes in the commercial software industry which need more
flexibilty, re-usability, data security and the power of C++ is really
superb. I too was a supporter of C when I was studying. But when I
started working, i realized that it is possible to express real world
problems using C++ pretty well in manner. It also has a powerful
standard library and also supports generic programming. It solely
depends on the system, complexity, performance and many other factors
decides to choose between programming languages.

Mar 1 '07 #2
lakshmi wrote:
Hi all,
We mostly use C for system programming.
Why not C++?
Since c++ is superset of C.
we can combine both if needed...
do we have any file system written in C++.
Thx.
The Fiasco microkernel has been written in C++ - take a look at it:
http://www.inf.tu-dresden.de/index.p..._id=1435&ln=en

Bjoern
Mar 1 '07 #3
Bjoern Doebel wrote:
lakshmi wrote:
>>Hi all,
We mostly use C for system programming.
Why not C++?
Since c++ is superset of C.
we can combine both if needed...
do we have any file system written in C++.
Thx.


The Fiasco microkernel has been written in C++ - take a look at it:
http://www.inf.tu-dresden.de/index.p..._id=1435&ln=en

Bjoern
Great name! Does it mean something different in German than in English?
I hope not.

john
Mar 1 '07 #4
On Mar 1, 6:38 am, "lakshmi" <lakshmipath...@gmail.comwrote:
Since c++ is superset of C.
Not strictly speaking. The standard libraries and keywords of each
have diverged a bit between the current versions of each (though C++0x
will try to remedy some of that).

See the Creator's FAQ:

http://www.research.att.com/~bs/bs_faq.html#C-is-subset

Cheers! --M

Mar 1 '07 #5
John Harrison wrote:
Bjoern Doebel wrote:
>lakshmi wrote:
>>>Hi all,
We mostly use C for system programming.
Why not C++?
Since c++ is superset of C.
we can combine both if needed...
do we have any file system written in C++.
Thx.


The Fiasco microkernel has been written in C++ - take a look at it:
http://www.inf.tu-dresden.de/index.p..._id=1435&ln=en

Bjoern

Great name! Does it mean something different in German than in English?
I hope not.
This is actually addressed in the FAQ:

http://os.inf.tu-dresden.de/fiasco/faq.html#2900

Mar 1 '07 #6
Thanks you people ...for valuable info
thanks for the links ...
On Mar 2, 4:19 am, Rolf Magnus <ramag...@t-online.dewrote:
John Harrison wrote:
Bjoern Doebel wrote:
lakshmi wrote:
>>Hi all,
We mostly use C for system programming.
Why not C++?
Since c++ is superset of C.
we can combine both if needed...
do we have any file system written in C++.
Thx.
The Fiasco microkernel has been written in C++ - take a look at it:
http://www.inf.tu-dresden.de/index.p..._id=1435&ln=en
Bjoern
Great name! Does it mean something different in German than in English?
I hope not.

This is actually addressed in the FAQ:

http://os.inf.tu-dresden.de/fiasco/faq.html#2900

Mar 2 '07 #7
"lakshmi" <la************@gmail.comwrote in message
news:11**********************@v33g2000cwv.googlegr oups.com...
: Hi all,
: We mostly use C for system programming.
: Why not C++?
Mainly historical reasons. It is easier to find a C expert
than a C++ expert in this application domain.

: Since c++ is superset of C.
well... mostly.

: we can combine both if needed...
: do we have any file system written in C++.
The Haiku-OS (an open source reimplementation of BeOS)
has re-implemented the complete file system in C++:
http://haiku-os.org/

hth -Ivan
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
Brainbench MVP for C++ <http://www.brainbench.com

Mar 2 '07 #8
On 1 Mar 2007 03:38:24 -0800, "lakshmi" wrote:
>We mostly use C for system programming.
Why not C++?
Because C is the only portable system programming language available?
C++ is not appropriate for system programming.
>Since c++ is superset of C.
we can combine both if needed...
That was the original idea of the C++ inventor. Do piecemeal injection
of C++ into C code until C becomes extinct. It didn't work.
>do we have any file system written in C++.
Why would you want to have one?

Best wishes,
Roland Pibinger
Mar 2 '07 #9
On Mar 2, 4:31 pm, rpbg...@yahoo.com (Roland Pibinger) wrote:
On 1 Mar 2007 03:38:24 -0800, "lakshmi" wrote:
We mostly use C for system programming.
Why not C++?

Because C is the only portable system programming language available?
C++ is not appropriate for system programming.
Since c++ is superset of C.
we can combine both if needed...

That was the original idea of the C++ inventor. Do piecemeal injection
of C++ into C code until C becomes extinct. It didn't work.
do we have any file system written in C++.

Why would you want to have one?

Best wishes,
Roland Pibinger
yes..i would like to do that....
you think a file system in c++ will be as successful like the one
written in C?
Mar 2 '07 #10
Roland Pibinger wrote:
On 1 Mar 2007 03:38:24 -0800, "lakshmi" wrote:
>>We mostly use C for system programming.
Why not C++?

Because C is the only portable system programming language available?
Who told you that?
C++ is not appropriate for system programming.
It isn't?

Mar 2 '07 #11
On Mar 2, 6:31 am, rpbg...@yahoo.com (Roland Pibinger) wrote:
On 1 Mar 2007 03:38:24 -0800, "lakshmi" wrote:
We mostly use C for system programming.
Why not C++?

Because C is the only portable system programming language available?
C is certainly more portable because it is more simplistic and because
compiler/library vendors have not kept up with the C++ Standard in
short order. Then again, when you're doing systems programming, it's
often platform-specific and not something you port elsewhere. What one
should favor in a language for systems programming is power and speed,
not portability, and C++ does quite well on those compared to C.
C++ is not appropriate for system programming.
That's not what the Creator says:

http://www.research.att.com/~bs/bs_faq.html#whyC

Cheers! --M

Mar 2 '07 #12
On Fri, 02 Mar 2007 14:33:33 +0100, Rolf Magnus wrote:
>Roland Pibinger wrote:
>C++ is not appropriate for system programming.

It isn't?
Which 'systems' are written in C++?

Mar 2 '07 #13
On Fri, 02 Mar 2007 11:31:33 +0000, Roland Pibinger wrote:
On 1 Mar 2007 03:38:24 -0800, "lakshmi" wrote:
>>We mostly use C for system programming.
Why not C++?

Because C is the only portable system programming language available?
C++ is not appropriate for system programming.
>>Since c++ is superset of C.
we can combine both if needed...

That was the original idea of the C++ inventor. Do piecemeal injection
of C++ into C code until C becomes extinct. It didn't work.
Please don't feed the troll.

--
Lionel B
Mar 2 '07 #14
Roland Pibinger wrote:
On Fri, 02 Mar 2007 14:33:33 +0100, Rolf Magnus wrote:
>>Roland Pibinger wrote:
>>C++ is not appropriate for system programming.

It isn't?

Which 'systems' are written in C++?
I don't know. Why do you ask?

Mar 2 '07 #15
On Mar 1, 4:38 pm, "lakshmi" <lakshmipath...@gmail.comwrote:
Hi all,
We mostly use C for system programming.
Why not C++?
You can use C++ also but C++ has many other design issue like OOP
through which you can understand the power of C++ language. Other
being the historic reason as many lines of code(may be millions) is
written in C, so if you want to add something to it, then C is
preferred. Also some basic code structure for system programming is
already written in C, so just have to copy it and then proceed to
specialized part of your system's program.
Since c++ is superset of C.
we can combine both if needed...
But don't ever do that as then code maintaining ability would be at
lost. May be for 1000 lines code it would not show but once code is
expanded, you might have several serious problem and it is always
better to one programming language and focus on its issue if one
really wants to exploit the features of programming language.
do we have any file system written in C++.
Thx.

Mar 3 '07 #16
On 1 Mar 2007 03:38:24 -0800, "lakshmi" <la************@gmail.com>
wrote:
>Hi all,
We mostly use C for system programming.
Why not C++?
Since c++ is superset of C.
we can combine both if needed...
do we have any file system written in C++.
There are some systems written in C++. I am working on an embeddded
one that is comprised of a couple of thousand lines of C++ plus a
hundred lines of assembler, plus 0 (zero) lines of C.

Zara
Mar 5 '07 #17
Dnia Mon, 05 Mar 2007 08:15:19 +0100, Zara napisa³(a):
There are some systems written in C++. I am working on
an embeddded one that is comprised of a couple of
thousand lines of C++ plus a hundred lines of assembler,
plus 0 (zero) lines of C.
How did you make it?
How can C++ work in an embedded system?
I thaught C++ needs some additional implementation code,
which make base for C++ language facilities before it
call main() function. I mean the things like reserving
static memory, calling constructors for static objects,
exception handling mechanisms etc. And I thaught that
new and delete operators have to be implemented using
some system API/kernel calls to some system memory
manager, and cannot work in "blank" environment without
some system/kernel, which may do the memory management
for new/delete implementation code.
So how it's been done? I'm very curious about that,
because the plain old C doesn't need any runtime
support AFAIK.

--
SasQ
Mar 5 '07 #18
SasQ a écrit :
Dnia Mon, 05 Mar 2007 08:15:19 +0100, Zara napisa³(a):
>There are some systems written in C++. I am working on
an embeddded one that is comprised of a couple of
thousand lines of C++ plus a hundred lines of assembler,
plus 0 (zero) lines of C.

How did you make it?
How can C++ work in an embedded system?
I thaught C++ needs some additional implementation code,
which make base for C++ language facilities before it
call main() function.
A lot of thing happens before main and even before static initialisation.
You have to inititialize your processor, your stack (if you have one)
and other stuff (like disabling this damned watchdog if you have a long
boot time).
I mean the things like reserving static memory,
This is just a matter of knowing where to put it in the memory area.
calling constructors for static objects,
nothing magic in that, in the same way you initialize object with raw
memory: new(memory_ptr) object();.
But in fact this stage is handled by the compiler.
exception handling mechanisms etc.
This is a compiler question.
And I thaught that
new and delete operators have to be implemented using
some system API/kernel calls to some system memory
manager, and cannot work in "blank" environment without
some system/kernel, which may do the memory management
for new/delete implementation code.
The same way you would do it in C though C++ has a mixed position about
dynamic allocation, you cannot redefine completly new and delete (thanks
godness).

"C programmers think memory management is too important to be left to
the computer. Lisp programmers think memory management is too important
to be left to the user."

(from Ellis and Stroustrup's The Annotated C++ Reference Manual)

So how it's been done? I'm very curious about that,
because the plain old C doesn't need any runtime
support AFAIK.
You mean it doesn't provide a way to call code before main ?

Michael
Mar 6 '07 #19
On Mon, 05 Mar 2007 21:03:54 +0100, SasQ <sa***@go2.plwrote:
>Dnia Mon, 05 Mar 2007 08:15:19 +0100, Zara napisa?(a):
>There are some systems written in C++. I am working on
an embeddded one that is comprised of a couple of
thousand lines of C++ plus a hundred lines of assembler,
plus 0 (zero) lines of C.

How did you make it?
How can C++ work in an embedded system?
I thaught C++ needs some additional implementation code,
which make base for C++ language facilities before it
call main() function. I mean the things like reserving
static memory,
It is handled by the compiler
calling constructors for static objects,
exception handling mechanisms
Oh , sorry. I turned off exceptions. This is the only point I escape
from Std C++
etc. And I thaught that
new and delete operators have to be implemented using
some system API/kernel calls to some system memory
manager,
I wrote it myself, using C++. Not so difficult
and cannot work in "blank" environment without
some system/kernel, which may do the memory management
for new/delete implementation code.
See above
>So how it's been done? I'm very curious about that,
because the plain old C doesn't need any runtime
support AFAIK.
What about malloc/reee/realloc? But you may also write them yourself.

Regards,

Zara
Mar 6 '07 #20
On Mar 5, 12:03 pm, SasQ <s...@go2.plwrote:
So how it's been done? I'm very curious about that,
because the plain old C doesn't need any runtime
support AFAIK.
Of course C needs run-time support. What run-time support is needed
depends on the compiler. Not every expression, declaration or
statement is necesarily turned into pure inline machine code.

On some RISC-like processors, for instance, some math operations, even
simple integer ones like divisions, may necessitate the use of a
library routine. This explains the various __mul* and __div* type
functions in the GNU compilers's ``libgcc'' library. If you're using
GCC to write a kernel, then you still have to supply that library.

How about structure initialization and assignment?

Code like

some_struct x = { 0 };
/* ... */
y = x;

may actually translate into machine code which calls memset and
memcpy. If you don't supply these, the thing won't link due to
unresolved references.

C++ construction and destruction has its API also. One possibility is
for the comiler to generate a special hidden construction and
destruction hook functions. Each object file with C++ objects in it
has such functions.

The embedded kernel's startup code would have to have a routine which
would iterates over these functions and calls them.

Now how do you get a list of these functions? One possible way is to
make use of a linker feature known as named sections (also known as
segments). If you've done assembly language programming, you might
have run into conventional sections like .text or .data.

Anyway, for each constructor hook function, a variable holding a
pointer to that function (by way of a symbolic reference that will be
resolved at link time) is also emitted, and that variable is placed
into a section. When the objects are linked, the linker will merge all
of the objects that belong to the same section name into one
contiguous segment of memory in the target object. The routine then
simply has to iterate from some symbolic address marking the section
start to another symbol which resolves to the section end. It knows
that the section contains nothing but pointers to the constructor
functions which are all equally wide, and so essentially it is working
with an array of pointers set up by the linker. And that is how you
can complete the run-time support for C++ global construction and
destruction. The compiler does one part, a linker script defines the
sections to do the second part, and some loop does the rest.

Exceptions? Similar concept. There will be some exception handling ABI
expected by the generated code, which the system has to complete. That
ABI will have some function for unwinding the stack frame by frame,
querying each frame for useful information such as the entry point for
clean-up cod for that frame, etc. The ABI has to map to the
concurrency model also. Do you allow exceptions within interrupt
service routines? If so, the unwinder has to know that it's in an
interrupt stack, and how to recognize that it's hit the top of it,
etc. Moreover, the interrupt may have gone off while the interrupted
task context was processing an exception already, so the two can't get
mixed up, etc.
Mar 6 '07 #21
SasQ wrote:
Dnia Mon, 05 Mar 2007 08:15:19 +0100, Zara napisał(a):
>There are some systems written in C++. I am working on
an embeddded one that is comprised of a couple of
thousand lines of C++ plus a hundred lines of assembler,
plus 0 (zero) lines of C.

How did you make it?
I don't know, but I did it too. The smallest controller I used with C++ is
an 8 bit one with 1k of program memory and 64 bytes of data memory. Of
course there are some sacrifices you have to make on such a small system.
Most of the C++ standard library for instance wouldn't make much sense on
such a system, because it heavily depends on dynamic memory and the code
would be too big.
How can C++ work in an embedded system?
Just like C can.
I thaught C++ needs some additional implementation code,
which make base for C++ language facilities before it
call main() function.
So?
I mean the things like reserving static memory, calling constructors for
static objects, exception handling mechanisms etc. And I thaught that
new and delete operators have to be implemented using some system
API/kernel calls to some system memory manager, and cannot work in "blank"
environment without some system/kernel, which may do the memory management
for new/delete implementation code.
What makes you think new/delete must use a kernel to manage memory? It can
just as well have its own memory manager.
So how it's been done? I'm very curious about that, because the plain old
C doesn't need any runtime support AFAIK.
Well, it also has to initialize static variables. And if you have malloc and
free, implementing new and delete is trivial. Exception handling is
currently not supported by the implementation I use, but that's mostly
because nobody bothered to implement it yet. I guess on the small
controller I mentioned above, the overhead would be way too big, but there
are controllers of the same architecture with up to 256k of program memory
and (through an external memory interface) up to 64k of data space, and
this would definitely be enough for exception handling to be reasonable.

Mar 6 '07 #22
Dnia Mon, 05 Mar 2007 08:15:19 +0100, Zara napisał(a):
>
There are some systems written in C++. I am working on
an embeddded one that is comprised of a couple of
thousand lines of C++ plus a hundred lines of assembler,
plus 0 (zero) lines of C.
Embedded systems written in c++ ....Did you ever felt that,
you should have used C instead of C++ ?....:-)

Mar 7 '07 #23
lakshmi wrote:
>>>Dnia Mon, 05 Mar 2007 08:15:19 +0100, Zara napisał(a):
>>>>There are some systems written in C++. I am working on
an embeddded one that is comprised of a couple of
thousand lines of C++ plus a hundred lines of assembler,
plus 0 (zero) lines of C.


Embedded systems written in c++ ....Did you ever felt that,
you should have used C instead of C++ ?....:-)
No, why should I? C++ is a very good fit in the embedded space.

--
Ian Collins.
Mar 7 '07 #24
lakshmi wrote:
Dnia Mon, 05 Mar 2007 08:15:19 +0100, Zara napisał(a):
>There are some systems written in C++. I am working on
an embeddded one that is comprised of a couple of
thousand lines of C++ plus a hundred lines of assembler,
plus 0 (zero) lines of C.

Embedded systems written in c++ ....Did you ever felt that,
you should have used C instead of C++ ?....:-)
I started with C, but I felt I should have used C++ instead of C ;-)

Mar 7 '07 #25
On 6 Mar 2007 23:18:13 -0800, "lakshmi" <la************@gmail.com>
wrote:
Dnia Mon, 05 Mar 2007 08:15:19 +0100, Zara napisa?(a):
>There are some systems written in C++. I am working on
an embeddded one that is comprised of a couple of
thousand lines of C++ plus a hundred lines of assembler,
plus 0 (zero) lines of C.

Embedded systems written in c++ ....Did you ever felt that,
you should have used C instead of C++ ?....:-)

I started in C, felt that I shoudl have started in C++, trashed all
previous work, restarted in C++. Now my progress goes faster.

Zara
Mar 7 '07 #26
On Mar 7, 2:18 am, "lakshmi" <lakshmipath...@gmail.comwrote:
Embedded systems written in c++ ....Did you ever felt that,
you should have used C instead of C++ ?....:-)
We also use C++ on our embedded systems running TI DSPs. (BTW, the TI
compiler is quite compliant with the Standard, but it doesn't ship
with the full standard library, particularly the STL. One can easily
add STLport, though.)

Cheers! --M

Mar 7 '07 #27
On 6 Mar 2007 23:18:13 -0800, "lakshmi" <la************@gmail.comwrote:
Dnia Mon, 05 Mar 2007 08:15:19 +0100, Zara napisa?(a):
>There are some systems written in C++. I am working on
an embeddded one that is comprised of a couple of
thousand lines of C++ plus a hundred lines of assembler,
plus 0 (zero) lines of C.

Embedded systems written in c++ ....Did you ever felt that,
you should have used C instead of C++ ?....:-)
I've been writing safety-critical embedded code in C++ for years. Wouldn't
trade it for C, ever.

-dr
Mar 8 '07 #28

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

Similar topics

3
by: William C. White | last post by:
Does anyone know of a way to use PHP /w Authorize.net AIM without using cURL? Our website is hosted on a shared drive and the webhost company doesn't installed additional software (such as cURL)...
2
by: Albert Ahtenberg | last post by:
Hello, I don't know if it is only me but I was sure that header("Location:url") redirects the browser instantly to URL, or at least stops the execution of the code. But appearantely it continues...
3
by: James | last post by:
Hi, I have a form with 2 fields. 'A' 'B' The user completes one of the fields and the form is submitted. On the results page I want to run a query, but this will change subject to which...
0
by: Ollivier Robert | last post by:
Hello, I'm trying to link PHP with Oracle 9.2.0/OCI8 with gcc 3.2.3 on a Solaris9 system. The link succeeds but everytime I try to run php, I get a SEGV from inside the libcnltsh.so library. ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.