RE: [GD-General] JavaScript as a scripting language
Brought to you by:
vexxed72
|
From: Brian H. <bri...@py...> - 2002-12-06 20:25:30
|
Ignacio, These are, in fact, the reasons I was looking at JavaScript. From a pragmatic standpoint, it has a syntax and methodology that's a lot more approachable than Lua's for a lot of programmers (and even non-programmers who may have experience from Web site development). It has GC (although, like you, I'm unclear on what kind of garbage collection is prevalent -- it's up to each browser and/or engine to select the form GC, but early versions were mark-and-sweep and I think very early versions of Netscape were ref-counted). It's trivial to embed. It's interpreted and quite fast (the njs benchmarks at the GCLS are generally as fast, if not faster, than Lua's). It also has a reasonably clean interface to and from an application, although looking at some of the docs for garbage collection, the active participation an app must undergo in order to "root" an object seems kind of ugly. I also like that it's dynamically typed and prototype based instead of being class based. I think this provides a lot of clean generality since there's no artificial bifurcation between types and objects -- they're one and the same, and 'types' are now first class objects (which I believe SmallTalk and Obj-C also supported). So given all this, I'm confused as to why JavaScript isn't mentioned in the same breath as Python and Lua and Ruby when it comes to game scripting. There are free implementations (SpiderMonkey), it's portable, and it's already heavily used and well understood with a TON of documentation available for it. My only guess is that there's a stigma attached to it since some people consider it (erroneously) a glorified form of HTML. Of course, there's also the obvious "it sucks because of [these reasons]", but I've never actually seen someone do a post-mortem or at least a rationalization on why njs/SpiderMonkey/JS are bad for game scripting. All that said, I'm pretty down on game scripting in general, but I'll leave that for another post. Brian |