Scripting language

Last updated
GDScript in Godot 3.4 Gdscript3.4.png
GDScript in Godot 3.4

A scripting language or script language is a programming language that is used to manipulate, customize, and automate the facilities of an existing system. [1] Scripting languages are usually interpreted at runtime rather than compiled.

Contents

A scripting language's primitives are usually elementary tasks or API calls,[ clarification needed ] and the scripting language allows them to be combined into more programs. Environments that can be automated through scripting include application software, text editors, web pages, operating system shells, embedded systems, and computer games. A scripting language can be a general purpose language or a domain-specific language for a particular environment; in the case of scripting an application, it is also known as an extension language. Scripting languages are also sometimes referred to as very high-level programming languages, as they sometimes operate at a high level of abstraction, or as control languages, particularly for job control languages on mainframes.

The term scripting language is also used in a wider sense, namely, to refer to dynamic high-level programming languages in general; some are strictly interpreted languages, while others use a form of compilation. In this context, the term script refers to a small program in such a language; typically, contained in a single file, and no larger than a few thousand lines of code.

The spectrum of scripting languages ranges from small to large, and from highly domain-specific language to general-purpose programming languages. A language may start as small and highly domain-specific and later develop into a portable and general-purpose language; conversely, a general-purpose language may later develop special domain-specific dialects.

Examples

Some game systems have been extensively extended in functionality by scripting extensions using custom languages, notably the Second Life virtual world (using Linden Scripting Language) and the Trainz franchise of Railroad simulators (using TrainzScript). In some games, such as Wesnoth, users may play custom variants of the game defined by user-contributed scripts.

Characteristics

Typical scripting languages are intended to be very fast to learn and write in, either as short source code files or interactively in a read–eval–print loop (REPL, language shell). [4] This generally implies relatively simple syntax and semantics; typically a "script" (code written in the scripting language) is executed from start to finish, as a "script", with no explicit entry point.

For example, it is uncommon to characterise Java as a scripting language because of its lengthy syntax and rules about which classes exist in which files, and it is not directly possible to execute Java interactively, because source files can only contain definitions that must be invoked externally by a host application or application launcher.

publicclassHelloWorld{publicvoidprintHelloWorld(){System.out.println("Hello World");}}

This piece of code intended to print "Hello World" does nothing as main() is not declared in HelloWorld class, although the one below would be useful.

publicclassHelloWorld{publicvoidprintHelloWorld(){System.out.println("Hello World");}publicstaticvoidmain(String[]args){printHelloWorld();}}

In the example above, main is defined and so this can be invoked by the launcher, although this still cannot be executed interactively. In contrast, Python allows the definition of some functions in a single file, or to avoid functions altogether and use imperative programming style, or even use it interactively.

print("Hello World")

This one line of Python code prints "Hello World"; no declarative statement like main() is required here.

A scripting language is usually interpreted from source code or bytecode. [5] By contrast, the software environment (interpreter) the scripts are written for is typically written in a compiled language and distributed in machine code form.

Scripting languages may be designed for use by end users of a program—end-user development—or may be only for internal use by developers, so they can write portions of the program in the scripting language. Scripting languages typically use abstraction, a form of information hiding, to spare users the details of internal variable types, data storage, and memory management.

Scripts are often created or modified by the person executing them, [6] but they are also often distributed, such as when large portions of games are written in a scripting language, notably the Google Chrome T-rex game.

History

Early mainframe computers (in the 1950s) were non-interactive, instead using batch processing. IBM's Job Control Language (JCL) is the archetype of languages used to control batch processing. [7]

The first interactive shells were developed in the 1960s to enable remote operation of the first time-sharing systems, and these used shell scripts, which controlled running computer programs within a computer program, the shell. Calvin Mooers in his TRAC language is generally credited with inventing command substitution, the ability to embed commands in scripts that, when interpreted, insert a character string into the script. [8] Multics calls these active functions. [9] 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. [10] Multics included an offshoot of CTSS RUNCOM, also called RUNCOM. [11] EXEC was eventually replaced by EXEC 2 and REXX.

Languages such as Tcl and Lua were specifically designed as general-purpose scripting languages that could be embedded in any application. Other languages such as Visual Basic for Applications (VBA) provided strong integration with the automation facilities of an underlying system. Embedding of such general-purpose scripting languages instead of developing a new language for each application also had obvious benefits, relieving the application developer of the need to code a language translator from scratch and allowing the user to apply skills learned elsewhere.

Some software incorporates several different scripting languages. Modern web browsers typically provide a language for writing extensions to the browser itself, and several standard embedded languages for controlling the browser, including JavaScript (a dialect of ECMAScript) or XUL.

