Читать книгу Beginning Programming All-in-One For Dummies - Wallace Wang - Страница 25

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.

Beginning Programming All-in-One For Dummies

Подняться наверх