Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

1.1.1 Natural language vs.

programming language

We've met here to show you what the “C” language is and what we use it for. Let us consider for a
moment, what language itself is, not only a “C”, but any language people use. We will try not to resort
to scientifically sounding definitions and speaking informally, we can say that a language is a tool for
expressing and recording human thoughts. In other words, it's a mechanism known to us and to our
partners, allowing us all to understand and to be understood . We can use our language for speaking,
writing, reading, listening, thinking and many others purposes.

At least one language accompanies us throughout our whole lives - it's our native language, our mother
tongue, which we learn almost unconsciously at the very beginning of our programming career. We will
learn other languages, mostly as a result of a conscious decision, forced by social conditions or business
needs. Such languages, which we use to communicate with other people, are called natural languages.
They were created over the centuries and still are subject to change. If we ignore languages that have
been created artificially, such as Esperanto or even Quenya (the language used by elves in Tolkien's
world), their development is almost independent and takes place naturally, in a way that gives us little
or even no control over it.

However, there are languages whose creation and development were and continue to be dictated by
the specific needs while the development is fully subject to control by very wide groups of people, like
international committees and work groups. The shape of these languages is defined by international
standards and although they are understood by many people, the exchange of thoughts between
human-beings is not their most important application.

Such languages are, among others, programming languages. You are probably familiar with this concept
already. Aprogramming language is defined by a set of certain rigid rules, much more inflexible than any
natural language. For example, these rules determine which symbols (letters, digits, punctuation marks,
and so on) could be used in the language. This part of the definition of the language is called lexicon.
Another set of rules determines the appropriate ways of collating the symbols - this is the syntax of the
language. We would like to be able to recognize the meaning of every statement expressed in the given
language and this is what we call semantics. Any program written by us must be correct in these three
ways: lexically, syntactically and semantically. Otherwise, it will neither run nor produce acceptable
results. You can be sure that you will experience all of the described errors, as to err is human and these
humans write computer programs.

The expressive power of programming languages is much, much weaker than those offered by natural
languages. We will not be able (although we can try) to use such a language to express human emotions
and it is hard to imagine a declaration of love encoded in the programming language. It is a simple
consequence of the fact that the message embedded inside a computer program is not intended for a
human but for a machine.
Some would want to ask why there is a need for using a programming language. It's a good question.
We will try to answer it.

1.1.2 Natural language vs. programming language

A computer, even most technically sophisticated, is devoid of even a trace of intelligence. You could say
that it is like a well-trained dog - responds only to a predetermined set of known commands. The
recognized commands are very simple. We can imagine that the computer responds to orders like “take
that number, add to another and save the result”. A complete set of such well-known commands is
called an instruction list, sometimes abbreviated to IL. Different types of computers may vary depending
on the size of their ILs and the instructions themselves could completely differ in different models.

The IL is in fact an alphabet of a language, which is commonly known as a machine language. This is the
simplest and the most primary language we can use to give commands to our computer. We can say, it's
a computer’s mother tongue.

Computer programming is an act of composing the selected commands (instructions) in a proper order
that will cause a desired effect. The effect itself could be different in every specific case – it's up to the
programmer's imagination, knowledge and experience.

It is possible and often used in practice for a computer program to be coded directly in the machine
language using elementary instructions (orders). This kind of programming is tedious, time consuming
and highly prone to a programmer's mistakes. At the early stages of computer technology it was the
only available method of programming and very quickly revealed its serious flaws. Programming in
machine language requires full knowledge of a computer’s hardware design and its internal structure.
This also means that replacing the computer with one that differs in design from the previous one used
can make the programmer's entire knowledge unusable. Also , the old programs could be completely
useless if the new computer “used” different IL. Thus, a program written for a specific type of a
computer could be also completely useless for other computers and vice versa. Secondly, programs
written in the machine language are very difficult to understand for humans, including experienced
programmers. It is also common that developing programs written in a machine language takes a lot of
time, is very costly and cumbersome.

All those circumstances created a need for some kind of abridge between the people's language (natural
language) and a computer language (machine language). That bridge is also a language – an
intermediate common language for humans and computers working together. Such languages are often
called high-level programming languages.

Such a language is at least somewhat similar to a natural language, uses symbols, words and
conventions readable to humans. This language enables humans to express complex commands for
computers.
You can ask how to persuade computers to understand programs written in this way. Encouragement
will not work, but you can just translate your program into the machine language. Moreover, the
translation can be done by a computer, making the whole process fast and efficient.

Notice how many benefits you can get from such a course. There is no need to learn many different
machine languages – it's enough to know one high-level programming language. If there is
a translator designed for a specific computer, your program could be run without any problems. In other
words, the programs written in high- level languages could be translated into any number of different
machine languages and thus make them able to be used on many different computers. This important
and useful feature of high level programming languages is called portability.

