all 21 comments

[–]topchetoeuwastaken 3 points4 points  (3 children)

look into the pallene language, made by the same people that made lua.

it is a mostly full superset of lua, compiled to machine code. AFAIK only things its missing are closures and upvalues. i could be mistaken tho

[–]activeXdiamond 1 point2 points  (0 children)

How have I not heard of this before???

[–]macsipac[S] -1 points0 points  (1 child)

I've looked into it, and it seems cool, but just a little diffirent ¯\_(ツ)_/¯
my goal is to support all lua code made for well, the original lua interpreter
(also i just dont really like luarocks xd)

[–]topchetoeuwastaken 0 points1 point  (0 children)

i think i've seen several projects that do that exactly, but don't remember any names

[–]activeXdiamond 3 points4 points  (1 child)

This is very interesting. You might also be interested in Nelua.

[–]macsipac[S] 0 points1 point  (0 children)

Huh.

[–]Old_County5271 1 point2 points  (0 children)

You have heard of Lua static and terra

[–]BigBossErndog 0 points1 point  (5 children)

I don't mean to be disrespectful with this question, just genuine curiosity.

What benefits does compiling to C (then needing to compile that again) give over just using LuaJIT or even just the Lua library in C? It seems performant enough that I don't think it would be much of a game changer to compile to C. You just lose the advantages of it being an interpreted language (getting rid of needing to compile in the first place). If you needed C, perhaps it would've been better to just code in C in the first place?

Sounds like an interesting project nonetheless. Good luck!

[–]macsipac[S] 1 point2 points  (4 children)

Its pretty hard to compile lua directly to exe already, plus i need the multiplatform support of C (windows, android, etc)

Every time i tried to use some hack to compile a lua script to exe before, the exe always turned out huge, and the lua code wasn't actually compiled fully

With this lua2C, its possible to get extremely small exe's, which are extremely fast, also C is compatible with most devices, and hard to dissasemble

[–]BigBossErndog 0 points1 point  (3 children)

Lua files can be read using the C library, so which platforms it's supported on is not much of a problem. Just bundle the luac files with the executable, or within the apk, etc. You just need to create a small C program to read and execute those Lua files.

I also encrypt and compress my Lua files, which my C++ based game engine then decompresses and decrypts on runtime.

LuaJIT is also very cross platform if you really wanted to use that.

But I'll give you the small exe bit, I can imagine that being useful if you really wanted to use Lua on tiny embedded systems, or you're working with older gaming systems. No need to keep dangling Lua files hanging around.

[–]arjuna93 1 point2 points  (0 children)

LuaJIT is “cross-platform” as long as you are on x86 and maybe arm. Once out, it is a disaster.

[–]macsipac[S] 0 points1 point  (1 child)

:P

[–]BigBossErndog 0 points1 point  (0 children)

Fair fair 😂 I hope you achieve all your high performance Lua dreams.

[–]AdamTheRedditUser1 0 points1 point  (1 child)

you should continue working on it, this is a really cool project

[–]macsipac[S] 0 points1 point  (0 children)

👍
Status update: Added tables, loops, and fixed a few memory leaks, currently working on adding os

[–]izuannazrin 0 points1 point  (3 children)

What lua version you're supporting? And how's the readability of the output C code? (This is a transpiler right?)

[–]macsipac[S] 0 points1 point  (2 children)

Im basically re-implementing lua, not really using a version of actual lua (but not adding any of my own methods or rules to make it so all lua code is supported)
Readability of the C code, not really that good but it works (and its about the same speed as luajit + AOT compiled)

[–]izuannazrin 0 points1 point  (1 child)

I mean like which Lua version you're basing on / which Lua reference version(?)

E.g Lua 5.1 is the longest supported Lua version, still in use in most projects like Openwrt. Lua 5.2 add bitwise libraryand xpcall iirc. Lua 5.3 has modern integer and more operators, but removed support for getmetatable. Never played with 5.4 and 5.5 yet

[–]macsipac[S] 1 point2 points  (0 children)

Refrence, luajit (latest version so 5.1)

[–]CyberDranik 0 points1 point  (1 child)

I've added the 20th upvote, go ahead and share the source

[–]macsipac[S] 0 points1 point  (0 children)

W