6 ms·
JavaScript to Lua translator
- simple10 12y agoFor 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-differences-between-javascript-and-lua http://stackoverflow.com/questions/1022560/subtle-difference...
- nothrabannosir 12y agoDo 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 12y agoOff 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
- wizzard0 12y agoTake a look what happens if you write something simple, like "a[5]=1": http://es5.github.io/#x15.4.5.1 http://es5.github.io/#x15.4.5.1 Or "a > b": http://es5.github.io/#x11.8.5 http://es5.github.io/#x11.8.5 This, in turn, causes all sorts of weird behavior nicely described at https://www.destroyallsoftware.com/talks/wat https://www.destroyallsoftware.com/talks/wat
- gpfault 12y agoHow about a reverse translator that lets me write more lua and less javascript?
- justincormack 12y agoThere is Moonshine http://moonshinejs.org/ http://moonshinejs.org/ to run Lua in the browser. There are a few more too.
- nothrabannosir 12y agoThis 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.
- deleted 12y ago[deleted]
- wizzard0 12y agoYep, *nix support is definitely part of the plan.
- justincormack 12y agoTessel 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 12y agoIs 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 12y agoAuthor 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 12y agoJust 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 12y agoAuthor here. Tessel uses modified eLua, I want to use Node modules in vanilla Lua, so naturally that approach was not viable to me.