c++ productivity

By: Linus Torvalds (torvalds.delete@this.linux-foundation.org), June 8, 2010 7:49 am
Room: Moderated Discussions
anon2 (anon@anons.com) on 6/8/10 wrote:
>But productivity is a difference thing when it comes to
>kernel code. Linux devs are working practically for free.
>So the same amount of budget can get you whole lot work

Actually, this is wrong.

People working for free still doesn't mean that it's fine
to make the work take more effort - people still work for
other compensation, and not feeling excessively
frustrated about the tools (including language) and getting
productive work done is a big issue.

So if a language change were to make people much more
productive, that would be a good thing regardless of how
much people end up getting paid. It's definitely not about
the money.

But the thing is, "lines of code" isn't even remotely close
to being a measure of productivity, or even the gating
issue. The gating issue in any large project is pretty much
all about (a) getting the top people and (b) communication.

In the kernel, we have roughly a thousand people being
attributed for each and every kernel release (at
about three months apart). Now, there's a long tail, and
the hundred (or even fifty) top contributors do most of
the bulk work, but even then, the biggest issue that I end
up worrying about is not even the code, but the "flow" of
code and development.

For example, I personally don't even write much code any
more, and haven't for years. I mainly merge (and to a
large degree - don't merge: a large portion of what
I do is telling people "No, I won't take this, because of
xyz". Even if rejection ends up being the rare case, it's
actually the main reason for me existing. Anybody can say
"yes". Somebody needs to say "no").

And the best way to make things work is to not need
to communicate at all. It's exactly the same issue as in
parallel programming - any communication inevitably is the
main bottleneck.

And the best way to avoid communication is to have some
"culture" - which is just another way to say "collection of
rules that don't even need to be written down/spoken, since
people are aware of it". Sure, we obviously have a lot of
documentation about how things are supposed to be done,
but exactly as with any regular human culture, documentation
is kind of secondary.

(Put another way: there are lots of books about culture,
and you can get a PhD in anthropology and spend all your
life just studying it - but for 99% of all people, you
don't read a book about your culture, you learn it by
being part of the community).

And there is a very strong "culture" of C (and UNIX, for
that matter). And this is also where it's so important for
the language to be simple and unambiguous. One of the
absolute worst features of C++ is how it makes a
lot of things so context-dependent - which just means
that when you look at the code, a local view simply seldom
gives enough context to know what is going on.

That is a huge problem for communication. It immediately
makes it much harder to describe things, because you have
to give a much bigger context. It's one big reason why I
detest things like overloading - not only can you not grep
for things, but it makes it much harder to see what a
snippet of code really does.

Put another way: when you communicate in fragments (think
"patches"), it's always better to see "sctp_connect()"
than to see just "connect()" where some unseen context is
what makes the compiler know that it is in the sctp module.

And you have to communicate in fragments in order
to communicate efficiently. And I don't mean "efficiently"
as in network bandwidth - I mean as in "in general". The
reason we use patches instead of sending the whole project
(or even just a couple of whole files) around is not because
it's denser in email - it's because the only thing that
matters is the change, not the end result.

So that is a very fundamental reason for development to
avoid ambiguity and context. And that, btw, has absolutely
nothing to do particularly with "kernel programming". It's
true in general in any sw project, but it's true in real
life too: speaking or writing ambiguously is not good in
normal human communication either.

So a simple and clear language is a good thing. You don't
want to be unnecessarily verbose (meaningless syntactic
fluff is always bad), but at the same time you do not want
to require too much context either.

[ Lots of implicit context is fine if everybody is an
expert on the subject. Which is why really esoteric
scientific literature is basically unreadable unless
you're an expert - it requires huge amounts of context
to make sense at all. But that is simply not possible
in a large project that has many different areas.

For example, I know the VM and core kernel really well,
but I still need to be able to read the code of various
filesystems and networking code. So even for somebody
like me, the code needs to be written without hidden
context. ]

And C is a largely context-free language. When you see a
C expression, you know what it does. A function call does
one thing, and one thing only - there will not be some
subtle issue about "which version" of a function it calls.

Of course, you can use the preprocessor and inline functions
to do that, but even then you have to be pretty explicit:
you can still grep for that preprocessor symbol, and it's
all pretty "direct".

Now, in other situations you do want more language support,
and you do want the language to do memory allocation etc
for you (ie GC - I'm not talking about that idiotic
"new" keyword in C++, or other crap). In the kernel, we
couldn't do that anyway. Similarly, in the kernel, we do
really require very specialized locking and direct control
over memory ordering etc, so a language that exposes some
model of concurrency would almost certainly be too limited
in that concurrency too.

So there are particular reasons why I think C is "as simple
as possible, but no simpler" for the particular case of an
OS kernel, or system programming in particular. That's why
I'm absolutely not saying that you should use C for all

But C++? I really don't think the "good features" of it
are very good at all. If you leave C behind, do it properly
and get some real features that matter. GC, some
concurrency support, dynamic code generation, whatever.

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