15.04.2018 Views

programming-for-dummies

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

74<br />

Scripting Languages<br />

Rather than write an entirely new program from scratch using a systems <strong>programming</strong><br />

language, more people are likely to use an existing program and<br />

customize it in some way. Programming languages that customize existing<br />

programs are typically called scripting languages.<br />

Scripting languages work with one or more existing programs and act as<br />

“glue” that connects different parts of an existing program together. For<br />

example, the Microsoft Office suite consists of a word processor (Microsoft<br />

Word), a spreadsheet (Microsoft Excel), and a database (Microsoft Access).<br />

By using the scripting language that comes with Microsoft Office, you can<br />

write a program that can automatically yank in<strong>for</strong>mation from an Access<br />

database, create a chart from that in<strong>for</strong>mation in an Excel spreadsheet, and<br />

then copy both the data and its accompanying chart into a Word document<br />

<strong>for</strong> printing.<br />

Trying to yank in<strong>for</strong>mation from a database, create a chart with it, and print<br />

the data and chart using a systems <strong>programming</strong> language, like C++ or<br />

Pascal, would mean creating everything from scratch including a database, a<br />

spreadsheet, and a word processor. By using a scripting language, you use<br />

existing components and simply “glue” them together. The existing components<br />

do all the work while the scripting language just passes the data from<br />

one component to another.<br />

Because scripting languages work with existing programs, they differ from traditional<br />

<strong>programming</strong> languages (like C++ or BASIC) in two important ways.<br />

First, because scripting languages work with one or more existing programs,<br />

scripting languages are usually interpreted rather than compiled. There<strong>for</strong>e,<br />

if someone else wants to run your program, written in a scripting language,<br />

they need the source code to your program along with all the programs your<br />

scripting program needs, such as Microsoft Word and Microsoft Access. As a<br />

result, scripting languages are used less to create commercial applications<br />

and more to create custom solutions.<br />

Second, to make scripting languages easy to understand and use, even <strong>for</strong><br />

non-programmers, most scripting languages are typeless languages. (Systems<br />

<strong>programming</strong> languages, like C++ and Pascal, are strongly-typed or type-safe<br />

languages.)<br />

Strongly-typed languages <strong>for</strong>ce you to define the type of data your program<br />

can use at any given time. So if your program asks the user to type a name, a<br />

strongly-typed language makes sure that the user doesn’t type in a number<br />

by mistake. This protects a program from accidentally trying to manipulate<br />

the wrong type of data, which could crash the program as a result.

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

Saved successfully!

Ooh no, something went wrong!