Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Abstract
Scripting languages such as Visual Basic and Tcl represent a very different style of programming than system programming languages such as C or Java. Scripting languages are designed for "gluing" applications; they use typeless approaches to achieve a higher level of programming and more rapid application development than system programming languages. Increases in computer speed and changes in the application mix are making scripting languages more and more important for applications of the future. Whereas object-oriented approaches have largely failed to increase software reuse or reduce development costs, scripting languages have succeeded.
Scripting languages are designed for different tasks than system programming languages, and this leads to fundamental differences in the languages. System programming languages were designed for building data structures and algorithms from scratch, starting from the most primitive computer elements such as words of memory. In contrast, scripting languages are designed for gluing: they assume the existence of a set of powerful components and are intended primarily for connecting components together. System programming languages are strongly typed to help manage complexity, while scripting languages are typeless to simplify connections between components and provide rapid application development.
Scripting languages and system programming languages are complementary, and most major computing platforms since the 1960's have provided both kinds of languages. However, several recent trends, such as faster machines, the increasing importance of graphical user interfaces and component architectures, and the growth of the Internet, have greatly increased the applicability of scripting languages. These trends will continue over the next decade, with scripting languages used for more and more applications and system programming languages used primarily for creating components.
ADD
might be used to represent the opcode for an addition instruction and SP
might be used to specify the register that serves as stack pointer. An assembler reads the statements, converts symbols to the corresponding binary values, and generates a binary program suitable for execution.The use of textual symbols in assembly language makes programs substantially easier to write than binary approaches while still providing complete control over the machine. However, assembly language suffers from three defects. First, it requires the programmer to write one line of code for each instruction or variable, which becomes tedious as programs grow in size. Second, assembly language forces programmers to deal with many low-level details such as register allocation and procedure calling sequences. Third, assembly language provides almost no structure; for example, all instructions have roughly the same appearance and integer and floating-point variables are declared in the same way. As a result, it is difficult to write and maintain large programs in assembly language.
By the late 1950's higher level languages such as Fortran and Algol began to appear. In these languages statements no longer correspond exactly to machine instructions; a compiler translates each statement in the source program into a sequence of binary instructions. Over time a series of system programming languages evolved from Algol, including such languages as PL/1, Pascal, C, C++, and Java. System programming languages allow large applications to be developed much more quickly than assembly languages while providing nearly the same level of efficiency. As a result, they have almost completely replaced assembly language for the development of large applications.
System programming languages differ from assembly languages in two ways: they are higher level and they are strongly typed. The term "higher level" means that many details are handled automatically so that programmers can write less code to get the same job done. For example:
while
and if
for control structures; the compiler generates all the detailed instructions to implement the control structures.
On average, each line of code in a system programming language causes about five machine instructions to be executed, compared to one instruction per line in assembly language. Various studies have shown that programmers can write roughly the same number of lines of code per year regardless of language, so system programming languages allow applications to be written much more quickly than assembly languages.
Typing makes large programs more manageable by clarifying how things are used and differentiating between things that must be treated differently. Compilers can use type information to detect certain kinds of errors, such as an attempt to use a floating-point value as a pointer.
3 Scripting languages
Scripting languages such as Perl, Tcl, Visual Basic, and the Unix shells represent a very different style of programming than system programming languages. Scripting languages assume that there already exists a collection of useful components written in other languages. Scripting languages aren't intended for writing applications from scratch; they are intended primarily for plugging together components. For example, Tcl and Visual Basic are used to arrange collections of user interface controls on the screen while Unix shell scripts are used to assemble filter programs into pipelines. Scripting languages are often used to extend the features of components but they are rarely used for complex algorithms and data structures; features like these are usually provided by the components. Scripting languages are sometimes referred to as glue languages or system integration languages.button .b -text Hello! -font {Times 16} -command {puts hello}
This command creates a new button control that displays a text string in a 16-point Times font and prints a short message when the user clicks on the control. It mixes six different types of things in a single statement: a command name (button
), a button control (.b
), property names (-text
, -foreground
, and -command
), simple strings (Hello!
and hello
), a font name (Times 16
) that includes a typeface name (Times
) and a size in points (16
), and a Tcl script (puts hello
). Tcl represents all of these things uniformly with strings. In the button example the properties may be specified in any order and unspecified properties are given default values; more than 20 properties were left unspecified in the example.LOGFONT lf;
Almost all of this code is a consequence of the strong typing: variables
memset(&lf, 0, sizeof(lf));
lf.lfHeight = -16;
strcpy(lf.lfFaceName, "Times New Roman");
CFont *fontPtr = new CFont();
fontPtr->CreateFontIndirect(&lf);
buttonPtr->SetFont(fontPtr);
lf
and fontPtr
must be declared, fields in the font descriptor structure lf
must be filled in individually, then a new object of type CFont
must be created from lf
in order to match the API of the button's SetFont
method. In Tcl, the essential characteristics of the font (typeface Times, size 16 points) can be used immediately with no declarations, intermediate structures, or conversions. Similarly, in C++ the behavior for the button must placed in a separately declared method, whereas in Tcl it can be included directly in the command that creates the button.xyz
. The difference is that scripting languages do their error checking at the last possible moment, when a value is used. Strong typing allows errors to be detected at compile-time, so the cost of run-time checks is avoided. However, the price to be paid for this efficiency is more conservative restrictions on how information can be used: this results in more complex and less flexible programs.4 Different tools for different tasks
A scripting language is not a replacement for a system programming language or vice versa. Each is suited to a different set of tasks. For gluing and system integration, applications can be developed 5-10x faster with a scripting language; system programming languages will require large amounts of boilerplate and conversion code to connect the pieces, whereas this can be done directly with a scripting language. For complex algorithms and data structures, the strong typing of a system programming language makes programs easier to manage. Where execution speed is key, a system programming language can often run 10-20x faster than a scripting language: the flexibility provided by the scripting language results in more run-time checks.
Most of the major computing platforms over the last 30 years have provided both system programming and scripting languages. For example, one of the first scripting languages was JCL (Job Control Language), which was used to sequence job steps in OS/360. The individual job steps were written in PL/1, Fortran, or assembler language, which were the system programming languages of the day. In the Unix machines of the 1980's, C was used for system programming and shell programs such as
sh
and csh
for scripting. In the PC world of the 1990's, C and C++ are used for system programming and Visual Basic for scripting. In the Internet world that is taking shape now, Java is used for system programming and languages like JavaScript, Perl, and Tcl are used for scripting. 5 Scripting is on the rise
Scripting languages have existed for a long time, but their importance has increased in recent years because the application mix has shifted more towards gluing applications. Three examples of this shift are graphical user interfaces, the Internet, and component frameworks.6 The failure of object-oriented programming
Scripting languages have received little attention in the programming language community or in the press; instead, most of the attention has been focused on object-oriented programming languages such as C++ and Java. Object-oriented programming is widely believed to represent the next major step in the evolution of programming languages. Object-oriented features such as strong typing and inheritance are often claimed to reduce development time, increase software reuse, and solve many other problems including those addressed by scripting languages.goto
statements are overused. As a result, object-oriented systems suffer from complexity and lack of reuse.7 What will happen to system programming languages?
It might seem from the above arguments that scripting languages will eventually replace system programming languages entirely. After all, a similar effect occurred with assembly language. In the early 1960's, most serious programming was done in assembly; higher level languages like Fortran and Algol were widely viewed as too slow for serious programming tasks. But the quality of compiled code improved and machines got faster, so the performance differences were less important. At the same time, it became clear that programmers were substantially more productive with high level languages than with assembly. Over time, more and more people decided that it was worth giving up a little speed to get faster application development. Today, assembly language is rarely used, even for the most performance-critical code. The same arguments might be made for scripting versus system programming: scripting does not use the computer as efficiently as system programming, but it enables much faster development.8 Conclusion
Scripting languages represent a different set of tradeoffs from system programming languages. Scripting languages give up execution speed and strength of typing relative to system programming languages but provide significantly higher programmer productivity and software reuse. This tradeoff makes more and more sense as computers become faster and cheaper in comparison to programmers. System programming languages are well suited to building complex data structures and algorithms from scratch, while scripting languages are well suited for gluing applications such as graphical user interfaces and component assembly. Gluing tasks are becoming more and more prevalent, so scripting will become an even more important programming paradigm in the next century than it is today.9 References
[1] K.Arnold and J. Gosling, The Java Programming Language, Addison-Wesley, ISBN 0-201-63455-4, 1996.http://home.netscape.com/eng/mozilla/3.0/handbook/javascript/atlas.html#taint_dg
.
Last updated: 03/28/97 09:40:23
Article ID: W12708
Filename: Scripting White Paper.txt
File Created: 2017:08:29:11:37:14
Last Updated: 2017:08:29:11:37:14