This lesson will give you a complete introduction to C programming among other things such as why we write programs, and the need for a programming language such as C. The C programming language is a MUST for students and working professionals to become great software engineers especially when they are working in the software development domain.
Need for a Programming Language
Computers are general-purpose machines that can do various tasks with one caveat i.e. we need to instruct them on how to perform the task. These instructions must be given in a machine-readable language (binary streams of 0 and 1) for the computer to understand the task. For example, if we want the computer to add two numbers, we can’t just tell the computer to do that in English as the computer will not understand it. Thus comes the need for programming languages which are required to write instructions (programs) that a computer can understand and then execute to perform a certain task.
Types of Programming Languages
All programming languages can be broadly classified into two categories as mentioned below:
- Low-Level Languages
- High-Level Languages
Low-Level Programming Languages
A low-level language is also sometimes referred to as a computer’s native language. It is writing machine instructions (0 and 1) or something very close to it, that a computer can understand with minimum or no translation. To write code in a low-level programming language, one needs extensive knowledge of the hardware system and architecture of the specific CPU, the code is going to run on. Different CPUs have different architectures based on a variety of needs, and one will need to learn each of them first before one can write low-level programs for them. By this, it must be clear that low-level programming languages are machine-dependent as well as machine oriented. A low-level program written for one machine may not be compatible with another machine if its architecture is different.
There are broadly two types of Low-Level programming languages:
- Machine Language: The code here is written as a string of binary values (0 and 1) and stored directly in the CPU memory without further processing. This is machine-level code that the CPU can understand but is very hard for humans to comprehend. The main advantage of a program written in machine language is that it can be directly executed on hardware without requiring translation or interpretation. This also results in the program running with a minimal memory footprint and being very fast in its execution time. The major disadvantage of programs written in machine language is their difficulty in comprehension by humans and their inability to be ported between various hardware with different architectures.
- Assembly Language: To overcome the drawback of machine language being incomprehensible to humans, assembly language was developed which promoted the use of specific mnemonic words that are human-readable as well as understandable. Assembly language works as a bridge between high-level programming languages and machine-level languages. But it also requires an assembler to convert the code into machine code before execution is possible. Assembly languages are not universal and are created with a specific computer architecture in mind. This means that, similar to machine language, code written in an assembly language is not portable between different CPUs with different architecture types.
High-Level Programming Languages
Brief Introduction to C Programming
C is a general-purpose, procedural, machine-independent, structured programming language. It was created by Dennis M. Ritchie at the Bell Telephone Laboratories in 1972 for developing the UNIX operating system. C was derived from a language called B created by Ken Thompson. As it was a successor of Language B, hence the name C.
Contrary to popular belief, C is not a high-level language. It is a mid-level language with the simplicity of a high-level language but the power of a low-level language. Programs written in C are wicked fast. It is also a small language compared to others, with only 32 keywords. Keywords are reserved words used by a language for doing certain tasks. We will talk about them in detail, later in the course. Due to the small library of keywords, C can be learned easily.
After nearly four decades of its creation, C is still used to write everything from Operating Systems (Windows) to complex programs like the Oracle database, GIT, Python Interpreter and more. The whole world of Embedded Systems is still heavily reliant on C owing to its fast execution time in safety-critical real-time systems.
History of C Language
The development of the UNIX operating system is closely tied to the origin of C. UNIX was originally written in assembly language on a PDP-7 by Dennis M. Ritchie and Ken Thompson. Thompson wanted a programming language to make utility applications for the new platform. He tried to make a Fortran Compiler but soon gave up on that idea. Later he created a cut-down version of the recently developed BPCL systems Programming Language. This new language had no official description as of yet, and Thompson modified its syntax to be less wordy, producing a new similar but simpler language B. However, B was slow and only a few utilities were ever written on it.
Ritchie started to improve upon this new language created by his friend in 1972. This resulted in the creation of the new language C. Later the C Compiler and some utilities written in it were included in Version 2 of UNIX OS.
Brain Kernighan and Dennis Ritchie published the first edition of the “C Programming Language”, in 1978. This book, known as K&R, served for many years as the informal specification for this language.
ANSI C and ISO C
In the early 1980s, C was getting popular as some versions of it were implemented in mainframe computers, minicomputers and microcomputers including the IBM PC. Therefore, in 1983, the American National Standards Institute(ANSI) formed a committee, X3J11, to establish a standard specification of C. They based it on UNIX implementation and this version is widely known as ANSI C or C89. It is also called simply C and is taught in schools as the first Introduction to C Programming Language.
In 1990, the International Organization for Standardization adopted the ANSI standard as ISO/IEC 9899:1990, which is sometimes called C90. Therefore, the terms C89 and C90 refer to the same programming language.
The C standard was further revised in the late 1990s, leading to the publication of ISO/IEC 9899:1999 in 1999, which is commonly referred to as C99.
There was another revision of the standard C language in 2007 which was informally called C1X. It was officially published in 2011 and called C11.
This version is the current C standard and it was published in 2018. It introduced no new language features, only technical corrections and clarifications to the shortcomings in C11.
Embedded C Programming requires some nonstandard extensions of the current C language to support features such as fixed and floating-point arithmetic, I/O Operations, multiple memory bank operations etc. In 2008, the C standards committee released a technical report which extended the C language to include these features and create a common standard for Embedded C.
Where is C Language used?
- Linux OS, Apple’s OS X and Windows have been written in C. Other Operating Systems such as Symbian for mobile OS, are also written in C.
- Web Developing Tools such as PHP has been written in C.
- C is widely used in Embedded Systems due to its fast execution time.
- It is also used to develop system and desktop applications.
- Most of the applications by Adobe such as Photoshop and After-Effects are developed using the C programming language.
- It is also used to develop databases. MySQL, for example, is the most popular database software which is built using C.
- C is also used for developing browsers and their extensions. Google’s Chromium is built using the C programming language.
- C is used for producing Compilers for other Programming Languages.
- C is now widely used in IoT applications.
All these applications in a wide range of fields make it one of the most widely used languages today. In fact, in 2019, C was the third most commonly used language even after almost 40 years of its creation. Not bad…!
Introduction to C Programming Language Features
C is a Compiled Language
A compiler is a piece of software or program that converts high/mid-level language to machine-level language (1 and 0). In a compiled language such as C, this piece of software will convert the entire code at once before execution. In comparison, an Interpreter based language such as Python converts one line of code at a time and then executes it.
Efficiency of C
C is very efficient in terms of memory management and is very fast. It was designed for UNIX OS, so it was essential for a C program to run quickly and with a limited amount of memory.
Portability of C Programs
Code written in C is extremely Portable. What this means is, that a program written in C can run in a wide variety of operating systems with little or no modifications.
Even after almost forty years since its creation, this language is still used to write Operating Systems, and create compilers and interpreters for other Programming Languages such as Python, Perl, PHP, BASIC etc.
This concludes the first lesson “Introduction to C Programming”. I hope you found it helpful. Feel free to share this course using the sharing buttons below and do Enrol if you haven’t already. In the next lesson, we will learn how to install the Codeblocks IDE.
- History of C Programming(Wikipedia)
- American National Standard Institute(Wikipedia)
- International Organisation for Standardization(Wikipedia)
Sharing is Caring
If you liked this post, then feel free to share it with your loved ones!