1. Introduction In the past fifteen years, people have a fundamental change in the method of writing computer programs. This transition is a transition from a scripting language such as C or C and other system programming languages to Perl or Tcl. Although many people participated in the transformation, few people realized that it happened, but also not to say why happened. This article is my view that I can better deal with many programming work than the system programming language in the next century.
Different scripting languages are designed for different work compared to system programming languages, which leads to the fundamental difference between language. The system programming language originated from the initial computer elements such as memory word, which is created for establishing data structures and algorithms. Conversely, the scripting language is the skin design: they assume that there is already a powerful component, and it mainly connects the components together. The system programming language uses a strong type definition to help process complex transactions, and the scripting language uses non-type definition to simplify the connection between components and provide fast application development.
The scripting language and system programming language are complementary, and most of the main computer platforms since the 1960s have also provided both types of languages. These languages have typical applications in the component framework: Components are created by the system programming language and are combined by scripting languages. However, the speed of faster machines, better scripting languages, graphical user interfaces, and components constructive importance, the development trend of the Internet development has greatly improved the application of scripting languages. In the next decade, this trend will continue, and more and more fully use scripting languages and system programming language written applications will be mainly used to create components.
2. System programming language In order to understand the difference in scripting language and system programming language, it is best to learn how the system programming language is developed. The system programming language is introduced as another option other than assembly language. In assembly language, every detail of the machine is reflected in the program. Each status represents a simple machine instruction, and the programmer must process low-level details such as register allocation and program call sequence. Therefore, use assembly It is difficult to write and maintain large programs.
In the early 1950s, high-level language like Lisp, Fortran and Algol begins. The status and machine instructions in these languages are no longer completely consistent, and the compiler translates each state in the process program into a series of binary instructions. After a paragraph Time, a series of system programming languages include PL / 1, PASCAL, C, C and Java developed by Algol. The system programming language does not have the efficiency of assembly language, but they have developed faster applications, so The system programming language has almost completely replaced the assembly language in the development of large application projects.
The system programming language and assembly language differ in two aspects: it is a high-level language and is a strong type. "High-level" means that many details are automatically processed so that programmers can write less code to do the same job. For example, :
★ Compiler processing register allocation, so programmers do not need to write code to transfer data between registers and memory ★ Automatic design program call sequence: Programmer does not need to worry about parameter transfer between call stacks ★ Programmer can use WHILE and IF Simple keywords to control the structure, the compiler performs all instruction details to complete the control structure
The average system programming language code is translated into approximately five machine instructions, and each line assembly language code is translated into a machine directive (in informal analysis of 8 C files written by 5 different people, I This ratio is found to be 3 to 7 instructions per line; CAPERS JONES found from a large number of languages to a given job, the length of code required by assembly language is approximately 3-6 times the length of the system programming language code. No matter whether it is In what language, programmers can write substantially the same number of code rows each year, so the system programming language allows for a language written in a language than assembly language.
The second difference between assembly language and system programming language is type setting. I use "Type" to clear the meaning of information is specialized before it is used. Programmer in strong type language declares how to use each message, And avoid this information is used in other ways. Information applications in weak type languages are no priority restrictions: information is completely determined by its use, not any initial conventions.
Modern computers are basically unmatched: any word in memory is effective, such as integer, floating point, pointer, or structural body. Value means that it is determined by it: If you point to a memory word Then he is considered structural; if a word involves a constant plus structure, he is considered intellectual, so. So. The same words can be used in different methods at different times. Now the current system programming language is a strong type definition. For example:
★ Each variable in the system programming language must be declared as a special type such as integer or pointer or string, and must be used to suit this type of variable ★ Data and code completely separated: Create a new code is difficult Or at all. ★ Variables can be concentrated in the structure or in objects of the sub-structure and procedures or methods for use; one type of object cannot be used to expect other types of objects.
Determined types of benefits. First, how to declare variables make large programs easier to manage and distinguish between variables that must be treated separately. Second, compilers can use type information to detect certain types of errors, such as, for example, Trying to put a floating point value as a pointer. Third, the definition type can make the compiler better execute special code. For example, if the compiler knows that a variable is always valid, then he can generate an integer Instructions to manipulate this variable; if the compiler does not know the type of variable, he must generate additional instructions to check the variable type at runtime.
In summary, the system programming language is designed to handle the same work as assembly language, namely randomly generated requests. The system programming language is higher than the assembly language hierarchy, which makes the request more quickly and more easily. In addition to a loss of loss at runtime, the illustration 1 is a comparison of assembly language and several other system programming languages.
3. Scripting language scripting language, like Perl, Python, REXX, TCL, Visual Basic, and UNIX shells represents completely different programming with the system programming language. Scripting language assumes already exists a range of useful components written in other languages. The scripting language does not want to randomly generate a request, and he wants to connect the component mainly. For example, TCL and Visual Basic can be used to arrange a series of user graphics controls on the screen, and UNIX Shells Scripts is used to set the filter assembly collection. Into the pipeline. Script language is often used to extend component features, but they rarely use complicated algorithms and data structures; these things are often available. Scripting language sometimes involves glue language or system overall language.
To simplify the work of the connection component, the scripting language is designed to have no type: all things are exactly the same, so they can be interchanged. For example, a variable in TCL or Visual Basic can be a while Handling a string, handling an integer for a while, code and data can often be interchangeable, so you can write another program with a program, then execute, the scripting language is generally for many different things. Consistent description.
There is no type of language makes the component more easily. There is no priority limit when used, and all components and their values are described in a unified manner. In addition, any components and values can be used in any case; Components designed for a certain purpose can be used for completely different purposes of designers. For example, in UNIX shells, all filters are read into byte streams, and the characters consisting of bytes String write output; any two programs can link both by connecting one output to another.
The following shell command puts three filter stacks together to calculate the number of rows that contain the word "scripting" in the selected area:
Select | grep scripting | wc
The SELECT program reads the currently displayed text and outputs it; the GREP program reads the input and outputs the row of "scripting"; the WC program is for the number of rows input. Each program can be used in many others. The situation is working different work.
The quality of the system programming language is in nature to prevent reuse. Type encourage programmers create a type containing incompatible interfaces ("The interface is very good, the interface is better"). Each interface requires a special type of object, and the compiler The interface is not allowed to use any other type of object, even if it is useful. In order to use a new object that already exists interfaces, you must write the conversion code to translate between the type of object and the type of interface, which is in turn needs. Compile part or all of the distribution of binary forms in normal cases, it is impossible.
In order to see the advantages of non-type languages, consider the following TCL commands:
Button .b -text hello! -font {piers 16} -command {puts hello} This command creates a new button to display a small information when the user tap the control button. It puts six Different types are mixed into a single status: a command name (Button), a button control (.b), ownership name (-Text, -font, and -command), simple string (Hello! And Hello), The font name (TIMES 16) and TCL scripts containing a lead name (TIMES) and a word size (16) .TCL represent all of these informal strings. In this example, the property can be assigned in any command. The attribute that does not assign value uses a given default. In this example, more than 20 attributes are not particularly assigned.
The same example is required to perform 7 lines of code when performing two methods in Java. Use C and Microsoft Basic Class (MFC) requires three procedures 25 line code, only set the font in the Microsoft Basic class, you need a few lines of code:
CFont * fontPtr = new CFont (); fontPtr-> CreateFont (16, 0, 0,0,700, 0, 0, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Times New Roman"); buttonPtr-> SetFont (Fontptr);
Most of the code is caused by a strong type. In order to set the button font, the setFont method must be applied, but this method must pass the pointer to the CFont object, which in turn needs to declare and initialize a new object. In order to initialize the CFont object must awaken it The CreateFont method, but CreateFont has a fixed interface that requires 14 specialty quotes. The basic feature of the font (Times Lead, 16 points) in Tcl does not use declaration or conversion. In addition, TCL allows commands to create buttons The button behavior is directly included, while C and Java need to put it in a separate statement.
(In fact, a graphical development environment that can be used in the complexity of the basic language can be dealt with in this case: the user enters the appropriate value in the table, and the environment output code is developed. However, in more complex situations like plan Conditional tasks producing a suitable value or interface The developer must write code in the basic language) This may appear that there is no type of scripting language that cannot be found, but actually the scripting language and system programming language is as safe. For example on it In the button example, if the font size is set into a non-integer string, it is like XYZ, then an error will occur. Different is that the scripting language is incorrect when a value is used, and the strong type is compiled. Errors This avoids runtime checks. However, the cost of increasing efficiency is how to use information: this leads to more code and more difficult procedures.
Another important difference between scripting language and system programming languages is that the scripting language is interpreted and the system programming language is compiled. The interpretable language provides quick conversion due to no compile time. By allowing users to write applications, The interpreter makes it more flexible, for example, integrated analysis tools for many overall lines, including TCL interpreters; program users write TCL scripts to make their design and control tool operation. Strong tools can be achieved by fast design code interpreter Function. For example, a TCL-based web browser can analyze the web page by converting HTML in the web to using some of the TCL scripts that use some normal expressions, then analyzing the web page and performs scripts to display page translation on the screen.
The scripting language is not as high as the system program design language. Part is because they use the interpreter instead of the compiler, and because the selection criterion of their basic components is functional and easy to use rather than effectively correspond to basic hardware. For example, scripting languages are often used The length variable string, while the system programming language uses the binary value corresponding to a machine word; the scripting language often uses a hash table, and the system programming language uses the address array.
Fortunately, the performance of the scripting language is not often a major problem. Scripting language applications are usually smaller than the application language of the system programming language, and the execution of the script application is controlled by the component, and these components are system programs Design language provides typical tools.
The scripting language is more advanced than the system programming language, and the average instruction can do more work. A typical scripting language instruction executes hundreds of machine instructions, and a typical system programming language instruction executes approximately five machines ( Refer to one). The part is different because the scripting language uses the translator, which is not as compiled in the system programming language. But the main difference is a more powerful function because the initial operation of the scripting language is more powerful. For example, Wake it in Perl Conventional expression is alternatively and awakening a integer addition is as simple as the same. In Tcl, the variable will have an icon associated with it. Therefore, setting variables will result in the side impact. For example, an icon may be used to keep the value of the variable on the screen. Continue to update. Table 1. Each line of the table describes the application that is executed, using the system programming language, like C or Java, using scripting languages, like TCL. Code rate column, two The application rate of the application (> 1 means that the system programming language requires more code), the scope is given the development rate. In most cases, the two versions are executed by different developers. The information in the table is Different people who respond to the article in the Comp.lang.TCL newsgroup. .
Due to the features described above, the scripting language allows the rapid development of the glue application. Table 1 provides interesting support. It describes several applications that re-execute them in the scripting language after execution in the system programming language. Or the same is true.
In each case, the script version requires less code and shorter development time, and the changes in different points from 2 to 60. The first time the scripting language is not significant, this makes people think about any The heavy execution in the first execution will be better, and the true difference between script and system programming is 5 to 10 times, not extreme end points in the table. The advantage of scripts is also dependent on the application. In the table In an example, the graphical user interface portion of the application is based on glue, but the simulation device portion is not; this may explain why the scripting application is not as good as other applications.
In short, the scripting language is designed to glue applications, they provide higher-level programming than assembly or system programming language, more weak type, and understand the development environment after the system programming language. Script language sacrifices to improve Development speed.
4. Different tasks, different tool script languages are not alternatives for system programming languages, which is the same. They are each suitable for different types of work. Integrating glue and systems, the application can be faster than the scripting language 5- 10 times; system programming language will require a large number of copying and conversion code to connect to each block. This is directly using scripting language. For complex algorithms and data structures, the system programming language is more likely to manage. Perform speed It is the key. The system programming language can run 10-20 times faster than the scripted language because it produces less runtime check.
Consider the following questions when deciding whether to use a scripting language or system programming language to handle a special task:
★ Whether the main work of the application is to link existing components ★ Whether the application wants to manipulate different types of things ★ The application contains a graphical user interface ★ Whether the application makes a large number of string operations ★ Can the application function can be quickly Solve the problem ★ Does the application need to scale
If these questions answer "Yes", this application will use the scripting language better. On the other hand, if you answer the following question "Yes", the system programming language is more suitable for this application:
★ Whether the application performs a complex algorithm or data structure ★ Whether the application manipulates a large number of datasets (like all pixels in the image) thus executing speed is important ★ Whether the application's function is already defined, and few changes
In the past 30 years, most of the main computer platforms simultaneously provide system programming and scripting languages. For example, the first scripting language is rough, it is a JCL (job control language), which is used to rank the working level in order in OS / 360. Individual working levels are written by PL1, Fortran or assembly language, then the system programming language. On the 1980s, the Unix machine is used for system programming and SH, CSH and other shell programming are used for scripts. In the PC era of the 1990s, C and C were used for system programming E and Visual Basic was used for scripts. In the currently basic network era, Java is used for system programming and other languages such as JavaScript, Perl, and TCL.
Scripts and system programming are symbiosis, commonly used, they can produce an exceptional programming environment: system programming language is used to generate exciting components, and then assemble them with scripting languages. For example, Visual Basic's primary attraction is that system programmers can write ActiveX components with C, instead of exclusive programmers to use them in Visual Basic applications. Warrants the shell script of applications for waking up with C under UNIX is easy. One reason for TCL Popularization is that the C code that can be written to execute new commands to expand the language. 5. The script has an upward trend scripting language already has a long time, but the comprehensive result of several factors in recent years has increased its importance. The most important factor is the transformation of the application of the application to the development of the application. Three examples of such transformations are graphical user interfaces, the Internet, and component frameworks.
The graphical user interface appeared in the early 1980s and is popular in the late 1980s. The graphical user interface is half even more than half of the graphical user interface in many programming projects. The graphical user interface is based on glue application: his goal is not to create new features, but link the graphic control collection and the internal function of the application. I don't worry about any rapid development environment because the graphical user interface is based on the system programming language, whether it is a Windows environment, Macintosh Toolbox or UNIX Mctif, graphical user interface based on C or C has proven to be difficult to master, use is not flexible, the result is not Flexible language. Some such systems have a good graphics tool to design screen outputs and hide BRINTORTANT, and once designers have to write code, it is difficult to provide behavior as interface elements. All well-developed graphical user interface environments are based on scripting languages: Visual Basic, Hyperlard, and TCL / TK, with the popularity of the graphical user interface, scripting languages are increasingly popular.
The growth of the Internet also makes the scripting language popularize. The Internet is just a glue tool, which does not create any new calculation results or data; it simply connects a lot of existing things. One of the perfect work of Internet programming work is to work together for all connected components, like scripting languages. For example: Perl is popular because of writing CGI scripts, JavaScript is popular for writing a web page.
The third example of scripts is the component framework, like ActiveX, OpenDoc, and JavaBeans. Although the system programming language can create components well, the script is more suitable for assembly components to the application. There is no good scripting language to manipulate components, and most of the functionality of the component framework is not. This can be partially explained why component frameworks are more successful than Visual Basic's Script tools more successful than in a platform that does not contain scripts in component frames such as UNIX / CORBA.
Another reason for the scripting language continues to spread is the improvement of scripting technology. Modern scripting languages like TCL and Perl are far from the public announcement of the early scripting language like JCL. For example, JCL does not provide basic repetition and early UNIX shells do not provide a process, even in today, scripting technology is still relatively immature. For example, Visual Basic is not a true scripting language: it initially performs a simple system programming language and then modifying makes it more suitable for scripts. The subsequent scripting language will be better than the current use.
Script technology benefits from the accelerated development of computer hardware. In the past, the acceptable implementation is often obtained in a complex application in a system programming language. In some cases, even the system programming language is not effective enough, so it has to be written applications with assembly. However, today's machine is 100-500 times faster than 1980, and continues to grow at a rate every 18 months. Today, many applications can be implemented by the released program and still have excellent execution. For example, the TCL script can manipulate a few more objects to provide a good mutual response. Due to the continuous improvement of computer speed, the script will appeal to increasing application.
The growing growth of scripting language is ultimately leads to the change of programming groups. Most of the programming persons are the skilled programming staff of large projects. The programming personnel take a few months to master a language and its programming. Environment, system programming language is designed for these people. However, since the appearance of personal computers, more and more non-professional programmers join the ranks of the programmer. For these people, the program is not their main job, But they can occasionally use tools to help them work. The example of accidental programming is a simple database query or a huge expansion film. Casual programmer does not want to spend a few months to learn the system programming language but they can spend a few Hours of time learned enough scripting language to write a useful code. Since the script language is made by simple syntactics and omitting object threads, it is easy to learn from the system programming language. For example, compare Visual Basic And Visual C , very few occasional programmers will choose Visual C , and most of them use Visual Basic to build a useful application. Even in today, the number of applications written in scripting languages is far more than using the system programming language The number of applications written. There is a more external script than the C program in the UNIX system, while the programmer of Visual Basic's Visual Basic is more than C or C . Of course, most large and widely used Both the application is written in system programming language, so if the number of code total lines or established copies, the system program design language is slightly better. No matter how, the scripting language is already the initiative of application development, And in the future, its market share will continue to increase.
6. The role of the object is usually ignored by experts in programming language and software engineering. Reveared, they pay more attention to object-oriented system programming languages like C and Java. Object-oriented programming is considered to be the mainstream of the next programming language development Object-oriented features such as strong types and inheritances are said to reduce development time, improve software reuse rate, and solve other issues including scripting language skills.
How much benefits can be provided in object-oriented programming? Unfortunately, I haven't seen enough data to answer this question. In my opinion, the object can only provide a certain benefit: maybe increase 20-30% creation Force, but never double, not to say is ten times. Now complaining about C and like it, and some language experts start publicly oppose object-oriented programming. This remaining part is used to explain why objects It is not possible to improve the creation as a script, and discuss the benefits of object-oriented programming available in the scripting language.
Object-oriented programming cannot significantly improve creativity, which does not improve programming level or encourage reuse. Programming people in object-oriented language in C still use the basic small units that need to be described and manipulated with a large number of details. Theoretically develop Powerful function library package and will increase programming hierarchy if these function libraries are widely used. However, such a library is very small. Most object-oriented language has restricted the definition of the package to be difficult to reuse. Each Packages require special types of objects. If two packages work together, you must write to translate the conversion code between the two packets needed. Another problem for object-oriented language is to emphasize inheritance. When a class is borrowed When a class written code is not a good idea, it makes the software difficult to manage and reuse. It puts the execution of the class together, so there is no other class any other class is not understandable: I don't know how to inherit. How to execute in the parent class, you can't understand the subclass; instead of how the method is inherited, you can't understand the parent class. In a complex class inherit, you don't understand all other classes it inherited. Any class. Worse, a class cannot be separated from the class it inherited for reuse. Multiple inheritance makes this problem more cumbersome. Execution inheritance is the same as the goto statement is repeatedly executed. Standard and unreliable. Therefore, object-oriented systems often cannot handle complex problems and lack of reuse.
On the other hand, the scripting language actually causes a valid software reuse. In the interesting component, it is built by the system programming language to make them use the module, followed by the scripting language to apply them in the application. This labor segmentation provides Reuse natural frameworks. Components are designed to be reusable components and scripts with defined interfaces to facilitate the use of components. For example, components in TCL are regular commands performed in C. They look more like it is inherent. Command, so it is easier to use in the TCL script. Components in Visual Basic are ActiveX extensions, which can be used to drag directly from the tool panel to the form. No matter how object-oriented programming provides two useful features. The first is a package: the object is linked to the code with some kind of hidden execution details. This makes the management large system easier. Another useful feature is an interface inheritance, which involves providing the same method and APIs, even They have different executions, which can be transformed with each other, which encourages reuse. Fortunately, these benefits of objects can be implemented as in the scripting language, and all scripting languages provide Object Programming. For example, Python is an object-oriented scripting language, and the Python fifth edition includes the object, Object Rexx is an object-oriented version of REXX, and the InCr TCL is an object-oriented version of TCL. One point is different, the subject matter in the scripting language Types, and the object in the system programming language is a strong type.
7. Other languages This article is not all of all the characteristics of all programming languages. In addition to the type length and programming hierarchical features, there are many other features that cannot be explicitly defined as system programming languages or scripting languages. Interesting language. For example, the language of the LISP system is in the scripting language and system programming language, and the features of the two parties have some. It has created a very common point of view in the scripting language, such as interpretation and activity types, There is also the concept of automatic storage management and integrated development environments such as scripting and system programming languages.
8. Conclusion The scripting language represents a set of different agreements with system programming languages. They sacrificed the speed and the type length associated with the system programming language, providing higher programming power and software reuse. When the computer becomes faster This agreement is increasingly wide than the programmer's labor force. The system programming language is also suitable for creating components in complex data structures and algorithms, while scripting languages are more suitable for glucid in contact complex applications. Glue work has become more and more popular, so the script will become more important programming examples than today.
I hope this article can affect programming groups in three aspects; ★ When starting a new project and chooses the most powerful tool for each job I want programming people to take into account the difference between scripts and system programming ★ I want components The frame design can recognize the importance of the script and the confident frame is not only a tool for creating components, but also tools that put them together. ★ I hope that the Programming Language Research Association can transform their attitude toward scripting language and help Develop a more powerful scripting language. For language designers, improve the programming level should be the only important goal, because he is the most important factor in improving the creativity of the programming; the strong type helps to achieve this goal is still unclear .
9. Thanks to this article, thanks to many people's views, including Joel Bartlett, Bill Eldridge, Jeffrey Haemer, Mark Harrison, Paul Mcjones, David Patterson, Stephen Uhler, Hank Walker, Chris Wright, IEEE computer executive, and many enthusiasm Participate in this article, the early draft online newsgroup discussion. Colin Stevens wrote the version of the MFC button example, and StrPhen Uhler wrote the Java version.