post your favorite scripting language

Hello!

Please post your choice of scripting language! I’ve been learning my first agile programming language groovy.

Well JavaScript WOULD be my favorite, but so many browsers have so many differences in DOM implmentation… which pretty much breaks JavaScript in many ways. Other than that it has pretty simple syntax rules…

My actual favorite scripting language (not programming language) would have to be PHP. It has extremely easy syntax and an enormous library of functions to use. If you don’t believe me… check this out

Other decent languages I like are ActionScript (for Macromedia Flash) and BeanShell

Java. It’s in memory compilable to bytecode and then infusable to rest of the code. So why use something like scripting, when Java would work flawlessly? If you would like to kick out some of braces, write your variation, then parse it into legal version.

BeanShell (as mentioned by Woogley above) integrates well with Java applications. Scripting is useful for things like User Macros (just think msoffice) as well as being useful for describing entity behaviours in games. This latter use allows content to be divorced from code which “is a good thing”.

I use Javascript a fair bit too.

Alan

This post isnt about Java (which is a programming language, not a scripting language).

The reason why you use scripting languages is because (surprise!) Java can’t do everything. Java cannot modify pages on-the-fly in a web browser like JavaScript, for example

Another use for scripting (like BeanShell) is adding interactivity without recompliling Java bytecode. THe bytecode simply runs it. BeanShell can be VERY useful (especially in RPGs when you need scripting for things like characters moving around in a world… dialogue, and all that.) Hardcoding that into bytecode isnt a good idea… this way you can build a map editor which allows user scripting (and still, no compiling) :wink:

You’re just plain wrong woogley; true you have to use javascript for DHTML in a web page because that’s how browsers are implemented but the java runtime can load text files of java source code and execute them at runtime performing the exact same function as beanshell, groovy, jython, rhino, whatever. I pestered these guys for about 6 months on this topic and finally someone pointed me to an article that explained it, but sadly I’ve lost the link…

That doesn’t seem to make sense that the java runtime can also run uncompiled java files. Is this really possible? If it is, what is the purpose of beanshell?

SpiritWolf,

Beanshell uses a dynamic class loading/compiling method that allows to provide exactly that, the ability to run even snippets of java source without percievably compiling them. The downside is the performance, which is not suitable for anything real time (by this I mean AI routines etc…). However, it is a powerful tool for scripting events and actions within game systems.

Personally, I like groovy for scripting. However, I a bigger fan of determining your operating context and writing an object hiearchy to support interacting with it. Through trial and error I’ve discovered that integrating scripting languages just doesn’t work for me. At the end of the day, I don’t want my desigers scripting things, I want them using tidy GUIs to define how they’d like things to work. If they’re going to use GUIs, then the format underneath doesn’t matter as much.

Kev

Do you mean defining a scripted event with a GUI?
Is using a GUI to define the scripted events as flexible as a full-fledged scripting language?

none there all crap

Yes, it would limit flexibility. In most things I’ve worked on you’re letting your scripting system out to some pretty inexperience or non-tech savy people. In these cases a limit of flexibility is a good thing, it prevents the scripter breaking the system over and over. IMHO, java is just too complicated and open ended to be a really useful scripting tool for non-programmer builders.

Kev

A little story about RuneScape…

It was considered far too dangerous to allow large numbers of people access to modify anything and everything in the codebase to add new features and quests - but most quests, to be interesting, needed previously-un-thought-of new features.

So, they created a proprietary scripting language very similar to ARM assembler (a simple to use assembly language, similar to bytecode but simpler) and allowed anyone to use it.

At runtime, that language is interpreted by the JVM, and the interpreter ensures certain things like preventing infinite loops and other ruinous things that non-programmers can easily end up doing.

…back to Beanshell et al:

Exactly the same thing is theoretically possible using anything like Beanshell (bsh); I believe the main reason it’s not done at present with bsh is simply that the implementation classes for bsh are far too complex, spaghetti-code (I’ve hacked on quite a few of them, and it’s incredibly confusing for classes that are inherently quite simple). It’s worth noting that this barrier to usage is widely aired and there’s considerable pressure and apparently a lot of intent to fix it ASAP…so worth checking the situation again in 6 months time, and you might find some very good stuff avaialbe for use.

