106 points · by keyle · 12y ago · 70 comments
The result is a much smaller size, it's more understandable, hackable, extensible - all things that Lua's standard C implementation is great for. It's likely also easier to optimise this way.
I began on a similar project some years back, but as many spare-time projects go, never finished it: http://code.matthewwild.co.uk/ljs
No but seriously, if you want to write a VM in Javascript, I would suggest learning how to write a VM in a language more suited to writing a VM in. Maybe C or C++ then writing one in Javascript.
http://getmoai.com/forums/moaifiddle-an-online-moai-editor-a...
(Edit: some direct links to already-working examples: http://moaifiddle.com/Q09BJWGMW6 and http://moaifiddle.com/262FBR1ZR8 and http://moaifiddle.com/262FBR1ZR8/2)
This is a full-blown (web-based) development environment for the MOAI Game toolkit, which just happens to be able to deploy to not only Android, iOS, Windows, Linux, OSX hosts .. but also - as demonstrated - to html5+js hosts.
So, if you've ever wanted to check out MOAI but have been put off by the need to build your own host for the OS of your choice, you can just use moaifiddle to get your project done, see the results directly in-browser, and prepare your app before even having to download the MOAI SDK. Sweet!
(More details about the cross-platform game toolkit, MOAI, are available here: http://getmoai.com/)
The documentation is especially off-putting: http://getmoai.com/docs/
Yes, the Docs - well these are generated docs, courtesy of doxygen. You really need to start at the wiki, and then work your way through all the samples in $MOAI_ROOT/samples/
http://getmoai.com/wiki/index.php?title=Main_Page
And of course the tutorials and other refs from the github:
https://github.com/moai/moai-dev/
MOAI does take some patience - but on the other side of that effort, is a fantastic framework that makes game development easy and fun. There's something just so elegant about it!
But yeah, you'll have to suit up for the task of producing a working MOAI host from sources .. this isn't done for you, it is after all free software and there's nobody to buy a license from ..
I work with Lua-based engines on my startup, and right now the "winner" is Gideros.
Corona is also good (But has several issues that made me use Gideros for the current project, but all currently done projects were made with Corona).
Corona is going for HTML5, I hope Gideros can do something like that soon too.
I don't doubt Moai technical capabilities, I was very impressed by it, also the fact that it is FOSS is really cool, but the barrier to start using it was too big and insane.
Things like ASM.js are interesting, but not really helpful, in my mind, as it just adds another unnecessary layer of overhead just to be able to implement something interesting in a language suited to it. I just wish browser vendors saw this the way I do.
I understand clojurescript, parenscript and haskell to js compilers, because these languages are really different from javascript, so they offer you a very different way of working and different tradeoffs (Clojure, CL, Haskell offer you the ability to choose a programming style that is just not possible in Javascript). Maybe even Opal or Amber - rubyan/smalltalkian oop semantics really are very different from Javascript's and you end up using very different design patterns. And I understand the wish to have static typing for large projects/teams, ergo TypeScript or Dart.
But I really don't understant why would anyone go through such pain (by pain I mean not writing the transcompiler/vm, this is the fun part, I know, but debugging it, maintaining it and debugging the code you use it on), to use a language so similar to Javascript, like Lua or Python, instead of using just plain Javascript and making some minor effort to 'use strict', avoid some dark corners and get used to living with a little less syntactic sugar?
Lua is very portable, I wouldn't choose Javascript to replace it for multi-platform game development. However Javascript has a monopoly on the web. I don't see why this ought to be.
[1]: Source: https://skillsmatter.com/skillscasts/3820-developing-a-lua-v...
You can use objects as keys in Lua. This makes a lot of code in Lua a pain to port to JavaScript. I have Lua code I would like to port to JavaScript that this applies to.
¹ https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
Whats not to like?
[1] https://github.com/gamesys/moonshine/tree/master/extensions/... [2] http://yueliang.luaforge.net/
Can someone explain why I might want to use Lua in a browser over JS? Does it have a fundamental feature that JS does not have?
Cool name btw!
Lua is pretty much JS done right, which actually makes it a poor choice for something like this IMO. A program written in Lua is not going to be fundamentally different from the same program written in JS, and the problems introduced by using this (worse debugging experience etc.) are very likely to outweigh the benefits of avoiding JS's warts.
How do you know? Maybe try this first? Apparently, there is a in-browser debugger you can activate just by including two files. This is theoretically a first-class debugger that doesn't even need source maps.
http://moonshinejs.org/how-to/debug-locally/
Were you assuming that Moonshine is a compiler targeting Javascript? It's actually a Lua bytecode VM.
For more info: $ moonshine help distil
At that point we'd probably see some subset of JS devolve to a bytecode, I'll bet.