Skip to content

Instantly share code, notes, and snippets.

@paulcuth
Forked from daurnimator/gist:7627513
Last active December 29, 2015 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulcuth/7656951 to your computer and use it in GitHub Desktop.
Save paulcuth/7656951 to your computer and use it in GitHub Desktop.

Moonshine questions

https://github.com/gamesys/moonshine/

What is your table representation?

  • Weak tables?
  • non-string keys?
  • ES6 maps?
  • issues with 'hasOwnProperty'?

Weak tables are currently not supported.
Non-string keys are fully supported.
I've generally avoided using anything controversial (ie. only supported in a few browsers) in order to maintain support for older browsers. However, if there is good reason to use a feature then I will (ie. typed arrays).
I've not come across any issues with hasOwnProprty. Please let me know if you do.

Multiple VMs?

  • Marshalling?

Multiple VM are now supported (since our conversation at the Lua Workshop). Marshalling should be done through communication with the host environment.

Globals?

  • noconflict? This is a good idea; I've added an issue.

Benchmarks?

I'm currently working on functionality to significantly increase performance, so I'll publish some figures when I've finished. Are there any benchmarks that you'd like to see in particular?

Multiple return values

Lua functions always return arrays in order to handle this. Within Lua this should be invisible.

Browser Compatability?

  • IE?
  • Fallback to flash?

I've done limited testing in IE, but the test script (/test/test-package.json) runs in IE6. Moonshine doesn't include code to make ajax requests using ActiveX, so you'd need to load the json file manually and pass the contents to vm.load(). vm.load() accepts distilled json or bytecode (if the distillery is also included in the page) or a filename that points to a file containing either of those formats.

Source Maps

  • Use of normal chrome debugger

Not sure how possible this is going to be as the code is interpreted. I would like to look into this though in the future. I'd also like to see it working with remotedebug.org.

Code size

  • Dead code elimination?

I'd really like to do this, but not sure of the best aproach. Do you have any suggestions?

"Browser Library"

  • Storage via localStorage?
  • Events?

Absolutely, io library via localStorage is on the backlog, but currently low priority (for us).
There is the DOMAPI that can be used to hook into browser events. Otherwise, you'd have to add listeners via your own host API.

Lua Standard library

  • Can probably write most function in lua itself...

    • coroutine.wrap
  • date stuff looks needlessly complex?

  • patterns: Just translate the original processing code to js; it's not complex.

  • dofile is just loadfile()()

  • select: just use slice??

  • xpcall error in error handler?

  • debug library: why not implemented?

  • table.getn doesn't just use length operator?

There's a perfomance hit with writing functions in Lua vs JS.
You're probably right about the date functionality. Your input is welcome.
I took a quick look at the C code for patterns, but haven't had a go at reimplementing it. It's on the backlog.
I think I need to revisit the dofile/loadfile/etc functions to clean them up.
You're right about select() and Array.slice(). The implementation of numeric properties has changed relatively recently and some lib functions were missed. I'll fix this, cheers.
I didn't think about the possiblity of an error occurring inside an error handler. I'll have to look at this.
As the implementation is quite different to C Lua, some of the functionality is not possible. We don't use the debug lib at Gamesys, so never had cause to implement the functions that are possible. I've added it to the backlog though.
table.getn() uses ported code for the C code. This is only present so that it can match the behaviour of C Lua when passed a table with "holes".

Lua 5.2?

Not supported at present.

Error compatability: rethrowing over js lua barrier?

Any error in the Lua code will throw a JavaScript error if uncaught. These errors can be differentiated from other JS errors by the fact that they are instanceof shine.Error.

@daurnimator
Copy link

ping?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment