C is one of the most powerful "modern" programming language, in that it allows direct access to memory and many "low level" computer operations. C source code is compiled into stand-a-lone executable programs. C is sometimes criticized because it assumes the "programmer is always right" and allows many "questionable" programming practices.
C is a very powerful and widely used language. It is used in many scientific programming situations. It forms (or is the basis for) the core of the modern languages Java and C++. It allows you access to the bare bones of your computer.
Yet, with great power comes great responsibility. C will not coddle you (okay, raise your hand if you think Matlab was coddling... well compared to C it was very generous to you). C will require your syntax to be even more perfect than Matlab. C will make you define every variable with a Type, and not let you ever change these (in a given program). C will assume you are a master of everything you do.
Further, C is a very basic language. There are no frills, no GUIs, no Matrix processing abilities, very little file I/O support, etc. (Note: to be honest, all of these things have been written in C and are available as libraries, but the core C language is in some sense, bare boned.)
Then, why do we use C?
It was (and still is in some circumstances) the language of choice in Operating System Development (including all of Unix).
It allows you direct control over the very low level aspects of the computer.
Many legacy programs are written in C.
Most of the things you learn with C will be directly transferable to future programming languages.
Programs that are created with C run very quickly.
C has a syntax (and some semantics) very close to Matlab, making the transition easy (okay, easier...).
The programs you create in C will run "standalone". All of the programs we wrote in Matlab, need Matlab in order to work, and if you don't have access to Matlab, you are out of luck. C programs, once compiled into "executables", can be transferred to other (similar) machines, and run without the need for the source code.
Many of the codes you will use in your future work/studies will have been written in C. You should at the least, be able to read them. And hopefully, you will be able to maintain, modify, and update them.
The following is a "Design Pattern" for any basic C program:
#include <stdio.h> // tell C about printf
int // return value of main function
main() // where the program begins
{
printf("hello world\n");
return 0; // exit status of main program (could be any number
// that we agree means the program is finished)
}
See also: