Re: C++ in kernel. was Re: Batch file for Visual S tudio build,

This looks like an ad??

-----Original Message-----
From: Moreira, Alberto [mailto:xxxxx@compuware.com]
Sent: Wednesday, October 23, 2002 11:48 AM
To: NT Developers Interest List
Subject: [ntdev] Re: C++ in kernel. was Re: Batch file for Visual S
tudio build,

The issue of correctly handling exceptions is a library issue and an OS
issue, not a language one. If MSVC++ 6.0 doesn’t have a good level of
support for kernel side code, that’s not a problem with the language but
a problem with that particular compiler ! Part of using a language in
kernel mode, well, any language for that matter, is to have a suitable
library that works fine in kernel mode and lets you use the full
language, or as much of it as it is possible.

Alberto.

-----Original Message-----
From: Jamey Kirby [mailto:xxxxx@storagecraft.com]
Sent: Wednesday, October 23, 2002 12:40 PM
To: NT Developers Interest List
Subject: [ntdev] Re: C++ in kernel. was Re: Batch file for Visual S
tudio build,

Throw exceptions… You mean C++ exceptions? In kernel-mode? I rest my
case…

Jamey

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Moreira, Alberto
Sent: Wednesday, October 23, 2002 9:12 AM
To: NT Developers Interest List
Subject: [ntdev] Re: C++ in kernel. was Re: Batch file for Visual S
tudio build,

Say you have an Irp class. You declare in the beginning of your program

Irp myirp;

By the time the next line has been executed, the constructor has already
run. How do you believe a return value from a constructor should be used
by the language ? Then, say you have a line of code such as

Irp *newirp = new Irp(…parameters…);

here, again, how do you believe the return value should be used ? You
see, constructors ain’t functions ! And if you really want to diagnose
errors, you can throw an exception.

Alberto.

-----Original Message-----
From: Jamey Kirby [mailto:xxxxx@storagecraft.com]
Sent: Wednesday, October 23, 2002 11:57 AM
To: NT Developers Interest List
Subject: [ntdev] Re: C++ in kernel. was Re: Batch file for Visual Studio
build,

Let’s not forget about those constructors and destructors that have no
return value. This makes life real easy; NOT!

Jamey

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of David J. Craig
Sent: Wednesday, October 23, 2002 8:04 AM
To: NT Developers Interest List
Subject: [ntdev] Re: C++ in kernel. was Re: Batch file for Visual Studio
build,

C has no advantage over C++ when it comes to good code design or
efficiency. That is in the hands of the developer.

This is false in the first sentence, but the second is always true. If
you have a group of junior device driver developers, the limited
environment in “C” can help keep them from shooting themselves in the
foot. Cobol is even better at allowing almost anyone with minimal
skills to be a coder, though it takes a long time for them to become a
programmer.

My point is that people seem to be saying that if their file is
labeled
“.cpp” there code will somehow be tainted and neither clear or
efficient. Where do you draw the feature line at? Since c++ is a
super-set of c, which features are the ones that don’t belong in the
kernel? You can’t tell me none of them.

I use C++ in my device drivers because it makes sense. I use the .cpp
extensions even if the code is still pure “C” because the latest
Microsoft compilers do a better job of catching errors. Since the stack
is so limited in kernel mode, the full capabilities of C++ exception
handling don’t belong and aren’t supported by Microsoft. Passing large
data items on the stack is another bad idea in either “C” or “C++”.

Does that mean if I prefer the power/features of
a c++ compiler then by definition I don’t understand the language? I
have
met so many C programmers that had zero clue about how the language
works
or describes what is happening in the hardware. One of my favorite
arguments that I heard in person: “There are no dynamic arrays in C”.
I
spent hours trying to explain that “pointer” and “array”
interchangeable. He left unconvinced, but said he would study it
further
(he said it was a non portable compiler exploit or some nonsense).

I have been in environments, government, where you are give some people
who the “system” says are programmers. You have a job to do and they
are your resources. Sometimes you just have to apply the KISS principle
even in your choice of language. Luckily in today’s civilian job
environment, you can get rid of the non-performers, but it much more
difficult in the military or civil service. It takes a supervisor at
least a year to get a civilian fired for incompetence and most
supervisors don’t have that much time to devote to that. It is easier
to get the person promoted or transferred.

