LuauExecutor/LuauDIspatcher - Yet another loadstring-esque library

LuauExecutor

GitHub | Download | Documentation

LuauDispatcher

GitHub | Download | Documentation

LuauParser

This entire project was built around this project by the amazing vantoanvh!

GitHub | Download | Documentation

Introduction

For a while now the gold standard for a luau-in-luau type module was vLuau, a Luau VM written entirely in Luau as a replacement for Roblox’s loadstring. However, there are a few issues with it.

  1. It has MASSIVE. In most of the games I’ve worked on, it’s been about 1/3 of all the lines of code.
  2. It isn’t very future-proof. If something new gets added to Luau there is no guarantee it gets added to vLuau.

So, when I saw someone had made an AST generator that was fast, small, and easy to learn, I hooked into it.

Over the past 2 weeks I’ve worked on LuauDispatcher on-and-off, which uses an AST made by LuauParser to execute luau code. I already can tell you it is going to be easier to maintain than vLuau. A new library gets added? New key in Dispatcher.globals, push an update, we’re done. Something core about the language changes? Just add another node in the list of supported AST nodes.

Not only is it easier to maintain, but it is generally faster than vLuau, too. Not by too much, only about 10%, and on things like deep recursion and big loops, it falls behind. If you’re interested in the exact benchmarks check the GitHub for LuauDispatcher.

Usage

You can either use LuauDispatcher + LuauParser individually, or use the wrapper I created to make it as easy to use as possible, LuauExecutor.

It is just like the vLuau you already know and love:

local LuauExecutor = require(path.to.LuauExecutor)
LuauExecutor(code, options, ...)

You can read more about the options on the LuauExecutor GitHub.

Issues

If you run into issues, make a github issue or comment here. I will try to help you the best I can, and if you find a bug you’ll be credited in the next release!

Anyway, I know this has been a very brief summary, but I do highly encourage you to check these out, and check out LuauParser by vantoanvh. I did the easy part here.

6 Likes

I was literally looking for an alternative to vLuau and I just see you posted this 19 hours ago. Wadahell…

Quite the timing :joy:
I’m glad you could find use out of this module! If you run into any issues make sure to report them to me so I can fix them as fast as possible :smile:

1 Like

I was lately working on one of my game for some LuauExecutors as I don’t want to loadstrings(). They are not that safe, anyways thank you I will let you know if there any bugs.