• About Jakob Engblom and this blog
Observations from Uppsala Computer Simulation, Virtual Platforms, Embedded Programming, Multicore and More (by Jakob Engblom)

Joel Spolsky: You cannot program parallel in C, period

2009 October 11 18:40 / 15 Comments / Jakob

stackoverflowlogo250hq2I found this quote in Stackoverflow Podcast #68 quite funny in its extreme dislike of parallel programming in C…

Thanks to the community transcripts wiki:

Spolsky: Quite probably. I mean C is a car, it’s very dangerous – it doesn’t have seatbelts, but it’s very powerful because it goes very fast. In fact, I’d go so far as to say, unless some people are gonna punch me about this one, but you cannot write multi-threaded code in the C programming language. You just can’t. Although technically all the capabilities are there, it is beyond the capability of mortal humans – and I know, some of you out there are very smart and you think that you have the capability of writing multi-threaded code in the C programming language, because you’re hot shit. Well, let me tell you, it is beyond the capability of humans on this planet, for their brains are just not adequate to the task of writing multi-threaded code in most languages, least of all low-level languages like C. It’s just not gonna work, it’s just not gonna make you happy. So there.

The only problem with this statement is that it means we are all doomed: since all operating systems are written in C, and all low-level libraries, it means that we have no way to build the first level of abstraction needed to provide the higher-level primitives for C# and Python and everything else higher up the stack.

But in general, I think this is a fairly true statement for volume programming.

Tweet
Posted in: uncategorized / Tagged: C/C++, Joel Spolsky, stackoverflow.com

15 Thoughts on “Joel Spolsky: You cannot program parallel in C, period”

  1. Evan Carroll on 2009 October 11 at 21:48 said:

    Thanks for succinctly summing this up! People are too stupid to write multi-threaded code in C. This argument by fiat is the most sound, logical, and rational argument by fiat that I’ve seen yet. I’m delighted to finally understood these vivid points you hit on — hopefully someone can do something really great with this constructive advice and revise the C language!!! Thanks Joel!!! U ROX.

  2. Kevin Bowling on 2009 October 11 at 22:13 said:

    Joel,

    You are an idiot.

    OpenMP much?

  3. Astro on 2009 October 11 at 22:22 said:

    You’re confusing parallel & concurrent programming. While parallel programming is very easy with OpenMP and still easy with threads, concurrent programming is the nightmare you are talking about. Asynchronous programming to the rescue, it’s still concurrent.

  4. herp derp on 2009 October 11 at 22:54 said:

    i leave a coment on der paeg.

  5. Machielo on 2009 October 12 at 01:43 said:

    MPI is parallel, and works with C flawlessly. Joel usually goes to the extreme to make his point, but this time he failed.

  6. Paul Betts on 2009 October 12 at 03:59 said:

    Every modern production operating system kernel is written in C, and an OS kernel is the most concurrent environment you could ever program in.

  7. Chauncy on 2009 October 12 at 12:30 said:

    Aren’t the UNIX-like kernels (E.g., Linux, BSD) written in C, aren’t they multi-threaded, and aren’t they very reliable?

  8. f055 on 2009 October 12 at 14:14 said:

    Some programmers are not human, thus this does not comply. Also, concurrency is one of the last areas where your code can be 100% correct and still produce an error in 0.01% situations, and this obviously will appear during the most important moment of the user. Murphy is evil, I tell you.

  9. Jakob on 2009 October 12 at 15:46 said:

    Looks like this post caught fire.

    I think that the truth, if there is such a thing, is not as bad as Joel is making it out to be: C in general is hard to use for parallel programming, but it does seem to be successfully applied in some critical code, by good programmers.

    But as a general programming language for general parallel software, I think there are many better choices than plain C with a low-level API. OpenMP does count to low-level in my book. You want at least a gc, and preferably asynchronous message-passing or similar crash cushions to make it comfortable.

    One size does not fit all, but “size C” does fit some.

  10. henk on 2009 October 12 at 18:23 said:

    It of course depends on the libraries and tools you use. Using the low-level C primitives, which are somewhat associated with native C (even though technically even those low-level primitives aren’t a part of C itself), like Pthreads and fork/join, it is indeed barely possible for mere humans to code parallel.

    Now some higher beings (like kernel coders) might put these to good use, but for the rest of us it’s pretty much a no-go.

    Now move up the concurrency ladder and take a look a higher level frameworks like map/reduce, GCD (grand central dispatch) and the kind of stuff that you find in e.g. Java’s concurrent package. Armed with these tools, concurrent and parallel programming suddenly comes within the reach of use groups of mere mortals.

  11. Tim Berglund on 2009 October 12 at 18:34 said:

    Joel is, per his usual enjoyable style, making an overly generalized, contrarian statement in support of a valid point: C is the wrong choice for almost all concurrent programming. No one writing concurrent code at the application level on a general-purpose server is going to sit down with a diverse toolset and a blank sheet of paper and pick C as his language. They just aren’t.

    That said, his statement is, on its face, false. I know this because I *do not* think of myself “hot shit”—I’ve taken far too many blows on my developer’s back for that!—and I have, in fact, written complex concurrent code in C. It’s some of the most difficult code I’ve ever written, but it can be done. Firmware developers do it all the time. Would it be cool if we could give them tools to work at a higher, safer level of abstraction while maintaining C’s time and space advantages? Yeah! We can afford those trade-offs at the application level on the server, so C is always the wrong choice there. But that’s not because the alternative is impossible; it’s because the alternative is prohibitively expensive in development time and quality.

    Another important point: I enjoy making fine distinctions and elaborating on them at length. Joel likes making bombastic, sweeping generalizations. Lots of people read Joel. Not quite as many read me. Something to think about as we consider this debate. :)

  12. Charlie Martin on 2009 October 12 at 18:34 said:

    Oh, come on, Joel, that’s just dumb. Or, at least, it’s reducible to “parallel programming cannot be done at all”, because if it were possible to parallel program at all, it would then be possible to reduce the components in the magical Parallel Programming Language to C fragments (proof via Turing equivalence.)

    Of course, what you really mean is “conventional programmers, trained in a conventional manner with no special training in dealing with concurrency, find it extremely difficult to write parallel programs that are correct.”

    To which the knowledgeable response is “well, duh.”

  13. Lars on 2009 October 13 at 10:44 said:

    Hey, maybe Joel is not to stupid for this:

    http://macresearch.org/cocoa-scientists-xxxi-all-aboard-grand-central
    http://arstechnica.com/apple/reviews/2009/08/mac-os-x-10-6.ars/12

  14. Andras on 2009 October 15 at 01:49 said:

    Well, consider Cilk. Simple elegant and even an average programmer (and Joel ;-) ) can understand.
    At Ericsson, we write parallel and concurrect programs in C all the time. While it’s not the simplest thing to do, it’s done by average programmers and the very reason you are able to make a mobile phone call is that it works :-)

  15. mireseinspirate.ro on 2013 May 7 at 16:53 said:

    I like what you guys tend to be up too. This type of
    clever work and exposure! Keep up the good works guys I’ve added you guys to blogroll.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Post Navigation

← Previous Post
Next Post →

Recent Posts

  • Wind River Blog: Simics 4.8 is Here
  • A Few Electrons too Many
  • Wind River Blog: Visuality NQ CIFS Server on Simics
  • Everything in the Cloud?
  • Wind River Blog: TCF and Simics
  • Off-Topic: Moving Bad Piggies Save Games
  • Two Cores, Four Cores, Eight Cores – Mobile Variety
  • Bliss: Failing to Pivot for Ideology
  • Wind River Blog and Movie: Demo of Simics Debugging
  • Simulation vs Reality in Schlock Mercenary
  • Programming like Lego
  • Does ISA Matter for Performance?
  • Wind River Blog: Debugging Simics using Simics
  • Wind River Blog: Simics and Flying Piggies
  • Dragons can be Useful – when AT Models Make Sense