----- Original Message -----
From: “Justin Frodsham”
To: “NT Developers Interest List”
Sent: Wednesday, October 23, 2002 7:25 AM
Subject: [ntdev] Re: C++ in kernel. was Re: Batch file for Visual Studio
build,


You are currently subscribed to ntdev as: xxxxx@storagecraft.com To
unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to %%email.unsub%%

The contents of this e-mail are intended for the named addressee only.
It contains information that may be confidential. Unless you are the
named addressee or an authorized designee, you may not copy or use it,
or disclose it to anyone else. If you received it in error please notify
us immediately and then destroy it.


You are currently subscribed to ntdev as: xxxxx@storagecraft.com To
unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to %%email.unsub%%

The contents of this e-mail are intended for the named addressee only.
It contains information that may be confidential. Unless you are the
named addressee or an authorized designee, you may not copy or use it,
or disclose it to anyone else. If you received it in error please notify
us immediately and then destroy it.


You are currently subscribed to ntdev as: chakradhar.kommuri@hp.com To
unsubscribe send a blank email to %%email.unsub%%

I agree with some of your points with respect to C and C++ in general.
My point is that as I read your posts, I am trying to envision some of
your driver code. C++ exceptions and such…

What I see is a bloated driver that would be a nightmare to support. The
kernel is already object based. It seems to me to be a waste of time to
spend development hours simply writing C++ wrappers around an existing
abstraction. I want my developers writing production code, not
personalizing the environment to suit their fancy. I have some door
knobs that need polishing; anyone interested?

Jamey

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Moreira, Alberto
Sent: Wednesday, October 23, 2002 9:48 AM
To: NT Developers Interest List
Subject: [ntdev] Re: C++ in kernel. was Re: Batch file for Visual S
tudio build,

The issue of correctly handling exceptions is a library issue and an OS
issue, not a language one. If MSVC++ 6.0 doesn’t have a good level of
support for kernel side code, that’s not a problem with the language but
a
problem with that particular compiler ! Part of using a language in
kernel
mode, well, any language for that matter, is to have a suitable library
that
works fine in kernel mode and lets you use the full language, or as much
of
it as it is possible.

Alberto.

-----Original Message-----
From: Jamey Kirby [mailto:xxxxx@storagecraft.com]
Sent: Wednesday, October 23, 2002 12:40 PM
To: NT Developers Interest List
Subject: [ntdev] Re: C++ in kernel. was Re: Batch file for Visual S
tudio build,

Throw exceptions… You mean C++ exceptions? In kernel-mode? I rest my
case…

Jamey

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Moreira, Alberto
Sent: Wednesday, October 23, 2002 9:12 AM
To: NT Developers Interest List
Subject: [ntdev] Re: C++ in kernel. was Re: Batch file for Visual S
tudio build,

Say you have an Irp class. You declare in the beginning of your program

Irp myirp;

By the time the next line has been executed, the constructor has already
run. How do you believe a return value from a constructor should be used
by
the language ? Then, say you have a line of code such as

Irp *newirp = new Irp(…parameters…);

here, again, how do you believe the return value should be used ? You
see,
constructors ain’t functions ! And if you really want to diagnose
errors,
you can throw an exception.

Alberto.

-----Original Message-----
From: Jamey Kirby [mailto:xxxxx@storagecraft.com]
Sent: Wednesday, October 23, 2002 11:57 AM
To: NT Developers Interest List
Subject: [ntdev] Re: C++ in kernel. was Re: Batch file for Visual Studio
build,

Let’s not forget about those constructors and destructors that have no
return value. This makes life real easy; NOT!

Jamey

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of David J. Craig
Sent: Wednesday, October 23, 2002 8:04 AM
To: NT Developers Interest List
Subject: [ntdev] Re: C++ in kernel. was Re: Batch file for Visual Studio
build,

C has no advantage over C++ when it comes to good code design or
efficiency. That is in the hands of the developer.

This is false in the first sentence, but the second is always true. If
you
have a group of junior device driver developers, the limited environment
in
“C” can help keep them from shooting themselves in the foot. Cobol is
even
better at allowing almost anyone with minimal skills to be a coder,
though
it takes a long time for them to become a programmer.

My point is that people seem to be saying that if their file is
labeled
“.cpp” there code will somehow be tainted and neither clear or
efficient. Where do you draw the feature line at? Since c++ is a
super-set of c, which features are the ones that don’t belong in the
kernel? You can’t tell me none of them.

