15.04.2018 Views

programming-for-dummies

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

22<br />

Figuring Out Programming<br />

Big companies, like Microsoft and Adobe, can af<strong>for</strong>d to pay programmers to<br />

write and modify programs to run under different operating systems, such as<br />

Windows and Mac OS X. Most smaller companies and individuals don’t have<br />

the time to rewrite a program to run under multiple operating systems. That’s<br />

why most small companies write programs <strong>for</strong> Windows because it’s the<br />

largest market. If the program proves popular, they can later justify the time<br />

and expense to rewrite that program and compile it to run under Mac OS X.<br />

Choose your compiler carefully. If you use a compiler that can create only<br />

Windows programs, you may never be able to re-compile that program to run on<br />

a different operating system, such as Linux or Mac OS X. One reason Microsoft<br />

gives away their compilers <strong>for</strong> free is to trap people into writing programs that<br />

can run only under Windows. For example, if you write a program with<br />

Microsoft Visual Basic, you can’t run that program on Mac OS X without major<br />

modifications, which most people will probably never do.<br />

Translating source code with an interpreter<br />

In the old days, compilers were notoriously slow. You could feed source<br />

code to a compiler and literally come back the next morning to see if the<br />

compiler was done. If you made a single mistake in your program, you had to<br />

correct it and re-compile your program all over again — with another<br />

overnight wait to see if it even worked.<br />

Trying to write a program with such slow compilers proved maddening, so<br />

computer scientists created something faster called an interpreter. Just like a<br />

<strong>for</strong>eign language interpreter who listens to each sentence you speak and<br />

then translates that sentence into another language, a computer interpreter<br />

does the same thing.<br />

Type a program command into an interpreter, and the interpreter immediately<br />

translates that command into its equivalent machine language command.<br />

Type in another command, and the interpreter translates that second<br />

command right away.<br />

The problem with interpreters is that they only store the equivalent machine<br />

language commands in memory instead of in a separate file like a compiler<br />

does. If you want to sell or distribute your program, you have to give people<br />

your source code, along with an interpreter that can convert your source<br />

code into machine language commands. Because giving away your source<br />

code essentially means giving away your program, everyone who wants to<br />

sell their programs uses a compiler instead of an interpreter.<br />

The original reason why computer scientists developed interpreters was<br />

because compilers were so slow. But after computer scientists started creating<br />

faster compilers, most people stopped using interpreters and just used<br />

compilers. Nowadays, computer scientists use interpreters <strong>for</strong> running

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!