Why Learn C?
► Many of the most popular current programming languages share significant syntax with C.
Here's a program in C to sum the numbers from 1 to N (file: test.c):
#include <stdio.h> int getSum(int value) { int sum = 0; int i = 1; while(i <= value) { sum += i; i++; } return(sum); } int main() { printf("%d\n", getSum(20)); return(0); }
And here is the corresponding code in java (file: test.java):
public class test { static int getSum(int value) { int sum = 0; int i = 1; while(i <= value) { sum += i; i++; } return(sum); } public static void main(String[] args) { System.out.printf("%d\n", getSum(20)); } }
In C++ (file: test.cpp):
#include <iostream> int getSum(int value) { int sum = 0; int i = 1; while(i <= value) { sum += i; i++; } return(sum); } int main() { std::cout << getSum(20) << "\n"; return(0); }
In C# (file: test.cs):
using System; public class test { public static int getSum(int value) { int sum = 0; int i = 1; while(i <= value) { sum += i; i++; } return(sum); } public static void Main() { Console.WriteLine(getSum(20)); } }
In PHP (file: test.php):
<? function getSum($value) { $sum = 0; $i = 1; while($i <= $value) { $sum += $i; $i++; } return($sum); } printf("%d\n", getSum(20)); ?>
And finally, javascript (file: test.js):
function getSum(value) { var sum = 0; var i = 0; while(i <= value) { sum += i; i++; } return(sum); } alert(getSum(20));
Clearly there is some merit to the claim that many other popular languages have significant syntactical overlap with C!
► Further, while languages like c++, java, c#, php and javascript are constantly changing and evolving, c has remained more steady. Standards-complaint c programs written decades ago still compile and run without any problems.
► Additionally, C is just a more straightforward language than many other popular languages like: c++, java, php and c#. The C89 standard lists a total of 32 C language keywords, here are the totals for several languages:
Language | Number Of Keywords |
C (1989) | 32 |
C (1999) | 37 |
Java | 52 |
PHP | 70 |
C# | 77 |
C++ | 97 |
As you can see, the other languages have two or even three times as many reserved words as C does.
► Many programs that are used all over the world every day are written in C:
Program Name | Description |
Linux | Operating System |
GIT | Version Control |
Apache | Web Server |
Python | Programming Language |
PHP | Programming Language |
Perl | Programming Language |
► As of July, 2021, the TIOBE Index of programming popularity was:
So, (the merits of the TIOBE index notwithstanding) it's pretty clear that even though C is much older than the other languages it is still quite popular.
► ONLINE RESOURCES
► COMPILERS
► TEXTBOOKS