Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (552)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2
  ignore  |  Print  
  Scripting languages  (Read 5514 times)
0 Members and 1 Guest are viewing this topic.
pokkelipoo
Guest
« Posted 2004-03-13 07:55:26 »

What scripting language do you use in your games?
I was thinking to use BeanShell as it seems to fit in nicely with Java. The interpreter is also quite small (140kb). Anyone used it? Anyone got experiences of Jython?

Thanks.
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #1 - Posted 2004-03-13 10:03:01 »

I know the search on this board sucks, but do a search for "beanshell" and set it to 300 days and you will find several threads.

Q: Would this be better in the tools category?

malloc will be first against the wall when the revolution comes...
Offline nonnus29

Senior Member




Giving Java a second chance after ludumdare fiasco


« Reply #2 - Posted 2004-03-13 10:26:27 »

I like rhino/javascript.  If you compile it to the 'small footprint' version it comes in at about 200k.  Rhino is very simple to use, you can embed it in your game/app with very little code.  My understanding is that jython or beanshell would be just as easy to embed.  

One reason I like rhino is the fact that javascript is well known to any possible end user.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #3 - Posted 2004-03-13 10:42:03 »

Quote

One reason I like rhino is the fact that javascript is well known to any possible end user.


Well...I don't know Javascript, but I do know Java (hence beanshell).

