What's the best C/C++ course for someone like me? - Embedded.com

What’s the best C/C++ course for someone like me?

As I've mentioned on many an occasion, I am a hardware design engineer by trade — I am in no way a paid-up member of the software cognoscenti — so when it comes to creating code, I'm largely reduced to making things up as I go along (see also Coding tips & tricks for LED ring lighting effects).

The thing is that I seem to be doing more and more coding these days for projects like my BADASS Display and my Cunning Chronograph. I can’t tell you how many times I've devoted hours to wrestling a recalcitrant program into submission, ended up with something that looks like the software equivalent of a dog's dinner, and then had a more experienced programmer glance over my grizzly effort and replace my convoluted constructions with a few elegant and succinct lines of code that have left me awestruck and gasping in delight.


(Source: pixabay.com)

“Enough already!” I cry. It's time for me to send the butler out to fetch my programming trousers and, while I'm waiting for him to track them down, for me to take a C and/or C++ course. If I had a choice, I'd prefer to attend a live presentation because I personally learn a lot faster when I have someone to question about stuff. However, there's also the time and hassle associated with leaving my office and attending such a course, so I guess we're reduced to online training.

“I see,” said the blind man…
Let's start with C, which is the language I predominantly work in these days (in addition to multiple assembly languages, I used to play with BASIC, FORTRAN, Pascal, and Forth in the days of my youth). I'm sure there are lots of courses for absolute beginners, but I think I'm a bit beyond that, and starting at too low a level would bore my socks off. On the other hand, I know that there's always something new to learn. Take a simple for() loop, for example. I'm really comfortable with something like the following:

for ( init; test; update ) {   statement(s);}

Where the init step, which is executed first and only one time, is used to declare and initialize your loop control variable; next, the test step is performed and, if the result is true , the statements in the body of the loop are executed; finally, after the body statements have been executed, the update step is used to modify your loop control variables. Based on this, I'm used to creating for() loops like the following:

