
JavaScript to Lua translator - luu
https://github.com/wizzard0/js2lua
======
simple10
For reference, here's why JavaScript to Lua converters are really hard to make
feature complete.

[http://phrogz.net/lua/LearningLua_FromJS.html](http://phrogz.net/lua/LearningLua_FromJS.html)

[http://stackoverflow.com/questions/1022560/subtle-
difference...](http://stackoverflow.com/questions/1022560/subtle-differences-
between-javascript-and-lua)

~~~
nothrabannosir
Do you have specific examples? I went over both lists, and most differences
were either syntax, or "Lua has complicated feature X, JS doesn't."

~~~
alloyed
Off of the top of my head, with varying difficulty

* js has UTF-16 strings with the same semantics(compare-by-value, immutable, interned) as lua strings. you could store UTF-16 in normal lua strings, but then you'd need some way of marshalling them for C code that expects const char* values

* JS has a lot of type coercions when doing binary operations, etc. replicating that seems like a source of indirection

* Lua tables have no explicit length, or any way to preallocate, so it's not entirely obvious what Array(len) or a.length = newlen would do

------
justincormack
Tessel has a Javascript to Lua compiler too, as their hardware runs Lua
underneath [https://github.com/tessel/colony-
compiler](https://github.com/tessel/colony-compiler)

~~~
meowface
Is there any reason why they didn't just stick with Lua, or some abstraction
over Lua like Moonscript ([http://moonscript.org](http://moonscript.org))? Why
is there such a big desire to put Javascript in places where it's not needed?

~~~
wizzard0
Author here. Actually, I wanted to do exactly the reverse - ability to use
tons of Node.js modules in Lua, while coding in Lua. Think of it :)

------
fieldforceapp
Just in case you haven't already heard of what the nice folks at Tessel are
doing, this may be useful to you:

[https://github.com/tessel/colony-compiler](https://github.com/tessel/colony-
compiler)

~~~
wizzard0
Author here. Tessel uses modified eLua, I want to use Node modules in vanilla
Lua, so naturally that approach was not viable to me.

------
nothrabannosir
This repository is Windows only, it uses \ as a path delimiter all over the
place. Gives you weird error messages on Linux.

Consider using / instead: it is accepted on both Windows and UNIX.

~~~
wizzard0
Yep, *nix support is definitely part of the plan.

------
gpfault
How about a reverse translator that lets me write more lua and less
javascript?

~~~
justincormack
There is Moonshine [http://moonshinejs.org/](http://moonshinejs.org/) to run
Lua in the browser. There are a few more too.

