That was the question being asked from the very beginning. The short answer is yes.
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?:
String.prototype.foo = function() { ... }
… instead of simply writing it as:
String.foo = function() { ... }
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.
var s1 = " my string ".trim();
"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.
- 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 Foo.bar(value) { ... } var foo = new Foo(); var val = foo.bar; // reading our property.
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.
class MyClass {}; ... function MyClass.bar() {...} ... 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…