Ditto the performance issues: bsh can be fast, should become very fast (but won’t be until the next version appears, using the bytecode compilers as long requested and promised), but has some deep bug which makes it very very slow in several situations. On average, it’s rather like javascript or visual-basic: for some things, it’s very fast (you won’t find it’s a noticeable bottleneck, your own java code and hardware interfacing will be much slower), but for others it’s godawful.

Personally…I can’t wait another 6-24 months for bsh to come up to where it could be, so I can’t/don’t use it much at the moment (I use it in particular places where I know it will be OK, but much less widely than I would like).

I suppose it all depends on what you want to use it for.

I personally like to use java as a scripting language (and use beanshell or janino) because it doesn’t limit me in any way. I don’t think java is more complicated to use for scripting than say, VBscript or javascript, and when you use Janino you get excellent performance. I’ve seen so many cases where I needed to use some scripting language which was nice for simple things, but when things got complicated it quickly became horrible.
For server side web scripting, I like JSP. It’s clean, easy and powerful. I kind of dislike PHP for that (although it has some nice features) because I’ve seen too many compatibility issues.
A language that got me into programming after a few years without doing any coding at all, was UnrealScript. Very much like java (it even compiles to it’s own version of platform independent bytecode), but with some added language features for game scripting (I especially liked the concept of ‘states’ for games). OTOH, it lacks a few nice things compared to java.

A long time ago, there was a discussion here about the difference between scripting languages and ‘real’ programming languages. I suppose in many cases the boundaries are not clear, and it depends on what you use the language for. Like if you use java for scripting, than in that case java is a scripting language.

chill, dude! you don’t have to say people are 100% wrong because you personally dont like scripting languages. You’re right about Java loading dynamic classes like BeanShell, but why reinvent the wheel? BeanShell has done this in a very stable manner. That’s like saying using LWJGL is 100% wrong because you could use Java3D!

The fact is there are alot of ways to do alot of things in the programming world. There are languages out there that can perform better than Java at certain tasks. Like PHP for instance. PHP doesnt need to mess with Servlets and all of that, it just lets you build dynamic pages without worrying about object types and such. PHP also doesn’t need JDBC drivers to load just to load a simple SQL table. So… I’m not saying Java can’t do it (because it can), but it IS easier to do it in PHP.

So java can be used as a scripting language because it loads classes dynamically? Could I use the reflection apis to call methods and such at the speed of java instead of the speed of a embedded scripting language? If that’s the case I would have compile the code, but that shouldn’t be too hard unless you edit things a lot in a game. A game like a rpg or something where your changing the npcs behavior alot…

btw kevglass, didn’t you mention that scripting with a gui is easy to use for developers inexperienced in programming, and makes sure that they don’t mess up the game rules. Isn’t there a middle ground here? Why not code some library that encapsulates the game rules and maybe use the facade pattern to wrap the game entities and other data that they might try to access? Just a thought…

No, I said that building a context (an API to which your container game conforms) in which you use Java to “script” the specifics of your game then use dynamic class loading to support, which is what you’ve said above.

The GUI comment was with repsect to non-techy users who are affeared of lanaguages of any sort. In that case it makes little difference what scripting you use underneath since you’re going to be translating anyway.

Kev

It’s quiet warm here actually…

That’s a groundless statement. Have you clicked on the jsgc link in my sig?

[quote]You’re right about Java loading dynamic classes like BeanShell, but why reinvent the wheel?
[/quote]
No, Beanshell loads dynamic classes like Java, so yes, why reinvent the wheel?

I was merely posting to the implied tone of your post that java wasn’t suitable for ‘scripting’ whatever ‘scripting’ actually means.

In you original post you also said;

[quote]Java can’t do everything.
[/quote]
Which in fact it can. Both in a Turing complete sense and in a ‘leap tall buildings in a single bound’. :stuck_out_tongue:

Nothing personal, I’m bored and just having fun :-* .

eh that is a good point… whatever “scripting” is. java is, in a sense, a scripting language. Every scripting language has an interpreter… in this case the VM. :o

