Internet Technical Bookshop

Books and Reources for the Sciences and the Arts

Beginning Programming Books Part 2

I was in a bit of a dither in deciding whether to go down the C/C++/C# route or to go down the Java route for this second part of the beginning programming series. In the end I decided, for Part 2 to go down the C/C++/C# route. Why so ?

Since my thoughts are to a signifcant extent concerned with the theme of programming as a second career I chose these languages because I think that they have a most interesting career potential. Let me explain a bit more. There is much interest nowadays in the Internet of Things (IoT). Most of the small gadgets / widgets that populate the IoT space are embedded systems, and these are programmed in C. These small systems, unlike Workstations and the larger server machines which run things such as databases and web servers, for example, are called embedded systems. They have smaller processors on board which are called micro-controllers, and have relatively small amounts of memory (tens to hundreds of Kilo Bytes (KB)). By and large the code that runs on them is written in the C programming language. This is why learning C can be the start of a very interesting programming career.

In an earlier scribend about the history and importance of C I introduced some introductory books for learning C programming. Over several decades of teaching C programming I have found that, though initially, C looks easy it is, in fact a very subtle language that one learns to appreciate over several years of programming. C++ was, originally, developed as an extension of C by Bjarne Stroustrup. It is an object oriented programming language that builds on top of C. The first C++ standard took some time to materialise. More recently the C++ standard has been extended and modernised, and most modern C++ compilers support the C++11 standard. Further developments have led to the C++14 and C++17 standards.

C# was developed by Microsoft in conjunction with the development of the .Net framework. Rumour has it that is was meant to be a "better Java than Java", and, in all fairness it does have some nice features. The implementation of C# for Linux systems is called Mono, and it does a pretty good job of playing catchup with all the new features Microsoft keeps adding to C#. Once again, knowing the syntax of C is useful when learning C#. Knowledge of C# programming and .Net is essential for anyone aspiring to develop applications on Microsoft Windows platforms. Full proficiency requires mastery of various Microsoft frameworks such as WPM (Windows Presentation Foundation), WCF (Windows Communication Foundation) and ASP.Net, as well as the Microsoft MVC framework.

Beginnning Programming Part 2a - C Programming

If planning on a career developing embedded systems and IoT (Internet of Things) applications learning C programming is essential. For complex applications running on Linux and Unix C++ programming skills are in considerable demand, and C++ is becoming more widely used in implementing embedded systems applications. In the computer games world C++ programming is very much the language of choice e.g. your scribendist ran several C++ programming courses for King (the makers of Candy Crush) who switched many game developers from Action Script programming to C++ for performance reasons and the ability it gave developers to write complex and maintainable code efficiently. Interestingly we also ran a C++ unit testing course for them as well.

Learning C out of a book is not as easy as it sounds. Over quite a number of decades teaching C programming courses a common scenario in introductory C programming courses is the following ... " I started teaching myself C from a book / web links and then ... (a silence descends on the class .. and a wee shiver) .. I started on "pointers". If there is any area of C programming that causes "fear and anxiety" in relative beginners it is the area of "pointers and dynamic memory management". Yet it is precisely this aspect of C that gives it its power and versatility. Then, for the very brave and the more advanced there is the subject of "mixed C and assembler programming". Mastering C does not, to most of us come easily. If you are a "timid" programmer, like me, who literally "suffers" when compiler errors are displayed, or a program that compiled with no errors or warnings crashes and emits a "core dump" you will apreciate the assertion that mastering C takes a number of years ... and probably you never really master all its subtleties fully, even if you explore the art of implementing a C compiler in C. The good news is that C programming can be mastered. However, do not be seduced or impressed by "glitzy commercial web sites" that claim that by attending an intensive 12 week workshop in some "fashionable and luxurious venue" you will become a one of the "Jedi of the C programming world" and be able to command princely salaries and freelance consultancy fees. There is a great need for C programming skills, especially when it comes to developing IoT (Internet of Things) applications and there are good salaries to be earned. However, embedded software development is not the world of "high finance and international banking" which, as well as ability exploits the advantages of influential connections, education at top private schools and top Oxbridge and Ivy League colleges and business schools. The problem with aspiring to mastery of C programming is "where to begin".

Embarking on a pilgrimage to master C programming

Nowadays I recommend learning C by developing C programs on a number of different platforms. These should include

  • Regular PCs and laptops running MacOSX, Windows or Linux
  • Arduinos
  • BBC Microbit
  • Embedded Linux systems such as e.g. the RaspberryPi and the BeagleBone Black

There are many aspects to become a competent C programmer, as demonstrated by the various courses run by Cloudy Apps Training and The Training Arm

Nowadays the main area where C programming expertise is in demand is in developing embedded systems applications. This requires, typically, not just an understanding of programming but also an understanding of how to interface various devices such as motors, servos and sensors to a microcontroller. The other area where C programming is important is that of developing embedded Linux applications and the implementation of device drivers. Embedded Linux programming will be covered in a later section.

General Introductory or not too advanced specialised C Programming Books

The books in this section provide an introduction to C programming without delving into the details of embedded systems application development.

Arduino Programming Books

The Arduino was developed, originally, as a means for enabling the creation of interactive art installations. The Arduino IDE was based on the Processing IDE which, itself, was designed to enable artists to create interesting graphics displays in a language called Processing, without needing to be skilled in advanced graphics programming frameworks such as OpenGL.The history of the Arduino project and the early Arduino prototypes is quite fascinating. I only realised the ideological implications of the thinking behind the Arduino when teaching Arduino programming and marking assignments for working engineers taking a "foundation year" degree module at Carshalton College. They found programming very difficult, yet the practical projects they built were "gems of craftsmanship". This "epiphany" made me realise that software systems and software are tools that should be usable by craftsmen - hence "artisanal computing". The Arduino is programmed, essentially, in simplified C++ i.e. mostly C with a bit of C++ and libraries containing methods that hide much of the underlying low level detail needed to program an Arduino application. Learning to program an Arduino should provide inspiration and ideas to tackle larger and more complex projects. It can also serve as a stepping stone to being inspired and motivated to put in the effort to really master C programming. Not that long ago the head of IT for EMEA for a major "fizzy drinks manufacturer" booked an intensive Arduino programming course from Friday through to Sunday. As he put it "When I follow the various Arduino recipes I can build something that works. When I try to design a project of my own from scratch it seems to be a total failure". Another Arduino course I ran, which also explored serious Arduino C programming, was for a charismatic first year 6th former (year 12) and his younger brother planning to set up a robotics club at his school. Yet another Arduino course was for "some government employees from the Middle East" interested in using Arduino based sensors for monitoring applications which ended up as a moderately advanced embedded C programming course. The path from Arduino to C is quite a well trodden path and starting programming with an Arduino can be a good way to get started with C programming. The following books are all readable practical introductions to Arduino programming. The one by Mike McRoberts is really helpful. Mike used to put together Arduino kits and I got to know him through reselling his kits. They have since been overtaken by cheap kits manufactured in China and distributed by companies such as Seeed. Jack Purdum's book on beginning C for the Arduino serves as a good introduction to C programming centred on programming Arduino devices.

More advanced and specialised C Programming Books

Developing more advanced C programming skills involves, typically,

  • Studying more advanced data structures and algorithms implemented in C
  • Studying operating systems Application Programming Interfaces (APIs) implemented C
  • Studying mixed C and assembler programming of various target microcontroller architectures

Data Structures and Algorithms in C

Loudon's book on Algorithms in C is an excellent resource, especially when combined with related books published by O'Reilly such as Understanding and Using C pointers and, for coverage of recent developments in the C language Klemens' book 21st Century C.

Other classic books on algorithms and data structures in C are those by Robert Sedgewick, Thomas Standish, Mark Weiss and by G. Gonnet. Binstock's book on practcial algorithms for programmers contains some useful implementations. Skeppstedt and Soderberg's book on writing efficient C code covers recent developments in the C language standards and is more than just an introduction.

Micrcontroller Programming in C

The following is a list of widely used microcontrollers including 8 bit, 16 bit, and 32 bit microcontrollers.

  • 8051 microcontroller - a classic 8 bit architecture still in use
  • Atmel 8 bit AVR - the original processor used in the Arduino
  • Microchip 8 bit microcontrollers - PIC10, PIC12, PIC16 and PIC18
  • PIC24 and dsPIC - Microchip 16 bit microcontroller families
  • PIC32 - Microchip's 32 bit processor family - based on the MIPS processor architecture
  • ARM Cortex M0, M3 and M4 - widely implemented 32 bit ARM microcontrollers designed for embedded applications
Many books on C programming for these various microcontrollers have been published. The ones that have been widely used when researching and developing training materials for FTT and related embedded systems programming courses. In the case of books covering C programming of Microchip microcontrollers it should be noted that in the last 5 years Microchip has moved to a new integrated IDE called MPLABX and has developed a consolidated range of C compilers for its PIC microcontrollers. These are XC8 for 8 bit microcontrollers, XC16 for 16 bit microcontrollers and XC32 for 32 bit microcontrollers. These are available in free versions which lack the full compiler code optimisation features and commercial versions which provide full code optimisation. For learning purposes the free version is, generally sufficient. The older PIC programming books use older versions of compilers. Generally porting examples in these books to use the new Microchip C compilers is not too difficult, and the older books contain a wealth of knowledge and experience and many useful examples.

8051 Microcontroller Programming

Atmel AVR 8 bit Microcontroller Programming

PIC16 Microcontroller Programming

