C, The Beautiful Language


They call soccer the beautiful game, and when we watch Ronaldo doing things on the pitch that no earthly being should be allowed to, we understand why.

And yet, to me, it’s not so much the ungodly talent of the superstars that makes the sport such a pleasure to watch, but more the beating heart of the match itself. The slow, ordinary rhythms that come between the highlight plays. The tidal, life-like forces that propel a team toward its goal and the equally strong counter-forces that prevail from the opposite direction.

Watching a good match, I get the sense that the gameplay exists unto itself — that the players are merely agents to it. Soccer is a simple sport. One ball, forty-four feet, two goals, and grass. There’s nothing preventing the living soul of the game from speaking to us directly. We see this and feel this, and we (or at least I) say soccer is the beautiful sport.

When I look at good C code, I feel the same way.

On slow days, I’ll poke around the kernel, sched.c, page_alloc.c, etc., and it very much feels like I’m peering in on a living thing. I can see the code steering the execution, the logic funneling the energy of the program, and even though I’m not a kernel hacker, I can almost get the gist of what I’m looking at simply by watching the way the code “moves”.

In other languages, the abstractions and sweet (if helpful) syntactic sugar that attend the code conceal the heartbeat. But in C, as in soccer, the quickening happens on the ground. A simple syntax, a smattering of keywords, an almost perfect description of a general Von Neumann machine. In C, the spirit of the program speaks to us directly. We see this and feel this, and we say —

C, the beautiful language.