Java is pretty cripple without the VM… and the VM is pretty cripple without the machine code thats behind everything! confusion! :o

Have you clicked on the jsgc link in my sig?

Have you? (hint: the links are broken, you need a “http://” infront)

I use beanshell and jython. Beanshell is really really slow (like 400 [fourhundret!] times slower than java) and jython is ugly, but only like 40 times slower. Those figures are pretty rough, but it doesn’t matter much at that degree of slowness.

Either way it’s not usable for inner loop stuff, but it’s of course perfeclty fine for prototyping those bits. Like… write it with beanshell, test, change, test, change etc and once you’re satisfied rename, compile, take care about some bits here and there, compile again and you’re done. That final step takes usually about 1 minute. So, yea it’s really worth it.

Everyone should really give it a try (at least once). It’s fun :wink:

[quote]Please post your choice of scripting language! I’ve been learning my first agile programming language Groovy.
[/quote]
IMHO Groovy is a bad mixture of random concepts, lacking the elegance of other languages. So I won’t recommend that language at all. You didn’t say whether the scripting language shall run inside a VM or not. I assume the latter.

Ruby is nice and clean scripting language (mainly OO, but procedural and functional also works) from which Groovy brorrowed most concepts. Ruby is a mixture of concepts from Smalltalk and Perl, adding some nice features from Python and Sather. Although Python seems to be more popular than Ruby, I think, Ruby has better concepts. But perhaps it’s only because I see my beloved Smalltalk behind Ruby and feel more comfortable with that language. There’s an attempt to create a Ruby running on Java (actually it was started by me a couple of years ago) but even if I really respect what the JRuby people do, I don’t think nowadays that recreating a 90%+ compatible Ruby clone is worth the effort.

Lua is tiny, embeddable, Pascal like functional scripting language which is actually quite popular among game developers. Probably because it’s easy to embed and considered quite fast - being a bytecode interpreter. And probably because other developers used it… World of Warcraft’s UI is scripted with Lua (I got a lua error message when I tried to start the game after my 10 day guest pass went off - I’m now playing Guild Wars instead :slight_smile: I once created a Lua parser for Java but because I don’t like the Lua function library that much, I abandoned that project.

IMHO, every developer should know Scheme and it can be a decent scripting language, too. With JScheme and SISC there are two Scheme implementation for Java. Actually, it for ignore syntax, any language can be mapped on Scheme and vice versa.

If you like rather exotic languages, I can recommend Io and Goo. Io is a prototype based language (like JavaScript, both inherit the idea from Self, a Smalltalk dialect) with a very clean syntax. Goo is also a prototype based language, this time featuring Dylan-style dynamic multimethods and therefore influenced by the Lisp school of thought.

Probably the most underrated scripting language is JavaScript. I kind of like it, but I really hate the fact that 1 + “2” is the string “12” while 1 - “2” is the number -1. Don’t overload “+” for Strings if you at the same time automatically convert types. That is crap and makes me really hate that language. Otherwise, it has prototypes and closures, two features I really like.

A nice JVM-based language I’d like to mention is Pnuts. However, it’s only interesting if you’re looking for a scripting language which is similar to Java and which runs on Java. According to benchmarks on the Pnuts web site, Pnuts is the fastest scripting languages for the JVM.

While I understand the idea that it is useful to use a Java language compatible scripting language like BeanShell or Janino, I consider this kind of boring and - more important - you can’t really workaround the Java syntax limitations. To be able to gain something, you should also consider radically different languages.

Factor (from the guy who created JEdit) is such a language. It’s a postfix language modelled after Forth and Joy, having also a lot of Lisp influence (as every good language should have IMHO). I can barely read Forth and are lost with APL so I’ve a hard time to understand factor. A little bit more ordinary syntax would be okay for me :slight_smile:

Ah yes, and REBOL (from the guy who built the original Amiga) might be worth a look. It’s a pure postfix language, modelled after Logo which has some nice concepts. Like with most languages I found interesting to study, I created a tiny Java parser for to play around and then abandoned the project. I like the (old, because derived from Lisp in 1960) idea that program and data are expressed in the same way which makes meta-programming quite easy.

[Sorry for the long rant ;-)]

Stefan