sodapopcan

sodapopcan

I’m experimenting with ways to allow backend scripting for a web app. Lua seemed like an obvious choice and I found Lua (an Elixir package with a semi-confusing name) which is built off of Robert Virding’s luerl. Lua (the package) is quite nice in that it’s not just a wrapper. It has a nice API for exposing Elixir data to Lua scripts and importantly handles sandboxing.

I admittedly don’t have a clear question here, I’m mostly just wondering if anyone has any experience doing this and if it’s a terrible idea or not. I’m thinking of a usercase like Shopify’s legacy scripts where they let you just write plain Ruby, giving you limited access to objects for accomplishing things like creating more complex discounts than its UI can provide. I’m just experimenting to learn here and (probably) not trying to build my own Shopify :upside_down_face:

Showing Posts 1 to 10

Asd

Asd

I think that you should consider using Dune with a separate node setup. For example, you can start a separate node where the user scripts are running and these scripts will communicate with main node through some API (REST or maybe just some erlang terms over TCP/socket)

sodapopcan

sodapopcan OP

Thanks for the reply! I’m aware of Dune but the idea is to have a more general scripting language for use in a hypothetical product used by mere mortals who would be offended by having to learn a valuable skill like Elixir or FP :slight_smile:

danj

danj

Dave Lucia has talked about extensively using luerl for his product at tvlabs.ai to enable customer scripting. I was present for the codeBEAM talk given by Dave and Robert and the approach is compelling. My takeaway is that it is a good solution.

sodapopcan

sodapopcan OP

That makes sense since Dave Lucia is the author of Lua (the package). Thanks! Unfortunately the talk doesn’t seem to be on YouTube, but I’m still looking there. There is one by Robert about luerl which I’m about to watch. Thanks!

olivermt

olivermt

Latest elixirpodcast talked about a company making a safe ast thing that let them let people write elixir without fear of getting pwned.

I am not sure I would trust that myself tbf, but I think they have published some of that as open source.

However a key takeaway they mentioned in the podcast was that in their benchmarking of homegrown vs luerl vs deno etc lurerl was really fast, just a little behind homegrown thing.

We are talking microseconds here. That means that luerl will often be done executing before you have even transmitted the payload to the executor over tcp when using something like Dune or Deno.

Its also extremely simple to expose functions from your codebase to luerl.

And as Dave has said at a few conferences now, lua is a very good LLM target because its so simple grammar and logic. Meaning you can probably make great helpers if you have users who are only partial programmers.

olivermt

olivermt

The talk is codebeam berlin last year about tvlabs. I dont think luerl or lua was in the title.

sodapopcan

sodapopcan OP

Ah thank you, found it!


And thanks, that’s all good info! I should have mentioned that I played with Lua (the package) a bunch before posting and yes, it’s reallllllly easy to pass variables and functions to scripts, sandbox, and call Lua in Elixir—it’s great!

I guess another thing I’m curious about is sandboxing in general. I’ve read how to do it (and Lua.ex does it out of the box) but have read several murmurings that it’s not perfect, or at least hard to get totally right. Of course none of these posts expand on that, so I’m trying to discover those kinds of pitfalls.

olivermt

olivermt

I think there is academic proof that luerl is unpwnable? I feel that was mentioned somewhere

sodapopcan

sodapopcan OP

I’ll seek that out, thank you!

jstimps

jstimps

One thing to be on the lookout for luerl’s max_reductions and max_time options. Not only do you want to sandbox certain capabilities, but you likely want to protect against infinite loops and unbounded memory growth, or any other resources that could be exploited.

https://github.com/rvirding/luerl/blob/076510701bd0f1f1bde9c49f5ccde0701be88d49/doc/luerl_sandbox.txt#L51

Have fun, I personally love luerl, big fan :heart:

Where Next? Top

Trending in Questions Top

katta
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
apz
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews