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

Scripting Languages

Оглавление

Languages, such as C and C++, are often dubbed system programming languages because they can create programs that access and manipulate the hardware of a computer, such as an operating system (for example, Linux or Windows) or a utility program (for example, an antivirus or anti-spyware program). However, using system programming languages, like C++, for everything can get clumsy. Instead of writing an entirely new program from scratch using a system programming language, more people are likely to use an existing program and customize it in some way. Programming languages that customize existing programs are typically called scripting languages.

Scripting languages work with one or more existing programs and act as “glue” that connects different parts of an existing program together. For example, Microsoft Office consists of several programs including a word processor (Microsoft Word), a spreadsheet (Microsoft Excel), and a database (Microsoft Access). By using the scripting language that comes with Microsoft Office, you can write a program that can automatically yank information from an Access database, create a chart from that information in an Excel spreadsheet, and then copy both the data and its accompanying chart into a Word document for printing.

Trying to yank information from a database, create a chart with it, and print the data and chart using a system programming language, like C++ or Java, would mean creating everything from scratch including a database, a spreadsheet, and a word processor. By using a scripting language, you use existing components and simply “glue” them together. The existing components do all the work, while the scripting language just passes the data from one component to another.

Because scripting languages work with existing programs, they differ from traditional programming languages (like C++ or Java) in two important ways:

 Because scripting languages work with one or more existing programs, scripting languages are usually interpreted rather than compiled. Therefore, if someone else wants to run your program, written in a scripting language, they need the source code to your program along with all the programs your scripting program needs, such as Microsoft Word and Microsoft Access. As a result, scripting languages are used less to create commercial applications and more to create custom solutions.

 To make scripting languages easy to understand and use, even for nonprogrammers, most scripting languages are typeless languages. System programming languages, like C++ and Swift, are strongly typed or type-safe languages. Strongly-typed languages force you to define the type of data your program can use at any given time. So, if your program asks the user to type a name, a strongly typed language makes sure that the user doesn’t type in a number by mistake. This protects a program from accidentally trying to manipulate the wrong type of data, which could crash the program as a result.In comparison, typeless languages don’t care what type of data the program stores at any given time. This makes writing programs much easier because your program assumes if it’s going to yank data from a particular program, such as Microsoft Excel, the data is probably going to be the right “type” anyway, so type-checking would just be restrictive and tedious.

Scripting languages are typically used in four different ways:

 To automate repetitive tasks

 To customize the behavior of one or more programs

 To transfer data between two or more programs

 To create stand-alone programs

Beginning Programming All-in-One For Dummies

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