What Is C

What This Tutorial Will Cover

This tutorial will cover the basics of C programming. By the end of this tutorial, you should be able to perform mathematical operations, understand and be able to use several of C's different data types and structures, and print text to a console window. You must learn the concepts taught in this tutorial in order to be able to do more advanced things in C.

Introduction

Before reading, just know that the words with a dotted line under them are abbreviations, and you can see what they mean by hovering over them. Also, some of the italicized words will display definitions if you hover over them (if you are not using a phone to view this web page). This applies to all web pages on this site.

C is what is known as a progamming language. A programming language is simply a set of commands that can be used to tell the computer to do something. Specifically, C is what is known as a low-level programming-language, meaning it gives you a great amount of control over the computer (which also means you have to write more code and worry about more details, but with the reward of being able to write programs that are both faster and more energy efficient). C can also be decsribed as a general-purpose programming-language, meaning that it can be used to achieve most programming goals, from writing an operating system, to making a web-browser, and making a game.

However, C can't be used to make web sites, because websites are meant to be relatively free of viruses (in the sense that you usually cannot get a virus from a web page without actually executing a file that it downloads into your computer). C is considered "unsafe" for web pages because it allows you to do anything, which is a good thing, otherwise most of the programs on your computer wouldn't be nearly as fast (for reasons that will be described shortly), and wouldn't be able to do some "dangerous" tasks, such as open windows by themselves or save files. If you want to program web pages, then you need to use HTML, and optionally, other languages like javascript, PHP and web assembly (if you want to make your web pages perform caclulations and be dynamic, meaning that they can change and interact with the user more). So, to summarize things, if you want to make programs for computers, phone apps, etc., then use C. Otherwise, use a combination of the website programming languages, such as the ones described above.

After the talk about programming languages, you might be wondering whether or not there are multiple general purpose programming languages as well. There are, but I would recommend sticking to C, because it gives you the most control over your programs, allows you to make faster programs (if you program well), achieve very fast load times (have you ever seen how long a Java program takes to load?), and gain access to a huge amount of libraries (sets of pre-made code made to faciliate programming, and/or allow you to do things specific to a device or operating system that C along cannot offer. Examples of libraries include WINAPI, OpenGL, DirectX, and several other libraries, including some made by regular programmers, and not by operating-system programmers, like the three libraries I provided as examples). Other programming languages have severe limitations and problems. Java programs, for example, must be processed by the JVM (Java virtual machine) (which is what you are actually downloading whenever you donwload "Java"), every time they are executed, which increases loading time and reduces the programs speed and battery efficiency. Python and C# (not related to C, and made by Microsoft), other general-purpose programming languages, also require VMs (virtual machines) to be able to run. These programming languages are often advertised as being "easier" than C and therefore, "more productive", but C has several libraries that you can use, and just as in those programming languages, you can reuse code that you write in C to facilitate things. And if you want the Object-Oriented features (special organization features, that I do not like to use, because I find that they don't improve organization much, and just hide program details) of other programming languages, then learn C++ after learning C (C++ is basically just C, with those features, so by learning C++, you are learning C as well).

The only other common programming language that gives nearly as much control over the computer as C, and doesn't require a VM, is Fortran, which was made more for making calculations than making programs. There is actually even a programming language that gives you much more control of the computer than C, known as assembly. Assembly is basically just machine instructions converted directly into acronyms (such as MOV, SUB, ADD, to name the easiest and shortest acronyms in x86 assembly), and requires a seperate version of the program to be made for each different processor. I would recommend that you learn the basics of C first if you want to learn assembly, because learning the basics of C will allow you to at least understand the logic behind assembly programs, and C integrates very well with assembly (and several other programming languages. In fact, C is the programming language that integrates the best with other programming languages out of all the programmign languages). If you ever program in assembly, I would recommend you just program some parts of your program in assembly, because writing different versions of a program for every type of processor, in a difficult programming language (if Java's difficulty is 3, then C is 6, and assembly is 10) is stressful.

Time to get back to C. Yet another way in which C can be described is as a compiled programming language. Code written in C (which is essentially just text) is converted into a machine-readable form (numerical machine instructions) through a program called a compiler (web programs are not compiled, and are instead interpreted by another program (the web browser, usually), which is why they are slower, as I mentioned earlier) Some popular compilers include Microsoft Visual Studio, Clang (also known as LLVM), and GCC (which is part of a larger compiler collection for multiple programming languages known as the GNU Compiler Collection). Even though programmers can use simple text editors, such as notepad to write code (which introduces complications, such as having to use a command prompt to compile code), most programmers choose to use special code editors called IDEs. IDEs provide programmers with a variety of features to simpilify the programming process, including code coloration, debugging (error-detection) mechanisms, and code completion (when lists of possible commands appear while typing code). Popular IDEs for C development include Microsoft Visual Studio (which comes with its own compiler) and Netbeans.