C: From Theory to Practice, 2nd Ed

Author: Dr. George S. Tselikis & Dr. Nikolaos D. Tselikas
Publisher: CRC Press
Pages: 716
ISBN: 978-1138636002
Print: 1138636002
Kindle: B00I60MUIQ
Audience: Potential C programmers
Rating: 3
Reviewers: Harry Fairhead & Ian Elliot

C is still a very important language and perhaps still growing in importance because of the IoT.

The big problem with C is that there is a well known "best book" in the form of the original K&R introduction - see the side panel for the second edition.  However, K&R is terse and some criticize it for being a bit dated. This is a book that is easy to compare to K&R in that it adopts the same dry style of presentation and it doesn't really go in for discussion or talking around the topic. It might be terse in this sense, but it has a lot of pages - over 700 - and it is a substantial book.

One of the great advantages of K&R is that it is short and easy to use as a refresher if you are already a programmer. A great deal of the space in this volume is taken up with 500 exercises with solutions and some unsolved exercises. In this sense the book is good for self study or as a course text, but there is more to know before you choose.

 

Banner

 

Chapter 1 is an introduction to C and it is where you write your first program. No IDE or explicit environment is used or explained. If you really are a beginner then you are going to have a hard time getting started. Doing things from the command line is fine for small programs but an IDE is so much more productive.The whole topic of how you get started with compiling a C program is  reduced to:

Many companies (e.g. Microsoft and Borland) have developed C compilers for Windows, while one of the most popular free compilers for Unix/Linux is gcc.

After this gcc is used as a command line example. The problem is that gcc is not installed by default under Windows and no guidance on how to get it is given. This is easier since the introduction of the Windows Linux Subsystem but if you are a beginner and need this book then you are going to need some help. If the book is being used as part of a course then presumably the development environment will be set up and this is then less of a  problem. If you are a lone reader make sure you know where your C compiler is coming from before buying this book.

Chapter 2 deals with data types and its not really logical in that we have floats and doubles being used before the whole idea of data representation is introduced. Do we really need to confuse the beginner with an example of why you shouldn't compare floats or even doubles with equality so early? There is much to learn and this sort of important idea is likely to make more sense later. We also have an almost encyclopedic examination of printf() - great for a reference but not so much for an introduction to C. Scanf is next, in Chapter 3 and it is another in-detail look at something messy which is better put off till later. Chapter 4 launches into a detailed and complete listing of all the operators you can use, including bitwise, logic, shift and coma operators. This is far too much detail for the complete beginner.

You can see that even by Chapter 4 we have a problem in that the book reads more like a reference manual than an introduction to a language. This approach continues in Chapters 5 and 6 where we are introduced to the control statements - if, switch and the loops. Nothing is spared and if you haven't got much of an idea about the flow of control this will not ease you in. If you want a complete coverage of a topic as soon as it is introduced then this will suit you.

From here the book continues in this completist fashion on a fairly predictable course - arrays, pointers, chars, strings, functions, searching and sorting, structures and unions, malloc, files and finally macros.

 

ctheory

 

I say finally because this is where the first edition finished. But the second edition has three more chapters. Chapter 17 is a short look at the problem of building large programs - which briefly introduces makefile. There's nowhere near enough for you to follow some of the more advanced, but common, ways that makefiles are used. Chapter 18 is an introduction to C++ and Chapter 19 does the same for Java.

I can just about see why an introduction to C++ is included, but why Java?

I have no idea. In any case both chapters are inadequate to give you a useful understanding of object-oriented programming. If you are learning C then C++ is a reasonable next language, but not Java - Rust probably has more claim to be included than Java.

There is a lot of material in this book and much of its value would be expected to be in the solved exercises and the many examples of complete programs. However, many of them are simply provided to get you to practice a topic and have you jump though hoops. In practice you would probably go out of your way to design the program so that you didn't have to do what the question was getting you to do. Many of the larger examples are of the sort of task that you might code in say Java or a higher level language than C and it at least goes to prove that C can be used for such tasks, however concerns about security make it less than ideal.

The authors have clearly worked very hard to produce their 700+ pages and the result is a highly attractive hardback volume. There are many things to admire about the book in its production values and its provision of exercises and examples. The programs are in the main nicely presented, but there are often arbitrary wraps of over long lines which is a shame because it is clear that a lot of work has gone into the examples. There are also lots of hints and tips although nothing about debugging and nothing about testing.

The biggest problem is that the book doesn't address any of the typical uses of C - low level or systems programming. It goes over searching and sorting, hashing and so on, but there's nothing about bit manipulation or system calls. While it is true that these aren't part of ANSI C, they are part of a typical C programmer's skill set. C is a language that is close to the hardware and to the operating system and this is the reason most programmers use it.For example, the book covers the bitwise operations in two or three pages but it doesn't go into the way that these are used to do standard tasks such as setting or unsetting a single bit, using masks and what shifts are for.

What we have in this book is C presented as you might present Java. If this is the way you want to use C then you will find this book helpful. If you want to write C for lower level tasks such as programming microcontrollers or creating systems extensions and drivers you will find it less useful.

It isn't a suitable book for a the complete beginner, unless it is used as part of a course - it is too encyclopedic and doesn't introduce ideas gradually. It also doesn't give enough help in the initial phase of getting started.  It also isn't a particularly good book for the programmer wanting to move from an existing language to C. The reason is that it doesn't do a good job of highlighting what is special about C and, what makes it different and worth the effort of learning.

 

Related Reviews

C Programming Absolute Beginner's Guide (3e)  Rated 4.5 out of 5 by Mike James

21st Century C Rated 4.5 by Mike James

C Primer Plus, 6e Rated 4 by Mike James

Secure Coding in C and C++ 2nd Edition Rated 4.5 by Mike James

Programming in C (4e) Rated 4 by Alex Armstrong

 

To keep up with our coverage of books for programmers, follow @bookwatchiprog on Twitter or subscribe to I Programmer's Books RSS feed for each day's new addition to Book Watch and for new reviews.

Banner


Python All-in-One, 3rd Ed (For Dummies)

Authors: John Shovic and Alan Simpson
Publisher: For Dummies
Date: April 2024
Pages: 720
ISBN: 978-1394236152
Print: 1394236158
Kindle: B0CW1C834N
Audience: People wanting to learn Python
Rating: 2
Reviewer: Mike James
All-in-one refers to the fact that this is seven books put together - why?



Machines Like Me

Author: Ian McEwan
Publisher: Vintage, 2019
Pages: 304
ISBN: 978-1529111255
Print: 1529111250
Kindle: B07HR6SGQ9
Audience: General
Rating: 4.5
Reviewer: Mike James
A novel about a synthetic human has become so much more relevant recently and guess what - it features Alan Turing.


More Reviews

 

<ASIN:0131103628>

<ASIN:0789751984>

<ASIN:1491903899>

<ASIN:1449399916>

<ASIN: 0321928423>

<ASIN: 0321822137>

Last Updated ( Friday, 04 May 2018 )