Thought Leadership

C is great, but…

As I am still off on my vacation, we have another guest blogger. This time it is Meador Inge, a member of the Mentor Graphics embedded software products engineering team, who, just like Scott last week, has chosen a subject that interests me greatly and, by coincidence, picks up on theme that I highlighted recently. -Colin

C is great, but C alone makes you a bad programmer. My introduction into computing started in a desktop-centric world. My first love was programming languages and I was fortunate enough to spend several years of my professional career working on compilers. As such, I came to value more the concepts that a programming language can offer rather than the instantiation of a particular concept in a particular programming language…

With this love of programming languages in mind my life took a very strange turn when I started to delve into embedded programming for my work. I know the C programming language quite well, which is good, because that is all we really use in my workplace. In fact that is all that several people I know in the embedded programming community ever use and ever want to use.

On top of that, you typically find embedded programmers using a stricter form of C. Sometimes I think I am living in some sort of programming bizzaro world where function calls (well, abstraction in general) are evil and macros and global variables are the bee’s knees. The mere utter of the word recursion would probably get me fired (which is sad, because this is probable one of the most fundamental CS skills).

I can’t imagine what would happen if I wanted to use a real programming language with concepts such as first-class functions, closures, duck typing, reflection, and garbage collection. It wouldn’t be pretty. And, yes, I do understand the resource constraints of an embedded environment. However, resource limitations should not limit you from exploring other options even if you can not apply those options.

Who knows, maybe a language with some of these features could be applied in an embedded context in some limited form. If I take the stance from the get-go that these features are bad things, then I am limiting my options.

I am probably going to have to live with the fact that more powerful programming languages will not be used in most embedded projects. I do, however, encourage folks to go out and learn other languages in their own time. Learning a new computer language is about learning new concepts, concepts that transcend any language alone.

C is great. C is something that every programmer should learn at one point in time. C alone may make you a wizard embedded programmer, but C alone will make you a bad programmer.

Colin Walls

I have over thirty years experience in the electronics industry, largely dedicated to embedded software. A frequent presenter at conferences and seminars and author of numerous technical articles and two books on embedded software, I am a member of the marketing team of the Mentor Graphics Embedded Systems Division, and am based in the UK. Away from work, I have a wide range of interests including photography and trying to point my two daughters in the right direction in life. Learn more about Colin, including his go-to karaoke song and the best parts of being British: http://go.mentor.com/3_acv

More from this author

Comments

0 thoughts about “C is great, but…
  • What’s interesting to me is that I came from the other side of the fence where we’re used to more dynamic languages, garbage collection, fancy IDEs, etc. and to me, we’re missing some of the things that you C programmers (especially the embedded guys) take with a grain of salt.

    This is particularly evident with things like performance comparisons of one language versus another which usually boils down to the fact that “modern” programmers don’t really know computer science at all and are horrible implementors. It’s kind of like the difference between knowing the syntax of English and know how to write well. Of course in the embedded world, you can’t just allocate memory willy-nilly and chew up all the CPU cycles you like.

    Oh well, I guess the grass is always greener.

  • Dear Sir,

    I stumbled on to this blog post today, and I’m very glad i read it.

    I am not a good programmer. I know it. Most others know it. But unfortunately for me I have a great passion for programming. And over the last couple of years I have had a taste of C, C++, Python, PHP, Perl, and even a painful language called MHEG (for Digital TV).

    I am very keen in learning embedded systems – which was sadly not part of my undergraduate education. I have been rejected from many Embedded Developer job interviews, with responses like “you have good system skills, but you lack embedded programming skills” or “you can write C programs but NOT for Embedded systems”.. which is very painful to hear.

    So after after working 1 year as a Junior C programmer, I have decided to do a Masters specialising in Embedded Systems, in the hope that it may help me to get into the Embedded Systems field. One of tools I have found out that we will use is ModelSim from Mentor Graphics.

    I am however a bit scared – as I’m not sure how I will perform. So many job rejections have demotivated me.

    I have tried to learn embedded C programming on my own, but have failed miserably. I wish to ask you, as a complete beginner – what steps should I take to learn programming for embedded systems ? Are there any books you recommend ?

    I always thought, people who don’t code in C are not real programmers, but your article has certainly changed my perspective in things.

    Many Thanks
    Rosh

    • Rosh.
      I am not sure what to suggest. There are certainly quite a few books that you might read, but the course you have enrolled on should be driving you in the right direction. However, I am very concerned that you ModelSim, as that product is nothing to do with embedded system programming – it is for hardware design. You really need a course specializing in embedded software, not embedded systems.

  • Rosh, I would respond to your post.

    My background was similar in one way and different in others. I was/am good with hardware, but didn’t have much software experience.

    My C programming experience (as I had only previously done embedded programming in assembly) came by accident after fixing a ROYAL screw-up on an embedded board by an outside “consultant.”

    Since then I have done the following to enhance my embedded design experience:
    1. Purchased low-cost microcontrollers and/or development kits and programming tools
    2. Used low-cost or free compilers specific to those devices
    3. Wrote test programs or compiled and programmed demo code by the manufacturer

    …and after much work…and studying books purchased from Amazon, and reading on the internet…

    I came up with several embedded design projects at home (typically Microchip PIC-based) and got them working.

    Then I entered manufacturer-sponsored design contests to force me to work hard to design, understand, and succeed with REAL design challenges.

    I will have to say that for embedded systems, a C compiler with decent documentation will help A LOT because the compiler manual will describe how items are implemented in hardware.

    You will learn by DOING.

    I purposely documented my designs with photos, documentation, and well-documented code for demonstrating competency to potential employers.

    🙂 Best of luck-I’m moving from hardware-only and really want to work regularly in embedded software as well.

Leave a Reply

This article first appeared on the Siemens Digital Industries Software blog at https://blogs.sw.siemens.com/embedded-software/2009/11/16/c-is-great-but/