Erlang Scripting Language Interpreter
Asked Answered
C

4

10

Does anyone know of an implementation of a scripting language interpreter (something appropriate for a game) in Erlang? Something like Javascript or Lua would be great.

Consubstantial answered 21/12, 2009 at 6:28 Comment(3)
Why would you want a Javascript or Lua interpreter written in Erlang? What kind of benefit do you think you will get from something like this?Autocephalous
I'm writing a game server in Erlang, and I'd like players to be able to write scripts for the game that run on the server.Consubstantial
In some cases, there is a very important reason not to use Erlang as an exposed scripting language. If you are going to allow player created scripts then you need a way to isolate what they can do. An example where you might do this is in a mud. Putting some type of interpreter into erlang is going to be a good way to allow for player created content, but still be able to restrict what actions their scripts can take.Poker
M
6

You may try C/C++ port driver for running lua (or other) language interpreter, erlua is more likely what you need (it works via port driver, i guess).

Mairemaise answered 22/12, 2009 at 8:36 Comment(0)
P
4

Erlang itself can be used as a scripting language. See escript at Erlang docs.

Planetary answered 21/12, 2009 at 6:31 Comment(1)
This is cool, but I'm looking a language similar to the two I mentioned. I have a feeling Erlang itself wouldn't make such a great scripting language. =/Consubstantial
C
4

I second Vijay's suggestion to use Erlang itself. However, I'll also point out the existence of Reia, which seems to be precisely what you ask for.

EDIT: Right, so there's erlyjs, a JavaScript compiler targetting the Erlang virtual machine. I've no idea whatsoever if what stage of development this project is at, how well it's progressing etc., but you could check it out. Not sure if it requires ahead-of-time compilation of JS code, you'd need to see for yourself...

Here you'll find one of several github forks of the code base. All in Erlang, as far as I can see.

Once again, this is not a mature product. But then, with the rise of CouchDB, something like this might actually be useful in some significant ways... so it might hopefully actually become mature somewhat soonish.

Contraoctave answered 21/12, 2009 at 6:51 Comment(4)
Maybe I'm not coming across clearly enough, but I'm not looking to write Erlang programs (as in, programs that will compile to Erlang bytecode) in another language. What I'm looking for is an interpreter written in Erlang.Consubstantial
Well, from Reia's homepage: "Reia (pronounced RAY-uh) is a Ruby/Python-like scripting language". It does compile your programme to byte code, but so does Python -- in both cases it happens on the fly when required. The syntax is nothing like Erlang IMO. I guess it's not entirely similar to JS / Lua, but at least worth a look. Anyway, I'm not sure if it wasn't possible to run JavaScript on an Erlang based engine; will look around & update if I find something.Thirzia
Yeah, erlyjs looks like an awesome project, unfortunately the github version seems fairly immature, and all that's available. The original google code repo mysteriously disappeared: code.google.com/p/erlyjs I also looked into how CouchDB handles javascript, and I see that it spawns SpiderMonkey processes. Perhaps I could find a way to embed V8 into an Erlang Cnode... Bummer. Thanks for your help, though!Consubstantial
Sure. Sorry not to know about something more useful. If you do embed V8 in Erlang code, that would actually be super cool! Happy hacking. :-)Thirzia
R
2

This question comes up in google search - but the comments do not answer the original request. The answer the original poster was seeking is luerl on github - https://github.com/rvirding/luerl

Luerl is lua 5.3 vm implemented in Erlang and developed by Robert Virding - one of the original Erlang developers.

Rushton answered 26/11, 2016 at 12:12 Comment(1)
Please note: luerl implements lua 5.2. There are some big differences when handling integer/floats with 5.2 and 5.3Elope

© 2022 - 2024 — McMap. All rights reserved.