Jump to content

Scripting language

From Simple English Wikipedia, the free encyclopedia
Revision as of 19:40, 16 November 2016 by Nerfer (talk | changes) (History: Fixed a link)

A scripting or script language is a programming language that supports scripts. Scripts are usually short computer programs that automate steps that could be done by hand by a person. It is often a simpler language, and easier to learn than other languages, but still can do many things.

Scripts may run inside of another program, like a web browser or Microsoft Excel. They may also be a shell that runs from a command line interface and makes calls to the operating system (OS). The shell is considered interactive - the user can choose what to type, and the shell responds to the command. These can be used to control jobs on mainframes and servers.

Some people say a scripting language must be tied to a specific use. Others use a wider definition and include Dynamic programming languages that are interpreted (rather than compiled). These are called general purpose, and can be used in many ways. Some general-purpose languages (such as Visual Basic) have variations that can be scripted. Most of this page will use the narrower definition. There is no specific rule on what is, or is not, a scripting language.

Examples

Some common examples of scripting languages:

  • Bash and C shell, as control languages for the Unix or Unix-like operating systems
  • Scripts that run inside another applications are called an extension language. Web browsers allow several kinds of scripts, including ECMAScript (JavaScript) or XUL. For instance, the Google home page uses JavaScript. Visual Basic for Applications is used inside Microsoft Office. Lua is a language purposely made as an extension language, and can be used within many applications.
  • Games that have scripting extensions include the Second Life virtual world and the Trainz Railroad simulators. In other games like Wesnoth, the variety of actual games played are scripts written by other users.
  • Text-processing languages sed and [[AWK]
  • General purpose: Perl,[1] Tcl, and Python[2] are high-level programming languages (closer to human language than to machine code) that can be used for a many different things. Some of these languages were first made for a particular use, and then were changed into general-purpose languages.

Characteristics

Most scripting languages are made to be easy to learn. They often can be either short files with source code, or entered one command at a time in a command line interface, which has a read–eval–print loop (REPL, language shell).[3] This usually means a simple syntax and semantics. There might not be functions or a main, it just runs from start to finish.

For example, most people do not call Java a scripting language, because of its lengthy syntax and rules about which classes exist in which files, and because Java cannot be executed interactively in a REPL. It needs files with source code, and they can only contain definitions that must be used by a host application or application launcher. (Java is not the same as JavaScript).

But Python allows choices - functions can be put in a file, it can be run without functions and use imperative programming style, or even use it interactively (type and run one line at a time).

print ("Hello World")

This one line of Python code prints "Hello World"; no main() function or anything else is needed.

A scripting language is usually interpreted from source code or bytecode.[4] However, the application or OS that runs the script is often written in a compiled language and distributed in machine code form (as an executable that doesn't make sense to humans).

Scripting languages may be designed to be used by the people using a program — end-user development. Other times they may be built by programmers for their own use. Scripting languages often use abstraction, a form of information hiding. This means users do not need to know the details of variable types, data storage, and memory management.

Scripts are often made or changed by the person executing them,[5] but some are shared or sold to others. For example, when large parts of games are written in a scripting language. Sometimes a script can be compiled before others use it. Once compiled, it will run faster and doesn't need another application to run it. And it prevents end users from changing the code.

History

Early mainframe computers (in the 1950s) were not interactive, but used scripts stored in batch files. IBM's Job Control Language (JCL) is the common example of a scripting language used to control batch processing.[6]

The first interactive shells were made in the 1960s to help remote operation of the first time-sharing systems. These used shell scripts, which can run computer programs within a computer program, the shell. Calvin Mooers in his TRAC language is generally given credit with inventing command substitution. This lets commands change the script (self-modifying code).[7] Multics calls these active functions.[8] Louis Pouzin wrote an early processor for command scripts called RUNCOM for CTSS around 1964. Stuart Madnick at MIT wrote a scripting language for IBM's CP/CMS in 1966. He originally called this processor COMMAND, later named EXEC.[9] Multics included an offshoot of CTSS RUNCOM, also called RUNCOM.[10] EXEC was eventually replaced by EXEC 2 and REXX.

Languages such as Tcl and Lua were made from the start to be general-purpose scripting languages that could be put into any application. Other languages such as Visual Basic for Applications (VBA) could do much of the same, but needed to work only with certain applications. Using a general-purpose scripting language instead of making a new language for each application usually makes it easier for both the person writing the application and the user writing the scripts.

Types of scripting languages

Glue languages

Scripting is often contrasted with system programming, as in Ousterhout's dichotomy or "programming in the large and programming in the small". In this view, scripting is particularly glue code, connecting software components, and a language specialized for this purpose is a glue language. Pipelines and shell scripting are archetypal examples of glue languages, and Perl was initially developed to fill this same role. Web development can be considered a use of glue languages, interfacing between a database and web server. But if a substantial amount of logic is written in script, it is better characterized as simply another software component, not "glue".

Glue languages are especially useful for writing and maintaining:

  • custom commands for a command shell;
  • smaller programs than those that are better implemented in a compiled language;
  • "wrapper" programs for executables, like a batch file that moves or manipulates files and does other things with the operating system before or after running an application like a word processor, spreadsheet, data base, assembler, compiler, etc.;
  • scripts that may change;
  • rapid prototypes of a solution eventually implemented in another, usually compiled, language.

Glue language examples:

Macro languages exposed to operating system or application components can serve as glue languages. These include Visual Basic for Applications, WordBasic, LotusScript, CorelScript, Hummingbird Basic, QuickScript, SaxBasic, and WinWrap Basic. Other tools like AWK can also be considered glue languages, as can any language implemented by an Windows Script Host engine (VBScript, JScript and VBA by default in Windows and third-party engines including implementations of Rexx, Perl, Tcl, Python, XSLT, Ruby, Delphi, &c). A majority of applications can access and use operating system components via the object models or its own functions.

Other devices like programmable calculators may also have glue languages; the operating systems of PDAs such as Windows CE may have available native or third-party macro tools that glue applications together, in addition to implementations of common glue languages—including Windows NT, MS-DOS and some Unix shells, Rexx, PHP, and Perl. Depending upon the OS version, WSH and the default script engines (VBScript and JScript) are available.

Programmable calculators can be programmed in glue languages in three ways. For example, the Texas Instruments TI-92, by factory default can be programmed with a command script language. Inclusion of the scripting and glue language Lua in the TI-NSpire series of calculators could be seen as a successor to this. The primary on-board high-level programming languages of most graphing calculators (most often Basic variants, sometimes Lisp derivatives, and more uncommonly, C derivatives) in many cases can glue together calculator functions—such as graphs, lists, matrices, etc. Third-party implementations of more comprehensive Basic version that may be closer to variants listed as glue languages in this article are available—and attempts to implement Perl, Rexx, or various operating system shells on the TI and HP graphing calculators are also mentioned. PC-based C cross-compilers for some of the TI and HP machines used in conjunction with tools that convert between C and Perl, Rexx, AWK, as well as shell scripts to Perl, VBScript to and from Perl make it possible to write a program in a glue language for eventual implementation (as a compiled program) on the calculator.

Job control languages and shells

A major class of scripting languages has grown out of the automation of job control, which relates to starting and controlling the behavior of system programs. (In this sense, one might think of shells as being descendants of IBM's JCL, or Job Control Language, which was used for exactly this purpose.) Many of these languages' interpreters double as command-line interpreters such as the Unix shell or the MS-DOS COMMAND.COM. Others, such as AppleScript offer the use of English-like commands to build scripts.

GUI scripting

With the advent of graphical user interfaces, a specialized kind of scripting language emerged for controlling a computer. These languages interact with the same graphic windows, menus, buttons, and so on that a human user would. They do this by simulating the actions of a user. These languages are typically used to automate user actions. Such languages are also called "macros" when control is through simulated key presses or mouse clicks, as well as tapping or pressing on a touch-activated screen.

These languages could in principle be used to control any GUI application; but, in practice their use is limited because their use needs support from the application and from the operating system. There are a few exceptions to this limitation. Some GUI scripting languages are based on recognizing graphical objects from their display screen pixels. These GUI scripting languages do not depend on support from the operating system or application.

Application-specific languages

Many large application programs include an idiomatic scripting language tailored to the needs of the application user. Likewise, many computer game systems use a custom scripting language to express the programmed actions of non-player characters and the game environment. Languages of this sort are designed for a single application; and, while they may superficially resemble a specific general-purpose language (e.g. QuakeC, modeled after C), they have custom features that distinguish them. Emacs Lisp, while a fully formed and capable dialect of Lisp, contains many special features that make it most useful for extending the editing functions of Emacs. An application-specific scripting language can be viewed as a domain-specific programming language specialized to a single application.

Extension/embeddable languages

A number of languages have been designed for the purpose of replacing application-specific scripting languages by being embeddable in application programs. The application programmer (working in C or another systems language) includes "hooks" where the scripting language can control the application. These languages may be technically equivalent to an application-specific extension language but when an application embeds a "common" language, the user gets the advantage of being able to transfer skills from application to application. A more generic alternative is simply to provide a library (often a C library) that a general-purpose language can use to control the application, without modifying the language for the specific domain.

JavaScript began as and primarily still is a language for scripting inside web browsers; however, the standardization of the language as ECMAScript has made it popular as a general-purpose embeddable language. In particular, the Mozilla implementation SpiderMonkey is embedded in several environments such as the Yahoo! Widget Engine. Other applications embedding ECMAScript implementations include the Adobe products Adobe Flash (ActionScript) and Adobe Acrobat (for scripting PDF files).

Tcl was created as an extension language but has come to be used more frequently as a general-purpose language in roles similar to Python, Perl, and Ruby. On the other hand, Rexx was originally created as a job control language, but is widely used as an extension language as well as a general-purpose language. Perl is a general-purpose language, but had the Oraperl (1990) dialect, consisting of a Perl 4 binary with Oracle Call Interface compiled in. This has however since been replaced by a library (Perl Module), DBD::Oracle.[11][12]

Other complex and task-oriented applications may incorporate and expose an embedded programming language to allow their users more control and give them more functionality than can be available through a user interface, no matter how sophisticated. For example, Autodesk Maya 3D authoring tools embed the MEL scripting language, or Blender which uses Python to fill this role.

Some other types of applications that need faster feature addition or tweak-and-run cycles (e.g. game engines) also use an embedded language. During the development, this allows them to prototype features faster and tweak more freely, without the need for the user to have intimate knowledge of the inner workings of the application or to rebuild it after each tweak (which can take a significant amount of time). The scripting languages used for this purpose range from the more common and more famous Lua and Python to lesser-known ones such as AngelScript and Squirrel.

Ch is another C compatible scripting option for the industry to embed into C/C++ application programs.

References

  1. Sheppard, Doug (2000-10-16). "Beginner's Introduction to Perl". dev.perl.org. Retrieved 2011-01-08.
  2. Programming is Hard, Let's Go Scripting…, Larry Wall, December 6, 2007
  3. Hey, Tony; Pápay, Gyuri (2014). The Computing Universe: A Journey through a Revolution. Cambridge University Press. p. 76. ISBN 978-1-31612322-5, "A major characteristic of modern scripting languages is their interactivity, sometimes referred to as a REPL programming environment. […] The characteristics of ease of use and immediate execution with a REPL environment are sometimes taken as the definition of a scripting language."{{cite book}}: CS1 maint: postscript (link)
  4. Brown, Vicki. "Scripting Languages". Retrieved 2009-07-22.
  5. Loui, Ronald (2008). "In praise of scripting". IEEE Computer.
  6. IBM Corporation (1967). IBM System/360 Operating System Job Control Language (C28-6529-4) (PDF).
  7. Mooers, Calvin. "TRAC, A Procedure-Describing Language for the Reactive Typewriter". Archived from the original on 2001-04-25. Retrieved March 9, 2012.
  8. Van Vleck(ed.), Thomas. "Multics Glossary -A- (active function)". Retrieved March 9, 2012. {{cite web}}: |last= has generic name (help)
  9. Varian, Melinda. "VM AND THE VM COMMUNITY: Past, Present, and Future" (PDF). Retrieved March 9, 2012.
  10. Van Vleck, Thomas(ed.). "Multics Glossary -R- (RUNCOM)". Retrieved March 9, 2012. {{cite web}}: |first= has generic name (help)
  11. Oraperl, CPAN]
  12. Perl, Underground Oracle FAQ

Further reading

Other websites