Sciter. Part IV. Does European-Computer-Manufacturers-Association-Script sound good enough for you?

That was the question being asked from the very beginning. The short answer is yes.

In our opinion ECMAScript ( a.k.a. JavaScript ) is probably the best scripting language if it will be discussed in the context of web client execution environment.
Well thought and designed. Documented excessively. Relatively simple in implementation. Uses flexible and universal prototype-based schema allowing to use JavaScript as both: functional and object-oriented programming languages. Already known to broad range of developers. Why learning is a curve by the way? (rhetoric question, forget it)

But (oh, eh, how can I live without these “but”s ?) there is one thing which I don’t like in it as probably majority of people doing JavaScript programming too: what is the idea of this prototype stuff? Why do I need to write following if I need to extend say String class?: = function() { ... }

… instead of simply writing it as: = function() { ... }
String “class” in JavaScript is an object by definition – collection of methods. Why do I need that special “rack” with the name prototype on it? What is the idea? I asked this question in many places and conferences and didn’t get answer more meaningful than “just because!”. Technically prototype as a separate “extender” object is not needed.
If you are JavaScript programmer and understand what means String.prototype.trim=function(){…} then try to imagine the language without this prototype. Did you manage to do that? And so? … Correct, you can live without it happily.
Statement String.trim = function() { … } is clear as it is – atttach method named trim to the class String thus all string instances will be able to use it as:
  var s1 = " my string ".trim();
prototype as a property of object instance is definitely needed when you need to know of what class this thing belongs. So in the Sciter/TIScript following statement evaluates to true:
  "some string".prototype === String;

Natural? Understandable? Yes! Is it more clear than the same in JavaScript: “some string”.prototype === String.protype; ? If honestly then yes. You may think about the prototype as a property referring to object’s class.

So how scripting language in Sciter (tiscript) is different from ECMAScript?:
  • There is no such thing as String.prototype, Function.prototype, etc. as I said before. classes in Sciter are real objects.
  • There is keyword super for calling constructor of super class and methods of super class with the same name. The super here is almost the same as super in “big Java”. Use it if you need to solve situations like this.
  • There is a range operator like: arr[0..3]. It allows you to create subranges in ordered collections like array, string and index.
  • Sciter has streams. Stream object supports file, socket and text (in-memory) streams. Streams can be appended and read by using << and >> operators and by very convenient yet powerfull printf method. There is a plan to support scanf method too but not yet.
  • Instead of single Number class TIScript has separate Integer and Float classes. Don’t ask me why. Just because!
  • There is a property keyword. property here is a synonym of a function with single parameter. property allows you to define virtual properties in classes:
  •   property { ... }
      var foo = new Foo();
      var val =; // reading our property.
  • There is a symbol as a built-in data type. Notation of symbol is nmtoken starting from ‘#’ character. Internally symbol is a unique number (integer) assosiated with nmtoken. Think about symbols as a global enum type. number assignment to symbols happens in compile time so operations like something == #somesymbol are effective. Symbols in tiscript are exactly what is known as Symbols in Ruby.
  • Constructors. If you will declare something as:
  •   class MyClass {
        function this(whatever) { this.that = whatever; }
  • Inheritance. Declaration like

  •   class MyClass: MyBaseClass
        function this(whatever) 
          super(whatever);  this.that = whatever;  

    will allow you to define derived class. Pay attention on the super in constructor. I think I don’t need to explain what it means to people knowing taste of Java.

  • Sciter allows you to define methods of classes using fully qualified names:
  •   class MyClass {};
      function {...}
      function MyClass.buz() {...}

    (Yeh, C++, I feel you!)

  • Persistence. Also known as JSON-DB ( ? mine ). Alexei promised to explain it in the next article. Stay tuned…