The Benefits of NewtonScript

Portability

NTK compiles NewtonScript into machine code for a stack-based, virtual machine. Each Newton contains an interpreter for this virtual machine. This is the same approach that is used for the Java programming language. There are a couple of advantages to this approach:

There is one main disadvantage: your application is slower. This disadvantage can be addressed, however:


Note:You specify which functions should have native code generated using the native keyword. Here's an example:
func native(a, b)
if a < b then
a
else
b;

You can declare types so that the compiler can generate more efficient code. The two types you can declare are int and array. Here's the same function which declares a and b to be integers:
func native(int a, int b)
if a < b then
a
else
b;


An online version of Programming for the Newton using Macintosh, 2nd ed. ©1996, 1994, Julie McKeehan and Neil Rhodes.

Last modified: 1 DEC 1996