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
peck
Hi everyone. My team and I have been working on a fairly modest app based around video streaming and chat, but we’ve landed a customer t...
New
achenet
Hello, I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind. However, when I launch mix phx.server, I get an error...
New
bradley
I really like the adapter patterns that ecto, nebulex, waffle, etc. use and would love find something similar for a key management servic...
New
unaware8150
Hello folks! So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
New
Alvinkariuki
How Can I Optimise Compile Time Dependencies I have been building an elixir application for about 2 years now. Many modules and files ha...
New

Other Trending Topics Top

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
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
budgie
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with. But I don’t use it anymore. Serverless was the promis...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews