Thread: interview with Linus

  1. #76
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Quote Originally Posted by Yarin View Post
    I think though, that the kernel should run closer to the bare metal than literally any other software in the OS
    how is C++ any further from the bare metal than C? C++ is (essentially) a superset of C, in the context that we're talking about, and given a block of pure C code, both a C and a C++ compiler will generate nearly identical results. your argument holds absolutely no water.

  2. #77
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    That makes me feel like I'm talking to the wind... ?
    Imagine how I feel; you've been asked several times for anything that supports your view and you've posted nothing beyond "I think", "I feel", and "Linus says".

    *shrug*

    Still, troll slaying is best left to "Orcs Must Die"...

    Soma

  3. #78
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by Yarin View Post
    If one wants their kernel to run according to their envisioned C++ paradigm, then of course they should code it in C++.
    I think though, that the kernel should run closer to the bare metal than literally any other software in the OS, including drivers. And to best do that, one should avoid the C++ mindset. Embedded devices and kernels are where C shines the brightest, I think, for the very bare bones qualities that you ridicule.
    Oh, but this isn't about the C++ mindset. Obviously going awry with OOP design with heavy reliance on virtual functions and temporary objects is going to hurt performance. No, I agree with you that one has to be careful inside a kernel.
    However, we are trying to convey the message of C++ as the language. C++ is a better C in many ways. As long as one is aware that one is working with hardware, one can use any language suited to the task.
    Heard of Microsoft's little research project Singularity? It's not written in C. And yet, it works, and it works well, I'd probably say. For a research OS anyway.
    The point is that you must separate the mindset from the language. Separate design from language. Just because you use C++ doesn't mean you have to use OOP, exceptions, polymorphism, etc.
    You can just use, say, templates and the better type system. What you need, or should, use depends on the requirements of the project. Naturally you also base the choice of language around this.

    I really don't think so. Literally the whole system relies on it, and I imagine it's routines are traversed way more than any other in a normal computing session. You'd want it to be fast.
    But that doesn't mean you have to squeeze every little imaginable piece of speed out of it. Many functions are rarely called.
    The principle of avoiding premature optimization is a good one, even in kernels.
    First you build your system so that it works. Then you start profiling it. Then you start optimizing.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #79
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    Quote Originally Posted by phantomotap View Post
    Imagine how I feel; you've been asked several times for anything that supports your view and you've posted nothing beyond "I think", "I feel", and "Linus says".
    Heh, I have given reasons, including asking for examples contrary to what I'm saying, and you've failed to produce as well. So you're argument is the pot calling the kettle back.

    End point: C++ is a higher level paradigm language than C, by enough that makes it less suitable for kernel development than C. I don't know if I can make it any more succinct than that.

    Quote Originally Posted by Elkvis View Post
    how is C++ any further from the bare metal than C? C++ is (essentially) a superset of C, in the context that we're talking about, and given a block of pure C code, both a C and a C++ compiler will generate nearly identical results.
    If you code C++ like it's C, then of course it will, and then what's the point of using C++ in the first place? The debate of C++ vs C for the kernel, is assuming both languages are used normally, so your point is off track.

  5. #80
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by Yarin View Post
    ...The debate of C++ vs C for the kernel, is assuming both languages are used normally, so your point is off track.
    No it isn't. You have to adapt the features in the language you use to your platform.
    C++ is used in the embedded space, too, and you can be sure all of its features aren't put into use there.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #81
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    Quote Originally Posted by Elysia View Post
    Oh, but this isn't about the C++ mindset. Obviously going awry with OOP design with heavy reliance on virtual functions and temporary objects is going to hurt performance. No, I agree with you that one has to be careful inside a kernel.
    However, we are trying to convey the message of C++ as the language. C++ is a better C in many ways. As long as one is aware that one is working with hardware, one can use any language suited to the task.
    Heard of Microsoft's little research project Singularity? It's not written in C. And yet, it works, and it works well, I'd probably say. For a research OS anyway.
    The point is that you must separate the mindset from the language. Separate design from language. Just because you use C++ doesn't mean you have to use OOP, exceptions, polymorphism, etc.
    You can just use, say, templates and the better type system. What you need, or should, use depends on the requirements of the project. Naturally you also base the choice of language around this.
    Well, with that thought, one could use pretty much any compilable language. And sure, you're right about that. I'm simply arguing that using C instead of C++ is that more appropriate choice (by "C", I'm including using "C++ written like it's C" )

    Quote Originally Posted by Elysia View Post
    But that doesn't mean you have to squeeze every little imaginable piece of speed out of it. Many functions are rarely called.
    The principle of avoiding premature optimization is a good one, even in kernels.
    First you build your system so that it works. Then you start profiling it. Then you start optimizing.
    Your 3 steps sound sound to me. There's no reason though, that the last step shouldn't include extreme optimization, specifically on the heavily traveled routines, obviously there's little need to squeeze performance out of rarely called routines.

  7. #82
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by Yarin View Post
    Well, with that thought, one could use pretty much any compilable language. And sure, you're right about that. I'm simply arguing that using C instead of C++ is that more appropriate choice (by "C", I'm including using "C++ written like it's C" )
    Well, if you are using that definition, then we are in agreement.

    Your 3 steps sound sound to me. There's no reason though, that the last step shouldn't include extreme optimization, specifically on the heavily traveled routines, obviously there's little need to squeeze performance out of rarely called routines.
    Obviously, yes, you are right. If the profiler shows that it is a heavily traveled path, then by all means, you should try squeezing out as much performance as possible.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  8. #83
    Registered User antred's Avatar
    Join Date
    Apr 2012
    Location
    Germany
    Posts
    257
    Quote Originally Posted by Yarin View Post
    If you code C++ like it's C, then of course it will, and then what's the point of using C++ in the first place?
    I'm starting to think you may have a little reading comprehension problem. C++ has vastly better type safety and offers RAII and templates. All of these can be used in a kernel, to great benefit and with no additional cost at all. THAT is the point.

  9. #84
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    Quote Originally Posted by antred View Post
    I'm starting to think you may have a little reading comprehension problem.
    ...
    Quote Originally Posted by antred View Post
    C++ has vastly better type safety and offers RAII and templates. All of these can be used in a kernel, to great benefit and with no additional cost at all. THAT is the point.
    Please re-read this thread. I have responded to all these points already.

  10. #85
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Quote Originally Posted by Yarin View Post
    If you code C++ like it's C, then of course it will, and then what's the point of using C++ in the first place? The debate of C++ vs C for the kernel, is assuming both languages are used normally, so your point is off track.
    it's quite possible, and even in many cases perfectly appropriate to use C++, but not use all of its features, and still call it normal use.

  11. #86
    Registered User antred's Avatar
    Join Date
    Apr 2012
    Location
    Germany
    Posts
    257
    Quote Originally Posted by Yarin View Post
    ...

    Please re-read this thread. I have responded to all these points already.
    No, you really haven't. What you did do is regurgitate the same thing over and over, namely that you feel C++ is not worth it if you strip off many of its features. You have never even attempted to explain in which way the built-in support for runtime and compile-time polymorphism, RAII and better type safety provided by C++ __ISN'T__ a massive improvement over C.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. linus c client program
    By bazdagirl in forum Linux Programming
    Replies: 1
    Last Post: 01-21-2011, 12:22 PM
  2. Basic Linus Shell
    By Josh_Dude83 in forum C Programming
    Replies: 11
    Last Post: 09-19-2010, 07:43 PM
  3. Interview???
    By verbity in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 08-09-2007, 07:47 AM
  4. linus svm
    By axon in forum Tech Board
    Replies: 2
    Last Post: 01-16-2004, 07:38 PM
  5. Linus VS. Bill
    By Yoshi in forum A Brief History of Cprogramming.com
    Replies: 31
    Last Post: 12-25-2001, 09:28 PM