Javascript and OS development
Posted: Fri Mar 28, 2008 4:42 pm
Probably you think what has Javascript (JS) to do with OS development, well i am not sure yet either. It just occurred to me that one can build websites(GUI) with JS and judging on the work of ExtJS integrate it with an OS using Adobe Air for instance. This means that you can develop an application which runs in both a browser and natively in an OS framework. Fun stuff, but what if you can have native JS in your OS... Any one has an opinion in advantages and disadvantages?
Currently i am implementing some form of class (OO) support in JS, meaning classes with public, private and static members and methods. Also partial class support is available. A class can be created like:
Also support for single inheritance is made, but there are some problems/design desicions regarding partial classes. Consider the following code:
This gives a class 'myClass' with the function 'func1' and a class 'myClassExt' with the functions 'func1' and 'funcExt' but as said before there is partial class support thus what would happen is we do
Do i now also have 'func2' available in 'myClassExt' due to the earlier defined inheritance or do i only add the 'func2' to 'myClass'. The former is available now but i have some doubts. What do you think?
Currently i am implementing some form of class (OO) support in JS, meaning classes with public, private and static members and methods. Also partial class support is available. A class can be created like:
Code: Select all
myClass =
classCreate(
{ ctor : function () {
var self = this;
var privateVar = <value>;
var privateFunc = function () {
//- access to <public, private> via self.
}
this.privilegedFunc = function () {
//- access to <public, private> via this.
}
},
publicVar : <value>,
publicFunc : function () {
//- access to <public> via this.
}
},
{ staticVar : <value>,
staticFunc : function () {
//- access to <static> via <classname>.
}
}
)
Code: Select all
myClass =
classCreate(
{ ctor : function () { }
func1 : function () { }
}
)
myClassExt =
classExtend(
myClass,
{
funcExt : function () { }
}
)
Code: Select all
myClass =
classExtend(
myClass,
{
func2 : function () { }
}
)