alternative to lua

Discussion in 'Java' started by ridpiska@hotmail.com, Mar 29, 2007.

Guest

Hi

I'm looking for an alternative to lua.

My problem is that I need to send scripts to multiple clients, where
some are developed in c++ and some in Java. I would like to find an
off-the-shelf scripts interpretator that I can use for both clients.
I first though LuaJava would do the trick, but since LuaJava needs the
native calls to the lua c library, I can't use it for my Java clients.
I can distribute the c native lua to my c++ clients, but my Java
clients need to run "pure java".

Advertisements

Never heard of it. Do you mean this?
<http://www.keplerproject.org/luajava/>
> I first though LuaJava would do the trick, but since LuaJava needs the
> native calls to the lua c library, I can't use it for my Java clients.

Lua is a scripting language like Python. I'd never heard of LuaJava
before, but I suspect it's an implementation of Lua in Java, much like
Jython is a Python implementation in Java.
>
>> I first though LuaJava would do the trick, but since LuaJava needs the
>> native calls to the lua c library, I can't use it for my Java clients.
[...]
>> I can distribute the c native lua to my c++ clients, but my Java
>> clients need to run "pure java".

How about Jython?

http://www.jython.org/Project/index.html
<quote>
Jython is an implementation of the high-level, dynamic, object-oriented
language Python written in 100% Pure Java, and seamlessly integrated with
the Java platform. It thus allows you to run Python on any Java platform.
</quote>

wrote:
> My problem is that I need to send scripts to multiple clients, where
> some are developed in c++ and some in Java. I would like to find an
> off-the-shelf scripts interpretator that I can use for both clients.
> I first though LuaJava would do the trick, but since LuaJava needs the
> native calls to the lua c library, I can't use it for my Java clients.
> I can distribute the c native lua to my c++ clients, but my Java
> clients need to run "pure java".

Oliver has already mentioned Python, which has a Java-only variant in JPython.
(I'm not sure how easy it is to use the standard Python implementation as an
embedded scripting language, but it is certainly very possible to use JPython).

JavaScript/ECMAScript has widely used C and Java implementations in
SpiderMonkey and Rhino respectively. (The last time I looked -- several years
ago -- the SpiderMonkey code wasn't completely thread-safe, but it wasn't
difficult to make it so.) Apparently Java 1.6 comes with a cut-down Rhino in
the box[*].

If you want to use a language from the Lisp family, then you'll have little
difficulty finding embeddable versions for both implementation languages. I
don't know whether you'll be able to find two packages which implement
sufficiently similar dialects, but it isn't obviously unlikely (depending on
what you want to do).

If you /really/ need the two languages to be identical in both incarnations,
then you could consider using JNI to embed a Java-based implementation into the
C version of your applications. (You say that your Java application needs to
be "pure Java", but I don't know whether the reverse is also true).

Guest

Hi

Thank you all for very interesting answers. I'll take a closer look at
Jython, but from my first glance at their documentation I'm afraid it
won't quite fit.

As a browse through different script languages I realise more what I
need:
I need to be able to send script to my clients that call methods
within my clients, and the scripts should be able to receive the
results and act upon it (the same script must be able to run on both
the c++ client and the Java client).
I'm stuck with Java 1.5, and I cannot use jni (in any direction), but
it was a good thought Chris.

The more I read the more I'm staring to think of implementing an
script interpretator by myself (one in the c++ client, and one in the
java client).

I'm sorry I cannot provide you with more details of my clients.

thank you for your helpful answers
cheers
/ jonas

On 30 Mar, 07:15, "Chris Uppal" <-
THIS.org> wrote:
> wrote:
> > My problem is that I need to send scripts to multiple clients, where
> > some are developed in c++ and some in Java. I would like to find an
> > off-the-shelf scripts interpretator that I can use for both clients.
> > I first though LuaJava would do the trick, but since LuaJava needs the
> > native calls to the lua c library, I can't use it for my Java clients.
> > I can distribute the c native lua to my c++ clients, but my Java
> > clients need to run "pure java".
>
> Oliver has already mentioned Python, which has a Java-only variant in JPython.
> (I'm not sure how easy it is to use the standard Python implementation as an
> embedded scripting language, but it is certainly very possible to use JPython).
>
> JavaScript/ECMAScript has widely used C and Java implementations in
> SpiderMonkey and Rhino respectively. (The last time I looked -- several years
> ago -- the SpiderMonkey code wasn't completely thread-safe, but it wasn't
> difficult to make it so.) Apparently Java 1.6 comes with a cut-down Rhino in
> the box[*].
>
> If you want to use a language from the Lisp family, then you'll have little
> difficulty finding embeddable versions for both implementation languages. I
> don't know whether you'll be able to find two packages which implement
> sufficiently similar dialects, but it isn't obviously unlikely (depending on
> what you want to do).
>
> If you /really/ need the two languages to be identical in both incarnations,
> then you could consider using JNI to embed a Java-based implementation into the
> C version of your applications. (You say that your Java application needs to
> be "pure Java", but I don't know whether the reverse is also true).
>
> -- chris
>
> [*] A sentence that not everyone gets the chance to use...

<> wrote in message
news:...
>
> I'm stuck with Java 1.5, and I cannot use jni (in any direction), but
> it was a good thought Chris.

I believe JNI is available in Java 1.5 (i.e. it isn't a feature that
was newly introduced in 1.6 or anything like that).
>
> The more I read the more I'm staring to think of implementing an
> script interpretator by myself (one in the c++ client, and one in the
> java client).

Oliver Wong wrote:
> <> wrote in message
> news:...
>> I'm stuck with Java 1.5, and I cannot use jni (in any direction), but
>> it was a good thought Chris.
>
> I believe JNI is available in Java 1.5 (i.e. it isn't a feature that
> was newly introduced in 1.6 or anything like that).

It is, and 1.4, and 1.3...

--
Steve Wampler --
The gods that smiled on your birth are now laughing out loud.

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!