52 thoughts on “C, The Beautiful Language”

  1. C is a beautiful language, I agree. I actually miss reading good C code. I also miss the Borland C compiler. Great stuff. I sold several of the first C programs I wrote (pre-Web). Oh ya, the good old days.

  2. Oil paints vs. water colors to me.

    I’ve worked on many systems in my career. Nothing touches the simple elegance of a well written C program. If for nothing other than performance, the language and the full potential of expression are masterful indeed.

  3. i was thinking what language should i learn, because i was messing around with python html and C. C is such a awesome language, it seems like it has endless capabilities, i think im going to stick with it

  4. Well, you’re right about that. But if you remember that old chestnut about shooting yourself in the foot, C’s actually one of the safer languages to “shoot” with!

  5. C *is* a beautiful language. You will be rewarded many times over by choosing to stick with it. Good C knowledge transfers directly into many other languages and gives you more insight into Unix.

  6. The beauty in C lies in the fact that, unlike so many other languages, it makes no great attempt to compensate for the foibles of the programmer. In simplicity there is beauty and C, for all it’s power, is simple simple language.

  7. Agree totally. There are many ways to achieve something in code, just as there are many ways to paint a picture. Beautiful code falls neatly into each other and cumbersome logic is expressed in the structure of the whole program. Just as the strokes of a painting combine to make the whole picture, the program functions come together to give texture and form to the program. Small wonder Dijkstra called his book “A short introduction to The Art of Programming”.

  8. C rules. I have worked in C a lot and there does not pass by a day when I think why the hell am I not able to do it anymore. Yea, the job.

  9. This is a wonderful piece of writing — thanks for this. For some reason this really resonated with me, even though I’m not much a C programmer 😉

  10. yeah c is a beautiful language unless until if you know the pointers but if you don’t pointers it’s very difficult one…….i asked my friends “how much you know c” every one replied me up to pointer….if any one make easy pointer concept then it’s simple and beautiful….

  11. C is a good language, I have been working with C for about 30 years +, also worked on other languages, if you master C then the others are soooo easier. C is not forgiving but it’s one of the best out there. I still use it most of the time with embedded system and use c++ and c# on other projects for the desktop. I agree with “C, The Beautiful Language” so thanks..

  12. C is a nice, elegant language and thus beautiful. It was designed by people who thought hard about the desirable features of structured languages and keeping things simple. The elegance of C and UNIX shows in all the derived languages and systems.

    However, I have seen some really horrible C code in my days.
    Some people can mess up a really good thing – like that rolls royce i saw with a big lift kit.

  13. Hi,
    I am loving machines. Yes, I can eat(ATM), chat(WEB) and sleep(Mobile) with machine. You can get all,
    when?
    if you known how to communicate with that? so you must learn machine language like C.

  14. I agree, but if we speak about beauty, we must not forget about ladies. We love them for their beauty and not because they are all the time performing well! It is just the same with C language. While we admire a perfect language construct in C, we are using other languages (C# for instance) because the productivity, the level of abstraction and the need for maintainable code is more important.
    To be in love is one thing, but to make a living is another one: we can practice both, but not for the same reasons.

  15. I agree. C is a beautiful language once you get to master it, but the same happens when you master other languages.
    Perhaps this is melancholy.
    How many of the positive comments come from people over 40? I am 😉

  16. Akin to walking into a hardware-store, deciding which tool to get. A screwdriver may be more elegant than a hammer, but there are tasks that require a hammer nonetheless. You need to know many languages, but C is a good starting-point, as many are based on it. If you follow up with a “modern” OO-language, and a functional language, you should have a decent base to build your skills on.

  17. “C” is a criminal language.
    If I had to judge the amount that “C” has cost the world, it would figure in the billions of dollars, let alone “man”-hours.
    Nearly every patch that has been issued, nearly every memory leak that has compromised, nearly every buffer over-run, nearly every security vulnerability has at it’s source, the embarrassingly, childishly, hideously flawed memory model that is: “C”.
    What? No bounds checking whatsoever?
    That is positively CRIMINAL.

  18. My gripe with this post is for using Ronaldo as the analogy
    Ronaldo is not a truly great player, truly great players do the simple pass when that’s what’s the best pass, show for the ball to help a teammate who’is in trouble even it it means getting into trouble themselves, work for the the team. That’s not Ronaldo.
    Messi is a great player he has the lot.

  19. I too learned C with the Borland Compiler, ca. 1992. It had a visual development IDE when Microsoft was still flogging the character-based Programmer’s Workbench.

    The whole C language was described in one chapter of the Borland manual. What a beautiful set of manuals! I still have them. The simplicity and conciseness of the language was a revelation. Unfortunately, not everyone who picks up a chisel will make a David.

  20. Gotta agree with Mr Grayq on this one. It’s 2011 and “C” and it’s ilk are still considered “state of the art” in computer languages. Ugh.

    There is definitely beauty in code. That I’ll agree with. But C as a language is about the last thing I’d call beautiful.

  21. C is an old-fashioned electronics kit. We have all the tools to make anything, but the result is only as robust and safe as the builder creates it to be. Sloppy design and soldering creates various problems, possibly even smoking resistors and power supplies.

    Now, we buy a modern kit. It has nothing but pre-soldered safety pieces with snaps that supposedly cannot do harm even if used foolishly.

    The language is not to blame for sloppy programmers. And it is not criminal to be the ancestor and motivation for all of the routines it is accused of criminal neglect to lack.

    Oh, and for the record, I’ve seen bad programming that avoided the security of bounds-checking routines and other non-criminal safety features to cause similar problems as those that bad C programmers do.

  22. I concur. I do not like the language. Even more so applies to C++ .
    The one thing i can put on the side of the language is it promotes hw architecture understanding more then PHP or Java . But that is it . I prefer assembly for low level stuff and the higher the better level language for high level.

    Countless hours of life spent in debugging { if (a=3)} will never be back.
    And yes i know my ability to program is very limited compared to “real hackers” .
    That is why i like languages that make doing complex things easy , not au contrare.

  23. I hope someone who doesn’t understand pointers isn’t coding professionally. It’s not that one has to manipulate pointers to be a good coder, but understanding the concept is necessary. I mean, there is an analogous concept in most other languages. For example in Java and .NET there are references, which, granted are not pointers, but are logically similar. Just the idea of memory allocation and management, you have to understand that. Sure, garbage collected environments and dynamic languages abstract a lot of it away from you, but if you never figure out why creating a billion objects in a tight loop eats your machine for breakfast EVEN THOUGH it doesn’t cause a long standing memory leak, you’re still in for a world of hurt. So, I hope you, the commenter to which i’m responding, understand pointers, or at least the idea of them. Because you need to. No matter what language you’re using. Black box mentality, no matter what, is best avoided, or at the very least, minimized.

  24. I do miss C and I really miss the Lattice compiler (and Manuals). I could complie C into clean machine code for embedded controllers with that rig.

  25. While you claim “C” is a criminal language without “C” most other languages will not exist. I say this because “C” is often the underlying language on which others are built, or modeled. Of course we could write everything in assembly language now that would be beautiful.

  26. I worked in C for 10 years under VMS and loved it! Having come from an assembly language background, pointers were no problem. I’m quite a bit over 40 and have been programming for 40 years. Of course I’ve adapted and am doing web development now, but get a bit misty eyed at the memories of malloc/free, object code, stepping through instructions…sigh.

  27. That is honestly the least informed argument I’ve ever heard. C made the today’s IT industry possible. If, as you say, C cost billions of dollars in man-hours, it has *easily* saved orders of magnitude more by giving us something better than assembly. Never mind that without C, we have no Internet, no personal-computer revolution, no higher-level languages, no recognizable IT industry.

    I hate to make IT analogies, but this one is too spot on: You are raving against Henry Ford and his his early death-trap cars because they didn’t have seat-belts or airbags, calling him a criminal, all the while silently ignoring the fact that he revolutionized the transport industry and forever altered the course of human history.

  28. C, beautiful? You can’t be serious. Really.

    C used to sport a clean syntax, but like it’s heavier relative, C++, it got ugly pretty quick.
    Why? Simple, because it absorbed features it was never meant to have.

    C isn’t the worst out there. That place is currently taken by Perl.

    But it’s far from the top 5 nice-looking languages out there.

  29. I agree perfectly. Just because there’s an obvious religious monopoly out there doesn’t mean it’s the best option. We should have ditched it when we were in time.

    To the critics, he mentioned bounds checking, overflows etc. Counter that argument and we’ll talk again.

  30. Though learning a language is always productive, it doesn’t make the language good.

    I’ve used C a couple of times, and I’m far from happy with it.

    I’ve been using Linux (nearest to Linux than anything else out there) for quite some time. The UNIX aspect of Linux drives me insane, starting with ridiculous hidden permission, for example.

    Sure, I got to know a lot about that, but I can’t say I’m particularly happy with it. On the same rounds, I’m not happy with Windows either. This isn’t bias, this is simply being realistic.

    Programming languages shouldn’t be praised for their ridiculously bad learning curve, something which C++ and Perl value highly!!

  31. By the same argument, assembly is even more beautiful. No ridiculous compiler optimizations and you know exactly what the computer is doing.

    Well, I’ve used assembly, ‘coz I needed to not for the beauty of it…

  32. Dave, C and C++ make an absolute mess out of pointers. Many languages, including PHP and JS make use of references (as you said) but the concept is represented way better than C.

  33. maybe if someone created a fantastic 50 hour video series about C programming, including which things you must avoid & stuff, some things could be remedied

    complex tools require users who understand them. ‘understanding users’ require appropriate training. ‘appropriate training’ still lives in the future

    this isn’t C’s fault

  34. C could have been a jewel, however there are a few things that could have been better… some things even the authors “regret”…

    just from the top of my head:
    dereference operator * being prefix (it may not seem so, but it would be much better postfix),
    a[] as a relict meaning *a (taken from B or BCPL),
    int as a default return type,
    empty parentheses in a function declaration meaning any number of arguments,
    ‘.’ and ‘->’ could have been one operator (‘.’) with no confusion introduced,
    0, NULL, (void *)0 mess,
    #include system (compare to e.g. google go and similar approaches that were implemented in other systems long time ago),
    nested functions (they are in gcc) would be helpful…

    type system could have been better, and type specification could have been more transparent, but these are much more subjective

  35. C may be a beautiful language but what about OOP? C++ supports OO but is not purely OO. Why not stick with a modern language like C# or Java?

  36. I suppose you are going to tell me that C is good for kernels, drivers and the like, well use, but is low level more beautiful than high level? Perhaps you see beauty in simplicity? However, seeing the structure of a good modular class hierarchy can also be beautiful.

  37. well… you learn C once (and maybe some platform-specific extensions, if later needed), but you learn new assembly every time your target platform is changed… C has some standard libraries as well…
    Good luck to learn all those tricky behaviors of modern CPUs as well (something a C compiler can take care of)…

  38. Counter what argument. That there is no bound checking? Overflows? Memory leaks? So naive. What language do you think they used to write all the bounds checking and overflow checking in your favorite language?

    You should not let your ‘religious’ bias get in the way. If you really want to excel at software you need to open you mind and not listen to the language peddlers at all. Learn C, appreciate C and you will become a better programmer. The same goes for assembly language (with BTW is also *not* machine language.)
    If the space shuttle hits my house I won’t care if it was because of a bad pointer, feet passed into a function that expected meters, garbage collector kicking in at the wrong time, a memory leak in some Java code caused by a stale reference, or some bonehead that things you can just add up a bunch of floating point numbers and use the result… The real danger is someone who does not know what they are doing no matter what language they are using.

  39. You can write bounds checking into C, I’ve done it before … and put it on a switch so I could turn it off and not suffer the performance hit. Unlike today’s languages where the performance hit is built in.
    But, let me just say … Large Object Heap. You can’t control it, you can’t compact it. Almost a guaranteed out of memory exception for a long running program that uses large memory blocks.

Comments are closed.