NewtonScript
Encyclopedia
NewtonScript is a prototype based programming language
created to write programs for the Newton
platform. It is heavily influenced by the Self computer language, but modified to be more suited to needs of mobile and embedded devices.
In the Newton platform, the system had two states that were more like "on" and "sleeping". When moving to the sleeping state the memory was not lost and instead the system simply stopped working on the contents of memory, which allowed for many of the chips inside to be turned off. This greatly extended battery life, yet still allowed the machine to turn back on almost instantly.
With the main memory always being kept alive, the system becomes much more amenable to use as a persistent object store
. Many object-oriented systems, like Smalltalk
, are based on a continually running object world (known as an image or, when saved as a disk file, a snapshot), so using the Newton platform with an object-oriented system seemed quite natural.
The developers then began looking for languages to use on the system. The Newton platform was originally going to be programmed in the new Dylan programming language
, but a lengthy series of delays combined with the "Not-Invented-Here syndrome
" eventually led to it being abandoned. The team had looked at Self and were very interested in it, but at the time Self was not yet ready for real-world use.
The result was a modified version of Self known as NewtonScript. Written primarily by Walter Smith, the language was a part of the Newton Toolkit, introduced along with the first Newton device (the Apple MessagePad) on August 3, 1993.
One of the advantages of NewtonScript's prototype based inheritance was reduced memory usage, a key consideration in the 128KB Newton. The prototype of a GUI object could actually be stored in ROM, so there was no need to copy default data or functions into working memory. For example, a developer might create a new button instance. If the button uses the default font, accessing its font "slot" (i.e., property or member variable) will return a value that is actually stored in ROM; the button instance in RAM does not have a value in its own font slot, so the prototype inheritance chain is followed until a value is found. If the developer then changes the button's font, setting its font slot to a new value will override the prototype; this override value is stored in RAM. NewtonScript's "differential inheritance
" therefore made efficient use of the Newton's expensive flash RAM
by storing the bulk of the default data and code in the PDA's cheaper and much larger ROM
.
One is that the typical Self snapshot requires 32MB of RAM to run in, whereas the Newton platform was designed to use only 128KB for the operating system. This required some serious paring down of the engine to make it fit and still have room for applications.
Another issue was performance. Since the language would be used for the entire system, as opposed to just running on an existing operating system, it needed to run as fast as possible.
Finally, the inheritance system in the normal Self engine had a single parent object, whereas GUI
s typically have two — one for the objects and another for the GUI layout that is typically handled via the addition of a slot in some sort of GUI-hierarchy object (like View).
The syntax was also modified to allow a more text-based programming style, as opposed to Self's widespread use of a GUI environment for programming. This allowed Newton programs to be developed on a computer running the Toolkit, where the programs would be compiled and then downloaded to a Newton device for running.
However this also led to what is generally considered the most serious flaw of the system. Since the code was written on one platform and run on another, it was practically impossible to debug. Better debugging code in the Newton engine would have helped offset this problem to some degree, but the limited memory made this difficult. Instead the developer would get a vague indication along with an error code, without any ability to match it to lines in the original code. However, software packages exist to allow Newton programs to be written on the Newton device itself.
. NewtonScript employs an inheritance model called differential inheritance
where only the differences with its parent prototype are stored in a list of properties (known as slots in Io). This is a very useful feature for resource-constrained systems. The Io language implements the same differential inheritance model.
The prototype-based object model of Self and NewtonScript was used in JavaScript
, the most popular and visible language to use the concept so far.
Programming language
A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine and/or to express algorithms precisely....
created to write programs for the Newton
Newton (platform)
The Newton platform was an early personal digital assistant and the first tablet platform developed by Apple, the second platform being iOS, used in the iPhone, iPod Touch and iPad. Development of the Newton platform started in 1987 and officially ended on February 27, 1998. Some electronic...
platform. It is heavily influenced by the Self computer language, but modified to be more suited to needs of mobile and embedded devices.
History
Traditional computers, at least in the desktop role, have two modes; "on" and "off". When moving from one mode to the other the state of the machine is lost from memory, and requires a sometimes lengthy "boot" process to return the machine to the "on" state. This does not suffice for a PDA type device where the user expects the machine to be available almost instantly for taking down quick notes. Yet a machine cannot be left "on" for any length of time either, as this would drain the battery too much to make it useful for carrying around.In the Newton platform, the system had two states that were more like "on" and "sleeping". When moving to the sleeping state the memory was not lost and instead the system simply stopped working on the contents of memory, which allowed for many of the chips inside to be turned off. This greatly extended battery life, yet still allowed the machine to turn back on almost instantly.
With the main memory always being kept alive, the system becomes much more amenable to use as a persistent object store
Persistent object store
A persistent object store is a computer storage system that records and retrieves complete objects, or provides the illusion of doing so. Simple examples store the object's data in binary format, along with additional data defining its structure...
. Many object-oriented systems, like Smalltalk
Smalltalk
Smalltalk is an object-oriented, dynamically typed, reflective programming language. Smalltalk was created as the language to underpin the "new world" of computing exemplified by "human–computer symbiosis." It was designed and created in part for educational use, more so for constructionist...
, are based on a continually running object world (known as an image or, when saved as a disk file, a snapshot), so using the Newton platform with an object-oriented system seemed quite natural.
The developers then began looking for languages to use on the system. The Newton platform was originally going to be programmed in the new Dylan programming language
Dylan programming language
Dylan is a multi-paradigm programming language that includes support for functional and object-oriented programming, and is dynamic and reflective while providing a programming model designed to support efficient machine code generation, including fine-grained control over dynamic and static...
, but a lengthy series of delays combined with the "Not-Invented-Here syndrome
Not Invented Here
Not invented here is a term used to describe persistent social, corporate, or institutional culture that avoids using or buying already existing products, research, standards, or knowledge because of their external origins. It is normally used in a pejorative sense, and may be considered an...
" eventually led to it being abandoned. The team had looked at Self and were very interested in it, but at the time Self was not yet ready for real-world use.
The result was a modified version of Self known as NewtonScript. Written primarily by Walter Smith, the language was a part of the Newton Toolkit, introduced along with the first Newton device (the Apple MessagePad) on August 3, 1993.
One of the advantages of NewtonScript's prototype based inheritance was reduced memory usage, a key consideration in the 128KB Newton. The prototype of a GUI object could actually be stored in ROM, so there was no need to copy default data or functions into working memory. For example, a developer might create a new button instance. If the button uses the default font, accessing its font "slot" (i.e., property or member variable) will return a value that is actually stored in ROM; the button instance in RAM does not have a value in its own font slot, so the prototype inheritance chain is followed until a value is found. If the developer then changes the button's font, setting its font slot to a new value will override the prototype; this override value is stored in RAM. NewtonScript's "differential inheritance
Differential inheritance
Differential Inheritance is a common inheritance model used by prototype-based programming languages such as JavaScript, Io and NewtonScript. It operates on the principle that most objects are derived from other, more general objects, and only differ in a few small aspects; while usually...
" therefore made efficient use of the Newton's expensive flash RAM
Flash memory
Flash memory is a non-volatile computer storage chip that can be electrically erased and reprogrammed. It was developed from EEPROM and must be erased in fairly large blocks before these can be rewritten with new data...
by storing the bulk of the default data and code in the PDA's cheaper and much larger ROM
Read-only memory
Read-only memory is a class of storage medium used in computers and other electronic devices. Data stored in ROM cannot be modified, or can be modified only slowly or with difficulty, so it is mainly used to distribute firmware .In its strictest sense, ROM refers only...
.
NewtonScript vs. Self
Changes were primarily aimed at three perceived problems with Self.One is that the typical Self snapshot requires 32MB of RAM to run in, whereas the Newton platform was designed to use only 128KB for the operating system. This required some serious paring down of the engine to make it fit and still have room for applications.
Another issue was performance. Since the language would be used for the entire system, as opposed to just running on an existing operating system, it needed to run as fast as possible.
Finally, the inheritance system in the normal Self engine had a single parent object, whereas GUI
Gui
Gui or guee is a generic term to refer to grilled dishes in Korean cuisine. These most commonly have meat or fish as their primary ingredient, but may in some cases also comprise grilled vegetables or other vegetarian ingredients. The term derives from the verb, "gupda" in Korean, which literally...
s typically have two — one for the objects and another for the GUI layout that is typically handled via the addition of a slot in some sort of GUI-hierarchy object (like View).
The syntax was also modified to allow a more text-based programming style, as opposed to Self's widespread use of a GUI environment for programming. This allowed Newton programs to be developed on a computer running the Toolkit, where the programs would be compiled and then downloaded to a Newton device for running.
However this also led to what is generally considered the most serious flaw of the system. Since the code was written on one platform and run on another, it was practically impossible to debug. Better debugging code in the Newton engine would have helped offset this problem to some degree, but the limited memory made this difficult. Instead the developer would get a vague indication along with an error code, without any ability to match it to lines in the original code. However, software packages exist to allow Newton programs to be written on the Newton device itself.
Legacy
NewtonScript is also one of the conceptual ancestors (together with Smalltalk, Self, Act1, Lisp and Lua) of a recently created general-purpose programming language called IoIo (programming language)
Io is a pure object-oriented programming language inspired by Smalltalk, Self, Lua, Lisp, Act1, and NewtonScript. Io has a prototype-based object model similar to the ones in Self and NewtonScript, eliminating the distinction between instance and class. Like Smalltalk, everything is an object and...
. NewtonScript employs an inheritance model called differential inheritance
Differential inheritance
Differential Inheritance is a common inheritance model used by prototype-based programming languages such as JavaScript, Io and NewtonScript. It operates on the principle that most objects are derived from other, more general objects, and only differ in a few small aspects; while usually...
where only the differences with its parent prototype are stored in a list of properties (known as slots in Io). This is a very useful feature for resource-constrained systems. The Io language implements the same differential inheritance model.
The prototype-based object model of Self and NewtonScript was used in JavaScript
JavaScript
JavaScript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. It is a multi-paradigm language, supporting object-oriented, imperative, and functional programming styles....
, the most popular and visible language to use the concept so far.
External links
- SELF and the Origins of NewtonScript, by Walter Smith, 1994.
- Using a Prototype-based Language for User Interface: The Newton Project’s Experience (PDF), by Walter Smith, 1995.
- Class-based NewtonScript Programming by Walter Smith, 1993.
- Additional Newton-related papers by Walter Smith.
- The NewtonScript Programming Language (archive.org cache; original link dead as of 10/15/04.)
- NEWT/0 A portable NewtonScript compiler/interpreter
- NewtDevEnv, a NewtonScript development environment that enables development to be carried out directly on the Newton by Steve Weyer.
- DyneTK, a NewtonScript development environment that replaces the original Newton ToolKit (NTK); works on MS Windows and Mac OS X by Matthias Melcher.