Skip to content
This repository has been archived by the owner on Oct 25, 2020. It is now read-only.

Status #1

Closed
Immortalin opened this issue Sep 14, 2018 · 3 comments
Closed

Status #1

Immortalin opened this issue Sep 14, 2018 · 3 comments

Comments

@Immortalin
Copy link

How feature complete is this right now? Which version of Lua is supported? How does it compare with Castl?

@ark120202
Copy link
Owner

How feature complete is this right now?

It's not usable now. That's an incomplete list of what is not implemented:

  • Most of JS standard library
  • Classes (I had some implementation locally, but I didn't finish it, because Babel's decorator proposal stage 2 implementation wasn't ready)
  • Switch Statement
  • Regular expressions
  • Destructuring assignment
  • continue in loops
  • Function declaration hoisting
  • Variables with var keyword (let and const are implemented)

Which version of Lua is supported?

The main target is LuaJIT (especially embedded one, so there won't be any native dependencies, as well as a complete regular expressions implementation).

How does it compare with Castl?

  • Castl intends to be able to transform any JS code to Lua. I want to find a balance between being close to normal JS and not over-complicating emitted code with questionable JS behavior (e.g. eval, loose comparison, falsy and truthy values, automatic argument type conversion (Math.floor('1')). Though all these assumptions would be detectable by a bunch of custom lint rules.
  • Castl uses specific type-annotations, babel-lua would eventually use TypeScript (see API to work with type definitions in plugins babel/babel#7162)
  • Castl uses babel to transform ES6+ code to ES5, which isn't the most rational solution, because a lot of ES6 features can be implemented a lot easier with a direct transformation (generators = coroutines, local has the same scoping rules as let and const, Proxy can be implemented with a simple metatable)
  • Babel-lua integrates to a Babel toolchain, meaning that you can easily make environment-specific plugins
  • Castl transforms JS AST to Lua code, while babel-lua transforms JS AST to Lua AST, which allows it to generate code that retains lines and generate sourcemaps (though they are useless for now, because there is no consumer)

That said, if you are interested in this project, come back a bit later. This project is a part of another project I'm working on, so for some time there won't be much progress, but it's not abandoned and would be finished eventually.

@Immortalin
Copy link
Author

Immortalin commented Sep 16, 2018

If I am going to e.g. compile Clojurescript to JavaScript and then finally to Lua for use with LuaJIT, which solution would you recommend?

@ark120202
Copy link
Owner

Since ClojureScript already emits ES5-compatible code I think CASTL would be better.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants