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.

Teaching Languages 55<br />

The Interactivity of BASIC Interpreters<br />

One reason why <strong>programming</strong> in the old days<br />

was so time-consuming was because you<br />

could never run a program until you compiled<br />

(translated) it into machine language. So if you<br />

wrote a program in a language like COBOL, you<br />

had to compile it into machine language first.<br />

Not only were early compilers notoriously slow<br />

(taking hours to compile even the simplest programs),<br />

but compilers also required that you<br />

write a complete program, even if you just<br />

wanted to write a single command.<br />

BASIC avoided this problem by using an interpreter<br />

instead. Unlike a compiler that would<br />

convert an entire program into machine language,<br />

an interpreter would convert each command<br />

into machine language and show you the<br />

results of your command right away.<br />

Because an interpreter could show you what<br />

each command would do, you could see right<br />

away if you typed a correct command or not.<br />

Such instant feedback could help you catch on<br />

to <strong>programming</strong> faster. Think how fast you can<br />

understand a <strong>for</strong>eign language if you can practice<br />

on someone sitting right in front of you.<br />

Now think how fast you could understand a <strong>for</strong>eign<br />

language if you had to write a letter to a<br />

pen pal overseas and then wait three weeks <strong>for</strong><br />

a reply. That’s the difference between a compiler<br />

in the old days (like writing and waiting <strong>for</strong><br />

a letter from overseas) and an interpreter (like<br />

talking to someone face to face).<br />

Nowadays, compilers are so fast that you can<br />

get near-instant feedback with most <strong>programming</strong><br />

languages, so this initial advantage of<br />

BASIC is no longer relevant. Almost all of today’s<br />

versions of BASIC use a compiler instead of an<br />

interpreter.<br />

Book I<br />

Chapter 3<br />

Types of<br />

Programming<br />

Languages<br />

Turtle graphics with Logo<br />

BASIC introduced the idea of giving programmers instant feedback every<br />

time they typed in another BASIC command. If you typed in the following<br />

BASIC command:<br />

PRINT 2+4<br />

The BASIC interpreter would display the following on-screen:<br />

6<br />

Although giving programmers instant feedback made figuring out <strong>programming</strong><br />

easier, a computer scientist named Seymour Papert felt that <strong>programming</strong><br />

should be accessible to everyone, including children. Because few<br />

children are excited about adding 2+4 together and seeing the number 6<br />

appear, Seymour Papert thought that a better <strong>for</strong>m of instant feedback <strong>for</strong><br />

children would involve seeing the results of your program visually.

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

Saved successfully!

Ooh no, something went wrong!