PhoneScript

The Problems

Mobile phone development has its own set of problems:

  1. memory - Most phones have very limited memory. This is compounded in the J2ME phone, where memory is saved by the JVM, pure garbage control, OO development, and the inability to load remote classes on demand.
  2. Platform Explosion - There are hundred of devices, each behaves differently. J2mE should solve, but each device implementation is often different even among model families. Code writ en in Java for a Samsung 610 will not be guaranteed to run on a 620 ! Many times simple Java core features are implemented badly or not at all. Calling Runtime.gc() on some phones works on some does nothing, on some power cycles and on some frys the handset.

3. Other frameworks are often to heavy or just on available J2ME phones.

The Solution

PhoneScript is a dialect of Postscript. It is a universal language that has been ported to most devices.

Two basic core version of the language exist:

J2ME version of PhoneScript is small under 25k, and the Brew version is much smaller.

Language Examples

%
% comments
abc%comment(/%) Blah blah blah

%
% ints
123

%
% Strings
(This is a string)

(Strings may contain new lines
and such.)

(Strings may contain special characters*!&|^% and
balanced parentheses ()(and so on).)

(The following is an empty string.)

()

(It has 0 (Zero) length.)

(These \
two strings \
are the same.)
(These two strings are the same.)

%
% Names
abc Offset $$ 23A 13-456 a.b $MyDict @pattern
%
% Literal Names
/abc /

% immediatly evaluated Names
//abc //

% Arithmatic
12 23  add 2 div .2 pow
                                                                                           
%stack manipulation
                                                                                              
(first) (2nd) exch
a b c 3 1 roll
a b c 3 -1 roll
                                                                                              
%Arrays
[ 12 23  add 2 div
(first) (2nd) exch
a b c 3 1 roll
a b c 3 -1 roll
[ 2 4 sub 4 mul (result) ] ]
                                                                                              
%Executable arrays
                                                                                              
{ 2 4 sub 4 mul (result) } exec
                                                                                              
% Executing strings
(3 2 add) cvx exec
                                                                                              
% files
(array.ps) (r) file
                                                                                              
% Executing files
(array.ps) (r) file read cvx exec
                                                                                              
%control
3 4 lt { (3 is less than 4) 3 4 sub }
                                                                                              
0 1 1 4 { add } for