Comparison of Scriptol, C and PHP code

The code of the Scriptol language is intuitive and simple. Instead, the PHP code is inherited from old languages such as C and the command line language of UNIX, Bash, designed to limit the consumption of resources and not to improve the productivity of programmers

A clear syntax

Scriptol doesn't need for semi-colon at end of statements. The end of the line is also the end of the 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 is able to recognizes it.

C++ syntax:

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

PHP syntax:

for($x = 0; $x < 10; $x++)
  echo "$x\n";

Scriptol syntax:

for int x in 0 .. 9 print x

This is also the choice of JavaScript (they are optional), of Go.

Objective design

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 phantasy of the author, Scriptol apply objectives rules, and it relies to the more used syntax in computer world, that of XML... XML is tagged and like C has support one-line statements.
Scriptol has one-line syntax, (see above) and is tagged:


Universal operators

Scriptol doesn't use an operator for different usages, as C uses & for deferencing or for binary and, and a same operator should have the same usage in different statements.

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

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

Types from the real word

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

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


A complicated and unreadable piece 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"

And a lot more...

This page and other pages on the site, show only a small part of the language. The manual describes also:

Scriptol vs. PHP

The scriptol code:

text x
input "Y/N?", x

if x.lower()
= "y":  print "yes"
= "n":  print "no"
  print "What?"

The PHP generated code:

echo "Y/N?";

   echo "yes", "\n";
      echo "no", "\n";
   echo "What?", "\n";