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.

Scripting Languages 73<br />

2. From the computer’s point of view, the original LISP command now<br />

looks like this:<br />

(list “Hello world”)<br />

This command now displays the following on-screen:<br />

(“Hello world”)<br />

So the command<br />

Book I<br />

Chapter 3<br />

Types of<br />

Programming<br />

Languages<br />

(list (print “Hello world”))<br />

prints the following:<br />

“Hello world”<br />

(“Hello world”)<br />

In the previous example, LISP treats the (print “Hello world”) list first<br />

as a command (to print “Hello world” on-screen) and then as data to feed<br />

into the list command to display the list (“Hello world”) on-screen.<br />

With traditional <strong>programming</strong> languages, like C or BASIC, commands and<br />

data are separate where data may change but commands never change. With<br />

LISP, a list can be both a command and data. That makes it possible <strong>for</strong> a<br />

program to change its lists (treated either as data or as a command), essentially<br />

allowing a program to modify itself while running, which can mimic the<br />

learning and thinking process of a human being.<br />

As you can see, both LISP and Prolog offer radically different ways to program<br />

a computer compared to C or BASIC. Just as languages, like C and<br />

BASIC, free you from the tedium of manipulating registers and memory<br />

addresses to program a computer, so do LISP and Prolog free you from the<br />

tedium of writing explicit step-by-step instructions to program a computer.<br />

Although the idea that a LISP program can modify its own commands might<br />

seem like science fiction, LISP is actually the second oldest <strong>programming</strong> language<br />

still in use today. (FORTRAN is the oldest <strong>programming</strong> language still in<br />

popular use.) LISP was invented in 1958, and although it’s been used primarily<br />

as a research tool, people have created commercial programs using LISP.<br />

Scripting Languages<br />

Languages, such as C and C++, are often dubbed system <strong>programming</strong> languages<br />

because they can create programs that access and manipulate the<br />

hardware of a computer, such as an operating system (Linux and Windows)<br />

or a utility program (an antivirus or anti-spyware program). However, using<br />

systems <strong>programming</strong> languages, like C++, <strong>for</strong> everything can get clumsy.

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

Saved successfully!

Ooh no, something went wrong!