c++ in linux kernel

By: Linus Torvalds (torvalds.delete@this.linux-foundation.org), June 6, 2010 8:35 pm
Room: Moderated Discussions
? (0xe2.0x9a.0x9b@gmail.com) on 6/6/10 wrote:
---------------------------
>Linus Torvalds (torvalds@linux-foundation.org) on 6/5/10 wrote:
>---------------------------
>>[cut]
>>And I really do dislike C++. It's a really bad language, in
>>my opinion. It tries to solve all the wrong problems, and
>>does not tackle the right ones. The things C++ "solves"
>>are trivial things, almost purely syntactic extensions to
>>C rather than fixing some true deep problem.
>
>Care to write an explicit example of a deep problem?
>(Except memory management - you already mentioned garbage
>collection.)

Concurrency, for example.

My point being, that C++ adds absolutely nothing
interesting.

>All right. Then why do you think C should have support
>for structures (struct {...})?

That's just singularly stupid.

C is a good language. It's complete enough (and yes, the
ability to handle structured data is very much required
for any serious language) to be supremely useful, while
at the same time being quite simple.

A language without structured data types would not be a
powerful language the way C is. You do need data structures,
and you need pointers (to both data and code) to be at
all interesting.

But where do you draw the line?

I know that you as a C++ proponent you probably won't
really "get" this simple argument, but try:

- read the K&R book on C (the ANSI edition), and be
enlightened.

Notice how the language is basically described by one
rather thin book. Readably.

So what C does so well is to do that whole "make it as
simple as you can, but no simpler". And that is what makes
it great. The language is powerful, yet fairly minimal.

There really aren't many features you could remove
from the C language without crippling it. Sure, there's
three different looping constructs, and you could make
trivial (syntactic) changes to the language, but that's
really not the point. The language is simple, but
without being too simple.

Now, that's not what you always want. I understand very
well why people want less system-oriented languages with
more built-in functionality. As mentioned, support for
both garbage collection and concurrency are quite real
problems, and they are both things you can do in C, but
that you cannot do well with library interfaces,
which is how you normally would extend on C.

And garbage collection and concurrency are way more than
just syntactic extensions. You can still do them very
badly, of course, so it's not a trivial path to go down,
and I'm not saying hat a language magically becomes "good"
just from supporting one or the other.

But again: C does what it does very well, and with a
clarity of thought and design that is entirely and
utterly lacking
from C++.

And yes, I happen to think that clarity of thought and
design is a good thing. It's why I liked UNIX, even though
I was initially introduced to other things (VMS - ugh).

C++ is a mess. There's no design. It's just "add crud on
top of C". And the crud isn't even meaningful, much less
does it have a design. It's totally and utterly random.

It started out random, now it's randomness that gets added
to by a committee.

>For example, namespaces and function overloading are *not*
>useless. They *do* solve a real problem that C is incapable
>of solving.

You're full of it.

>For example, if you want in your source code to define a
>function called "connect" and you also want include
>"sys/socket.h", you cannot do that in C.

So to prove how it's not just a syntactic feature, you
start talking about syntax?

What drugs are you on?

The name overloading is a total syntactic feature. In
C, the way you fix your problem is by a totally trivial
syntactic change: you call your function "my_connect()".

Wow. It's like magic. I added three characters, and made
your whole reason for the crap that is C++ go away.

The thing is, the above is a really good example of why
C++ is horrible, and why C is so simple.

Yes, the C solution is really simple. It's so simple that
it looks downright stupid. But it's actually so simple
that it is smart because quite frankly, it's a lot
easier to get confused in C++ code, when the same function
name means totally different due to overloading.

Of course, you're not "supposed" to overload things in
confusing ways, but the thing is, just do what C does:
just make your function names unique. It's not that hard,
and by avoiding the overloading mess, you make it a lot
easier to search for (hey look! "grep -w my_connect" just
works!), and you avoid ambiguity.