1.1.3 Natural language vs. programming language

The translation we are referring to is made by a specialized computer program called compiler. The
process of the translation from a high-level language into a machine language is called compilation.

Now let's get back to more interesting issues related to the process of creating a new program. We
already know that the main task is to write the program in accordance with the rules of the chosen
programming language. Such a program (which in fact is just a text) is called source code or
simply source while the file which contains the source is called source file.

To write the source code you will need a text editor that allows you to manipulate text without any
formatting information (for this reason Microsoft Word isn't a good choice, in contrast to the Notepad).
This code is placed in a file and the name of the file should imply its content. For example, it is common
for a file containing the source code in the “C“ language to have its name ending with the suffix “.c”, so if
you wrote a computer program and decided to name it "proggie" it would be a purposeful and
reasonable idea to put the source code into a file named “proggie.c”.

Next, your source code should be compiled. To do this you run an appropriate compiler, instructing it
where you stored the source code that you want to be translated into the machine language. The
compiler reads your code, makes some quite complex analysis and its first goal is to determine whether
or not you made any errors during the coding. These analyses are very insightful, but remember that
they are made by a machine, not a man and you should not expect too much from them. OK, if your
mistake was that you tried to add up two numbers using “#” instead of “+”, the compiler will kindly ask
you to be aware of that. However, if you have typed a "-" instead of a "+", the compiler will no longer be
able to guess that your intention was to add two numbers, rather than to subtract them. Do not expect
that the compiler will think for you. You have no reason to express regret about it - thanks to that,
developers are still needed.
If the compiler does not notice mistakes in your source, the result of its work will be a file containing
your program translated into the machine language. That file is commonly called an executable file. The
name of the file depends on the compiler you use and the operating system you are working with. For
example, most compilers designed for the Unix/Linux system create an output file named “a.out” by
default. Compilers designed for use in MS Windows® can name this file the same as the source file, only
changing the suffix from “.c” to “.exe”.

We should admit that the whole process is actually a bit more complicated. Your source code could be
comprehensive and divided among several or even dozens of source files. It may also happen that the
program is written not by you only, but by a team, in which case the division of sources into multiple
files is simply a must. In such a case, the compiling splits into two phases - a compilation of your source
in order to translate it into machine language and joining (or gluing) your executable code with the
executable code derived from other developers into a single and unified product. The phase of “gluing”
the different executable codes is commonly known as linking while the program which conducts the
process is named linker.

The “C” language is one of the huge numbers of programming languages currently used and one of the
oldest. It was created in the early seventies of the twentieth century by Dennis Ritchie while he was
working in Bell Laboratories. Some say that “C” was a by-product of a project which led to the very first
version of the Unix operating system. There are many other programming languages widely used – some
of them could be regarded as “C” descendants. They even inherited a name from their ancestor – like
“C++” or “C#”. Others borrowed some features from the original “C” and added lots of new ones – like
Perl, Java or JavaScript.

What is the most common use of “C”? It is the so-called general-purpose programming language, i.e.,
suitable for almost any programming project and at the same time not particularly predestined to any
specific, narrow class of applications. Best if used for coding drivers, embedded applications or operating
systems (for example, Linux kernel is mainly coded in “C”). You can also use it for building complex
utilities. We can assure you that knowing the “C” language is very helpful if you want to learn C++, C# or
Java.

The time you will spend learning the “C” language won't be wasted.

1.1.4 Further readings

If you take the learning of the “C” language seriously, you certainly will not stop your education on just
reading the text that is in front of your eyes at the moment. Among the hundreds of books written
about the “C” language there is one which is particularly recommendable. The book has been issued
dozens of times all around the world and is available in over 20 different (natural) languages. We can
recommend it without hesitation. Without any doubts it is the best book on C programming ever
written. Its high quality can be proved by the fact that one of its authors is Dennis Ritchie. The second
author is Brian Kernighan, Dennis' co-worker from the times of their cooperation at Bell Labs. The book's
title is simply The C Programming Language, but do not be surprised when your friends will address it by
just “Kernighan-Ritchie”.

Once you're a proficient programmer, you may want to have a source of knowledge, through which you
will be able to quickly explain the emerging questions or just fill in the gaps in your memory. Instead of a
handbook, you will want the book which briefly describes the language standards - everything what is
really important and nothing more. Such a document is a report (permanently improved and updated)
published by the ISO standardization committee. The most recent version of the report is ISO/IEC 9899:
TC3. You can find it on the Internet and look it up, but it is still too soon to be reading it.

Look into it when you finish our course. Not sooner.

You might also like