Understanding how computer programming works
History of computer programming
Discovering programming
Getting started
Believe it or not, if you can write a recipe on an index card, you can program a computer. At the simplest level, computer programming is nothing more than writing instructions for a computer to follow, step by step. The most important part of programming isn’t in knowing how to write a program or how to use a particular programming language, but in knowing what to create in the first place.
Some of the most popular and useful computer programs were created by people who didn’t have any formal training in math or computer science. Dan Bricklin invented the spreadsheet while studying for his MBA at Harvard Business School. Scott Cook, who worked in marketing and product development at Proctor & Gamble, created the popular money-management program Quicken after hearing his wife complain about the tedium of paying bills. Nineteen-year old Shawn Fanning created Napster, the first peer-to-peer file-sharing network, after hearing a friend complain about the difficulty of finding his favorite songs on the Internet.
The point is that anyone can figure out how to program a computer. What’s more important than knowing how to program a computer is knowing what to do with your programming skills. As Albert Einstein said, “Imagination is more important than knowledge.” After you have an idea for a program, you can use programming to turn your idea into reality.
Computer programming is nothing more than problem solving. Every program is designed to solve a specific problem. The more universal the problem (calculating formulas in a spreadsheet, managing your money, or searching for music files over the Internet), the more useful and popular the program will be.
The FBI had a problem. They had so much information, stored on paper, scattered among so many agents around the country that finding and using this information was nearly impossible. One agent might have vital information that could help a second agent crack a case, but unless those two agents knew what each other had, that information might as well never have existed in the first place.
So the FBI had a bright idea. Create a computer program that would allow agents to store and share information through the computer. Several years and a $170 million dollars later, the FBI had its program, dubbed Virtual Case File, which consisted of over 700,000 lines of error-prone commands that never even worked. Rather than try to salvage the project, the FBI decided it was easier just to cancel the whole thing and basically flush $170 million taxpayer dollars down the drain.
What went wrong? Although many factors contributed to the project’s failure, one reason stands out in particular. According to an audit of the program conducted by the U.S. Department of Justice, a prime cause for failure was “poorly defined and slowly evolving design requirements.” In other words, the FBI never knew exactly what they wanted the program to do.
How can you aim at a target if you don’t know what it is? You can’t. Or you can try, just as long as you spend $170 million dollars to discover that if you don’t know what you want, you’re probably never going to get it.
Before you even touch a computer, identify the specific problem you want the computer to solve. For example, spreadsheets eliminate the tedium of writing and calculating formulas manually. Word processors make editing and formatting text fast and easy. Even video games solve the problem of keeping people amused.
Although the most popular programs solve universal problems, literally thousands of programs are designed to solve specific problems in niche markets, such as hotel reservation software, construction billing and invoice management programs, and dental office management programs. If you can identify a problem that a computer can solve or simplify, you have an idea for a computer program.
After you know what you want your program to do, the second step is defining all the steps that tell the computer how to solve that particular problem. The exact steps that define how the program should work is called an algorithm. An algorithm simply defines one of many possible ways to solve a problem.
Knowing what you want the computer to do is the first step. The second step is telling the computer how to do it, which is what makes programming so difficult. The more you want the computer to do, the more instructions you need to give the computer.
Think of a computer program as a recipe. It’s easy to write a recipe for making spaghetti. Just boil water, throw in the noodles until they’re soft, drain, and serve. Now consider a recipe for making butternut squash and potato pie with tomato, mint, and sheep’s milk cheese from Crete. Not as simple as boiling water to make spaghetti, is it?
The same principle holds true for computer programming. The simpler the task, the simpler the program. The harder the task, the bigger and more complicated the program:
If you just want a program that displays today’s date on the screen, you won’t need to write many instructions.
If you want to write a program that simulates flying a space shuttle in orbit around the Earth, you’ll need to write a lot more instructions.
The more instructions you need to write, the longer it takes and the more likely you’ll make a mistake somewhere along the way.
Identifying exactly what you want the computer to do
Writing step-by-step instructions that tell the computer how to do what you want
Although computer programming may seem like a recent invention, the idea behind writing instructions for a machine to follow has been around for over a century. One of the earliest designs for a programmable machine (computer) came from a man named Charles Babbage way back in 1834.
That was the year Charles Babbage proposed building a mechanical, steam-driven machine dubbed the Analytical Engine. Unlike the simple calculating machines of that time that could perform only a single function, Charles Babbage’s Analytical Engine could perform a variety of tasks, depending on the instructions fed into the machine through a series of punched cards. By changing the number and type of instructions (punch cards) fed into the machine, anyone could reprogram the Analytical Engine to make it solve different problems.
The idea of a programmable machine caught the attention of Ada Lovelace, a mathematician and daughter of the poet Lord Byron. Sensing the potential of a programmable machine, Ada wrote a program to make the Analytical Engine calculate and print a sequence of numbers known as Bernoulli numbers.
Although Charles Babbage never finished building his Analytical Engine, his steam-driven mechanical machine bears a striking similarity to today’s computers. To make the Analytical Engine solve a different problem, you just needed to feed it different instructions. To make a modern computer solve a different problem, you just need to run a different program.
Over a hundred years later, the first true computer would appear in 1943 when the U.S. Army funded a computer to calculate artillery trajectories. This computer, dubbed ENIAC (Electronic Numerical Integrator and Computer), consisted of vacuum tubes, switches, and cables. To give ENIAC instructions, you had to physically flip its different switches and rearrange its cables.
Physically rearranging cables and switches to reprogram a computer would work, but it was tedious and clumsy. Rather than physically rearranging the computer’s wiring, computer scientists decided it’d be easier if you could leave the computer physically the same but just rearrange the type of instructions you give it. By giving the computer different instructions, you could make the computer behave in different ways.
In the old days, computers filled entire rooms and cost millions of dollars. Today, computers have shrunk so far in size that they’re essentially nothing more than a little silicon wafer, about the size of a potato chip. These silicon wafers are called the central processing unit (CPU), a microprocessor, or just a processor.
A processor is essentially an entire computer. To tell the processor what to do, you have to give it instructions written in machine language — a language that the processor can understand.
To understand how machine language works, you have to understand how processors work. Basically, a processor consists of nothing more than millions of tiny switches that can turn on or off. By turning certain switches on or off, you can make the processor do something useful.
Instead of physically turning switches on or off, machine language lets you turn a processor’s switches on or off by using two numbers: 1 (one) and 0 (zero) where the number 1 can mean “turn a switch on” and the number 0 can mean “turn a switch off.” So a typical machine language instruction might look like this:
1011 0000 0110 0001
If the preceding instruction doesn’t make any sense, don’t worry. The point is that machine language is a just way to tell a processor what to do.
Machine language is considered the native language of CPUs, but almost no one writes a program in machine language because it’s so tedious and confusing. Mistype a single 1 or 0 and you can accidentally give the wrong instruction to the CPU. Because writing instructions in machine language can be so difficult and error-prone, computer scientists have created a somewhat simpler language — assembly language.
The whole purpose of assembly language is to make programming easier than machine language. Basically, one assembly language command can replace a dozen or more machine language commands. So rather than write ten machine language commands (and risk making a mistake in all ten of those commands), assembly language lets you write one command that does the work of ten (or more) machine language commands.
Not only does this reduce the chance of mistakes, but it also makes writing a program in assembly language much faster and easier.
To understand how assembly language works, you must first understand how processors store and manipulate data. The processor is the “brain” of the computer that does all the work. By itself, the processor is fairly useless. (Think of Einstein’s brain floating in a jar of formaldehyde. It may be one of the smartest brains in the world, but if it can’t communicate with the outside world, it’s completely useless as anything other than a very unusual paperweight.)
Like Einstein’s brain in a jar, your computer’s processor is useful only if it can communicate with the outside world. The processor communicates with the other parts of the computer through a series of wires called a bus.
When a processor needs to work with data, it retrieves it from another part of the computer (such as the hard disk or memory) and temporarily stores that data in a storage area called a register, as shown in Figure 1-1.
The processor then edits the data in its registers and sends the changed data back to another part of the computer, such as its memory or hard disk.
So computer programming progressed from physically rearranging wires and switches (with ENIAC), to flipping switches using 1’s and 0’s (with machine language), to telling the computer which data to store in which registers and how to manipulate that data (with assembly language).
A typical assembly language command might look like this:
mov al, 061h
This command tells the processor to move (mov) the hexadecimal number 061h into the specific register named al. Other assembly language commands might tell the processor to add (add) or subtract (sub) a value from the number stored in a specific register.
When you use assembly language, you have to tell the processor what data to store in which registers, how to manipulate the data in its registers, and when to remove data out of its registers.
Sound tedious? It is. Although assembly language is far easier to understand and write than machine language, it’s still too complicated to use for creating really big computer programs, like word processors or video games.
The biggest problem with assembly language is that you need to manipulate the processor’s registers just to do the simplest tasks. If you wanted to add two numbers together, you’d have to tell the processor to store a number into a register, add a second number to the number in the register, and then yank the result out of the register.
Forcing people to know how to manipulate the processor’s registers before they can program a computer is like forcing people to know how their carburetor works before they can drive a car. Ideally, you don’t want to tell the processor how to manipulate data in its registers; you just want the processor to add two numbers without worrying about specific registers. So to make computer programming even easier, computer scientists have hidden the technical details of manipulating registers by creating high-level languages.
The whole purpose of high-level languages is to make programming more intuitive. So rather than tell the computer to store the number 2 in register al, add the number 3 to the number stored in register al, and then yank out the result from register al, high-level languages let you tell the computer what to do and not worry about how the computer does it. So a typical high-level language command might look like this:
Total = 2 + 3
As you can see, high-level languages are much easier to read and understand, even if you know nothing about programming. Where assembly language forces you to tell the processor what to do and how to do it, high-level languages just let you tell the processor what to do.
Besides making programming more intuitive, high-level languages also make programming easier because a single high-level language command can do the work of a dozen (or more) assembly language commands.
A thousand lines of assembly language commands might do nothing more than multiply two numbers together. A thousand lines of high-level language commands might create a video game, a music player, or a stock market analysis program. By using high-level languages, programmers can spend more time being productive and less time worrying about the technical details of the computer.
High-level languages isolate you from the technical details of programming, but by isolating you from these details, high-level languages also limit what you can do. So as a compromise between assembly language (which can manipulate the processor) and high-level languages (which isolate you from the details of manipulating the processor), computer scientists created an intermediate language dubbed C.
The idea behind the C programming language is to give programmers the ability to manipulate the processor directly like assembly language, but also give you the chance to ignore these technical details, if you want, like a high-level language.
As a result, a C program doesn’t look as cryptic as assembly language, but also isn’t as easy to read as a high-level language, as the following C program demonstrates:
#include <stdio.h>
int main(void)
{
printf(“Hello World!\n”);
exit(0);
}
The whole purpose of machine language, assembly language, high-level language, and the C language is to give you different ways to give instructions to the processor (computer). Ultimately, it doesn’t matter which type of programming language you use because it’s possible to write the exact same program in machine language, assembly language, a high-level language (like BASIC or FORTRAN), and C.
The only difference is that writing a program in machine language takes a really long time and is very difficult to write, fix, and understand. A similar program written in assembly language is smaller and simpler than an equivalent machine language program.
Writing the same program in the C language makes the program even smaller and much easier to write and understand. If you use a high-level language, the program would most likely be the smallest and easiest to understand out of them all.
So given these advantages of C or high-level languages, why would anyone ever use machine language or assembly language? The answer is simple: speed and efficiency.
If you want to write the smallest, fastest program possible, use machine language because machine language is the native language of all computers. Unfortunately, machine language is so hard to understand, write, and modify that writing anything but small programs in machine language is nearly impossible.
Rather than use machine language, most programmers use assembly language when they need speed and efficiency. Assembly language creates small and fast programs, but they’ll never be as small or fast as machine language programs. That’s because processors understand only machine language, so when you write an assembly language program, you have to translate that assembly language program into machine language.
Translating assembly language into machine language by hand would be slow and error-prone, so computer scientists have created special programs that can do this automatically. These programs are assemblers.
An assembler takes an assembly language program and converts it into machine language, but this conversion process isn’t perfect. That’s why assembly language tends to create bigger and slower programs than equivalent hand-crafted machine language programs. However, assembly language programs are much easier to write and modify later than machine language, so assembly language is used much more often than machine language.
High-level languages are much easier to write and understand than machine or assembly language. The problem is that processors don’t understand high-level languages either, so you have to translate a high-level language program into equivalent machine language commands.
Doing this by hand is nearly impossible, so computer scientists have created special programs — compilers — to do this for them. A compiler does nothing more than take a program written in a high-level language and translates it into equivalent commands written in machine language.
This translation process isn’t perfect so that’s why programs written in high-level languages tend to be much bigger and slower than equivalent programs written in machine or assembly language. So when programmers want to create large, complicated programs that still run fast and take up as little space as possible, they tend to rely on the C programming language. That’s why so many programs are written in C because C creates programs nearly as small and fast as assembly language programs, while also being nearly as easy to write and understand as high-level languages. (Note the emphasis on the word “nearly.”)
As a general rule, if you want to make programming easy where speed and efficiency aren’t that crucial, use a high-level programming language. If you want to make a small and fast program and don’t care how inconvenient it may be to write it, use machine or assembly language.
What if you want to write a big and fast program (like an operating system or word processor) and also make it convenient for you to write? You’d use the C programming language.
Ultimately, no one cares what language you use just as long as your program works. A program that works is far better than a small, fast, and efficient program that doesn’t work. Think of a programming language as a tool. A good programmer can use any tool well, but a bad programmer can screw up using the best tool in the world.
The programmer’s skill always determines the quality of any program; the type of programming language used is always secondary. So the goal isn’t to become a “C programmer” or a “FORTRAN programmer.” The goal is to become a good programmer, regardless of the language you ultimately use.
After you understand that programming is nothing more than telling a computer how to solve a problem, you may wonder how you can get started figuring out programming on your own. If you want to figure out how to program a computer, this is what you need:
Desire
A computer
An editor
An assembler or a compiler
A lot of time on your hands
Desire is probably the biggest factor in studying how to program a computer. Many people think that you need a college degree or a mathematical background to know computer programming. Although a college degree and a mathematical background can definitely help, it’s not necessary. Saying you need to know math before figuring out computer programming is like saying you need a college degree in biology before you can reproduce.
Some of the most influential and popular programs in the world were created by people who had no formal training in computer programming or computer science. (Conversely, that also means that some of the most intelligent PhD candidates in computer science have done nothing to make this world a better place using their programming skills.)
So if you have an idea for a program, you can create it. After you have the desire to understand computer programming, you have (almost) everything you need to program a computer.
If you want to know how to program a computer, you need a computer to practice on. You can actually discover programming on any computer from a top-of-the-line machine, to an obsolete relic (that was once a top-of-the-line machine), to a simple handheld computer. As long as you have a computer, you can find out how to program it.
Although it’s possible to figure out programming by using an ancient Commodore-64 or an antique Radio Shack TRS-80, it’s probably best to figure out programming on a computer that’s going to be around in the future. That way you can directly apply your programming skills to a computer used in the real world, which boils down to a computer that runs one of the following operating systems: Windows, Linux, or Mac OS X.
Because so many businesses use computers that run Windows, many computer programmers focus their efforts on discovering how to write Windows programs. If you want to make money, write programs for the computers that most people use. At the time of this writing, that’s any computer that runs Windows.
Although the Windows market is the largest, don’t ignore these markets:
Mac OS X is the operating system that runs the Macintosh computer.
Apple Macintosh computers are growing steadily in popularity, so the Mac OS X market will be lucrative for the future.
Linux is a free operating system for almost every computer (including PCs).
Linux is becoming more popular with big companies (as opposed to individual users), so there’s a growing market for talented Linux programmers.
If you want to prepare yourself for the future, it’s probably best to begin programming on any computer that runs Windows, Linux, or Mac OS X.
After you have a computer that runs Windows, Linux, or Mac OS X, the next step is to get an editor. An editor acts like a simple word processor that lets you type, change, and save program commands in a file.
Almost every operating system comes with a free editor:
In Windows, the free editor is Notepad.
In Linux, hundreds of free editors — like Vi and Emacs — are available.
Mac OS X comes with a free word processor called TextEdit, which can work as a text editor.
If you’re using Mac OS X, you may find it easier to use a dedicated text editor such as TextWrangler (www.barebones.com) or jEdit (www.jedit.org). Both TextWrangler and jEdit are free.
Unlike a word processor, which offers commands for formatting text to make it look pretty or appear in different colors, a text editor is just designed for typing commands in a particular programming language, such as assembly language or C:
The simplest editor just lets you type commands in a file.
More sophisticated editors can help you write a program by
• Color-coding program commands (to help you identify them easily)
• Indenting your code automatically (to make it easier to read)
• Typing in commonly used commands for you
Figure 1-2 shows a simple editor used to write a BASIC program that creates a lunar lander video game.
Without an editor, you can’t write a program. With an editor, you can write a program, and with a really good editor, you can write a program quickly and easily.
An editor lets you type and save program commands (source code) in a file. Unless you’ve written a program completely in machine language, your source code might as well have been written in Swahili because processors don’t understand any language other than machine language.
So to convert your source code into machine language commands, you have to use an assembler (if you wrote your program commands in assembly language) or a compiler (if you wrote your program commands in the C language or a high-level language, like BASIC).
After converting your source code into equivalent machine language commands, an assembler or compiler saves these machine language commands in a separate file, often called an executable file, or just an EXE file. When you buy a program, such as a video game or an antivirus program, you’re really buying an executable file. Without an assembler or a compiler, you can’t create your program.
Compilers translate source code into machine language, which is the native language of a specific processor. But what if you want your program to run on different processors? To do this, you have to compile your program into machine language for each different processor. You wind up with one executable file for each processor, such as an executable file for an Intel Core Duo 2 processor and a separate executable file for a PowerPC processor.
One executable file contains machine language code for the PowerPC processor (used in older Macintosh computers).
The second executable file contains machine language code for the Intel processor (used in new Macintosh computers).
Most compilers work only on one specific operating system and processor. So a Windows compiler can only create programs that run under the Windows operating system. Likewise, a Linux compiler can only create programs that run under the Linux operating system.
If you write a program that runs under Windows, you can re-compile it to run under Linux. Unfortunately, you may have to modify your program slightly (or a lot) to make it run under Linux.
In the old days, compilers were notoriously slow. You could feed source code to a compiler and literally come back the next morning to see if the compiler was done. If you made a single mistake in your program, you had to correct it and re-compile your program all over again — with another overnight wait to see if it even worked.
Trying to write a program with such slow compilers proved maddening, so computer scientists created something faster called an interpreter. Just like a foreign language interpreter who listens to each sentence you speak and then translates that sentence into another language, a computer interpreter does the same thing.
Type a program command into an interpreter, and the interpreter immediately translates that command into its equivalent machine language command. Type in another command, and the interpreter translates that second command right away.
The problem with interpreters is that they only store the equivalent machine language commands in memory instead of in a separate file like a compiler does. If you want to sell or distribute your program, you have to give people your source code, along with an interpreter that can convert your source code into machine language commands. Because giving away your source code essentially means giving away your program, everyone who wants to sell their programs uses a compiler instead of an interpreter.
Creating separate executable files for each processor can get clumsy and giving away your source code with an interpreter may be unreasonable, so a third approach is to compile your program into an intermediate format called bytecode or pseudocode (often abbreviated as p-code). Unlike compiling source code directly into machine language, you compile your program into a p-code file instead.
You can take this p-code file and copy it on any computer. To run a p-code file, you need a special p-code interpreter, or a virtual machine. The virtual machine acts like an interpreter and runs the instructions compiled into the p-code file.
The advantage of p-code is that you can distribute a single p-code version of your program, which can run on multiple computers.
P-code has a couple disadvantages:
• P-code programs don’t run as fast as programs compiled into machine language.
• If a computer doesn’t have the right virtual machine installed, it can’t run your program.
The most popular programming language that uses p-code is Java. After you write a Java program, you can compile it into a p-code file, which can run on any computer that has a copy of the Java virtual machine (VM), such as Windows, Mac OS X, and Linux.
Programming is a skill that anyone can acquire. Like any skill, the best way to understand is to take the time to experiment, make mistakes, and learn from your failures. Some programmers prefer to spend their time mastering a single programming language. Others prefer to master the intricacies of writing programs for a specific operating system, such as Windows. Still others spend their time discovering a variety of programming languages and writing programs for different operating systems.
There is no right or wrong way to figure out programming. The only “right” way is the way that works for you. That’s why self-taught programmers can often write programs that are just as good (or even better) than programs written by PhD computer scientists.
Like any skill, the more time you spend programming a computer, the better you get. This book is designed to help you get started, but ultimately, it’s up to you to take what you know and start programming your own computer.
Believe it or not, programming a computer is actually fairly straightforward. The hard part is trying to write a program that actually works.
You can read about computer programming from a book, but the best way to understand computer programming is to actually write some programs on a real computer. If you don’t have a computer, borrow a friend’s computer or find some other way to get access to a computer. Trying to become skilled at computer programming without a computer is like trying to become skilled at swimming without any water.
To find out about programming, you need an editor and a compiler that works on your computer. Although you could buy an editor and a compiler, why bother when you can find so many editors and compilers for free?
You can figure out programming by using a free editor and a compiler; if you later decide you don’t like programming or the particular editor and compiler you’re using, you haven’t lost any money, so just erase it off your computer.
To encourage as many people as possible to write programs for Windows, Microsoft gives away free compilers called Visual Basic Express, Visual C++ Express, Visual C# Express, and Visual J++, which you can download from the Internet at http://msdn.microsoft.com/vstudio/express.
Most professional programmers use Microsoft compilers, so if you’re interested in knowing how to write programs for Windows, you might as well discover programming through one of Microsoft’s compilers as well.
If you don’t want to use one of Microsoft’s free compilers, plenty of free alternatives are just as good (or better). One popular compiler company is Borland, which offers three free compilers called Turbo C++, Turbo C#, and Turbo Delphi. You can download these at www.turboexplorer.com.
By giving away free compilers, companies like Microsoft and Borland hope to get you “hooked” on using their tools so you’ll eventually buy the more advanced, professional versions that offer additional features. If you need to write programs professionally, you’ll probably want to buy these professional versions, but when you’re just starting to program, these free compilers are great ways to discover programming without having to spend any money.
Some other free Windows compilers include Dev-C++ and Dev-Pascal (www.bloodshed.net) and Just BASIC (www.justbasic.com).
The most popular compiler for writing Mac OS X programs is Xcode, which comes with every Macintosh, although you can download the latest version for free at http://developer.apple.com/tools. Xcode is the same compiler that Microsoft, Adobe, and even Apple use to create programs like Microsoft Excel, Adobe PhotoShop, and iTunes.
Although most Mac OS X programmers use the free Xcode program to help them write programs, you can always buy other compilers for the Macintosh. The main reason to buy a compiler, rather than use the free Xcode tool, is if you want to use a programming language that Xcode doesn’t offer, such as BASIC. (Xcode lets you write programs in C, C++, Objective-C, and Java.)
The most popular free compiler for Linux is GCC, which stands for GNU Compiler Collection (http://gcc.gnu.org). Unlike other compilers that can compile only a single programming language, the GCC compiler can compile programs written in a variety of different programming languages.
I discuss in Book I, Chapter 3 that BASIC is one of the most popular beginner’s programming languages. If you want to write and compile a BASIC program for Linux, you can’t use the GCC compiler. Instead, you can grab a free copy of REALbasic (www.realbasic.com).
REALbasic gives away the Linux version of their compiler because they hope you’ll pay for the professional version, which lets you compile your programs for Linux, Windows, and the Mac OS X operating systems. If you just want to write BASIC programs in Linux, you can use the free version of REALbasic for as long as you want.
No matter which operating system you use, you can always get started programming with the Java language. If you want to write and run Java programs, you need
A Java compiler and virtual machine, which you can download for free from Sun Microsystems (http://java.sun.com)
An editor because the Java compiler doesn’t include one. If you want an editor to help you write Java programs, you can get a free one called NetBeans (www.netbeans.org), BlueJ (www.bluej.org), or Eclipse (www.eclipse.org).
There’s a big difference between knowing how to program compared to knowing a specific programming language. This book describes how programming works, which means you’ll understand the principles behind programming no matter what programming language you decide to use.
When you understand a specific programming language, you’ll figure out how to write a program using that language. Don’t confuse knowing how to program with knowing a programming language!
When people learn to speak their native language, they often think their particular spoken language is the only way to talk. So when they learn a foreign language, they try to speak the foreign language just like they speak their native language, but using different words. That’s why literal translations of foreign languages can sound so funny and awkward to a native speaker.
That’s exactly the same problem with understanding programming. To understand programming, you have to use a specific programming language, but each programming language works a certain way. So if you know how to write programs in the C programming language, you might mistakenly think that the way the C language works is the way computer programming also works, but that’s not true.
Like human languages, programming languages differ wildly. Someone who knows how to write programs in the C language thinks differently about programming than someone who knows how to write programs in assembly language.
So to describe how programming works, this book uses a variety of examples from different programming languages. You don’t have to understand how each program example in this book works. Just understand that programming languages can look and solve identical problems in wildly different ways.
First, try to understand general programming principles without worrying about the way a particular programming language works. Then try to understand how a particular programming language works. As long as you know how to keep these two topics separate, you can figure out how to program a computer without the distraction of knowing a particular programming language.
At one time, most programmers used assembly language. Then they used Pascal. When Pascal fell out of favor, programmers gravitated toward C. Because C was so hard to understand, many people started using BASIC. At the time of this writing, programmers have been flocking toward C++, C#, and Java. Tomorrow, who knows which programming language will be popular?