Categories

  • appearances (30)
  • articles (21)
  • blogging (10)
  • books (6)
  • business issues (31)
  • computer architecture (35)
  • conferences (34)
  • EDA (50)
    • ESL (35)
  • embedded (78)
    • embedded software (57)
    • embedded systeme (50)
  • general research (6)
  • history (32)
    • general history (7)
    • history of computing (26)
  • off-topic (94)
    • biking (5)
    • board games (1)
    • computer games (3)
    • desktop software (35)
    • food and drink (1)
    • funny (12)
    • gadgets (24)
    • Politics (3)
    • popular culture (5)
    • trains (5)
    • transportation (10)
    • travel (10)
    • websites (3)
  • parallel computing (92)
    • multicore computer architecture (51)
    • multicore debug (22)
    • multicore software (65)
  • programming (107)
  • review (8)
  • security (19)
  • teaching (7)
  • testing (9)
  • uncategorized (12)
  • virtual things (129)
    • computer simulation technology (68)
    • virtual machines (17)
    • virtual platforms (98)
    • virtualization (14)
  • Wind River Blog (40)

Tags

ARM blog commentary Cadence Checkpointing clock-cycle models Communications of the ACM computer architecture conference cycle accuracy debugging DML Domain-specific languages embedded freescale G900 heterogeneous homogeneous IBM Intel iPod lego linux mobile phones multicore off-topic office 2007 operating systems p4080 podcast commentary power architecture rant research reverse debugging reverse execution S4D SiCS Multicore days Simics simulation software tools Sun SystemC video virtualization Vista Windows

1

  • F-Secure Blog

Blogs and news

  • Andras Vajda's blog (on multicore)
  • Embedded in Academia (John Regehr)
  • Grant Martin
  • Jack Ganssle
  • My Wind River Blog
  • Security Now podcast
  • Secworks (Joachim Strömbergson)
  • Simon Kågström
  • Synopsys View from the Top
  • Worse Than Failure

Archives

  • May 2013 (2)
  • April 2013 (1)
  • March 2013 (4)
  • February 2013 (1)
  • January 2013 (3)
  • December 2012 (2)
  • November 2012 (2)
  • October 2012 (1)
  • September 2012 (6)
  • August 2012 (4)
  • July 2012 (4)
  • June 2012 (3)
  • May 2012 (4)
  • April 2012 (2)
  • March 2012 (3)
  • February 2012 (1)
  • January 2012 (6)
  • December 2011 (2)
  • November 2011 (3)
  • October 2011 (4)
  • September 2011 (5)
  • August 2011 (4)
  • July 2011 (3)
  • June 2011 (4)
  • May 2011 (7)
  • April 2011 (1)
  • March 2011 (3)
  • February 2011 (5)
  • January 2011 (1)
  • December 2010 (4)
  • November 2010 (3)
  • October 2010 (5)
  • September 2010 (5)
  • August 2010 (5)
  • July 2010 (6)
  • June 2010 (5)
  • May 2010 (3)
  • April 2010 (4)
  • March 2010 (3)
  • February 2010 (4)
  • January 2010 (7)
  • December 2009 (6)
  • November 2009 (6)
  • October 2009 (7)
  • September 2009 (6)
  • August 2009 (7)
  • July 2009 (11)
  • June 2009 (5)
  • May 2009 (10)
  • April 2009 (7)
  • March 2009 (8)
  • February 2009 (9)
  • January 2009 (12)
  • December 2008 (8)
  • November 2008 (9)
  • October 2008 (9)
  • September 2008 (10)
  • August 2008 (13)
  • July 2008 (12)
  • June 2008 (8)
  • May 2008 (9)
  • April 2008 (10)
  • March 2008 (7)
  • February 2008 (8)
  • January 2008 (5)
  • December 2007 (5)
  • November 2007 (7)
  • October 2007 (7)
  • September 2007 (12)
  • August 2007 (9)
  • July 2007 (2)
© Copyright 2013 - Observations from Uppsala
Infinity Theme by DesignCoral / WordPress