Why are most Linux programs written in C?












28














Why are most Linux programs written in C? Why are they not written with C++, which is newer?










share|improve this question




















  • 14




    C++ is newer than C, but that's a bit irrelevant. They are different languages.
    – Mat
    Oct 30 '11 at 18:27






  • 6




    You should probably ask this at StackOverflow or Programmers (where the topic has actually been already nicely covered).
    – rozcietrzewiacz
    Oct 30 '11 at 18:29








  • 4




    @Mat Well, it's not entirely correct, as C++ is a superset of C. You can program in C and compile it with a C++ compiler. It'll compile and work as expected.
    – polemon
    Oct 30 '11 at 23:56






  • 8




    @polemon: that's incorrect, there are incompatibilities. en.wikipedia.org/wiki/Compatibility_of_C_and_C%2B%2B
    – Mat
    Oct 31 '11 at 5:25
















28














Why are most Linux programs written in C? Why are they not written with C++, which is newer?










share|improve this question




















  • 14




    C++ is newer than C, but that's a bit irrelevant. They are different languages.
    – Mat
    Oct 30 '11 at 18:27






  • 6




    You should probably ask this at StackOverflow or Programmers (where the topic has actually been already nicely covered).
    – rozcietrzewiacz
    Oct 30 '11 at 18:29








  • 4




    @Mat Well, it's not entirely correct, as C++ is a superset of C. You can program in C and compile it with a C++ compiler. It'll compile and work as expected.
    – polemon
    Oct 30 '11 at 23:56






  • 8




    @polemon: that's incorrect, there are incompatibilities. en.wikipedia.org/wiki/Compatibility_of_C_and_C%2B%2B
    – Mat
    Oct 31 '11 at 5:25














28












28








28


8





Why are most Linux programs written in C? Why are they not written with C++, which is newer?










share|improve this question















Why are most Linux programs written in C? Why are they not written with C++, which is newer?







linux c c++






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 10 '17 at 0:40









MikeD

598215




598215










asked Oct 30 '11 at 18:19









hpnhpn

66651420




66651420








  • 14




    C++ is newer than C, but that's a bit irrelevant. They are different languages.
    – Mat
    Oct 30 '11 at 18:27






  • 6




    You should probably ask this at StackOverflow or Programmers (where the topic has actually been already nicely covered).
    – rozcietrzewiacz
    Oct 30 '11 at 18:29








  • 4




    @Mat Well, it's not entirely correct, as C++ is a superset of C. You can program in C and compile it with a C++ compiler. It'll compile and work as expected.
    – polemon
    Oct 30 '11 at 23:56






  • 8




    @polemon: that's incorrect, there are incompatibilities. en.wikipedia.org/wiki/Compatibility_of_C_and_C%2B%2B
    – Mat
    Oct 31 '11 at 5:25














  • 14




    C++ is newer than C, but that's a bit irrelevant. They are different languages.
    – Mat
    Oct 30 '11 at 18:27






  • 6




    You should probably ask this at StackOverflow or Programmers (where the topic has actually been already nicely covered).
    – rozcietrzewiacz
    Oct 30 '11 at 18:29








  • 4




    @Mat Well, it's not entirely correct, as C++ is a superset of C. You can program in C and compile it with a C++ compiler. It'll compile and work as expected.
    – polemon
    Oct 30 '11 at 23:56






  • 8




    @polemon: that's incorrect, there are incompatibilities. en.wikipedia.org/wiki/Compatibility_of_C_and_C%2B%2B
    – Mat
    Oct 31 '11 at 5:25








14




14




C++ is newer than C, but that's a bit irrelevant. They are different languages.
– Mat
Oct 30 '11 at 18:27




C++ is newer than C, but that's a bit irrelevant. They are different languages.
– Mat
Oct 30 '11 at 18:27




6




6




You should probably ask this at StackOverflow or Programmers (where the topic has actually been already nicely covered).
– rozcietrzewiacz
Oct 30 '11 at 18:29






You should probably ask this at StackOverflow or Programmers (where the topic has actually been already nicely covered).
– rozcietrzewiacz
Oct 30 '11 at 18:29






4




4




@Mat Well, it's not entirely correct, as C++ is a superset of C. You can program in C and compile it with a C++ compiler. It'll compile and work as expected.
– polemon
Oct 30 '11 at 23:56




@Mat Well, it's not entirely correct, as C++ is a superset of C. You can program in C and compile it with a C++ compiler. It'll compile and work as expected.
– polemon
Oct 30 '11 at 23:56




