Room:
Forum Date: 2/10/12 8:11 PM
Show Thread: Yes No
Topic: c++ productivity    Jump to Post       «Prev Thread       Next Thread»   
Name: Linus Torvalds (torvalds@linux-foundation.org) 6/8/10

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
>done.

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
projects.

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.

                   Linus


«Prev Post Next Post»

 Topics Posted by Date
   c++ in linux kernel  newbie  6/4/10 3:39 PM 
      c++ in linux kernel  rwessel  6/4/10 4:02 PM 
         c++ in linux kernel  slacker  6/4/10 11:18 PM 
            Forums and C/C++  David Kanter  6/5/10 2:17 AM 
               Forums : flat vs. threaded.  Dean Kent  6/5/10 6:59 AM 
                  Forums : flat vs. threaded.  anonymous  6/5/10 3:00 PM 
                     Forums : flat vs. threaded.  Rob Thorpe  6/5/10 7:28 PM 
                        Forums : flat vs. threaded.  Dean Kent  6/5/10 9:37 PM 
            c++ in linux kernel  newbie  6/5/10 11:10 AM 
               c++ in linux kernel  nksingh  6/5/10 11:44 AM 
               c++ in linux kernel  David Kanter  6/5/10 11:55 AM 
               c++ in linux kernel  Heath Provost  6/5/10 2:29 PM 
                  c++ in linux kernel  Linus Torvalds  6/5/10 8:07 PM 
                     c++ in linux kernel  6/6/10 1:34 AM 
                        c++ in linux kernel  nksingh  6/6/10 9:14 AM 
                           c++ in linux kernel  S. Rao  6/6/10 10:40 AM 
                        c++ in linux kernel  mpx  6/6/10 2:17 PM 
                           c++ in linux kernel  EduardoS  6/6/10 3:56 PM 
                        c++ in linux kernel  Linus Torvalds  6/6/10 9:35 PM 
                           c++ in linux kernel  Michael S  6/7/10 1:38 AM 
                           c++ in linux kernel  6/7/10 1:47 AM 
                              c++ in linux kernel  Pekka Enberg  6/7/10 5:35 AM 
                                 c++ in linux kernel  Michael S  6/7/10 5:54 AM 
                                    c++ in linux kernel  Pekka Enberg  6/7/10 6:17 AM 
                                       c++ in linux kernel  Michael S  6/7/10 6:50 AM 
                                          c++ in linux kernel  Pekka Enberg  6/7/10 6:57 AM 
                                 c++ in linux kernel  Vincent Diepeveen  6/23/10 6:10 AM 
                                    c++ in linux kernel  6/24/10 2:22 AM 
                              c++ in linux kernel  nemlis  6/30/10 7:56 AM 
                           c++ in linux kernel  Mark Christiansen  6/7/10 9:11 AM 
                           c++ in linux kernel  Neo  6/29/10 9:56 PM 
                              Poor troll, try harder next time (NT)  Matt Sayler  6/30/10 6:48 AM 
                              c++ in linux kernel  Rohit  6/30/10 8:10 AM 
                        c++ in linux kernel  gallier2  6/7/10 6:43 AM 
                           c++ in linux kernel  Michael S  6/7/10 7:07 AM 
                              c++ in linux kernel  gallier2  6/7/10 7:35 AM 
                                 c++ in linux kernel  Michael S  6/7/10 9:15 AM 
                                    c++ in linux kernel  gallier2  6/8/10 12:50 AM 
                           c++ in linux kernel  6/7/10 11:31 PM 
                              c++ in linux kernel  Michael S  6/8/10 1:39 AM 
                                 c++ in linux kernel  6/8/10 2:33 AM 
                                    c++ in linux kernel  Michael S  6/8/10 6:38 AM 
                                       c++ in linux kernel  6/8/10 8:23 AM 
                                          c++ in linux kernel  Michael S  6/8/10 9:52 AM 
                              c++ in linux kernel  EduardoS  6/8/10 3:13 PM 
                        c++ in linux kernel  CodeGrunt  6/12/10 11:19 AM 
                     c++ in linux kernel  newbie  6/6/10 9:04 AM 
                     c++0x any better?  Max  6/6/10 5:33 PM 
                        c++0x any better?  anon  6/7/10 8:32 PM 
                           c++0x any better?  Michael S  6/8/10 2:02 AM 
                     c++ in linux kernel  LispLover  6/6/10 10:46 PM 
                        c++ in linux kernel  Rob Thorpe  6/8/10 11:24 AM 
                     c++ in linux kernel - more disadvantages  Vincent Diepeveen  6/8/10 5:55 AM 
                     c++ in linux kernel  someone  6/8/10 9:22 AM 
                     c++ in linux kernel  John Regehr  6/10/10 11:59 AM 
                     c++/java in linux kernel  iirekm  6/11/10 8:02 AM 
                        c++/java in linux kernel  anon  6/11/10 8:20 AM 
                           c++/java in linux kernel  iirekm  6/11/10 8:38 AM 
                              c++/java in linux kernel  Rob Thorpe  6/11/10 11:17 AM 
                              Java is not just syntactic sugar on top of assembly  Mark Roulo  6/11/10 12:31 PM 
                                 no it is :-)  iirekm  6/11/10 1:47 PM 
                                    no it is :-)  Mark Roulo  6/11/10 3:19 PM 
                                       no it is :-)  iirekm  6/12/10 4:06 AM 
                                          no it is :-)  Gabriele Svelto  6/14/10 3:32 AM 
                              c++/java in linux kernel  anon  6/11/10 8:33 PM 
                           c++/java in linux kernel  6/11/10 9:41 AM 
                              c++/java in linux kernel  EduardoS  6/11/10 7:21 PM 
                              c++/java in linux kernel  anon  6/11/10 8:34 PM 
                                 C is more portable than assembly?  6/11/10 11:59 PM 
                                    C is more portable than assembly?  anon  6/12/10 1:15 AM 
                                       C is more portable than assembly?  6/12/10 3:50 AM 
                                          C is more portable than assembly?  anon  6/13/10 4:24 AM 
               c++ in linux kernel  Aaron Spink  6/6/10 5:20 PM 
                  c++ in linux kernel  Richard Cownie  6/7/10 8:49 AM 
                     c++ in linux kernel  anon  6/7/10 4:17 PM 
                        c++ in linux kernel  Richard Cownie  6/7/10 4:51 PM 
                           c++ in linux kernel  Aaron Spink  6/7/10 7:19 PM 
                              c++ in linux kernel  Richard Cownie  6/7/10 9:06 PM 
                                 c++ in linux kernel  Mark Roulo  6/8/10 7:56 AM 
                                    very interesting case study, thanks (NT)  Richard Cownie  6/8/10 8:57 AM 
                                    Okay, wait, let me get that straight  Timmy  6/21/10 9:07 PM 
                                       Split codebase..  Anon  6/21/10 10:47 PM 
                                       Okay, wait, let me get that straight  Richard Cownie  6/22/10 12:23 AM 
                                          Okay, wait, let me get that straight  anonymous  6/22/10 1:34 AM 
                                             Okay, wait, let me get that straight  Max  6/22/10 3:08 AM 
                                             Okay, wait, let me get that straight  Gabriele Svelto  6/22/10 4:51 AM 
                                                Okay, wait, let me get that straight  hobold  6/22/10 6:47 AM 
                                                   Okay, wait, let me get that straight  Salvatore De Dominicis  6/22/10 7:00 AM 
                                             Okay, wait, let me get that straight  Richard Cownie  6/22/10 6:19 AM 
                                             Okay, wait, let me get that straight  Mark Roulo  6/22/10 9:26 AM 
                                                Okay, wait, let me get that straight  Rob Thorpe  6/22/10 2:04 PM 
                                       Okay, wait, let me get that straight  Mark Roulo  6/22/10 9:21 AM 
                                       Okay, wait, let me get that straight  EduardoS  6/22/10 3:07 PM 
                           c++ in linux kernel  anon  6/7/10 9:27 PM 
                     Joke: C programs are high-performance  6/7/10 11:52 PM 
                        Programmers Need To Learn Statistics Or I Will Kill Them All  anon  6/7/10 11:57 PM 
                           Programmers Need To Learn Statistics Or I Will Kill Them All  6/8/10 12:24 AM 
                              Programmers Need To Learn Statistics Or I Will Kill Them All  hobold  6/8/10 5:33 AM 
                              Programmers Need To Learn Statistics Or I Will Kill Them All  Mark Roulo  6/8/10 7:44 AM 
                                 Programmers Need To Learn Statistics Or I Will Kill Them All  6/8/10 8:33 AM 
                                    Programmers Need To Learn Statistics Or I Will Kill Them All  Mark Roulo  6/8/10 8:56 AM 
                           To kill programmers just ship them to Tomtom - Gestapo methods there (NT)  Vincent Diepeveen  6/8/10 7:55 AM 
                     c++ productivity  anon2  6/8/10 7:57 AM 
                        c++ productivity  Linus Torvalds  6/8/10 9:49 AM 
                           c++ productivity  Rob Thorpe  6/8/10 11:38 AM 
                           c++ productivity  D.P.  6/8/10 2:25 PM 
                              c++ productivity  Linus Torvalds  6/8/10 9:27 PM 
                                 c++ productivity  anon2  6/9/10 12:32 PM 
                                    c++ productivity  Mark Roulo  6/9/10 2:15 PM 
                                       C with pointer checking  Max  6/9/10 3:05 PM 
                                          C with pointer checking  D.P.  6/9/10 11:06 PM 
                                             C with pointer checking  Max  6/10/10 1:56 PM 
                                                C with pointer checking  D.P.  6/10/10 2:16 PM 
                                       DIE FORTRAN, DIE  Rohit  6/10/10 5:50 AM 
                                          DIE FORTRAN, DIE  a reader  6/10/10 7:20 AM 
                                             DIE FORTRAN, DIE  hobel  6/10/10 10:05 AM 
                                             DIE FORTRAN, DIE  D.P.  6/10/10 2:17 PM 
                                    c++ productivity  D.P.  6/9/10 10:49 PM 
                           c++ productivity  Walter Bright  6/10/10 10:30 AM 
                              c++ productivity  D.P.  6/10/10 2:28 PM 
                                 c++ productivity  Nick Sabalausky  6/10/10 3:54 PM 
                                    c++ productivity  D.P.  6/10/10 9:57 PM 
                                       c++ productivity  Walter Bright  6/11/10 11:15 AM 
                                          c++ productivity  D.P.  6/11/10 2:26 PM 
                                             c++ productivity  Jesse Phillips  6/11/10 3:58 PM 
                                             c++ productivity  Walter Bright  6/11/10 7:15 PM 
                                                c++ productivity  D.P.  6/13/10 10:31 PM 
                                                   c++ productivity  Nick Sabalausky  6/13/10 11:19 PM 
                                                   c++ productivity  Walter Bright  6/14/10 10:38 AM 
                                                      c++ productivity  D.P.  6/15/10 4:18 AM 
                                             c++ productivity  Nick Sabalausky  6/11/10 9:41 PM 
                           Context-dependency considered harmful?  6/10/10 10:36 AM 
                           c++ productivity  Alok  6/10/10 5:21 PM 
                              c++ productivity  Linus Torvalds  6/10/10 7:00 PM 
                                 c++ productivity  anon  6/10/10 8:07 PM 
                                 c++ productivity  Eva  6/11/10 4:02 AM 
                                 c++ productivity  Oh Come On Dept  6/11/10 11:07 AM 
                                    c++ productivity  Linus Torvalds  6/11/10 12:17 PM 
                                       c++ productivity  Mark Christiansen  6/11/10 1:16 PM 
                                          c++ productivity  Linus Torvalds  6/11/10 5:35 PM 
                                             c++ productivity  stubar  6/11/10 8:39 PM 
                                             c++ productivity  a reader  6/12/10 6:30 AM 
                                                c++ productivity  Gabriele Svelto  6/14/10 5:18 AM 
                                                   c++ productivity  Brad Cantrell  6/14/10 8:54 AM 
                                             c++ productivity  6/13/10 10:36 AM 
                                                c++ productivity  Jouni Osmala  6/14/10 3:01 AM 
                                                   c++ productivity  EduardoS  6/14/10 2:46 PM 
                                             c++ productivity  Timmy  6/18/10 10:26 AM 
                                                c++ productivity  EduardoS  6/18/10 2:59 PM 
                                                   c++ productivity  rwessel  6/18/10 4:06 PM 
                                                      c++ productivity  EduardoS  6/19/10 8:31 AM 
                                                         c++ productivity  rwessel  6/21/10 12:50 PM 
                                                            c++ productivity  Anon  6/21/10 10:54 PM 
                                                               c++ productivity  Mark Roulo  6/22/10 9:10 AM 
                                                                  c++ productivity  EduardoS  6/22/10 3:34 PM 
                                                                     c++ productivity  Mark Roulo  6/22/10 3:51 PM 
                                                               c++ productivity  rwessel  6/22/10 1:42 PM 
                                                                  c++ productivity  Anon  6/22/10 6:05 PM 
                                                                     c++ productivity  rwessel  6/22/10 6:45 PM 
                                                                        c++ productivity  hobel  6/23/10 4:36 AM 
                                                                           c++ productivity  rwessel  6/23/10 1:19 PM 
                                                                              c++ productivity  Rob Thorpe  6/23/10 5:42 PM 
                                                                                 c++ productivity  hobel  6/24/10 3:12 AM 
                                                                        c++ productivity  Michael S  6/23/10 4:44 AM 
                                                                           c++ productivity  rwessel  6/23/10 12:33 PM 
                                                                              c++ productivity  Michael S  6/23/10 2:27 PM 
                                                                                 c++ productivity  rwessel  6/23/10 3:25 PM 
                                                                                    c++ productivity  Michael S  6/24/10 12:37 AM 
                                                                                       c++ productivity  rwessel  6/24/10 1:19 PM 
                                                                        c++ productivity - apology  rwessel  6/23/10 12:37 PM 
                                                                        c++ productivity  Rob Thorpe  6/23/10 5:34 PM 
                                                                           c++ productivity  Mark Roulo  6/23/10 6:11 PM 
                                                                              c++ productivity  Rob Thorpe  6/23/10 6:25 PM 
                                                                        c++ productivity  Anon  6/24/10 2:26 AM 
                                                   c++ productivity  anonymous  6/18/10 4:43 PM 
                                             c++ productivity  tm  9/14/10 3:43 AM 
                                                c++ productivity  gallier2  9/14/10 4:41 AM 
                                       c++ productivity  Oh Come On Dept  6/11/10 2:52 PM 
                           c++ productivity  Kagamin  6/11/10 4:21 AM 
                              c++ productivity  anon  6/11/10 8:29 PM 
                                 c++ productivity  David Kanter  6/13/10 10:37 AM 
                                    c++ productivity  Richard Cownie  6/13/10 2:24 PM 
                                       c++ productivity  Charles  6/14/10 11:41 AM 
                                          c++ productivity  Richard Cownie  6/14/10 1:06 PM 
                                          well-designed C++ libraries  D.P.  6/16/10 10:49 AM 
                                             boost sucks  anon  6/16/10 8:13 PM 
                                                what c++ libraries does not suck?  D.P.  6/17/10 12:09 AM 
                                                   amount of ignorance to history  6/17/10 5:14 AM 
                                                      amount of ignorance to history  Charles  6/17/10 11:33 PM 
                                                         amount of ignorance to history  anon  6/18/10 12:17 AM 
                                                            amount of ignorance to history  Mark Christiansen  6/18/10 8:22 AM 
                                                               amount of ignorance to history  anon  6/18/10 9:39 AM 
                                                         Boost is being used to illustrate that good C++ is unreadable by most  Mark Roulo  6/18/10 9:40 AM 
                                                         amount of ignorance to history  D.P.  6/18/10 4:13 PM 
                                             well-designed C++ libraries  anon  6/17/10 1:20 AM 
                                                well-designed C++ libraries  D.P.  6/18/10 4:25 PM 
                                                   well-designed C++ libraries  anon  6/18/10 9:57 PM 
                                                      well-designed C++ libraries  D.P.  6/21/10 9:11 AM 
                                                   well-designed C++ libraries  Kagamin  6/19/10 8:27 AM 
                                                      Lack of features can be a feature  David Kanter  6/19/10 1:03 PM 
                                                      some features have global effects  Richard Cownie  6/19/10 1:44 PM 
                                                         some features have global effects  Timmy  6/20/10 10:11 AM 
                                    c++ productivity  Rob Thorpe  6/14/10 9:31 AM 
                                    c++ productivity  Kagamin  6/18/10 10:30 AM 
                           c++ productivity  fast  6/11/10 11:47 PM 
Reply To This Topic
 
 Name:
 Email:
 Email Replies:
 Topic: No Text
 Body:
 Challenge Question:
  How do you spell 'blue'?