
Programming for the Newton using Macintosh, 2nd ed.
Fundamentals of NewtonScript
People should not travel until they have learned the language of the country they visit. Otherwise they voluntarily make themselves great babies--so helpless and so ridiculous.
--Ralph Waldo Emerson, paraphrased
NewtonScript, a new language designed specifically for the Newton, would be a delight on any platform. Its similarity to standard programming languages such as C and Pascal ensures an easy coding transition. At the same time, its innovative aspects--dynamic typing, frames, and so on--are constructs worth learning. Indeed, we expect that once you are familiar with NewtonScript, you will be reluctant to return to many older languages.
NewtonScript owes its nature to its principal architect, Walter Smith. Lured from graduate school by the heady aroma of language creation and new hardware, Smith endowed NewtonScript with powerful and elegant features:
- It is object-oriented. The view system relies heavily on the use of objects.
- It has an unusual type of inheritance. Prototype inheritance is far more memory-efficient than class-based inheritance. (We'll cover inheritance in detail in Chapter 4, Inheritance in NewtonScript.)
- It is dynamic. You do not declare variable types--values have type, but variables do not. A variable can hold different types at different times.
- It is portable and machine independent.
- It provides garbage collection. Memory deallocation is handled for you.
This chapter comprehensively covers NewtonScript, though some of the more esoteric details are left to your further reading in the NewtonScript manual. The order in which we describe the language is somewhat innovative, however. Disdaining the classic textbook structure of building from the simple constructs to the complex types, we are covering the good parts first. After a one-page description of all the language's constructs, we immediately discuss the innovative and complex aspects of NewtonScript. Simpler, more standard constructs are covered afterwards. For example, we use variables long before we tell you that NewtonScript allows them and describe the rules for their use.
Note:
We believe that this approach greatly benefits the programmer already familiar with one or two programming languages--you get to learn about the important variations and features in the language first (the areas that require more study and are, quite frankly, the most fun).
To those of you less familiar with programming languages, simply read through the chapter more than once--ignoring terms you don't understand until they are described. Anything undefined on the first reading should be more comprehensible upon subsequent readings.
- A Brief Overview of NewtonScript
-
- Frames
-
- Arrays
-
- Symbols and Path Expressions
-
- Iterating with foreach
-
- Types
-
- Methods
-
- Additional NewtonScript Features
-
- The Benefits of NewtonScript
-
- NewtonScript Examples
-
- Exercises
-
- Summary
-
An online version of Programming for the Newton using Macintosh, 2nd ed. ©1996, 1994, Julie McKeehan and Neil Rhodes.
Last modified: 1 DEC 1996