Chuck Hellebuyck's books on Embedded C Programming are useful introductory books covering C programming of Microchip's family of 8 bit microcontrollers. Though aimed at the hobbyist market (e.g. readers of the Nuts and Volts Magazine and Elektor) they do provide a good overview of many aspects of programming embedded systems in C. They do, however, need updating to cover recent developments in Microchip's new MPLABX IDE (Integrated Development Environment) Microchip's XC8 C compiler and Microchip's Code Configurator tool.

For those requiring serious professional training in embedded C and assembler programming of Microchip 8 bit microcontrollers FTT has, for over 20 years now, been running courses for programming PIC16 and PIC18 microcontrollers. These courses are also available as distance learning courses.

The PIC18 was developed by Microchip to extend the capabilities of the PIC16 and is widely used in many industrial and engineering applications. Probably the best book covering programming the PIC18 Microcontroller, and, also, an outstanding book on embedeed systems programming in general and programming of 8 bit microcontroller systems in particular is is Sid Katzen's The Essential PIC18 Microcontroller (Computer Communications and Networks). This too needs updating to cover MPLABX, XC8 and Code Configurator. It is, however, quite an expensive book and so only for the very serious programmer.

PIC24 and dsPIC Microcontroller Programming

These are the two Microchip families of 16 bit microcontrollers. The PIC24 is designed for standard industrial control applications, whereas the dsPIC is more complex and includes hardware support and an extended instruction set for carrying out digital signal processing computations.

Probably the most comprehensive book concerned with PIC24 programming is that written by Bryan Jones and colleagues and which is used in course ECE 3724 - Microprocessors at the University of Mississipi. It is very good value for money and very thorough. Programming 16-Bit PIC Microcontrollers in C by Lucio Di Jasio is also a good book. The second edition does cover the use of MPLABX. Lucio Di Jasio has had a distinguised career with Microchip and has much experience which has been distilled into some of the interesting and challenging projects covered in this book. The book is backed up by a website containing many further resources. Also worth having is Thomas Kibalo's introduction to PIC24/dsPIC33 programming. It focuses on the PIC24 architecture. However, code that does not involve use of DSP processing instructions is essentially the same for both the PIC24 and the dsPIC processors.

The First Technology Transfer courses oriented towards the PIC24 and the dsPIC processor families are shown below.

FTT Microchip 16bit Microcontroller Courses

These courses are typically taught as instructor led courses, but are also available as distance learning courses.

PIC32 Microcontroller Programming

The PIC32 microcontroller family is the top end of the Microchip microcontroller families. These are 32 bit processors that are based on the MIPS processor architecture. The high end members of the PIC32 have maths floating point units and are DSP capable processors. Over the coming years now that Microchip owns Atmel and, therefore, controls the Atmel AVR and Atmel ARM brands it will be very interesting to see how all these brands evolve and are further developed. It is worth bearing in mind that ARM itself is now in Japanese ownership and there have been rumours that it may, at some point in the future be sold to a Chinese company. This suggests that developing both MIPS and ARM based microcontrollers may have strategic advantages for Microchip. We certainly live in "interesting times".

I think that, currently, the most thorough and well thought out book on PIC32 programming is that developed out of the work at Cornell University by Kevin Lynch and his colleagues. The book and underlying course material is oriented around the NU32 board, and this aspect has been criticised in several reviews. However, I suspect that the reviewers are not approaching the book as engineers or as developers of course materials. Lucio Di Jasio's book on programming the PIC32, though it needs some updating is still a very good book. It was one of the first books to provide serious examples and approaches to PIC32 programming in C. Bill Petrick's book on working with Microchip's Harmony MPLABX tool for developing PIC32 real world applications is, to the best of my knowledge, currently the only book on this subject. Harmony is a very interesting tool that tries to take care of the hard work of configuring device driver code for particular PIC32 microcontrollers and which also provides support for the implementation of multi-tasking applications,including those using real time operating systems such as FreeRTOS.

The First Technology Transfer courses oriented towards the PIC32processor family are shown below. These are instructor led courses, however, distance learning based variants of these courses are available.

FTT Microchip 16bit Microcontroller Courses

ARM Cortex M0, M3, M4 Microcontroller Programming

The books selected here have been chosen based on research and development work carried out by FTT when developing its ARM Cortex M embedded systems courses. Course materials have been adapted to use various development tools such as those from Keil, IAR, Atmel and Atollic. These devices are widely used in the development of IoT devices. The BBC Microbit, itself, is based on an ARM CortexM0 core. Books dealing with the BBC Microbit and IoT programming will be covered in a later section.

The First Technology Transfer courses oriented towards the ARM Cortex M processor families are shown below. These are instructor led courses, however, distance learning based variants of these courses are available.

FTT Microchip ARM Cortex M0, M3, M4 Microcontroller Courses