Simplicity and Power Through Scripting Visit
Nombas Homepage for up-to-date script language technology |
|
A comparison of modern languages for the internet and WorldWide Web
Author's note: I wrote this article late in 1995. It is now April 1997. For the most part this information is still accurate although there have been some changes; for example, both languages have been updated, both support more platforms (Cmm evens treats Java as a platform), and the Cmm language has gone from being called ScriptEase to its current merging with JavaScript as the ECMA standard EcmaScript language. For more information about the Java changes in the last 18 months see Author's Update to Java the Illusion.
The Java and Cmm languages were each developed to be a secure and portable C-like language for extending safe programming control to everything from personal computers to consumer electronics, from the mainframe to the washing machine. Both development companies, Sun who developed Java and Nombas who developed Cmm, independently designed a language that was portable between all (or most) hardware platforms and operating systems, was safe from the types of bugs (intentional and unintentional) that programmers too often create, and that was familiar to the legions of existing C/C++ programmers.
Both languages attain these goals by creating a C-like interpreted language that protects programmers from the most common problems by automating memory management and removing risk-prone pointer references. Both languages implement run-time interpretation of virtual-machine object codes and also provide run-time verification of these object codes.
But in deciding what changes to make to the C language to meet their goals, these teams followed very different paths. Java started with the C++ class syntax, which is already an extension of C, and extended that language further by adding new Java-specific syntax, keywords, and restrictions. At one point the Java developers decided that C++ would need too much work to meet their goals and so they developed an entirely new language, although it still resembles C and C++. Cmm followed the opposite approach: creating a simplified script-language version of C that removes or automates C's difficult or unnecessary restrictions on syntax, keywords, or data management. The Cmm design goal was always to keep the Cmm language as close to C as possible (but no closer).
Both languages meet the goals of providing portability and restricting potential for errors. Java attains these goals by adding new complexity, restrictions, and classes to a new C++-like language, and creating a complete new safer set of classes and functions, putting the burden of extra work on the programmer. Cmm, on the other hand, achieves these goals by simplifying the C-language and loosening the restriction of that language, while retaining all of the of standard libraries of functions, putting the burden of extra work on the Cmm run-time interpreter (or compiler).
Handling of text strings is one good example of how Java and Cmm differ--an example that illustrates how the different Java and Cmm paths taken for modifying C can lead to very different code. Java strings are handled by one of two newly-created classes: String for constant-length strings and StringBuffer for strings that can be modified. Because these strings are a new type they receive a complete new set of methods for modifying strings, comparing strings, converting strings to arrays, and getting/setting substrings. In Cmm, by contrast, strings are defined exactly as they are in C: as an array of characters. Cmm arrays are just like C arrays, and so all of the string functions that have become standard in C over 25 years are the same functions used in Cmm, but become even easier to use because Cmm arrays are automatically grown and cleaned as needed. These standard and traditional C/C++ string functions would not work in Java because arrays and strings are new and independent data classes. The plus and minus operators, for example, work the same on Cmm string as they do in C, but in Java the plus and minus operators have entirely new meanings for strings.
Similar differences can be shown for handling structures, classes, arrays, lists, and so on. Starting from the same point, the initial design decisions differentiating Java from Cmm have sometimes led to very different paradigms. The following chart summarizes the main points: |