8




8




@polemon: that's incorrect, there are incompatibilities. en.wikipedia.org/wiki/Compatibility_of_C_and_C%2B%2B
– Mat
Oct 31 '11 at 5:25




@polemon: that's incorrect, there are incompatibilities. en.wikipedia.org/wiki/Compatibility_of_C_and_C%2B%2B
– Mat
Oct 31 '11 at 5:25










2 Answers
2






active

oldest

votes


















34














There have been many discussions about this. Mainly, the reason is a philosophical one.
C was invented as a simple language for system development (not so much application development). There are many arguments for using C++, but there are about as many for not using C++ and sticking to C.



In the end, it's a historical issue. Most application stuff is written in C, because most Kernel stuff is written in C. And since back then most stuff was written in C, people tend to use the original languages.



At this point, someone might ask "OK, so why is the kernel written in C and not ported to C++?". This has been discussed on kerneltrap some time ago. One nice explanation that can be quoted from this thread is a response by yoshi314 (quoting directly):




that's because nearly every c++ app needs a separate c++ standard library to operate. so they would have to port it to kernel, and expect an extra overhead everywhere.



c++ is more complex language and that means that compiler creates more complex code from it. because of that, finding that a problem stems from compiler bug,rather than code error is easier in c.



also c language is more barebone, and it's easier to follow its assembly representation, which is often easy to predict.



c++ is more versatile, but c is more suited for lowlevel or embedded stuff.






On the other hand, "most of Linux programs" is quite misleading. Take a look at graphical applications. Python is getting more and more ground especially in GUI environments on Linux. About the same thing that's happening with Windows and .NET.






share|improve this answer



















  • 3




    Additionally the C have stable ABI and can be easily plugged to other languages via their native FFI while C++ does not have human-readable ABI and g++ had changes in the ABI. Therefore the libraries tended to be written in C rather then C++. Because you want to have one language in project so did the programs bundled with library. (At least that was a story with Gnome).
    – Maciej Piechotka
    Oct 30 '11 at 23:33










  • @MaciejPiechotka All this is true, and it is a nice discussion, but c doesn't have a defined ABI, except that there is often a "obvious" way to work things on each platform. After that it's follow the leader.
    – dmckee
    Nov 1 '11 at 0:34










  • @dmckee: I haven't stated it has standardized but C API on each platform follows certain simple rules (including no or minimal mangling) which rarely changes - which makes it useful for the purpose even if not 100% correct.
    – Maciej Piechotka
    Nov 1 '11 at 13:08






  • 2




    Nowadays, you can also consider that ... * everything you can do in C you can also do in C++ in pretty much the same way, think also "extern C" ... * the compiler won't make more complex code if you don't write more complex code ... * you can write the same barebone stuff in C++ ... * you can link and use C++ libraries from C. In the end it is a quite a historical issue.
    – Zrin
    Dec 12 '14 at 21:04



















6














After reading the following email from Linus Torvalds the creator of linux. I can't help thinking the answer above is incorrect. He seems to think that C++ programmers are not good systems programmers. And that the extra features in C++ often cause more problems in the long term compared to the benefits they bring in the short term. While one may disagree with him, it's difficult to overstate the influence he has had on the linux operating system.



http://harmful.cat-v.org/software/c++/linus






share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f23634%2fwhy-are-most-linux-programs-written-in-c%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    34














    There have been many discussions about this. Mainly, the reason is a philosophical one.
    C was invented as a simple language for system development (not so much application development). There are many arguments for using C++, but there are about as many for not using C++ and sticking to C.



    In the end, it's a historical issue. Most application stuff is written in C, because most Kernel stuff is written in C. And since back then most stuff was written in C, people tend to use the original languages.



    At this point, someone might ask "OK, so why is the kernel written in C and not ported to C++?". This has been discussed on kerneltrap some time ago. One nice explanation that can be quoted from this thread is a response by yoshi314 (quoting directly):




    that's because nearly every c++ app needs a separate c++ standard library to operate. so they would have to port it to kernel, and expect an extra overhead everywhere.



    c++ is more complex language and that means that compiler creates more complex code from it. because of that, finding that a problem stems from compiler bug,rather than code error is easier in c.



    also c language is more barebone, and it's easier to follow its assembly representation, which is often easy to predict.



    c++ is more versatile, but c is more suited for lowlevel or embedded stuff.






    On the other hand, "most of Linux programs" is quite misleading. Take a look at graphical applications. Python is getting more and more ground especially in GUI environments on Linux. About the same thing that's happening with Windows and .NET.






    share|improve this answer



















    • 3




      Additionally the C have stable ABI and can be easily plugged to other languages via their native FFI while C++ does not have human-readable ABI and g++ had changes in the ABI. Therefore the libraries tended to be written in C rather then C++. Because you want to have one language in project so did the programs bundled with library. (At least that was a story with Gnome).
      – Maciej Piechotka
      Oct 30 '11 at 23:33










    • @MaciejPiechotka All this is true, and it is a nice discussion, but c doesn't have a defined ABI, except that there is often a "obvious" way to work things on each platform. After that it's follow the leader.
      – dmckee
      Nov 1 '11 at 0:34










    • @dmckee: I haven't stated it has standardized but C API on each platform follows certain simple rules (including no or minimal mangling) which rarely changes - which makes it useful for the purpose even if not 100% correct.
      – Maciej Piechotka
      Nov 1 '11 at 13:08






    • 2




      Nowadays, you can also consider that ... * everything you can do in C you can also do in C++ in pretty much the same way, think also "extern C" ... * the compiler won't make more complex code if you don't write more complex code ... * you can write the same barebone stuff in C++ ... * you can link and use C++ libraries from C. In the end it is a quite a historical issue.
      – Zrin
      Dec 12 '14 at 21:04
















    34














    There have been many discussions about this. Mainly, the reason is a philosophical one.
    C was invented as a simple language for system development (not so much application development). There are many arguments for using C++, but there are about as many for not using C++ and sticking to C.



    In the end, it's a historical issue. Most application stuff is written in C, because most Kernel stuff is written in C. And since back then most stuff was written in C, people tend to use the original languages.



    At this point, someone might ask "OK, so why is the kernel written in C and not ported to C++?". This has been discussed on kerneltrap some time ago. One nice explanation that can be quoted from this thread is a response by yoshi314 (quoting directly):




    that's because nearly every c++ app needs a separate c++ standard library to operate. so they would have to port it to kernel, and expect an extra overhead everywhere.



    c++ is more complex language and that means that compiler creates more complex code from it. because of that, finding that a problem stems from compiler bug,rather than code error is easier in c.



    also c language is more barebone, and it's easier to follow its assembly representation, which is often easy to predict.



    c++ is more versatile, but c is more suited for lowlevel or embedded stuff.






    On the other hand, "most of Linux programs" is quite misleading. Take a look at graphical applications. Python is getting more and more ground especially in GUI environments on Linux. About the same thing that's happening with Windows and .NET.






    share|improve this answer



















    • 3




      Additionally the C have stable ABI and can be easily plugged to other languages via their native FFI while C++ does not have human-readable ABI and g++ had changes in the ABI. Therefore the libraries tended to be written in C rather then C++. Because you want to have one language in project so did the programs bundled with library. (At least that was a story with Gnome).
      – Maciej Piechotka
      Oct 30 '11 at 23:33










    • @MaciejPiechotka All this is true, and it is a nice discussion, but c doesn't have a defined ABI, except that there is often a "obvious" way to work things on each platform. After that it's follow the leader.
      – dmckee
      Nov 1 '11 at 0:34










    • @dmckee: I haven't stated it has standardized but C API on each platform follows certain simple rules (including no or minimal mangling) which rarely changes - which makes it useful for the purpose even if not 100% correct.
      – Maciej Piechotka
      Nov 1 '11 at 13:08






    • 2




      Nowadays, you can also consider that ... * everything you can do in C you can also do in C++ in pretty much the same way, think also "extern C" ... * the compiler won't make more complex code if you don't write more complex code ... * you can write the same barebone stuff in C++ ... * you can link and use C++ libraries from C. In the end it is a quite a historical issue.
      – Zrin
      Dec 12 '14 at 21:04














    34












    34








    34






    There have been many discussions about this. Mainly, the reason is a philosophical one.
    C was invented as a simple language for system development (not so much application development). There are many arguments for using C++, but there are about as many for not using C++ and sticking to C.



    In the end, it's a historical issue. Most application stuff is written in C, because most Kernel stuff is written in C. And since back then most stuff was written in C, people tend to use the original languages.



    At this point, someone might ask "OK, so why is the kernel written in C and not ported to C++?". This has been discussed on kerneltrap some time ago. One nice explanation that can be quoted from this thread is a response by yoshi314 (quoting directly):




    that's because nearly every c++ app needs a separate c++ standard library to operate. so they would have to port it to kernel, and expect an extra overhead everywhere.



    c++ is more complex language and that means that compiler creates more complex code from it. because of that, finding that a problem stems from compiler bug,rather than code error is easier in c.



    also c language is more barebone, and it's easier to follow its assembly representation, which is often easy to predict.



    c++ is more versatile, but c is more suited for lowlevel or embedded stuff.






    On the other hand, "most of Linux programs" is quite misleading. Take a look at graphical applications. Python is getting more and more ground especially in GUI environments on Linux. About the same thing that's happening with Windows and .NET.






    share|improve this answer














    There have been many discussions about this. Mainly, the reason is a philosophical one.
    C was invented as a simple language for system development (not so much application development). There are many arguments for using C++, but there are about as many for not using C++ and sticking to C.



    In the end, it's a historical issue. Most application stuff is written in C, because most Kernel stuff is written in C. And since back then most stuff was written in C, people tend to use the original languages.



    At this point, someone might ask "OK, so why is the kernel written in C and not ported to C++?". This has been discussed on kerneltrap some time ago. One nice explanation that can be quoted from this thread is a response by yoshi314 (quoting directly):




    that's because nearly every c++ app needs a separate c++ standard library to operate. so they would have to port it to kernel, and expect an extra overhead everywhere.



    c++ is more complex language and that means that compiler creates more complex code from it. because of that, finding that a problem stems from compiler bug,rather than code error is easier in c.



    also c language is more barebone, and it's easier to follow its assembly representation, which is often easy to predict.



    c++ is more versatile, but c is more suited for lowlevel or embedded stuff.






    On the other hand, "most of Linux programs" is quite misleading. Take a look at graphical applications. Python is getting more and more ground especially in GUI environments on Linux. About the same thing that's happening with Windows and .NET.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Oct 30 '11 at 18:46


























    community wiki





    2 revs, 2 users 52%
    rozcietrzewiacz










    • 3




      Additionally the C have stable ABI and can be easily plugged to other languages via their native FFI while C++ does not have human-readable ABI and g++ had changes in the ABI. Therefore the libraries tended to be written in C rather then C++. Because you want to have one language in project so did the programs bundled with library. (At least that was a story with Gnome).
      – Maciej Piechotka
      Oct 30 '11 at 23:33










    • @MaciejPiechotka All this is true, and it is a nice discussion, but c doesn't have a defined ABI, except that there is often a "obvious" way to work things on each platform. After that it's follow the leader.
      – dmckee
      Nov 1 '11 at 0:34










    • @dmckee: I haven't stated it has standardized but C API on each platform follows certain simple rules (including no or minimal mangling) which rarely changes - which makes it useful for the purpose even if not 100% correct.
      – Maciej Piechotka
      Nov 1 '11 at 13:08






    • 2




      Nowadays, you can also consider that ... * everything you can do in C you can also do in C++ in pretty much the same way, think also "extern C" ... * the compiler won't make more complex code if you don't write more complex code ... * you can write the same barebone stuff in C++ ... * you can link and use C++ libraries from C. In the end it is a quite a historical issue.
      – Zrin
      Dec 12 '14 at 21:04














    • 3




      Additionally the C have stable ABI and can be easily plugged to other languages via their native FFI while C++ does not have human-readable ABI and g++ had changes in the ABI. Therefore the libraries tended to be written in C rather then C++. Because you want to have one language in project so did the programs bundled with library. (At least that was a story with Gnome).
      – Maciej Piechotka
      Oct 30 '11 at 23:33










    • @MaciejPiechotka All this is true, and it is a nice discussion, but c doesn't have a defined ABI, except that there is often a "obvious" way to work things on each platform. After that it's follow the leader.
      – dmckee
      Nov 1 '11 at 0:34










    • @dmckee: I haven't stated it has standardized but C API on each platform follows certain simple rules (including no or minimal mangling) which rarely changes - which makes it useful for the purpose even if not 100% correct.
      – Maciej Piechotka
      Nov 1 '11 at 13:08






    • 2




      Nowadays, you can also consider that ... * everything you can do in C you can also do in C++ in pretty much the same way, think also "extern C" ... * the compiler won't make more complex code if you don't write more complex code ... * you can write the same barebone stuff in C++ ... * you can link and use C++ libraries from C. In the end it is a quite a historical issue.
      – Zrin
      Dec 12 '14 at 21:04








    3




    3




    Additionally the C have stable ABI and can be easily plugged to other languages via their native FFI while C++ does not have human-readable ABI and g++ had changes in the ABI. Therefore the libraries tended to be written in C rather then C++. Because you want to have one language in project so did the programs bundled with library. (At least that was a story with Gnome).
    – Maciej Piechotka
    Oct 30 '11 at 23:33




    Additionally the C have stable ABI and can be easily plugged to other languages via their native FFI while C++ does not have human-readable ABI and g++ had changes in the ABI. Therefore the libraries tended to be written in C rather then C++. Because you want to have one language in project so did the programs bundled with library. (At least that was a story with Gnome).
    – Maciej Piechotka
    Oct 30 '11 at 23:33












    @MaciejPiechotka All this is true, and it is a nice discussion, but c doesn't have a defined ABI, except that there is often a "obvious" way to work things on each platform. After that it's follow the leader.
    – dmckee
    Nov 1 '11 at 0:34




    @MaciejPiechotka All this is true, and it is a nice discussion, but c doesn't have a defined ABI, except that there is often a "obvious" way to work things on each platform. After that it's follow the leader.
    – dmckee
    Nov 1 '11 at 0:34












    @dmckee: I haven't stated it has standardized but C API on each platform follows certain simple rules (including no or minimal mangling) which rarely changes - which makes it useful for the purpose even if not 100% correct.
    – Maciej Piechotka
    Nov 1 '11 at 13:08




    @dmckee: I haven't stated it has standardized but C API on each platform follows certain simple rules (including no or minimal mangling) which rarely changes - which makes it useful for the purpose even if not 100% correct.
    – Maciej Piechotka
    Nov 1 '11 at 13:08




    2




    2




    Nowadays, you can also consider that ... * everything you can do in C you can also do in C++ in pretty much the same way, think also "extern C" ... * the compiler won't make more complex code if you don't write more complex code ... * you can write the same barebone stuff in C++ ... * you can link and use C++ libraries from C. In the end it is a quite a historical issue.
    – Zrin
    Dec 12 '14 at 21:04




    Nowadays, you can also consider that ... * everything you can do in C you can also do in C++ in pretty much the same way, think also "extern C" ... * the compiler won't make more complex code if you don't write more complex code ... * you can write the same barebone stuff in C++ ... * you can link and use C++ libraries from C. In the end it is a quite a historical issue.
    – Zrin
    Dec 12 '14 at 21:04













    6














    After reading the following email from Linus Torvalds the creator of linux. I can't help thinking the answer above is incorrect. He seems to think that C++ programmers are not good systems programmers. And that the extra features in C++ often cause more problems in the long term compared to the benefits they bring in the short term. While one may disagree with him, it's difficult to overstate the influence he has had on the linux operating system.



    http://harmful.cat-v.org/software/c++/linus






    share|improve this answer




























      6














      After reading the following email from Linus Torvalds the creator of linux. I can't help thinking the answer above is incorrect. He seems to think that C++ programmers are not good systems programmers. And that the extra features in C++ often cause more problems in the long term compared to the benefits they bring in the short term. While one may disagree with him, it's difficult to overstate the influence he has had on the linux operating system.



      http://harmful.cat-v.org/software/c++/linus






      share|improve this answer


























        6












        6








        6






        After reading the following email from Linus Torvalds the creator of linux. I can't help thinking the answer above is incorrect. He seems to think that C++ programmers are not good systems programmers. And that the extra features in C++ often cause more problems in the long term compared to the benefits they bring in the short term. While one may disagree with him, it's difficult to overstate the influence he has had on the linux operating system.



        http://harmful.cat-v.org/software/c++/linus






        share|improve this answer














        After reading the following email from Linus Torvalds the creator of linux. I can't help thinking the answer above is incorrect. He seems to think that C++ programmers are not good systems programmers. And that the extra features in C++ often cause more problems in the long term compared to the benefits they bring in the short term. While one may disagree with him, it's difficult to overstate the influence he has had on the linux operating system.



        http://harmful.cat-v.org/software/c++/linus







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 2 days ago









        Community

        1




        1










        answered Jun 21 '16 at 16:48









        Arturo HernandezArturo Hernandez

        16111




        16111






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f23634%2fwhy-are-most-linux-programs-written-in-c%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            How to make a Squid Proxy server?

            Is this a new Fibonacci Identity?

            19世紀