(Same exact thing goes for your other example: just
add a module prefix or have some other trivial naming
rules for your functional split-up, and be happy)

Linus
< Previous Post in ThreadNext Post in Thread >
TopicPosted ByDate
c++ in linux kernelnewbie2010/06/04 02:39 PM
  c++ in linux kernelrwessel2010/06/04 03:02 PM
    c++ in linux kernelslacker2010/06/04 10:18 PM
      Forums and C/C++David Kanter2010/06/05 01:17 AM
        Forums : flat vs. threaded.Dean Kent2010/06/05 05:59 AM
          Forums : flat vs. threaded.anonymous2010/06/05 02:00 PM
            Forums : flat vs. threaded.Rob Thorpe2010/06/05 06:28 PM
              Forums : flat vs. threaded.Dean Kent2010/06/05 08:37 PM
      c++ in linux kernelnewbie2010/06/05 10:10 AM
        c++ in linux kernelnksingh2010/06/05 10:44 AM
        c++ in linux kernelDavid Kanter2010/06/05 10:55 AM
        c++ in linux kernelHeath Provost2010/06/05 01:29 PM
          c++ in linux kernelLinus Torvalds2010/06/05 07:07 PM
            c++ in linux kernel?2010/06/06 12:34 AM
              c++ in linux kernelnksingh2010/06/06 08:14 AM
                c++ in linux kernelS. Rao2010/06/06 09:40 AM
              c++ in linux kernelmpx2010/06/06 01:17 PM
                c++ in linux kernelEduardoS2010/06/06 02:56 PM
              c++ in linux kernelLinus Torvalds2010/06/06 08:35 PM
                c++ in linux kernelMichael S2010/06/07 12:38 AM
                c++ in linux kernel?2010/06/07 12:47 AM
                  c++ in linux kernelPekka Enberg2010/06/07 04:35 AM
                    c++ in linux kernelMichael S2010/06/07 04:54 AM
                      c++ in linux kernelPekka Enberg2010/06/07 05:17 AM
                        c++ in linux kernelMichael S2010/06/07 05:50 AM
                          c++ in linux kernelPekka Enberg2010/06/07 05:57 AM
                    c++ in linux kernelVincent Diepeveen2010/06/23 05:10 AM
                      c++ in linux kernel?2010/06/24 01:22 AM
                  c++ in linux kernelnemlis2010/06/30 06:56 AM
                c++ in linux kernelMark Christiansen2010/06/07 08:11 AM
                c++ in linux kernelNeo2010/06/29 08:56 PM
                  Poor troll, try harder next time (NT)Matt Sayler2010/06/30 05:48 AM
                  c++ in linux kernelRohit2010/06/30 07:10 AM
              c++ in linux kernelgallier22010/06/07 05:43 AM
                c++ in linux kernelMichael S2010/06/07 06:07 AM
                  c++ in linux kernelgallier22010/06/07 06:35 AM
                    c++ in linux kernelMichael S2010/06/07 08:15 AM
                      c++ in linux kernelgallier22010/06/07 11:50 PM
                c++ in linux kernel?2010/06/07 10:31 PM
                  c++ in linux kernelMichael S2010/06/08 12:39 AM
                    c++ in linux kernel?2010/06/08 01:33 AM
                      c++ in linux kernelMichael S2010/06/08 05:38 AM
                        c++ in linux kernel?2010/06/08 07:23 AM
                          c++ in linux kernelMichael S2010/06/08 08:52 AM
                  c++ in linux kernelEduardoS2010/06/08 02:13 PM
              c++ in linux kernelCodeGrunt2010/06/12 10:19 AM
            c++ in linux kernelnewbie2010/06/06 08:04 AM
            c++0x any better?Max2010/06/06 04:33 PM
              c++0x any better?anon2010/06/07 07:32 PM
                c++0x any better?Michael S2010/06/08 01:02 AM
            c++ in linux kernelLispLover2010/06/06 09:46 PM
              c++ in linux kernelRob Thorpe2010/06/08 10:24 AM
            c++ in linux kernel - more disadvantagesVincent Diepeveen2010/06/08 04:55 AM
            c++ in linux kernelsomeone2010/06/08 08:22 AM
            c++ in linux kernelJohn Regehr2010/06/10 10:59 AM
            c++/java in linux kerneliirekm2010/06/11 07:02 AM
              c++/java in linux kernelanon2010/06/11 07:20 AM
                c++/java in linux kerneliirekm2010/06/11 07:38 AM
                  c++/java in linux kernelRob Thorpe2010/06/11 10:17 AM
                  Java is not just syntactic sugar on top of assemblyMark Roulo2010/06/11 11:31 AM
                    no it is :-)iirekm2010/06/11 12:47 PM
                      no it is :-)Mark Roulo2010/06/11 02:19 PM
                        no it is :-)iirekm2010/06/12 03:06 AM
                          no it is :-)Gabriele Svelto2010/06/14 02:32 AM
                  c++/java in linux kernelanon2010/06/11 07:33 PM
                c++/java in linux kernel?2010/06/11 08:41 AM
                  c++/java in linux kernelEduardoS2010/06/11 06:21 PM
                  c++/java in linux kernelanon2010/06/11 07:34 PM
                    C is more portable than assembly??2010/06/11 10:59 PM
                      C is more portable than assembly?anon2010/06/12 12:15 AM
                        C is more portable than assembly??2010/06/12 02:50 AM
                          C is more portable than assembly?anon2010/06/13 03:24 AM
            c++ in linux kernelBob2014/05/24 10:40 AM
        c++ in linux kernelAaron Spink2010/06/06 04:20 PM
          c++ in linux kernelRichard Cownie2010/06/07 07:49 AM
            c++ in linux kernelanon2010/06/07 03:17 PM
              c++ in linux kernelRichard Cownie2010/06/07 03:51 PM
                c++ in linux kernelAaron Spink2010/06/07 06:19 PM
                  c++ in linux kernelRichard Cownie2010/06/07 08:06 PM
                    c++ in linux kernelMark Roulo2010/06/08 06:56 AM
                      very interesting case study, thanks (NT)Richard Cownie2010/06/08 07:57 AM
                      Okay, wait, let me get that straightTimmy2010/06/21 08:07 PM
                        Split codebase..Anon2010/06/21 09:47 PM
                        Okay, wait, let me get that straightRichard Cownie2010/06/21 11:23 PM
                          Okay, wait, let me get that straightanonymous2010/06/22 12:34 AM
                            Okay, wait, let me get that straightMax2010/06/22 02:08 AM
                            Okay, wait, let me get that straightGabriele Svelto2010/06/22 03:51 AM
                              Okay, wait, let me get that straighthobold2010/06/22 05:47 AM
                                Okay, wait, let me get that straightSalvatore De Dominicis2010/06/22 06:00 AM
                            Okay, wait, let me get that straightRichard Cownie2010/06/22 05:19 AM
                            Okay, wait, let me get that straightMark Roulo2010/06/22 08:26 AM
                              Okay, wait, let me get that straightRob Thorpe2010/06/22 01:04 PM
                        Okay, wait, let me get that straightMark Roulo2010/06/22 08:21 AM
                        Okay, wait, let me get that straightEduardoS2010/06/22 02:07 PM
                c++ in linux kernelanon2010/06/07 08:27 PM
            Joke: C programs are high-performance?2010/06/07 10:52 PM
              Programmers Need To Learn Statistics Or I Will Kill Them Allanon2010/06/07 10:57 PM
                Programmers Need To Learn Statistics Or I Will Kill Them All?2010/06/07 11:24 PM
                  Programmers Need To Learn Statistics Or I Will Kill Them Allhobold2010/06/08 04:33 AM
                  Programmers Need To Learn Statistics Or I Will Kill Them AllMark Roulo2010/06/08 06:44 AM
                    Programmers Need To Learn Statistics Or I Will Kill Them All?2010/06/08 07:33 AM
                      Programmers Need To Learn Statistics Or I Will Kill Them AllMark Roulo2010/06/08 07:56 AM
                To kill programmers just ship them to Tomtom - Gestapo methods there (NT)Vincent Diepeveen2010/06/08 06:55 AM
            c++ productivityanon22010/06/08 06:57 AM
              c++ productivityLinus Torvalds2010/06/08 08:49 AM
                c++ productivityRob Thorpe2010/06/08 10:38 AM
                c++ productivityD.P.2010/06/08 01:25 PM
                  c++ productivityLinus Torvalds2010/06/08 08:27 PM
                    c++ productivityanon22010/06/09 11:32 AM
                      c++ productivityMark Roulo2010/06/09 01:15 PM
                        C with pointer checkingMax2010/06/09 02:05 PM
                          C with pointer checkingD.P.2010/06/09 10:06 PM
                            C with pointer checkingMax2010/06/10 12:56 PM
                              C with pointer checkingD.P.2010/06/10 01:16 PM
                        DIE FORTRAN, DIERohit2010/06/10 04:50 AM
                          DIE FORTRAN, DIEa reader2010/06/10 06:20 AM
                            DIE FORTRAN, DIEhobel2010/06/10 09:05 AM
                            DIE FORTRAN, DIED.P.2010/06/10 01:17 PM
                      c++ productivityD.P.2010/06/09 09:49 PM
                    c++ productivityMaxthon T. Chan2013/09/19 11:02 AM
                c++ productivityWalter Bright2010/06/10 09:30 AM
                  c++ productivityD.P.2010/06/10 01:28 PM
                    c++ productivityNick Sabalausky2010/06/10 02:54 PM
                      c++ productivityD.P.2010/06/10 08:57 PM
                        c++ productivityWalter Bright2010/06/11 10:15 AM
                          c++ productivityD.P.2010/06/11 01:26 PM
                            c++ productivityJesse Phillips2010/06/11 02:58 PM
                            c++ productivityWalter Bright2010/06/11 06:15 PM
                              c++ productivityD.P.2010/06/13 09:31 PM
                                c++ productivityNick Sabalausky2010/06/13 10:19 PM
                                c++ productivityWalter Bright2010/06/14 09:38 AM
                                  c++ productivityD.P.2010/06/15 03:18 AM
                            c++ productivityNick Sabalausky2010/06/11 08:41 PM
                Context-dependency considered harmful??2010/06/10 09:36 AM
                c++ productivityAlok2010/06/10 04:21 PM
                  c++ productivityLinus Torvalds2010/06/10 06:00 PM
                    c++ productivityanon2010/06/10 07:07 PM
                    c++ productivityEva2010/06/11 03:02 AM
                    c++ productivityOh Come On Dept2010/06/11 10:07 AM
                      c++ productivityLinus Torvalds2010/06/11 11:17 AM
                        c++ productivityMark Christiansen2010/06/11 12:16 PM
                          c++ productivityLinus Torvalds2010/06/11 04:35 PM
                            c++ productivitystubar2010/06/11 07:39 PM
                            c++ productivitya reader2010/06/12 05:30 AM
                              c++ productivityGabriele Svelto2010/06/14 04:18 AM
                                c++ productivityBrad Cantrell2010/06/14 07:54 AM
                            c++ productivity?2010/06/13 09:36 AM
                              c++ productivityJouni Osmala2010/06/14 02:01 AM
                                c++ productivityEduardoS2010/06/14 01:46 PM
                            c++ productivityTimmy2010/06/18 09:26 AM
                              c++ productivityEduardoS2010/06/18 01:59 PM
                                c++ productivityrwessel2010/06/18 03:06 PM
                                  c++ productivityEduardoS2010/06/19 07:31 AM
                                    c++ productivityrwessel2010/06/21 11:50 AM
                                      c++ productivityAnon2010/06/21 09:54 PM
                                        c++ productivityMark Roulo2010/06/22 08:10 AM
                                          c++ productivityEduardoS2010/06/22 02:34 PM
                                            c++ productivityMark Roulo2010/06/22 02:51 PM
                                        c++ productivityrwessel2010/06/22 12:42 PM
                                          c++ productivityAnon2010/06/22 05:05 PM
                                            c++ productivityrwessel2010/06/22 05:45 PM
                                              c++ productivityhobel2010/06/23 03:36 AM
                                                c++ productivityrwessel2010/06/23 12:19 PM
                                                  c++ productivityRob Thorpe2010/06/23 04:42 PM
                                                    c++ productivityhobel2010/06/24 02:12 AM
                                              c++ productivityMichael S2010/06/23 03:44 AM
                                                c++ productivityrwessel2010/06/23 11:33 AM
                                                  c++ productivityMichael S2010/06/23 01:27 PM
                                                    c++ productivityrwessel2010/06/23 02:25 PM
                                                      c++ productivityMichael S2010/06/23 11:37 PM
                                                        c++ productivityrwessel2010/06/24 12:19 PM
                                              c++ productivity - apologyrwessel2010/06/23 11:37 AM
                                              c++ productivityRob Thorpe2010/06/23 04:34 PM
                                                c++ productivityMark Roulo2010/06/23 05:11 PM
                                                  c++ productivityRob Thorpe2010/06/23 05:25 PM
                                              c++ productivityAnon2010/06/24 01:26 AM
                                c++ productivityanonymous2010/06/18 03:43 PM
                            c++ productivitytm2010/09/14 02:43 AM
                              c++ productivitygallier22010/09/14 03:41 AM
                        c++ productivityOh Come On Dept2010/06/11 01:52 PM
                c++ productivityKagamin2010/06/11 03:21 AM
                  c++ productivityanon2010/06/11 07:29 PM
                    c++ productivityDavid Kanter2010/06/13 09:37 AM
                      c++ productivityRichard Cownie2010/06/13 01:24 PM
                        c++ productivityCharles2010/06/14 10:41 AM
                          c++ productivityRichard Cownie2010/06/14 12:06 PM
                          well-designed C++ librariesD.P.2010/06/16 09:49 AM
                            boost sucksanon2010/06/16 07:13 PM
                              what c++ libraries does not suck?D.P.2010/06/16 11:09 PM
                                amount of ignorance to history?2010/06/17 04:14 AM
                                  amount of ignorance to historyCharles2010/06/17 10:33 PM
                                    amount of ignorance to historyanon2010/06/17 11:17 PM
                                      amount of ignorance to historyMark Christiansen2010/06/18 07:22 AM
                                        amount of ignorance to historyanon2010/06/18 08:39 AM
                                    Boost is being used to illustrate that good C++ is unreadable by mostMark Roulo2010/06/18 08:40 AM
                                    amount of ignorance to historyD.P.2010/06/18 03:13 PM
                            well-designed C++ librariesanon2010/06/17 12:20 AM
                              well-designed C++ librariesD.P.2010/06/18 03:25 PM
                                well-designed C++ librariesanon2010/06/18 08:57 PM
                                  well-designed C++ librariesD.P.2010/06/21 08:11 AM
                                well-designed C++ librariesKagamin2010/06/19 07:27 AM
                                  Lack of features can be a featureDavid Kanter2010/06/19 12:03 PM
                                  some features have global effectsRichard Cownie2010/06/19 12:44 PM
                                    some features have global effectsTimmy2010/06/20 09:11 AM
                      c++ productivityRob Thorpe2010/06/14 08:31 AM
                      c++ productivityKagamin2010/06/18 09:30 AM
                c++ productivityfast2010/06/11 10:47 PM
Reply to this Topic
Name:
Email:
Topic:
Body: No Text
How do you spell purple?