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

THE ADVANTAGES OF INTERPRETED LANGUAGES

Оглавление

A program run by an interpreter is almost always slower than the same program compiled into machine language, so why not compile every language rather than run them under an interpreter?

One of the reasons is that creating a compiler for multiple operating systems is much more difficult than creating an interpreter for multiple operating systems. To create a compiler, you need to know how to translate a programming language into machine code, but because operating systems can run under different processors (such as the ARM or Intel processors), you have to translate language commands into completely different machine language commands. Creating a compiler that works correctly for one processor is hard enough, but creating that same compiler to work under multiple processors identically and error-free is much more difficult.

Compiling a program into machine language is great when you want to distribute a program to others. However, languages like Perl or Ruby are often used to create short programs that run on a web server. Using an interpreter may run a program more slowly, but you can write a program and run it right away without compiling it first. Also, by running the source code directly, interpreters let you see the source code of each program that’s running, so you can edit that source code and see how your changes affect the program. You can still do this with a compiler, but having to compile a program and then store a separate executable version of that program is a minor annoyance that you can avoid completely just by using an interpreter.

Compilers are great for distributing programs. Interpreters are much better for writing and running shorter programs when you don’t care whether anyone can see or copy the source code.

Beginning Programming All-in-One For Dummies

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