When Only C Will Do

or at least when you should seriously consider it

Andrew Stitcher

Red Hat


  • What I'm not saying
    • C is suitable for everything
    • C should be more widely used
    • Anything fundamentally new
  • These considerations are practical
  • I may make mistakes


  • C is supported everywhere
    • Tiny embedded controllers
    • Mobile phone handsets
    • Desktops
    • Servers
  • CPU Manufacturers usually support C first
  • GCC supports very wide range of CPUs
  • Well optimised

Low level

  • Close to the underlying machine
  • Doesn't hide or add much
  • Not very much built in

Portable Assembler

  • Library fallback code
  • Target "compiled" language for DSLs

Plugins/Foreign Function Interfaces

  • System itself was likely written in C
  • C ABI is very simple
  • Includes scripting langages
    • Python
    • Ruby
    • Perl
    • PHP
    • lua
  • JVM's JNI

What about C++?

  • Pro
    • C++ superset (nearly) of C
    • GCC also supports C++
  • C ABI is de facto platform standard
  • C++ ABI very complex - less likely to be standardised
  • Multiple C++ libs may not coexist in same executable

"Social" Reasons

  • C is most popular open source language by far
  • 40% of Open Source release last year was C
  • Next was C++ with only 15%, then Java with 7.5%
  • So using C gives you the largest pool of developers


  • Open source (Apache project)
  • "Messaging middleware"
  • Uses standard open protocol AMQP
  • Client - server

Qpid: What our users want

Qpid: Language Support

  • Qpid currently supports
    • C++
    • Java
    • Python
    • ruby
    • Perl
    • .Net
  • Platforms
    • Linux
    • Windows
    • FreeBSD (soon)

Qpid: Implementation

  • Three (3!) separate implementations of AMQP
  • C++, Java, Python
  • SWIG C++ for bindings to Ruby and Perl
  • .Net has hand written bindings


  • Protocol revisions
  • 0-8, 0-9, 0-9.1, 0-10
  • Maintenance effort too high

AMQP 1.0

  • AMQP now has a proposed international standard
  • Will be 1.0 version
  • Very different from previous protocol versions
  • Don't want to implement/maintain 3 protocol implementations
  • Domain of use has opened up
  • Decided to implement 1.0 protocol engine in C


  • There are still good reasons to use C even in a new project
  • But these are probably not the majority of things being programmed today
  • Consider C when
    • Coding libraries for wide use
    • Code that needs to run on many different platforms
    • Open source