I use C++ in my device drivers because it makes sense. I use the .cpp
extensions even if the code is still pure “C” because the latest
Microsoft
compilers do a better job of catching errors. Since the stack is so
limited
in kernel mode, the full capabilities of C++ exception handling don’t
belong
and aren’t supported by Microsoft. Passing large data items on the
stack is
another bad idea in either “C” or “C++”.

Does that mean if I prefer the power/features of
a c++ compiler then by definition I don’t understand the language? I
have
met so many C programmers that had zero clue about how the language
works
or describes what is happening in the hardware. One of my favorite
arguments that I heard in person: “There are no dynamic arrays in C”.
I
spent hours trying to explain that “pointer” and “array”
interchangeable. He left unconvinced, but said he would study it
further
(he said it was a non portable compiler exploit or some nonsense).

I have been in environments, government, where you are give some people
who
the “system” says are programmers. You have a job to do and they are
your
resources. Sometimes you just have to apply the KISS principle even in
your
choice of language. Luckily in today’s civilian job environment, you
can
get rid of the non-performers, but it much more difficult in the
military or
civil service. It takes a supervisor at least a year to get a civilian
fired for incompetence and most supervisors don’t have that much time to
devote to that. It is easier to get the person promoted or transferred.

----- Original Message -----
From: “Justin Frodsham”
To: “NT Developers Interest List”
Sent: Wednesday, October 23, 2002 7:25 AM
Subject: [ntdev] Re: C++ in kernel. was Re: Batch file for Visual Studio
build,


You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to %%email.unsub%%

The contents of this e-mail are intended for the named addressee only.
It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or
disclose
it to anyone else. If you received it in error please notify us
immediately
and then destroy it.


You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to %%email.unsub%%

The contents of this e-mail are intended for the named addressee only.
It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or
disclose
it to anyone else. If you received it in error please notify us
immediately
and then destroy it.


You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to %%email.unsub%%

Although it could be, Alberto would not do such a thing :slight_smile:

One more note:

I do not believe in mixing paradigms. C++ is an object oriented
language. If you are going to write C++ code, it should be pure. No
mixing of paradigms and mixing of language usage. There are things in a
KM driver that are not object oriented and because the kernel has
already been abstracted through its object base paradigm, you make have
to do some ‘ugly’ C++ things to make the two paradigms work together.
This in not in the vain of C++ and good object oriented design.

C++ is not a language designed for small and simple projects like a
device driver. Its whole reason for existence is to promote code reuse
and better component management in very large and complex projects. It
is not a better C. If you start mixing the paradigm and language usage,
you create a rats nest of unmanageable code; this worsens he product
from all perspectives.

Jamey

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Kommuri, Chakradhar
Sent: Wednesday, October 23, 2002 9:55 AM
To: NT Developers Interest List
Subject: [ntdev] Re: C++ in kernel. was Re: Batch file for Visual S
tudio build,

This looks like an ad??

-----Original Message-----
From: Moreira, Alberto [mailto:xxxxx@compuware.com]
Sent: Wednesday, October 23, 2002 11:48 AM
To: NT Developers Interest List
Subject: [ntdev] Re: C++ in kernel. was Re: Batch file for Visual S
tudio build,

The issue of correctly handling exceptions is a library issue and an OS
issue, not a language one. If MSVC++ 6.0 doesn’t have a good level of
support for kernel side code, that’s not a problem with the language but
a problem with that particular compiler ! Part of using a language in
kernel mode, well, any language for that matter, is to have a suitable
library that works fine in kernel mode and lets you use the full
language, or as much of it as it is possible.

Alberto.

-----Original Message-----
From: Jamey Kirby [mailto:xxxxx@storagecraft.com]
Sent: Wednesday, October 23, 2002 12:40 PM
To: NT Developers Interest List
Subject: [ntdev] Re: C++ in kernel. was Re: Batch file for Visual S
tudio build,

Throw exceptions… You mean C++ exceptions? In kernel-mode? I rest my
case…

Jamey

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Moreira, Alberto
Sent: Wednesday, October 23, 2002 9:12 AM
To: NT Developers Interest List
Subject: [ntdev] Re: C++ in kernel. was Re: Batch file for Visual S
tudio build,

