Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

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

David_J._CraigDavid_J._Craig Member Posts: 1,885
> 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" <zeppelin@io.com>
To: "NT Developers Interest List" <xxxxx@lists.osr.com>
Sent: Wednesday, October 23, 2002 7:25 AM
Subject: [ntdev] Re: C++ in kernel. was Re: Batch file for Visual Studio
build,

Comments

  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    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" <zeppelin@io.com>
    To: "NT Developers Interest List" <xxxxx@lists.osr.com>
    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%%
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    The only less relevant argument we could be having is what editor we
    should all be forced to use in order to ensure driver quality (me, I use
    VIM). I guess we could talk about whether /* */ or // comments provide
    for better code maintenance.

    C & C++ are the same and they both suck. neither is particularly type
    safe, neither has particularly advanced flow-control mechanisms (for,
    while and do aren't always the right choice), neither provides any real
    help for annotating your code such that the compiler could make better
    decisions about optimizations, so that code checking tools can extract
    the semantic information they need to do their jobs better, etc... And
    that's not even talking about this ridiculous "preprocessor" crap.

    personally I can't wait for a better language to come around that I can
    use to do my driver development work in. Saddly many language designers
    seem to think that C or C++ is the proper starting point and generally
    inherit all the flaws that come along with it.

    any chance we can get back to talking about drivers instead of having
    the same language zealot debate that we had 3 months ago?

    -p

    -----Original Message-----
    From: Jamey Kirby [mailto:xxxxx@storagecraft.com]
    Sent: Wednesday, October 23, 2002 8: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" <zeppelin@io.com>
    To: "NT Developers Interest List" <xxxxx@lists.osr.com>
    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@microsoft.com To
    unsubscribe send a blank email to %%email.unsub%%
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
Developing Minifilters 29 July 2019 OSR Seminar Space
Writing WDF Drivers 23 Sept 2019 OSR Seminar Space
Kernel Debugging 21 Oct 2019 OSR Seminar Space
Internals & Software Drivers 18 Nov 2019 Dulles, VA