for ( i = 0; i < 10; i++ ) {   // Do some clever stuff}

However, I only recently discovered that you can have multiple actions defined in the update portion of your for() loop; for example:

for ( i = 0; i < 10; i++, j-- ) {   // Do some clever stuff}

I think it's safe to say that this little nugget of knowledge has opened my eyes to all sorts of possibilities. Also, it's caused me to think of all sorts of questions, such as “Can I have multiple comma-separated init actions?”

So, based on all of this, what would be the best online C Programming course (free or fee-based) for someone like yours truly? If you have any recommendations, then I would really appreciate hearing them in the comments below.

To C++ or not to C++?
When I originally started playing with the Arduino, I vaguely believed its programming language was C. However, I quickly discovered that a lot of the libraries I'm using are written in C++, which leads to usage models different from the ones I expect. (I seem to recall hearing that C++ embraces C, but I'm not sure if this is really the case or not — any input here?)

Take Adafruit's NeoPixel library, for example. Once you've declared a NeoPixel element and given it a name like myRing , you can perform a variety of commands like:

ring.begin();ring.setPixelColor(1,255,255,255);ring.show();

This ring.xxx() notation is not something with which I'm familiar. Obviously, I can use these statements without fully understanding the underlying syntax, but it niggles me when I don’t know how stuff works. Sad to relate, when I actually look inside these libraries … well, some of the syntax I see makes my eyes water.

Again, I'm open to suggestions here. Should I first focus on becoming more proficient with C, and then think about moving onwards and upwards to C++? Alternatively, if C++ does indeed subsume C, would it be better for me to plunge headfirst into C++ and hope to pick up the understanding of C I'm currently lacking on the way?

36 thoughts on “What’s the best C/C++ course for someone like me?

  1. “Not an easy question, but judging by knowing who you are (electronics/embedded/FPGA uber-guru) I would say you need an ultra-fast -paced C++ course, with no freshman-level matter like “number systems” or “boolean logic” occupying half of the course.

    Log in to Reply
  2. “Thanks for this advice — I'm going to wait to see what the general consensus is and then I'll take whatever course rises to the top of the pile — also, I'll talk about my progress in future columns.”

    Log in to Reply
  3. “I would recommend a free course from coursera. It was great for me, it is for C++ programmers that have a C background. I didn't know how many things C++ adds on top of C before I took this course. It is definitely a good course for your current position.

    Log in to Reply
  4. “MaxnnI, like you could do with training with in many aspects of programming, C++ and Java (especially when I was working with Android) but who provide courses within the necessary slant towards electronics and control. If you don't have the slant then

    Log in to Reply
  5. “Hi Aubrey — with regard to having the “i++, j–” both located within the for() statement — I was made aware of this by someone who was offering a suggestion to a programming problem I was having with my BADASS Display.nnFor this particular example,

    Log in to Reply
  6. “Hi Max,nI've gone through the same “hardware guy trying to (re)learn C/C++” thing over the past two years, and it's been great fun.nI don't have a course to recommend, but had a couple thoughts…nAn initial consideration is if you just want to lear

    Log in to Reply
  7. “Hi Max,nI'd like to recommend my “Embedded Systems Programming” video course. With over half-million views and over 10K subscribers, this is probably the most popular such course on YouTube. Here is the playlist:nnhttp://www.youtube.com/playlist?l

    Log in to Reply
  8. “Hi Miro — thanks for this suggestion — I'll certainly take a look at your videos — but I'm not sure this is for me. My first job was on a team designing CPUs for mainframe computers — we were designing at the gate and register level using pencil and p

    Log in to Reply
  9. “Max,nPutting the j– in the control loop may also help the compiler's optimizer give you more efficient machine code.nAlso, the answer to you question – “Can I have multiple comma-separated init actions?” – is YES.”

    Log in to Reply
  10. “Very interesting and very cool — one more question — can the test be a complex compound test with multiple operations linked by Boolean operators — anything that can ultimately return true or false?nnAlso, is it possible to have multiple comma-separa

    Log in to Reply
  11. “@Antedeluvian…I'm a C virgin (but have messed around in a few other languages). Ref your statements above… I'd presume that j– means “decrement j” – fair enough – but in the for statement i is initialised (to 0) but not j – will this work? And c

    Log in to Reply
  12. “I found a little pocket book published by O'Reilly “C Pocket Reference C syntax and fundamentals”. This little beauty often digs me out of a hole or answers my immediate question. Main problem with nearly all code what ever language, is that coders fail

    Log in to Reply
  13. “MaxnnThe best way to get good at writing embedded C code is to not write embedded C code first. Write other C code instead, then come back to embedded.nnMost embedded systems code is really bad – particularly the stuff that comes from vendors. The mai

    Log in to Reply
  14. “Hi AntedeluviannnI think it is one of those “it depends” things.nnIf the i++ and j++ are independent, then I agree – keep them seperate. However if they are always lockstepped then I would disagree because they should be incremented together.nnYou

    Log in to Reply
  15. “”Also, is it possible to have multiple comma-separated tests?”nnTo answer that it is best to dig down to what the comma operator actually does.nnhttps://en.wikipedia.org/wiki/Comma_operatornnSo all calculations of the list of tests will be per

    Log in to Reply
  16. “Thanks for the feedback — I fully agree with your point about focusing on learning good C first, then worrying about creating embedded apps later — and similarly for C++”

    Log in to Reply
  17. “Re the comma as an operator vs a separator — I just read:nni = (a, b); // stores b into i n // … a=1, b=2, c=3, i=2nni = a, b; // stores a into i. Equivalent to (i = a), b;n // … a=1, b=2, c=3, i=1nnOMG — I ha

    Log in to Reply
  18. “Max,nnI am self taught programmer since the age of 5 with many languages under my belt. In-retrospect, at their core programming languages are pretty much the same. French and German are both different language, but are used to convey ideas, and or newe

    Log in to Reply
  19. “Hello Max,nnWhen I started working with Arduinos, I thought I already knew enough about C programming to actually go and check the libraries that came with it. I thought wrong. I realized that even though I knew how to code C, I did not really know how

    Log in to Reply
  20. “Hi there — thanks for taking the time to comment — in fact I've signed up for a course, bought an associated kit, and bought a book — I'll be talking about all of this in a follow-up column later this week (watch this space :-)”

    Log in to Reply
  21. “The comma operator has no known uses that is not obfuscation, and should be avoided at all times. Like many of the bad things in C, you have to know about it to understand it in other people's code – but don't use it in your own code. That also applies

    Log in to Reply
  22. “If bad coding style helps the optimizer, get a better compiler if possible. But good clear coding trumps optimisation in almost every case – it is better to put the “j–” outside the control loop even if that results in bigger or slower code.n”

    Log in to Reply
  23. “Just a general point about C++ – if you are going to learn C++, make sure it is C++11 (or even C++14, as supported by several major compilers). C++11 is a much better language than C++98 or C++03 for many reasons – it is a very significant change, and ca

    Log in to Reply
  24. “Hi there — I'm already going through one course (which I'll be discussing in a future column) — but when I finish that, I'll circle back and look at the CS50 course you recommend”

    Log in to Reply
  25. “I don't know any good books, I'm afraid – it's a long time since I learned C originally, and since then I have learned from experience, examples, web sites, Usenet groups, etc., rather than books. In the C++, there are some well-known gurus (such as Bjar

    Log in to Reply
  26. “For both C and C++, there have been a number of revised standards over the years. Technically, “C” and “ANSI C” refer to the current standard (C11), but in practice “C” is used as a general name and “ANSI C” is used as a synonym for C89/C90 (whi

    Log in to Reply
  27. “I used to like “int” — but I know it's platform dependent — I hate the look of “int16_t” but there's no ambiguity about what it means. Also, using something like “uint8_t” cuts down a teeny-weeny bit on memory usage as opposed to simply using “in

    Log in to Reply
  28. “The Arduino uses an AVR, which is an 8-bit processor. It is significantly more efficient at handling int8_t and uint8_t types than 16-bit or bigger types (int is 16-bit on the AVR). So usually when programming AVR's, it makes sense to use uint8_t for sm

    Log in to Reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.