0

First of all sorry for my English, it's not very good.

I am currently implementing an interactive 3d engine, and I want to add a script engine. After a hard search on the net, I decide to go with javascript (there exist several opensource engines like Google V8, spidermonkey...)

I also check ECMAscript versions and I see that v4 adds Classes, interfices, ... and some interesting features that I want, the problem is that v4 will never be implemented.

I aslo check that Unity uses this features but it seams that they implemented it.

I do some test with Chrome (because I'm interested in V8) but when I do something like:

class Foo
{
function test() {...}
}

It throws an error. "Unexpected reserved word". The same hapens with Firefox (spidermonkey).

My question is: Is there some javascript engine that implements this features (classes, static typed, interfices, inheritance, ...) to be embeded on a c++ aplication?

It has to had non comercial licence and writen in c or c++, and ofcorse fast...

ECMAScript v5 seems that didn't specificate this kind of things.

Maybe with Mono?

1
  • Consider using LUA. It's pretty common for embedding in games/-engines. Commented Jan 8, 2012 at 14:28

2 Answers 2

1

You should either investigate JavaScript as it is, or start investigating an alternative script language / engine that better meets your requirements.

JavaScript / ECMAscript supports many of the same features you're looking for - just maybe not in the same way you're expecting. Inheritance is available through prototyping. Interfaces can be done just by design / consistent naming - or other more advanced techniques. Functions can act as classes, and can even have public/protected/privileged members. (Statically typed may be a bit of a unresolvable difference, though.)

Sign up to request clarification or add additional context in comments.

Comments

0

The standard for Ecmascript 4, the version which introduced classes and interfaces, was never finished, so there aren't any implementations out there. The only mainstream Ecmascript 4 implementation is actually ActionScript 3, which isn't completely compliant with the unfinished standard.

Like @ziesemer and @ThiefMaster say, two good alternatives are Lua and JavaScript itself as it is today, mostly because there are very good open source standalone implementation that will be easier to integrate into your project.

1 Comment

I see that exist something named Tamarin, but I can't find many usefull information. It's the project dead? Adobe give to Mozilla fundation, but I can't find any recent information, all the info is out of date. I know javascript (ecmascript 5) but it doesn't fit my needs, I need a more OOP script engine, like ActionScript 3. I also tried AngelScript but it has some lacks. I also tried Lua and Squierrel, but again I need a static typed language. Thanks a lot for the answers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.