Scriptol, for robotics and apps built on Web standards
The Scriptol language created in 2001 by Denis Sureau was defined according to seven rules: simplicity, security, conformance
to standards, objectivity, multiple orientations, portability, easy
teaching.
The scriptol code is either interpreted or compiled in JavaScript, PHP or C++, a
scriptol program may be built as a binary executable.
Control structures are different and more powerful than in classical
languages, allowing pattern-matching and automata (DFA). Security is
one main goal of the language and variables are typed.
It is an universal language for robotics, making dynamic web pages, scripting,
prototyping or HTML 5 based applications. It allows to integrate XML in
source code.
Several innovations in Scriptol have been adopted by other languages created since 2001. It is the first language to have reactive variables, thus combining reactive and imperative programming.
You may use Scriptol:
- For web pages programming: Scriptol may be compiled into PHP, thus it is portable. The compiler detects errors before running the program.
- For script writing: This a clear and powerful language, very intuitive.
- For prototyping: test a scriptol program with the interpreter and produce a C++ source for inclusion into a large project.
- To program quickly and make portble applications without the pain of PHP or JavaScript.
- To make intelligent robots.
A new version of the language, Scriptol 2, appears in 2014 along with a compiler to JavaScript.
Features of Scriptol
- Universal: suited for applications, scripts or web pages.
- Typed variables.
- Object oriented. Even primitives and constants have methods.
- XML oriented: it is a data structure of the language.
- Control structures are safe while .. let, for .. in, etc...
- Pattern-matching and automata easy with the do..case structure.
- Rules are easily implemented thanks to the composite if structure.
- Multiple assignments. A function can return several values.
- Indexed or associative arrays.
- Reactive programming. Scriptol has reactive variable you can mix with imperative code.
- Can use APIs of PHP, JavaScript or C++.
Syntax:
Statements are terminated by end of line.
Xml-like terminators: /if, /while, etc...
Each operator has only one usage, not several acccording the context
as in C.
Scalar types are those of the real life: text, number, real, etc...
Compound assignments have the form:
x + 1 // means for: x = x + 1
Data structures:
Scalars, xml, class.
Control structures:
- if ... else, composite if
- for ... in ... step
- while ... let
- do case ... while, do case ... until
- break, continue, return
Composite if:
You can mix different types of comparisons and compare different types of data from one test to another.
if a
= 10: print "equal"
< 10: print "less"
else
print "more"
/if
While:
The while structure has several form and the let terminator protects against infinite loops.
while x < 10
print x
/while // infinite loop
while x < 10
print x
let x + 1
Function definition:
The header is similar to that of C but several types may be returned together. The terminator is the return statement, the keyword only if the function returns nothing.
int, text funcname(... arguments...)
...statements...
return a, b
Simple print command:
The print command sends a newline after the text. The echo command does not.
print "Hello world!"
Scan structure:
The contents of two lists are added and printed.
var list1=[1,2,3]
var list2=[10,20,30]
for i, v in list1
print v + list2[i]
/for
Should print: 11 22 33.
Embedding code into HTML page:
The scriptol code is converted to PHP by the solp compiler.
<?sol
print "code embedded inside html";
?>
Using reactive variables
This allows programming by formulas without having to write the code update the variables.
react v1
react v2
react sum = v1 + v2
sum.output = 'document.getElementById("sum").value = this.value;'
The v1 and v2 variables are assigned through the HTML interface. The HTML element with id "sum" will be updated whenever the contents of the variables v1 and v2 will be changed.
Scriptol 2
With the appearance of a compiler generating JavaScript code, the language has been adapted to a new audience. Originally created as a front-end in PHP 4, the language made programming easier with classes and inheritance, foreach and other structures PHP was missing at the time. PHP 5 has cost scriptol a part of its interest, and in addition the Hack language that adds typed variable, confirms this trend. The language had to adapt to a new environment.
The syntax is closer to the standard that is developed over time, where or a different syntax has no interest in itself:
- Dyn is replaced by var.
- A literal array is placed in brackets [], which is the case of JavaScript and many other languages.
- Methods of array and dictionary and builtin functions have evolved to distance themselves from PHP.
Scriptol 2 requires editing of existing programs by simple substitutions without grammatical change.
Scriptol 3
The version 3 of the language, which generates only JavaScript code, implements the concept of reactive programming and goal. The language is also simplified to get rid of function useful only for the PHP target code.
A goal is a condition represented by an expression to which a group of statements is associated, which is executed in a loop until the condition is satisfied. Since it is possible to make a goal dependent on another goal, complex processes can be transposed more intuitively than with procedural programming. And since goal may be asynchronous, it is easy also to program a robot.
More
- Language and compilers
Descripton of the language. Download a free and easy to install interpreter or compiler.