Say you have an Irp class. You declare in the beginning of your program

Irp myirp;

By the time the next line has been executed, the constructor has already
run. How do you believe a return value from a constructor should be used
by the language ? Then, say you have a line of code such as

Irp *newirp = new Irp(…parameters…);

here, again, how do you believe the return value should be used ? You
see, constructors ain’t functions ! And if you really want to diagnose
errors, you can throw an exception.

Alberto.

-----Original Message-----
From: Jamey Kirby [mailto:xxxxx@storagecraft.com]
Sent: Wednesday, October 23, 2002 11:57 AM
To: NT Developers Interest List
Subject: [ntdev] Re: C++ in kernel. was Re: Batch file for Visual Studio
build,

Let’s not forget about those constructors and destructors that have no
return value. This makes life real easy; NOT!

Jamey

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of David J. Craig
Sent: Wednesday, October 23, 2002 8:04 AM
To: NT Developers Interest List
Subject: [ntdev] Re: C++ in kernel. was Re: Batch file for Visual Studio
build,

C has no advantage over C++ when it comes to good code design or
efficiency. That is in the hands of the developer.

This is false in the first sentence, but the second is always true. If
you have a group of junior device driver developers, the limited
environment in “C” can help keep them from shooting themselves in the
foot. Cobol is even better at allowing almost anyone with minimal
skills to be a coder, though it takes a long time for them to become a
programmer.

My point is that people seem to be saying that if their file is
labeled
“.cpp” there code will somehow be tainted and neither clear or
efficient. Where do you draw the feature line at? Since c++ is a
super-set of c, which features are the ones that don’t belong in the
kernel? You can’t tell me none of them.

I use C++ in my device drivers because it makes sense. I use the .cpp
extensions even if the code is still pure “C” because the latest
Microsoft compilers do a better job of catching errors. Since the stack
is so limited in kernel mode, the full capabilities of C++ exception
handling don’t belong and aren’t supported by Microsoft. Passing large
data items on the stack is another bad idea in either “C” or “C++”.

Does that mean if I prefer the power/features of
a c++ compiler then by definition I don’t understand the language? I
have
met so many C programmers that had zero clue about how the language
works
or describes what is happening in the hardware. One of my favorite
arguments that I heard in person: “There are no dynamic arrays in C”.
I
spent hours trying to explain that “pointer” and “array”
interchangeable. He left unconvinced, but said he would study it
further
(he said it was a non portable compiler exploit or some nonsense).

I have been in environments, government, where you are give some people
who the “system” says are programmers. You have a job to do and they
are your resources. Sometimes you just have to apply the KISS principle
even in your choice of language. Luckily in today’s civilian job
environment, you can get rid of the non-performers, but it much more
difficult in the military or civil service. It takes a supervisor at
least a year to get a civilian fired for incompetence and most
supervisors don’t have that much time to devote to that. It is easier
to get the person promoted or transferred.

----- Original Message -----
From: “Justin Frodsham”
To: “NT Developers Interest List”
Sent: Wednesday, October 23, 2002 7:25 AM
Subject: [ntdev] Re: C++ in kernel. was Re: Batch file for Visual Studio
build,


You are currently subscribed to ntdev as: xxxxx@storagecraft.com To
unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to %%email.unsub%%

The contents of this e-mail are intended for the named addressee only.
It contains information that may be confidential. Unless you are the
named addressee or an authorized designee, you may not copy or use it,
or disclose it to anyone else. If you received it in error please notify
us immediately and then destroy it.


You are currently subscribed to ntdev as: xxxxx@storagecraft.com To
unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to %%email.unsub%%

The contents of this e-mail are intended for the named addressee only.
It contains information that may be confidential. Unless you are the
named addressee or an authorized designee, you may not copy or use it,
or disclose it to anyone else. If you received it in error please notify
us immediately and then destroy it.


You are currently subscribed to ntdev as: chakradhar.kommuri@hp.com To
unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to %%email.unsub%%

> device driver. Its whole reason for existence is to promote code
reuse

and better component management in very large and complex projects.
It

I would add - its whole reason for existence is to provide the way of
swift typing of code - “a + b” instead of Add(a, b) etc, strings,
containers and so on.

It saves the coder time (sometimes a lot, but not in drivers) and
increases the time necessary to comprehend the code (again sometimes a
lot).

Max