3 ms·
Author here if you have any question. Also if you have done any enhancement to Lua/LuaJIT and want help or talk about it I'm glad to hear from you. There is a
by mingodad 8y ago
Author here if you have any question.
Also if you have done any enhancement to Lua/LuaJIT and want help or talk about it I'm glad to hear from you.
There is an parser/transpiler using lemon/re2c that can transpile almost any Lua source to LJS see here https://github.com/mingodad/ljs/tree/master/lua2ljs https://github.com/mingodad/ljs/tree/master/lua2ljs .
Here are some non trivial projects converted to LJS:
ljsjit at https://github.com/mingodad/ljsjit https://github.com/mingodad/ljsjit
ljs-5.1 at https://github.com/mingodad/ljs-5.1 https://github.com/mingodad/ljs-5.1
ZeroBraneStudio port at https://github.com/mingodad/ZeroBraneStudioLJS https://github.com/mingodad/ZeroBraneStudioLJS
raptorjit-ljs at https://github.com/mingodad/raptorjit-ljs https://github.com/mingodad/raptorjit-ljs
snabb-ljs at https://github.com/mingodad/snabb-ljs https://github.com/mingodad/snabb-ljs
premake5-ljs at https://github.com/mingodad/premake-core/tree/ljs https://github.com/mingodad/premake-core/tree/ljs
The next steps that I have in mind now is to add the remaining syntax sugar like:
-C/C++/Java/Javascript for loop
-Switch statement
-Class statement
-const declarations
- type checking (actually https://fascinatedbox.github.io/lily/ https://fascinatedbox.github.io/lily/ has those and it seems a good one to port/add)
-Understand and make it easier for other people understand the implementation of LuaJIT.
- walterbell 8y agoWho maintains LuaJIT these days?
- mingodad 8y agoGood question ! It seems that Mike Paul is still the main one that do it. Now there is a repository on https://github.com/LuaJIT/LuaJIT/issues https://github.com/LuaJIT/LuaJIT/issues and after send a message to the mailing list and no answer for few days another user told me about it and I opened an issue of a problem I found while converting LuaJIT to LjsJIT see https://github.com/LuaJIT/LuaJIT/issues/461 https://github.com/LuaJIT/LuaJIT/issues/461
- jxub 8y agoAlso, CloudFlare was "stewarding" the project (not sure what it exactly means) but they seem to be moving away their codebase away from Lua.
- marktangotango 8y agoInteresting do you have any references about this?
- walterbell 8y agoThese are a few years old: https://news.ycombinator.com/item?id=9981802 https://news.ycombinator.com/item?id=9981802 https://news.ycombinator.com/item?id=10078848 https://news.ycombinator.com/item?id=10078848
- kryptiskt 8y agoThey had a blog post about LuaJIT profiling just a couple of weeks ago https://blog.cloudflare.com/more-consistent-luajit-performance/ https://blog.cloudflare.com/more-consistent-luajit-performan...
- lukego 8y agoThere’s also an active fork of LuaJIT called RaptorJIT that’s oriented towards building whole applications rather than embedding.
- stephen82 8y agoFor some reason, it reminds me of Squirrel language[1] and Lemon language[2]. [1] http://www.squirrel-lang.org/ [2] http://www.lemon-lang.org/
- mingodad 8y agoI'm also forked the Squirrel at https://github.com/mingodad/squilu https://github.com/mingodad/squilu fixing some in my point of view missing features and making it accept a small subset of C/C++ language.
- jxub 8y agoFYI, the link for https://github.com/mingodad/raptorjit-ljs https://github.com/mingodad/raptorjit-ljs is down. Congrats for the project, transpilers are great fun. An impactful project and a logical next step would be writing a new version of Moonshine (http://moonshinejs.org/ http://moonshinejs.org/) or writing a modern full-blown Lua to JS transpiler.
- mingodad 8y agoThank you for pointing it out. Fixed. Cheers !
- zeotroph 8y agoMaybe also properly separated list/array, map/dict and set types? The I-am-everything-{} type in lua is a bit unergonomic when you want to use it as only such a type and a stumbling block for unfamiliar users. Can a project using 5.3 lua continue using existing .lua files but also write new files in .ljs? > switch Aren't match statements all the rage nowadays? Even C++20 get's one (with a silly name, of course)! > class Finally, setmetatable is nice, but, yes, "proper" not handrolled classes. > const Too few scripting languages have these. Do you intend to make this include interior mutability as well or is this only pointer deep?
- mingodad 8y agoThe general idea is to be able to reuse code as much as possible, and C/C++/Java/Javascript style syntax make a lot of code available and if we ditch the 1 based index in favor of 0 based it makes it even easier.
- mkl 8y agoIt looks like it's still 1-based currently, is that right? 1-based arrays have been the biggest obstacle to me using Lua.
- spc476 8y agoI did years of assembly, then C, and now Lua. I've yet to find the 1-based indexing to be an issue, and that's even having written a few C modules to manipulate Lua arrays. What is it about the 1-based arrays that is so off-putting?
- mingodad 8y agoAgain the point is easy code reuse.
- mingodad 8y agoYes you are right it's still 1 based to allow easy conversion from actual existing Lua projects.
- dividuum 8y agoI only poked into the source code on github a bit, so I might be entirely wrong, but from what I understand, the original Lua runtimes (stock Lua, Luajit, etc) were modified for a new syntax? If so, what's the motivation for this approach? Since you already have an lua2ljs transpiler, wouldn't it be easier to use this knowledge to instead have an ljs2lua transpiler and just reuse all existing Lua implementations? Similar to how moonscript works?
- mingodad 8y agoFair point but I prefer less code to mantain move around, as you pointed out it's only a moderate modification of the Lua lexer/parser and not need anything else ~200KB ljs, ~500KB LjsJIT interperter and there you go.
- cordite 8y agoHave you considered a limited form of typescript transpilation?
- mingodad 8y agoYes that's a nice goal and in order to have it we need "class/switch/enum/...", come onboard and help implement then.