Although, since I know LotusScript, automatically I know 90% of javascript, vbscript, etc Grin. And I hate the name (I still can't believe they got away with doing that!)

malloc will be first against the wall when the revolution comes...
Offline overnhet

Junior Member




Java games rock!


« Reply #4 - Posted 2004-03-13 10:46:56 »

Gregory Pierce has some really interesting stuff on scripting languages for Java. Look for his shootout whitepaper :

http://www.jroller.com/page/gregorypierce
Offline morbo

Senior Newbie





« Reply #5 - Posted 2004-03-13 12:21:00 »

I've used BeanShell in a couple of projects. It's quite nice, except for performance: it's extensive use of reflection to access Java classes ends up creating a lot of small objects (eg. every call must create an object[] to pass the parameters). This causes the GC to kick in too frequently for any chance at realtime performance (if you call a script every frame, anyway). This was under 1.4, so maybe 1.5 has some upgrades that can handle this better, haven't checked.

One other language I looked into (but didn't get a chance to use in practice), was DynamicJava. It has many (though not all) of BeanShells language features, but compiles down to bytecodes, so it's fairly optimal performance-wise. The project seems inactive now (last update was mid-2002), but it appeared stable an feature complete. Plus the source looked fairly clean, so hacking it shouldn't be too scary.  Interpreter is a big bigger (~450k).

Snacks for thought.
Offline nonnus29

Senior Member




Giving Java a second chance after ludumdare fiasco


« Reply #6 - Posted 2004-03-13 15:32:01 »

Quote
Gregory Pierce has some really interesting stuff on scripting languages for Java. Look for his shootout whitepaper :

http://www.jroller.com/page/gregorypierce


I noticed gp kicked rhino from the shoot out; I'm not sure if  the last part of the test suite is really a scripting language job?  Sounds like more of a low level fundamental behavior that should be handled by the game engine, imo;

Quote
* Ultra combo - will test all of these in a real world scenario based on a 3D object moving through 3D space and checking to see if it collides with anything as it passes through that space, the result being the maximum frames per second a rendering engine would be able to render a scene if it depended on the scripting engine for that logic operation


The link to the paper didn't work for me.
pokkelipoo
Guest
« Reply #7 - Posted 2004-03-13 17:50:36 »

Thanks for all replies, I guess I'll be trying Pnuts first, instead of BeanShell.
Offline Rob Grzywinski

Junior Member




Reality Interactive


« Reply #8 - Posted 2004-03-20 13:46:37 »

Quote
What scripting language do you use in your games?


That's an easy one:  Java

Why would I introduce an interpreted language on top of an already interpreted language?
Offline princec

JGO Kernel


Medals: 363
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #9 - Posted 2004-03-20 14:19:53 »

Before everyone comes along and starts flaming Bob that Java's interpreted don't bother, we know what he means Smiley

The question is: why are people feeling a need to resort to scripting languages at all? What is it about the syntax of Java that just makes it no good for getting stuff to work?

I'd also like to ask, is it legal to ship Jikes with a game? Which basically would amount to a the most powerful scripting language on the planet as it's the entire Java language and SDK at your disposal...

<edit> Yes, you can ship Jikes (http://www.research.ibm.com/jikes/license/license3.htm) - so you really do have the most powerful scripting language ever devised...

Now, if only Java's syntax wasn't so bloody awful.

Cas Smiley

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Mark Thornton

Senior Member





« Reply #10 - Posted 2004-03-20 14:40:13 »

Quote
Before everyone comes along and starts flaming Bob that Java's interpreted don't bother, we know what he means Smiley

Even some of Sun's documentation says its interpreted (without qualification).

Quote

I'd also like to ask, is it legal to ship Jikes with a game?

I believe you can ship javac from the Sun JDK too.
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #11 - Posted 2004-03-20 14:50:36 »

Quote

The question is: why are people feeling a need to resort to scripting languages at all? What is it about the syntax of Java that just makes it no good for getting stuff to work?


Assuming you're not trolling...

No systems language is ever good at being a scripting language. They are two different tools for two mutually exclusive purposes.

You cannot have a language which simultaneously does everything of a systems lang and a scripting lang - either it's very quick and easy to use, and does little or no checking and enforcement, or it mandates correctness prior to runtime, and enforces it, and sacrifices ease-of-use for runtime efficiency. There are all sorts of interesting compromises/trade-offs, and in some areas you can increase everything at once, but in general you cannot reconcile fundamentally opposing aims.

NB: my definitions of scripting and systems languages are to follow the spirit of the original uses, not to slavishly re-use definitions that are meaningless in the world of the PC.

Java is not a scripting language. It's a poor fit in most places where a scripting language is called for (leaving aside the many exceptions). IMHO it's also "incomplete" as a systems language due to a few omissions such as structs (although in the original definitions structs are really a scripting language feature) which are invaluable for a modern systems language.

malloc will be first against the wall when the revolution comes...
Offline princec

JGO Kernel


Medals: 363
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #12 - Posted 2004-03-21 08:31:34 »

Well, that brings me full circle on the whole languages debate. What is the point of writing anything in Java when a scripting language lets me get stuff done without checking errors etc.? Or conversely what is the point of using scripting languages when they're so prone to error and have such poor performance?

The only reason I can think of for scripting languages existing is that you can actually dynamically load and compile from proper source code at runtime.

I just don't seem to get it otherwise.

Cas Smiley

Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #13 - Posted 2004-03-21 10:25:07 »

Quote
Well, that brings me full circle on the whole languages debate. What is the point of writing anything in Java when a scripting language lets me get stuff done without checking errors etc.?


(recalls that it was Cas who said he tended not to use Exceptions properly...)

In general, this is exactly the right question to ask (see my last comment below).

Quote

Or conversely what is the point of using scripting languages when they're so prone to error and have such poor performance?


If you want to code poorly (i.e. write code that will be fragile - but will generally be MUCH quicker to write first time), then java is not the best choice. In particular, if you will never need to maintain your code (very rare) or won't be affected if it's hard or expensive to maintain (much more common!), and if you're the only person working on it - then a scripting language is generally much better for coding than java.

e.g. Never use J2EE to do a site that meets the above criteria because you'll be able to achieve *exactly* the same site in 1/3 the time using PHP4.

Scripting languages don't necessarily have poor performance. This has been one of their marketing problems - a few famous ones are utterly dismal, performance-wise, usually due to being originally an academic project (speed is irrelevant) or written by naive inexperienced programmers (terrible code and design).

Ironically, the earliest scripting languages (on mainframes) were often fast or very fast Smiley.

Quote

The only reason I can think of for scripting languages existing is that you can actually dynamically load and compile from proper source code at runtime.
Cas Smiley


IBM (and others) did many studies over the last third of the 20th century on programmer efficiency in different languages. One of the results was that the number of KLOC (thousands of lines of code) each programmer specified, coded, tested, debugged, and deployed in unit time (usually measured per year, IIRC) was approximately constant *independent* of language used.

(another result was that different programmers' KLOC counts varied by a factor of up to 40, IIRC?)

So, really, the question ever since has been "Why the heck should you *ever* program in a system language?".

What this then comes down to is looking at the benefits of a system language on a case-by-case basis and deciding if you really need them. Most of the benefits are to do with long-term savings - reduced optimization effort, reduced maintenance, etc - BUT there are also long-term increased costs with systems langs, the biggest one these days often being refactoring: it's generally much more expensive to refactor systems code compared to the equivalent scripting code (and in the latter case it's less often necessary, simply because the code itself is looser to start with).

malloc will be first against the wall when the revolution comes...
Offline princec

JGO Kernel


Medals: 363
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #14 - Posted 2004-03-21 11:44:32 »

Now, why would I want to write code that doesn't work though, and that I wouldn't find out about it not working until it broke, just because I spelled something wrong in it? It just doesn't make sense not to have a compiler check it for you beforehand.

Cas Smiley

Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #15 - Posted 2004-03-21 12:02:35 »

A trivial example is complex calculations.

e.g. if you want a script that does the equivalent of one of Excel's built-in advanced functions (e.g. the interest-calculators that require about 8 parameters).

Type-checking will save you nothing here - the only way the result will be right or wrong is if you typed the equation correctly or not (assuming you don't accidentally insert a letter in the middle of a number or something equally moronic).

malloc will be first against the wall when the revolution comes...
Offline princec

JGO Kernel


Medals: 363
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #16 - Posted 2004-03-21 13:07:38 »

Exactly - you could type the equation in wrongly such that it was a syntax error. A scripting language won't detect it until runtime. Perhaps it only gets run 2/3rds of the way through the game in an obscure circumstance. This is why we developed compilers!

I still don't get it. Keep talking!

Cas Smiley

Offline nonnus29

Senior Member




Giving Java a second chance after ludumdare fiasco


« Reply #17 - Posted 2004-03-21 13:38:09 »

Using a jump-n-run game example like super mario bros you might have the following type of different platforms:

platforms that you can jump thru from the bottom
platforms you can't jump thru
stationary platforms
moving platform that follows a simple path
moving platform that follows a complex path
platform that desintegrates when you stand on it x seconds
platform that make you bounce really high
platform that moves you like a conveyer belt
platform that is a transition to another part of the level
platform with a switch that can follow different paths

So too code a level in java you could parse a level file and use a singleton platform factory getPlatform() with potentially ALOT of arguments.  In your project you would have ALOT of files that subclass simplePlatform.  And if you wanted to mix and match behaviors that would mean even more files?

Is there another way to do this in java?

With a scripting language you could concievable describe each behavior with a script so long as the versatility is built into a base object or platform class.

I think I prefer the latter, although I haven't done it yet....
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #18 - Posted 2004-03-21 14:21:25 »

All those examples are too low level (and *very* important to gameplay, so they should deserve special attention) to be considered for scripting in some way.

Scripting should (IMHO) be really high level stuff, probably specific to a single encounter in a level, a special weapon or behaviour etc. For a platformer it might be cut screens mid-level, or set pieces. Or perhaps for an unusual character like a co-op NPC. In short, scripts should be so easy to make (and debug!) you can let a level designer go nuts and make up loads of new ones for every single level.

I'd plug V-Script here, but at the moment the most complex thing you can script is a button that turns on and off a light... Embarrassed

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Rob Grzywinski

Junior Member




Reality Interactive


« Reply #19 - Posted 2004-03-21 14:41:50 »

Well, it's good that I can still start a debate rolling!   Wink

The current track seems to be questioning the actual semantics and expressivity (sp?) of a particular language.  This is currently a hot topic all over the programming world.  If you're an OOPSLA watcher, you've seen all of the hoopla on domain specific languages (DSL's) where one definition of DSL is:

... a programming language or executable specification language that offers, through appropriate notations and abstractions, expressive power focused on, and usually restricted to, a particular problem domain.

(taken from http://homepages.cwi.nl/~arie/papers/dslbib/)

I'll just cut to the chase:  I use an appropriate DSL (which is sometimes custom for an application) that I either compile directly into Java byte code or first translate into Java and then compile.

Rob
Offline Rob Grzywinski

Junior Member




Reality Interactive


« Reply #20 - Posted 2004-03-21 14:51:25 »

A coupla quick followups:

  • The literature is claiming that approximately half of current game development time is spent writing tools (so, no, writing a translator, for example, is not out of scope).

  • Given the Eclipse framework (no, I'm not looking to start an IDE discussion) it's essentially trivial to write a context assisted, etc, etc, etc langauge editor.  Integrate that with the AST and you have a DSL spitting out Java in an afternoon.
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #21 - Posted 2004-03-21 15:23:33 »

Quote

  • The literature is claiming that approximately half of current game development time is spent writing tools (so, no, writing a translator, for example, is not out of scope).


*Which* literature?

Quote

  • Given the Eclipse framework (no, I'm not looking to start an IDE discussion) it's essentially trivial to write a context assisted, etc, etc, etc langauge editor.  Integrate that with the AST and you have a DSL spitting out Java in an afternoon.


The obvious fundamental problem with DSL's is that you've created a new language. Cue: all the support and re-training costs inherent to that. You can't just go out and hire people who already know it in and out.

malloc will be first against the wall when the revolution comes...
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #22 - Posted 2004-03-21 15:29:35 »

Quote
Exactly - you could type the equation in wrongly such that it was a syntax error. A scripting language won't detect it until runtime. Perhaps it only gets run 2/3rds of the way through the game in an obscure circumstance. This is why we developed compilers!

I still don't get it. Keep talking!

Cas Smiley



In 99.999% of situations you will visually spot the syntax error. But writing that equation has taken you 3 seconds. Writing a class to house a method and a method to house the equation, and choosing an immutable signature and choosing (and possibly defining) types...all this takes a lot more than 3 seconds. You usually use a script in such a situation (IF you decided it was appropriate) because:

  • The equation would be edited by people who won't or can't edit java files - or can't be trusted to - but who can just about manage basic algebra (or, indeed, classless basic).
  • or: The minutes saved in not adding the java baggage, and compiling, and recompiling for each and every minor change, outweigh the time lost for the occasional syntax error that slips through and wastes a lot of time in one go.
  • or: You need to save time NOW and you are willing to do that at the expense of losing even more time in the future (e.g. "demo has to work tomorrow morning; we can re-code next month, after GDC is over, and gradually replace the scripted bits with systems bits").
  • or: You want people editing this who don't have access to a compiler (perhaps they're editing code in a web-browser and wouldn't have the nous to intrepet compiler errors even if you redirected them to the web browser; nb: I've been involved in a game project where this actually happens - people with 0 programming experience are able to edit complex scripts in web forms; this is appropriate for their use case, and works very nicely)
  • or:  ...many others...


Really, though, there isn't much cause for a debate about whether you should or shouldn't use scripting langs (it only makes sense to evaluate each situation separately). They're merely another tool, and AFAICS it's pretty obvious what their main pros and cons are compared to more proscribed languages, like Java. You just evaluate them for each part of your project, no?

malloc will be first against the wall when the revolution comes...
Offline princec

JGO Kernel


Medals: 363
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #23 - Posted 2004-03-21 21:19:25 »

Well, it would just seem that every time I think about such an evaluation I end up at the same conclusions: that the whole reason I use Java *at all* is because of a bunch of benefits it seems to offer over using any other language. And with javac shipped along with the game the only other advantage I can see in scripting - that source is compiled and loaded at runtime - is out the window too.

There are a couple of issues with the syntax but they are as nothing compared to what even PHP looks like.

I still don't get it really :/ Maybe I just don't have any need of scripting for anything...

Cas Smiley

Offline Mark Thornton

Senior Member





« Reply #24 - Posted 2004-03-22 06:23:51 »

Quote



In 99.999% of situations you will visually spot the syntax error. But writing that equation has taken you 3 seconds. Writing a class to house a method and a method to house the equation, and choosing an immutable signature and choosing (and possibly defining) types...all this takes a lot more than 3 seconds.

Surely your environment can provide a template class to suit the context so that the 'scripter' just has to fill in the body of the method. You can choose whether or not the surrounding templated text is visible (or editable). The code that the scripter writes does not now differ significantly from say JavaScript. You can either compile the code immediately or just before use.
Offline Rob Grzywinski

Junior Member




Reality Interactive


« Reply #25 - Posted 2004-03-22 13:14:36 »

Quote
The obvious fundamental problem with DSL's is that you've created a new language. Cue: all the support and re-training costs inherent to that. You can't just go out and hire people who already know it in and out.


It should be noted that DSL does not imply a new language.  Cas, for example, is saying that Java is the DSL of his choice (though the "domain" in this case is a bit broad).

If it's easier to write your FSM's in Prolog, then do so.  Some things are better in functional langauges whereas others are better in procedural languages.  Use what makes sense for the particular situation.
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #26 - Posted 2004-03-22 13:55:15 »

Quote

Surely your environment can provide a template class to suit the context so that the 'scripter' just has to fill in the body of the method. You can choose whether or not the surrounding templated text is visible (or editable). The code that the scripter writes does not now differ significantly from say JavaScript. You can either compile the code immediately or just before use.


Of course. And you can always simulate every scripting language in java. Or C++. Or probably in pretty much anything. For instance, every time we use BSH it's not far off from doing what you describe. But I don't understand what point you're trying to make? Other than that you could write a new scripting language similar to BSH but with only the most basic of the features very easily?

malloc will be first against the wall when the revolution comes...
Offline Mark Thornton

Senior Member





« Reply #27 - Posted 2004-03-22 14:34:08 »

Quote


Of course. And you can always simulate every scripting language in java. Or C++. Or probably in pretty much anything. For instance, every time we use BSH it's not far off from doing what you describe. But I don't understand what point you're trying to make?

You were talking about the time taken to write a java class instead of using scripting. However when you permit scripting at some point you are defining the context in which the script operates, which is much the same as defining the class 'template'. So if we eliminate the effort needed for the user to copy that template themselves, both ways of proceeding require very similar effort from the user. The remaining difference is one of weak vs strong typing for variables declared in the 'script'. This is what really (in my opinion) makes script languages easier; you don't have to know the appropriate types. However if you are scripting a games (or other application) that you wrote yourself, this advantage probably doesn't apply (you know what the type is).
Offline overnhet

Junior Member




Java games rock!


« Reply #28 - Posted 2004-03-22 16:00:40 »

With some scripting languages you can benefit from operator overloading and other constructs which makes the code more compact (and possibly more readable). OTOH if you stick with Java, you are tied to its syntax : great for robustness and security, but painful for quick and dirty prototyping.

Another point that is sometimes mentioned in favor of scripting languages is that scripting is easier for "artists" than C/C++ like languages. A simple, game-specific AI language would be much more efficient to test and fine tune gameplay than its C++ equivalent.
Offline nonnus29

Senior Member




Giving Java a second chance after ludumdare fiasco


« Reply #29 - Posted 2004-03-23 03:14:31 »

So far no one has really explained how to go about using java to, for example, script a cut scene....

Quote
All those examples are too low level (and *very* important to gameplay, so they should deserve special attention) to be considered for scripting in some way.

Scripting should (IMHO) be really high level stuff, probably specific to a single encounter in a level, a special weapon or behaviour etc. For a platformer it might be cut screens mid-level, or set pieces. Or perhaps for an unusual character like a co-op NPC.


I disagree, all of the different platform behaviors I listed can be derived from a few simple properties;

physical opacity (jump thru from the bottom or fall thru)
elasticity
motion/motion on a path
collision response
attaching 'teleporters' to transit to another part of the level
attaching script objects to trigger different paths or events

So you would have one meta-platform class such that all these properties can change and are exposed to the scripting language.

Am I way off base here or what?
Pages: [1] 2
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CopyableCougar4 (23 views)
2014-08-22 19:31:30

atombrot (34 views)
2014-08-19 09:29:53

Tekkerue (30 views)
2014-08-16 06:45:27

Tekkerue (28 views)
2014-08-16 06:22:17

Tekkerue (18 views)
2014-08-16 06:20:21

Tekkerue (27 views)
2014-08-16 06:12:11

Rayexar (65 views)
2014-08-11 02:49:23

BurntPizza (41 views)
2014-08-09 21:09:32

BurntPizza (31 views)
2014-08-08 02:01:56

Norakomi (41 views)
2014-08-06 19:49:38
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!