Scripting Languages
Someone once thought it would be a good idea to define a category of languages for “scripting.” This actually happened. But what do people mean by “scripting language,” and what is it that a scripting language does for us?
Definitions
There is no single definition of scripting language that everyone will agree upon. Still, here are some attempts (in order of increasing inclusiveness):
- A scripting language is a language for writing programs that run "jobs" made up of a bunch of other programs (which may be running on multiple computers).
- A scripting language is a language that makes it easy to write code that coordinates multiple components (where “components” are fairly complex entities in their own right, like programs, GUI components, elements of a document in a web browser or word processor, or objects in a game; this is the scripting language = glue language definition).
- A scripting language is a very high level language that makes it easy to crank out code because the programmer is completely freed from mundane tasks like managing memory and checking bounds and can use extremely simple constructs for lists, dictionaries, iterators, closures, list comprehensions, etc. Ease of writing is the main concern; performance concerns are a distant second.
Purists might object to the last definition, but the truth is that most people call fully general purpose languages like Python and Ruby scripting languages. However, the term dynamic language is becoming more popular, and covers nearly all scripting languages (including the general puprose
ones).
Motivation
Reasons to study scripting languages:
- Real life enterprise systems are made up of many programs working together: web servers, mail servers, nodes in clusters, search indexers, database servers, billing, shipping and receiving software, statistics gathering and computation, data mining processes, rendering engines, source code revision control,
etc. Scripts are often written to make these separate systems work together.
- Game developers writing complex logic, highly optimized geometric transformations, and gnarly 3-D effects like to offload some of the flow logic to artists with less coding skills.
- Writing anything other than systems utilties in C sucks. Writing small applications in Java and C# sucks.
- They use a lot of Python at Google.
Application Areas
Scripting is used in
- System administration (Wizard-level shell, Perl, and Python scripts can simplify your life)
- Games and Multimedia
- Web applications — server side
- Web applications — client side
- Multimedia
- Text and Document Processing (yes, even report generation)
- Writing extensions and plugins to existing applications (e.g. Firefox, Eclipse)
- Symbolic mathematics (but not usually for massive number crunching)
- Any application you can think of, if you take scripting to be synonymous with very high level programming.
Characteristics
Scripting languages may be hard to define, but many programmers know one when they see one. They tend to, but are not required to:
- be kept in source form, not compiled form
- be interpreted from source, or at least compiled into an intermediate form that is interpreted on a VM, or jitted to machine language.
- be dynamically typed
- have literal forms for complex data structures (regexes, dictionaries, closures, lookup tables, arrays, formatting patterns, list comprehensions, iterators)
- be unconcerned with the underlying machine (somtimes neglecting even the fixed-size integer)
- have source code that is a fraction of the size of systems-like languages
- produce code that doesn’t stand alone as full-fledged executables, but rather is run within some container (like JavaScript within a web browser).
- be fairly small in terms of linguistic concepts, gaining a lot of functionality from large libraries
- be extensible
- be application-specific (e.g. for games, word processing, text formatting, networking)
- have an interactive shell for typing in and executing fragments on the fly
- re-execute changed code instantly, without the hideous overhead of explicit recompilation and deployment.
- emphasize flexibility and rapid development
Exercise: Describe in a few paragraphs why C is not a scripting language.
Exercise: Defend the statement: “The line between high-level languages and scripting languages is already pretty blurry.”
Exercise: Read up on BeanShell and Groovy (Wikipedia articles are an acceptable place to start).
Readings
References
Essays, Articles, Opinions, and Papers
Exercise: In the Java vs. Python article, the author seems to not know that Java has unchecked exceptions, inner classes, generics, or autoboxing. What other misconceptions about Java can you spot?