Scriptol/The Scriptol Programming Language

From Wikibooks, open books for an open world
Jump to navigation Jump to search

The Scriptol Programming Language[edit | edit source]

A clean syntax[edit | edit source]

C++ syntax:

for(int x = 0; x < 10; x++)
 printf("%d\n", x);

Scriptol syntax:

for int x in 0 .. 9 print x

Scriptol doesn't need for semi-colon et end of statements. The end of line is also the end of statement unless several statements fits on a same line, in this case they are separated by semi-colons. If an instruction fits on two lines, the compiler recognizes the instruction.

Objective design[edit | edit source]

Unlike C that was designed with limited hardware in mind, Perl that has added features day after day, and other languages that depends upon the fantasy of the author, Scriptol apply objectives rules, and it near the more used syntax in computer world, the xml one... Xml is tagged and has as C one-line syntax. Scriptol has one-line syntax, (see above) and is tagged:


Universal operators[edit | edit source]

Some programming languages use the same operator for unrelated things. For example, The C programming language uses the "*" operator for both "deferencing" and "multiply". The C programming language uses the "&" for both "address-of" and "binary and".

Scriptol tries to avoid such confusion by making each operator mean something very similar in all the different ways it is used.

For example, the range operator " .. " is used:

  • as the range in the "for" loop (see above).
  • as an interval of an array or a dictionary (see array).
  • as a range in an expression:

if x in 0 .. 9 
  print "x inside range"

Types from the real word[edit | edit source]

In the 1970s, C and Pascal invented types that were related to hardware: char, long, short, char *, float, etc...

Scriptol uses types related to the real word: text, number, integer, natural, real, array, dict, dir, etc...

Readability[edit | edit source]

A complicated and unreadable part of C++ code...

int x[] = { 1, 2, 3, 4 };
int i;
for(i = 0; i < 4; i++)
  if(x[i] == test) std::cout << test << " found" << std::endl;

may be replaced by a single and clear Scriptol statement.

if test in { 1, 2, 3, 4 } print test, "found"