Chapter 2
Chapter 2
Notes
In our machine, this simple program would most likely be fixed to the
hardware itself, and unchangable. As machines gain complexity, their
programs must be updated to extend their functionality or fix old
functionality. Personal computers use these kinds of software
programs.
Software programs are still instructions, but they exist on some kind
of storage rather than on the machine's logical hardware itself. These
are not already simply "known" by the machine, they must be loaded
and run. In the world of computing you know, these are executable
files on your personal computer.
So, there is another platform on which much of this logic can be run:
the operating system. The operating system is a software program
or programs that can run other programs that are written specifically
for it. When these higher level programs need access to the hardware
of the machine, they will ask the operating system rather than talking
to the hardware directly through the CPU. This is safer and because the
operating system has a lot of logic already, higher-level programs
can use that logic without writing more of their own.
Mov ax, 5
I used some “new” terms there. One was “syntax”. It simply means
the rules of a language (or “features”, but those are inclusive to rules).
The latter was “programming language”. A high-level language is
known as a “programming language” for the simple reason that you
write in this foreign language for the purpose of programming.
The fundamental thing you must realize here is that computers cannot
read or understand C++ without it first being translated. Another way
a computer read instructions from a high-level language is through
“interpretation” rather the “compilation”. The term “interpretation” is
used by languages whose instructions are read by a translator when
the program is to be run.
Viva La Existance
The instructions for any language exist in files. For high-level
languages these files are known as “source” files as they contain
“source code”. The terms “source” and “source code” are
synonymous … I suppose someone just got tired of saying “code” and
dropped it and no one really has noticed since. Source is actually just
a way of saying “instructions”. When I say “Here my C++ source”,
what I mean is “Here are my instructions written in C++”. For C++,
these files usually have one of the following extensions: “c”, “cpp”,
“cxx”, “h”, or “hpp”. I’ll get into what each of them typically means
later.
Your C++ source files are not executable … though you would like
them to be. You cannot simply run them because the computer
doesn’t understand their language; it only knows the blasphemous
machine language. If you try to “run” a C++ source file on Microsoft
Windows, by say “double-clicking” it (a popular choice for many people
today – double clicking that is) … it will either open the file using a
program (like Microsoft Visual C++, TextPad, etc.) or ask you what you
want to do with it. But it cannot run the file; it isn’t executable.
Remember you must compile (translate) your C++ source files, and
therefore your C++ instructions, into machine code and an executable
file. More succinctly put, you must translate your source file into an
executable file.
Not all executable files can be run directly. Some of them are sucked
in when other files are run. For example, DLL’s (or SO’s if you’re on a
Unices platform) are executable files but you cannot run them directly.
They need additional information to run that you cannot give them;
other programs must.