Beginning Programming All-in-One For Dummies. Wallace WangЧитать онлайн книгу.
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: Linux, macOS, or Windows.
Some websites let you practice writing and running code completely within a browser. This spares you the trouble of installing a compiler directly on your computer and lets anyone learn to program as long as they have a browser and access to the Internet.
An operating system is a special program that makes all the hardware of your computer work together. The operating system tells the processor how to work with the hard disk, read keystrokes typed on a keyboard, and display information on the monitor. Without an operating system, your computer is nothing more than separate chunks of hardware that do absolutely nothing.
One of the most popular operating systems in the world is Unix, commonly run on big, expensive computers. Linux is based on Unix, so if you understand how to program a Linux computer, you can also program a Unix computer and vice versa.
It’s still possible to write programs for obsolete computers like the Atari ST, PDP-11, or Commodore Amiga, but most people choose to write programs for one of the following operating systems:
Linux: 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.
macOS: macOS is the operating system that runs the Apple Mac computer. Although Macs aren’t as popular as Windows computers, macOS is still a large and lucrative market.
Windows: Windows is the operating system that runs on most personal computers (PCs). Because so many people use Windows PCs at work and at home, the software market for Windows is huge and lucrative.
If you want to prepare yourself for the future, it’s probably best to begin programming on any computer that runs Linux, macOS, or Windows.
With virtualization software such as VirtualBox (
www.virtualbox.org
), you can run different operating systems at the same time, such as running both Linux and Windows on a PC or running both Linux and macOS on a Mac. That way you can practice writing programs for different operating systems on a single computer.
Most programmers use a desktop computer running Linux, macOS, or Windows to write software. With the growing popularity of mobile devices, wearable computers, and browser-based apps, there’s a huge market for writing apps for these devices as well:
Android: Android is Google’s free operating system that runs on the majority of smartphones and some tablets.
iOS and iPadOS: iOS and iPadOS are the operating systems that run on the iPhone and iPad, respectively. The iPhone is the most popular smartphone in the world, and the iPad is the dominant tablet in the world.
watchOS: watchOS is the operating system that runs on the Apple Watch. The Apple Watch is one of the most popular wearable devices in the world.
Wear OS: Wear OS is Google’s free operating system for smart watches. It’s a version of Android that runs on smart watches to compete against the Apple Watch.
To write apps for mobile and wearable operating systems, you normally need to use a computer that runs Linux, macOS, or Windows. However, you can use some of the more powerful tablets to write apps for smartphones and tablets, too.
Writing programs with an editor
After you have a computer that runs Linux, macOS, or Windows (or a powerful tablet), 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.
In the world of computer programming, a single program command is a line of code. Most programs consist of thousands of lines of code, although a large program (like Microsoft Windows) consists of millions of lines of code. When you write a program, you don’t tell people, “I’m writing a program.” You say, “I’m writing code.” It sounds cooler — at least to other programmers.
In the old days, you had to buy a programming editor. Today, you can often get a powerful, professional editor for free. Some editors are bundled with an integrated development environment (IDE), which combines the features of an editor with a compiler (to convert your code to assembly language or machine language) and a debugger (to find and fix problems in your code).
Some popular editors include the following:
GNU Emacs (www.gnu.org/software/emacs
): Editor only for Linux, macOS, and Windows
Playgrounds (www.apple.com/swift/playgrounds
): iPadOS and macOS
Visual Studio (https://visualstudio.microsoft.com
): macOS and Windows, with a limited version available for Linux
Xcode (https://developer.apple.com/xcode
): macOS only
Unlike a word processor, which offers commands for formatting text to make it look pretty or appear in different colors, text editors are just designed for typing commands in a particular programming language, such as C++, Java, or Swift:
The simplest editor just lets you type commands in a file.
More sophisticated editors can help you write a program byColor-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 Swift program that creates a hypotrochoid art figure.
FIGURE 1-2: An editor lets you write and edit the source code of a program.
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.
Professional programmers often get passionate (to the point of fanaticism) about their favorite editors. The quickest way to get into an argument with programmers is to either insult their favorite programming language or insult their favorite editor. If you insult a programmer’s mother, the programmer will probably just shrug and not care one bit.
Program commands stored in one or more files are called the program’s source code. Think of a program’s source code as the recipe that makes the program work. If someone can steal or copy your source code, they’ve effectively stolen your program. That’s why companies like Microsoft jealously guard the source code to all their programs, such as Windows or Excel.
Converting