Types

Scripting languages can be categorized into several different types, with a considerable degree of overlap among the types.

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 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:

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, Rexx, SaxBasic, and WinWrap Basic. Other tools like AWK can also be considered glue languages, as can any language implemented by a 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, Modern Pascal, Delphi, and 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, DOS, and some Unix shells, Rexx, Modern Pascal, 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 with tools that convert between C and Perl, Rexx, AWK, and shell scripts to Perl, Modern Pascal, 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.[ citation needed ]

Editor languages

A number of text editors support macros written either using a macro language built into the editor, e.g., The SemWare Editor (TSE), vi improved (VIM), or using an external implementation, e.g., XEDIT, or both, e.g., KEDIT. Sometimes text editors and edit macros are used under the covers to provide other applications, e.g., FILELIST and RDRLIST in CMS .

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 [16] (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.

When the GUI provides the appropriate interfaces, as in the IBM Workplace Shell, a generic scripting language, e.g. OREXX, can be used for writing GUI scripts.

Application-specific languages

Application specific languages can be split in many different categories, i.e. standalone based app languages (executable) or internal application specific languages (postscript, xml, gscript as some of the widely distributed scripts, respectively implemented by Adobe, MS and Google) among others 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. [17] [18]

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 Maya Embedded 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.

See also

Related Research Articles

<span class="mw-page-title-main">AWK</span> Programming language

AWK is a domain-specific language designed for text processing and typically used as a data extraction and reporting tool. Like sed and grep, it is a filter, and is a standard feature of most Unix-like operating systems.

<span class="mw-page-title-main">Shell script</span> Script written for the shell, or command line interpreter, of an operating system

A shell script is a computer program designed to be run by a Unix shell, a command-line interpreter. The various dialects of shell scripts are considered to be scripting languages. Typical operations performed by shell scripts include file manipulation, program execution, and printing text. A script which sets up the environment, runs the program, and does any necessary cleanup or logging, is called a wrapper.

<span class="mw-page-title-main">Unix shell</span> Command-line interpreter for Unix operating system

A Unix shell is a command-line interpreter or shell that provides a command line user interface for Unix-like operating systems. The shell is both an interactive command language and a scripting language, and is used by the operating system to control the execution of the system using shell scripts.

<span class="mw-page-title-main">Windows Script Host</span> Automation technology for Windows

The Microsoft Windows Script Host (WSH) is an automation technology for Microsoft Windows operating systems that provides scripting abilities comparable to batch files, but with a wider range of supported features. This tool was first provided on Windows 95 after Build 950a on the installation discs as an optional installation configurable and installable by means of the Control Panel, and then a standard component of Windows 98 and subsequent and Windows NT 4.0 Build 1381 and by means of Service Pack 4. The WSH is also a means of automation for Internet Explorer via the installed WSH engines from IE Version 3.0 onwards; at this time VBScript became means of automation for Microsoft Outlook 97. The WSH is also an optional install provided with a VBScript and JScript engine for Windows CE 3.0 and following and some third-party engines including Rexx and other forms of Basic are also available.

<span class="mw-page-title-main">Graphing calculator</span> Electronic calculator capable of plotting graphs

A graphing calculator is a handheld computer that is capable of plotting graphs, solving simultaneous equations, and performing other tasks with variables. Most popular graphing calculators are programmable calculators, allowing the user to create customized programs, typically for scientific, engineering or education applications. They have large screens that display several lines of text and calculations.

<span class="mw-page-title-main">IRAF</span> Software collection for astronomical data reduction and data analysis

IRAF is a collection of software written at the National Optical Astronomy Observatory (NOAO) geared towards the reduction of astronomical images and spectra in pixel array form. This is primarily data taken from imaging array detectors such as CCDs. It is available for all major operating systems for mainframes and desktop computers. IRAF was designed cross-platform, supporting VMS and UNIX-like operating systems. Use on Microsoft Windows was made possible by Cygwin in earlier versions, and can be today done with the Windows Subsystem for Linux. Today, it is primarily used on macOS and Linux.

In some programming languages, eval, short for the English evaluate, is a function which evaluates a string as though it were an expression in the language, and returns a result; in others, it executes multiple lines of code as though they had been included instead of the line including the eval. The input to eval is not necessarily a string; it may be structured representation of code, such as an abstract syntax tree, or of special type such as code. The analog for a statement is exec, which executes a string as if it were a statement; in some languages, such as Python, both are present, while in other languages only one of either eval or exec is.

In computer software, a general-purpose programming language (GPL) is a programming language for building software in a wide variety of application domains. Conversely, a domain-specific programming language (DSL) is used within a specific area. For example, Python is a GPL, while SQL is a DSL for querying relational databases.

Expect is an extension to the Tcl scripting language written by Don Libes. The program automates interactions with programs that expose a text terminal interface. Expect, originally written in 1990 for the Unix platform, has since become available for Microsoft Windows and other systems.

<span class="mw-page-title-main">Object REXX</span>

The Object REXX programming language is a general-purpose object-oriented scripting language.

<span class="mw-page-title-main">LAMP (software bundle)</span> Acronym for a common web hosting solution

LAMP is an acronym denoting one of the most common software stacks for the web's most popular applications. Its generic software stack model has largely interchangeable components.

Active Scripting is the technology used in Windows to implement component-based scripting support. It is based on OLE Automation and allows installation of additional scripting engines in the form of COM modules.

In programming and software design, binding is an application programming interface (API) that provides glue code specifically made to allow a programming language to use a foreign library or operating system service.

In computing, a shebang is the character sequence consisting of the characters number sign and exclamation mark at the beginning of a script. It is also called sharp-exclamation, sha-bang, hashbang, pound-bang, or hash-pling.

<span class="mw-page-title-main">Tk (software)</span> GUI toolkit or framework

Tk is a cross-platform widget toolkit that provides a library of basic elements of GUI widgets for building a graphical user interface (GUI) in many programming languages. It is free and open-source software released under a BSD-style software license.

<span class="mw-page-title-main">Rexx</span> Command/scripting/programming language

Rexx is a programming language that can be interpreted or compiled. It was developed at IBM by Mike Cowlishaw. It is a structured, high-level programming language designed for ease of learning and reading. Proprietary and open source Rexx interpreters exist for a wide range of computing platforms; compilers exist for IBM mainframe computers.

<span class="mw-page-title-main">Command-line interface</span> Computer interface that uses text

A command-line interface (CLI) is a means of interacting with a computer program by inputting lines of text called command-lines. Command-line interfaces emerged in the mid-1960s, on computer terminals, as an interactive and more user-friendly alternative to the non-interactive interface available with punched cards.

The following outline is provided as an overview of and topical guide to the Perl programming language:

References

  1. "ECMAScript 2019 Language Specification". Ecma International. Retrieved 2018-04-02.
  2. Sheppard, Doug (2000-10-16). "Beginner's Introduction to Perl". Perl.com. Retrieved 2011-01-08.
  3. Wall, Larry (2007-12-12). "Programming is Hard, Let's Go Scripting..." Perl.com. Archived from the original on Dec 8, 2023.
  4. 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.
  5. Brown, Vicki; Morin, Rich (1999). "Scripting Languages". MacTech. Retrieved 2009-07-22.
  6. Loui, Ronald. "In Praise of Scripting: Real Programming Pragmatism". IEEE Computer. Archived from the original on 2015-09-23. Retrieved 2013-08-27.
  7. IBM Corporation (Mar 1967). IBM System/360 Operating System Job Control Language (C28-6529-4) (PDF). Archived (PDF) from the original on May 25, 2023 via bitsavers.
  8. Mooers, Calvin (1965). "TRAC, A Procedure-Describing Language for the Reactive Typewriter". TRAC Foundation. Archived from the original on 2001-04-25. Retrieved March 9, 2012.
  9. Van Vleck, Thomas (ed.). "Multics Glossary – A — (active function)". Multics. Retrieved March 9, 2012.
  10. Varian, Melinda (April 1991). "VM and the VM Community: Past, Present, and Future" (PDF). Archived from the original (PDF) on Oct 6, 2011. Retrieved March 9, 2012.
  11. Van Vleck, Thomas (ed.). "Multics Glossary – R — (RUNCOM)" . Retrieved March 9, 2012.
  12. "What is glue code (glue code language)? - Definition from WhatIs.com". WhatIs.com. Retrieved 2022-01-31.
  13. Larson, Quincy (10 January 2020). "Interpreted vs Compiled Programming Languages". Free Code Camp. Retrieved 23 February 2022.
  14. Balkis, Anton. "Script Adalah". Raja Tips. Retrieved 23 February 2022.
  15. Axelsson, Mats. "Shell scripts - What can you change". Linux Hint. Retrieved 23 February 2022.
  16. "Job Control Basics (Bash Reference Manual)". www.gnu.org. Retrieved 2022-05-20.
  17. Oraperl, CPAN]
  18. Perl, Underground Oracle FAQ
  19. van Rossum, Guido (January 6–8, 1998). "Glue it all together". Glue It All Together With Python. python.org.

Further reading