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 languages 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 hasnt 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 werent 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.
You know that every programming language has some Primitive Data Types (PDTs). Using these PDTs, you can design your data structures and write your algorithms around them. These PDTs are part of the programming language, and they cannot be changed or removed. As an example, you cannot have C without the primitive types int and double.
Structures come into play when you need to have your own defined data types, and the data types in the language are not enough. User-Defined Types (UDTs) are those types which are created by the user and they are not part of the language.
Note that UDTs are different from the types you could define using typedef. The keyword typedef doesnt really create a new type, but rather it defines an alias or synonym for an already defined type. But structures allow you to introduce totally new UDTs into your program.
Structures have twin concepts in other programming languages, for example, classes in C++ and Java or packages in Perl. They are considered to be the typemakers in these languages.
So, why do we need to create new types in a program? The answer to this question reveals the principles behind software design and the methods we use for our daily software development. We create new types because we do it every day using our brains in a routine analysis.
We dont look at our surroundings as integers, doubles, or characters. We have learned to group related attributes under the same object. But as an answer to our starting question, we need new types because we use them to analyse our problems as a higher level of logic, close enough to our human logic.
Here, you need to become familiar with the term business logic. Business logic is a set of all entities and regulations found in a business. For example, in the business logic of a banking system, you face concepts such as client, account, balance, money, cash, payment, and many more, which are there to make operations such as money withdrawal possible and meaningful.
Suppose that you had to explain some banking logic in pure integers, floats, or characters. It is almost impossible. If it is possible for programmers, it is almost meaningless to business analysts. In a real software development environment that has a well-defined business logic, programmers and business analysts cooperate closely. Therefore, they need to have a shared set of terminology, glossary, types, operations, regulations, logic, and so on.
Today, a programming language that does not support new types in its type system can be considered as a dead language. Maybe thats why most people see C as a dead programming language, mainly because they cannot easily define their new types in C, and they prefer to move to a higher-level language such as C++ or Java. Yes, its not that easy to create a nice type system in C< but everything you need is present there.
Even today, there can be many reasons behind choosing C as the projects main language and accepting the efforts of creating and maintaining a nice type system in a C project and even today many companies do that.
Despite the fact that we need new types in our daily software analysis, CPUs do not understand these new types. CPUs try to stick to the PDTs and fast calculations because they are designed to do that. So, if you have a program written in your high-level language, it should be translated to CPU level instructions, and this may cost you more time and resources.
In this sense, fortunately, C is not very far away from the CPU-level logic, and it has a type system which can be easily translated. You may have heard that C is a low-level or hardware-level programming language. This is one of the reasons why some companies and organisations try to write and maintain their core frameworks in C, even today.
This extract is taken from Extreme C, by Kamran Amini, published by Packt. You can find out more and buy your copy by visiting here.
Interested in hearing industry leaders discuss subjects like this and sharing their use-cases? Attend the co-located5G Expo,IoT Tech Expo, Blockchain Expo, AI & Big Data Expo, andCyber Security & Cloud ExpoWorld Series with upcoming events in Silicon Valley, London, and Amsterdam.
The rest is here:
Extreme C book extract: Exploring structures and user-defined types in C - Developer Tech
- Offer Ends Soon Ready Version - The Human Longevity Project [Last Updated On: August 18th, 2024] [Originally Added On: September 11th, 2019]
- Human Longevity - Wikipedia [Last Updated On: August 18th, 2024] [Originally Added On: September 11th, 2019]
- Longevity - Wikipedia [Last Updated On: August 18th, 2024] [Originally Added On: September 11th, 2019]
- Careers Human Longevity, Inc. [Last Updated On: August 18th, 2024] [Originally Added On: September 29th, 2019]
- Is longevity determined by genetics? - Genetics Home ... [Last Updated On: August 18th, 2024] [Originally Added On: October 1st, 2019]
- Chinese Longitudinal Healthy Longevity Survey (CLHLS ... [Last Updated On: August 18th, 2024] [Originally Added On: October 1st, 2019]
- Longevity claims - Wikipedia [Last Updated On: August 18th, 2024] [Originally Added On: October 6th, 2019]
- To Love and Mourn an Animal - Sentient Media [Last Updated On: August 18th, 2024] [Originally Added On: October 21st, 2019]
- Opinion: Entrepreneurs and Their Startup Businesses Need San Diegos Support - Times of San Diego [Last Updated On: August 18th, 2024] [Originally Added On: October 21st, 2019]
- Overthinking Can Shorten Your Life, Says New Study - International Business Times [Last Updated On: August 18th, 2024] [Originally Added On: October 21st, 2019]
- Media Advisory: Artificial Intelligence in Health Care, Healthy Longevity, and Human Genome Editing Among Topics at Meeting of Nation's Top Health... [Last Updated On: August 18th, 2024] [Originally Added On: October 21st, 2019]
- Global Longevity & Anti-Senescence Therapy Market Review 2017-2018 and Forecast to 2023 - ResearchAndMarkets.com - Business Wire [Last Updated On: August 18th, 2024] [Originally Added On: October 21st, 2019]
- LyGenesis Closes $4 Million Convertible Debt Financing to Begin Clinical Development of its Liver Regeneration Technology - PRNewswire [Last Updated On: August 18th, 2024] [Originally Added On: October 21st, 2019]
- MicroRNA Expression Tied to Triple-Negative Breast Cancer in Latin America - Cancer Network [Last Updated On: August 18th, 2024] [Originally Added On: October 24th, 2019]
- Thinking deep thoughts has impact on life span - Mother Nature Network [Last Updated On: August 18th, 2024] [Originally Added On: October 24th, 2019]
- Vulnerability of the industrialized microbiota - Science Magazine [Last Updated On: August 18th, 2024] [Originally Added On: October 24th, 2019]
- What bamboo forests do for nature and human well-being - Forests News, Center for International Forestry Research [Last Updated On: August 18th, 2024] [Originally Added On: November 8th, 2019]
- Quorn's secret to longevity in the meat alternative sector - Food Dive [Last Updated On: August 18th, 2024] [Originally Added On: November 8th, 2019]
- The benefits of intermittent fasting - Starjournalnow [Last Updated On: August 18th, 2024] [Originally Added On: November 8th, 2019]
- New "Monsterpocalypse" releases: Ulgoth, Apes, and Robots, Oh My! - Bleeding Cool News [Last Updated On: August 18th, 2024] [Originally Added On: November 8th, 2019]
- The Global Human Microbiome Market Size was Worth $ 461 Million in 2018 and is Forecasted to Reach $ 1,380 Million by 2026, at a CAGR of 17.8% During... [Last Updated On: August 18th, 2024] [Originally Added On: November 8th, 2019]
- Term limits would make Congress members put the country first | Letters - NJ.com [Last Updated On: August 18th, 2024] [Originally Added On: November 10th, 2019]
- This Scientist Believes Aging Is Optional - Outside Magazine [Last Updated On: August 18th, 2024] [Originally Added On: November 10th, 2019]
- Longevity And Anti-Senescence Therapy Market to Witness Stellar Growth Rate in the Next 10 Years during 2023 - Crypto News Byte [Last Updated On: August 18th, 2024] [Originally Added On: November 17th, 2019]
- May's turn to meet Trudeau and 'anti-Alberta' activities; In-The-News Nov. 15 - larongeNOW [Last Updated On: August 18th, 2024] [Originally Added On: November 17th, 2019]
- The Future of Meat - Truthdig [Last Updated On: August 18th, 2024] [Originally Added On: November 24th, 2019]
- Surprising No One, The FBI's Watchdog Says The Agency Is Handling Its Informants Improperly - Techdirt [Last Updated On: August 18th, 2024] [Originally Added On: November 24th, 2019]
- Have Researchers Finally Figured Out Whether Dogs Are Good For Us? - Forbes [Last Updated On: August 18th, 2024] [Originally Added On: November 24th, 2019]
- Can the gut microbiome unlock the secrets of aging? - Medical News Today [Last Updated On: August 18th, 2024] [Originally Added On: November 24th, 2019]
- The disruptive power of disruption - Daily Pioneer [Last Updated On: August 18th, 2024] [Originally Added On: November 24th, 2019]
- Missing Link To Longevity Discovered In The Plant Kingdom - Texas A&M University [Last Updated On: August 18th, 2024] [Originally Added On: November 24th, 2019]
- 30-year-old Harvard study on longevity: Five daily habits to follow for a healthy living - Republic World - Republic World [Last Updated On: August 18th, 2024] [Originally Added On: November 25th, 2019]
- Leverates Success Task Force Scheduled to Launch Before the End of 2019 - Finance Magnates [Last Updated On: August 18th, 2024] [Originally Added On: November 25th, 2019]
- Partnership aims to accelerate cell and gene therapy - Harvard Gazette [Last Updated On: August 18th, 2024] [Originally Added On: November 25th, 2019]
- The Cost Of Underestimating The Rise Of Women: No Babies - Forbes [Last Updated On: August 18th, 2024] [Originally Added On: November 25th, 2019]
- What Will We Do When the Sun Gets Too Hot for Earth's Survival? - Scientific American [Last Updated On: August 18th, 2024] [Originally Added On: November 25th, 2019]
- Beyond Hello Kitty: The beauty of 'Animals in Japanese Art' - Los Angeles Times [Last Updated On: August 18th, 2024] [Originally Added On: November 25th, 2019]
- Startup of the Week: A Subscription for Anti-Aging Pills... for Mice - Free [Last Updated On: August 18th, 2024] [Originally Added On: November 25th, 2019]
- Mungo national park: where alien landscapes reveal ancient culture - The Guardian [Last Updated On: August 18th, 2024] [Originally Added On: November 25th, 2019]
- The New Face of Longevity: Dwayne Clark's Solution to America's Silver Tsunami Crisis and How Living on Stolen Potatoes Made It All Possible -... [Last Updated On: August 18th, 2024] [Originally Added On: November 25th, 2019]
- Liberty Science Centers Inaugural Genius of New Jersey to Honor Innovators Who Make the State a World Leader in Cutting-Edge Applied Science - Yahoo... [Last Updated On: August 18th, 2024] [Originally Added On: November 25th, 2019]
- Zelda Was One of the Greatest Modern Writers of Religious Experience in Any Language - Mosaic [Last Updated On: August 18th, 2024] [Originally Added On: November 26th, 2019]
- Precision Medicine Software Market : The Report Analysis And Overview of Global Market In Term Of Size, Share, Growth And Development 2019-2024 :... [Last Updated On: August 18th, 2024] [Originally Added On: November 26th, 2019]
- Making The Jetsons Jealous: Peter Diamandis Says The Future Is Better, And Coming Faster Than You Ever Dreamt - Thrive Global [Last Updated On: August 18th, 2024] [Originally Added On: November 26th, 2019]
- The biological defects that come with age and how to prevent them - Ladders [Last Updated On: August 18th, 2024] [Originally Added On: November 26th, 2019]
- Global Stem Cells Market Growth Driver 2016 2024: By Companies Osiris Therapeutics Inc., STEMCELL Technologies Inc., BIOTIMEInc., Celgene Corporation... [Last Updated On: August 18th, 2024] [Originally Added On: November 26th, 2019]
- Startup of the Week: A Subscription for Anti-Aging Pills... for Mice - VICE [Last Updated On: August 18th, 2024] [Originally Added On: November 26th, 2019]
- Phishing Trends Position ISPs to Protect Subscribers - Security Boulevard [Last Updated On: August 18th, 2024] [Originally Added On: November 26th, 2019]
- Longevity And Anti-Senescence Therapy Market: Market Development, Overview and Forecast up to 2023 - Statsflash [Last Updated On: August 18th, 2024] [Originally Added On: November 26th, 2019]
- The pain of a failed investment can be the best teacher of all - Financial Post [Last Updated On: August 18th, 2024] [Originally Added On: November 27th, 2019]
- Were all going to die: Alarmists in our midst - Daily Maverick [Last Updated On: August 18th, 2024] [Originally Added On: November 27th, 2019]
- 12 Powerful Ayurvedic Herbs and Spices with Health Benefits - Healthline [Last Updated On: August 18th, 2024] [Originally Added On: November 27th, 2019]
- Employee Engagement: Everything You Need to Know - HR Exchange Network [Last Updated On: August 18th, 2024] [Originally Added On: November 27th, 2019]
- Wherever The Human Heart Beats @ Alma Tavern - Epigram [Last Updated On: August 18th, 2024] [Originally Added On: November 27th, 2019]
- Fermenting the future of healthy aging - SynBioBeta [Last Updated On: August 18th, 2024] [Originally Added On: November 27th, 2019]
- Liberty Science Center's Inaugural Genius of New Jersey to Honor Innovators Who Make the State a World Leader in Cutting-Edge Applied Science -... [Last Updated On: August 18th, 2024] [Originally Added On: November 27th, 2019]
- Rich People Have Access to Better Microbes Than Poor People, Researchers Say - VICE UK [Last Updated On: August 18th, 2024] [Originally Added On: November 27th, 2019]
- Frankenstein vs. The Wolfman: Who Would Win (And Why) - Screen Rant [Last Updated On: August 18th, 2024] [Originally Added On: November 28th, 2019]
- How do consumer DNA tests from the US and China stack up? - Abacus [Last Updated On: August 18th, 2024] [Originally Added On: November 28th, 2019]
- Scott LaFee: Don't Think Too Hard About This - Noozhawk [Last Updated On: August 18th, 2024] [Originally Added On: November 28th, 2019]
- Lewis Hamilton is not only a peerless champion, he is the face of F1 - The Guardian [Last Updated On: August 18th, 2024] [Originally Added On: November 30th, 2019]
- Recent deaths at Dallas Zoo have seemed notable but aren't out of the ordinary - The Dallas Morning News [Last Updated On: August 18th, 2024] [Originally Added On: November 30th, 2019]
- Ruth Wishart on Kenneth Roy's diary of living and dying - HeraldScotland [Last Updated On: August 18th, 2024] [Originally Added On: November 30th, 2019]
- This Marketing Agency Wants To Put The Pleasure Back Into The Sex Tech Business - Forbes [Last Updated On: August 18th, 2024] [Originally Added On: November 30th, 2019]
- The 1975 Played a Greta Thunberg Speech During Their Grand Prairie Concert - Dallas Observer [Last Updated On: August 18th, 2024] [Originally Added On: November 30th, 2019]
- Global Warming Is Escalating The El Nio Weather - Science Times [Last Updated On: August 18th, 2024] [Originally Added On: November 30th, 2019]
- Turkey is a leading NATO member. Its time this commitment was recognised, not criticised View - Euronews [Last Updated On: August 18th, 2024] [Originally Added On: November 30th, 2019]
- National Spotlight on Ikarian Honey on CBS Sunday Morning News - The Pappas Post [Last Updated On: August 18th, 2024] [Originally Added On: November 30th, 2019]
- Rich People Have Access to Better Microbes Than Poor People, Researchers Say - VICE [Last Updated On: August 18th, 2024] [Originally Added On: November 30th, 2019]
- Commentary: We need a major redesign of life - Bend Bulletin [Last Updated On: August 18th, 2024] [Originally Added On: November 30th, 2019]
- How Bitcoin points to the future of decentralized protest - Decrypt [Last Updated On: August 18th, 2024] [Originally Added On: December 2nd, 2019]
- Pollution woes add to our ongoing survival struggle - Tehelka [Last Updated On: August 18th, 2024] [Originally Added On: December 2nd, 2019]
- Three reasons women live longer than men - Firstpost [Last Updated On: August 18th, 2024] [Originally Added On: December 2nd, 2019]
- Gail Fisher's 'Dog Tracks': Spoiling you dog with extra food could cut short its life - The Union Leader [Last Updated On: August 18th, 2024] [Originally Added On: December 2nd, 2019]
- The L Word: Nobody Rocks a Power Suit and Cufflinks Like Jennifer Beals - IndieWire [Last Updated On: August 18th, 2024] [Originally Added On: December 5th, 2019]
- Cycling Without Age Gives Seniors Access to Biking in Cities Around the Globe - Next City [Last Updated On: August 18th, 2024] [Originally Added On: December 5th, 2019]
- Longevity And Anti-Senescence Therapy Market 2018 Overview, Consumption, Supply, Demand & Insights - Downey Magazine [Last Updated On: August 18th, 2024] [Originally Added On: December 5th, 2019]
- OU voice students learn about the importance of vocal health - 2019 - School of Music, Theatre and Dance - News - OU Magazine - News at OU [Last Updated On: August 18th, 2024] [Originally Added On: December 5th, 2019]
- Purdue taking part in life-long study of dogs health and aging - WTHR [Last Updated On: August 18th, 2024] [Originally Added On: December 5th, 2019]
- Federal Agencies, Nonprofits and Global Companies Connect with Tech Entrepreneurs, Investors at Innovation in Longevity Summit Convened in Nation's... [Last Updated On: August 18th, 2024] [Originally Added On: December 5th, 2019]