Beginning Programming All-in-One For Dummies. Wallace Wang

Чтение книги онлайн.

Читать онлайн книгу Beginning Programming All-in-One For Dummies - Wallace Wang страница 40

Beginning Programming All-in-One For Dummies - Wallace Wang

Скачать книгу

systems, but that’s still much easier than writing a program from scratch for another operating system.

      Despite these drawbacks, Java has grown in popularity. Many companies write and sell programs entirely written in Java. As computers get faster and Oracle improves the performance of its VM, programs written in Java probably will run fast enough for most uses.

      To write programs, you need an editor, which acts like a special word processor just for helping you write commands in your favorite programming language. After you type your program commands in an editor, you can save this file (known as the source code). Then, you can feed this source code file into a compiler to turn it into a working program.

      You can choose from two types of editors: stand-alone or integrated development environment (IDE). Your best bet probably depends on whether you write programs in more than one programming language.

      Stand-alone editors

      A stand-alone editor is nothing more than a separate program that you run when you want to edit your program. You run the compiler separately.

      

If you regularly write programs in different programming languages, you may want to use a stand-alone editor. That way you can get familiar with all the features of a single editor.

      You can buy stand-alone editors, but here are two popular free ones; both of these editors run on multiple operating systems (such as Linux, macOS, and Windows):

       GNU Emacs (www.gnu.org/software/emacs/emacs.html)

       VIM (www.vim.org)

The nearby sidebar, “Common editor features,” lists features you find in most editors, including stand-alone editors.

      COMMON EDITOR FEATURES

      Whether you prefer a stand-alone editor or an integrated development environment, most editors offer the following features:

       Multiple undo/redo commands let you experiment with making changes to your source code. If they don’t work out, you can undo your changes. Typically, editors let you undo a large number of changes you made, such as the last 100 changes.

       Multiple file editing comes in handy so you can view different files in separate windows and copy code from one window to another, or just study how one part of your program will interact with another part of that same program.

       Syntax completion and highlighting is when the editor recognizes certain programming languages, such as C++ and Java. The moment you type a valid language command, the editor can finish typing that command for you at the touch of a button, thereby saving you time. So, if you type a typical if-then statement, the editor automatically types in a generic if-then statement (complete with necessary parentheses), so you just type in the actual data to use.

       Syntax highlighting occurs after you write a program; the editor highlights valid language commands to help you separate language commands from any data and commands you create. Without syntax highlighting, source code can look like a mass of text. With syntax highlighting, source code can be easier to read and understand.

       Automatic indentation and parentheses matching where indentation can align your code to make it follow a standard indentation format while parentheses matching helps you identify where an opening parenthesis, square bracket, or curly bracket begins and ends.

       Macros let you customize the editor and essentially program the editor to repeat commonly needed tasks, such as always displaying program commands in uppercase letters. If the editor doesn’t offer a feature you want or need, its macro language lets you add that feature. Without a macro language, an editor won’t give you the flexibility to work the way you want.

       Project management helps you keep your source code files organized. Most programs no longer consist of a single file but of multiple files. Trying to keep track of which files belong to which project can be confusing, so an editor can help you store and organize your files so you won’t lose track of them.

      Integrated development environments

Snapshot shows an IDE provides access to multiple programming tools within a single UI.

      FIGURE 4-5: An IDE provides access to multiple programming tools within a single UI.

      

If you mostly write programs in a single programming language, using an IDE can be more convenient than a stand-alone editor.

      Features

      In addition to a compiler and all the usual features of stand-alone editors (see the “Common editor features” sidebar), many IDEs include other features in a convenient UI:

       A debugger helps identify problems in your program.

       File management helps organize the source code for your various projects.

       A profiler helps identify which parts of your program may be slowing down the performance of your entire program.

       A graphical user interface (GUI) designer helps you design the appearance of your program’s windows, drop-down lists, and buttons.

      Free software

      Many compilers come with their own IDE, but you can always use another IDE or a stand-alone editor instead. These IDEs are popular (and free):

       Apache NetBeans (https://netbeans.apache.org): Designed for writing Java programs, it can be used for writing C and C++ programs as well. NetBeans is available for multiple operating systems.

       Atom (https://atom.io): Atom is an open-source editor for Linux, macOS, and Windows.

       Eclipse (www.eclipse.org): Designed for writing Java programs, it can also be used for writing C, C++, PHP, and even COBOL programs. Eclipse is available for multiple operating systems.

      Eventually,

Скачать книгу