Extreme C book extract: Exploring structures and user-defined types in C

The growth and popularity of C continues. The most recent TIOBE index of most popular programming languages saw C in a virtual dead heat with Java, knocking the latter off its perch for the first time in five years.

In his new book, Extreme C (left), Kamran Amini outlines the essential features of the language before moving onto encapsulation and composition, synchronisation, as well as advanced programming – with code samples – and integration with other languages, including C++, Java, and Python.

This extract, exclusive to Developer, explores structures within C, as well as touching on the reasons behind the almost 50-year-old language’s continued longevity.

From the design perspective, structures are one of the most fundamental concepts in C. Nowadays, they are not unique to C, and you can find their twin concepts nearly in every modern programming language.

But we should discuss them in the history of computation when there were no other programming languages offering such a concept. Among many efforts to move away from machine-level programming languages, introducing structures was a great step toward having encapsulation in a programming language. For thousands of years, the way we think hasn’t changed a lot, and encapsulation has been a centric means for our logical reasoning.

But it was just after C that we finally had some tool – in this case, a programming language – which was able to understand the way we think and could store and process the building blocks of our reasoning. Finally, we got a language that resembles our thoughts and ideas, and all of this happened when we got structures. C structures weren’t perfect in comparison to the encapsulation mechanisms found in modern languages, but they were enough for us to build a platform upon which to create our finest tools.

Source: www.developer-tech.com

Leave a Reply

Your email address will not be published. Required fields are marked *