preciz

preciz

I like to find performance optimizations and hidden bugs in Elixir codebases with coding agents.
If I just ask them directly to find those, they are not that successful, but recently I found two ways that are more fruitful.

Core Erlang and BEAM bytecode inspection:
If I ask my agent to inspect the Core Erlang and BEAM bytecode of a module, it finds much more insightful details and higher quality performance patches.

One of my prompts looks like this:

Further refactor ModuleName.function towards the Pareto frontier of performance, simplicity, elegance.
First, always check the Core Erlang & BEAM bytecode. Then do the refactor, then check Core Erlang & BEAM bytecode again so you continuously gain performance insights from them.

If there are low hanging performance improvement opportunities, the above prompt can find those usually.

Lean 4 formalization:

I would do something like this:

/goal Fully formalize module N of this Elixir codebase in a new formalization/ dir with the Lean 4 theorem prover.

Then it goes to work for a long time (it probably never finishes), but while the main thread is running, I’m using the /btw command to ask questions about the code based on the formalization. This can find very interesting things about the code and it seems like the optimizations/bugs/security issues it can find this way are numerous.

My Conclusion:
Maybe these are just different ways to force an agent to do work and to look at code from different perspectives, but I found that these work well enough to find surprisingly good issues in established codebases.

Showing Posts 1 to 10

mudasobwa

mudasobwa

Creator of Cure

The examples of both in the shape “Code: …, AI Finding: …, Fix: …” would have drastically improved the quality of this observation.

preciz

preciz OP

For me the real insight here is to force the agent to use Core Erlang, BEAM bytecode, Lean 4. Not in what form it reports the issues if you mean that.

mudasobwa

mudasobwa

Creator of Cure

I mean without an example this is not an insight. I was advocating for using static analysis with AI for more than a year already, but I am also an author of a bunch of static tools, way more powerful than just looking into bytecode, and I am an author of Cure language, making Lean4 just a redundant link in this chain.

preciz

preciz OP

That’s great, cause one of my goals were to learn more about this space. I’m now looking into Cure then.

dimitarvp

dimitarvp

What does formalising through Lean 4 gain you?

I admit I am no longer as worried about performance as I once was. Much more interested in idiomatic and easy-to-read code, not to mention self-explanatory and getting the job done in a minimalist manner (OK, now I am just repeating the same thing with synonyms).

I am not as far into the journey as some others but I found that formulating some property tests and doing a few (very expensive) mutation testing passes on key modules gets me in the territory of bug-free core business logic.

Not quite good enough but, since you mentioned the Pareto frontier, mine is: prove the code is doing what our spec requires, and try to minimise it and make it human-friendly. Barely any wins on the latter point still, admittedly. Currently gathering tools and libraries like Plyushkin and gradually am building my own ramshackle Rube-Goldberg contraption that hopefully will begin reducing coding lines in my professional work.

mudasobwa

mudasobwa

Creator of Cure

I can tell from my experience (that’s how I started Cure in the first place,) that in some applications (FinTech, Medical, Aircrafting, you name it) the cost of an error might be enough for the developer to want a proof rather than a “test coverage and probabilistic insurance.”

preciz

preciz OP

From a practical standpoint it finds issues with the code that I would not have found with simple prompting otherwise. So I can clone an Elixir codebase, tell my agent to try to formalize it in Lean 4 and interesting issues keep popping up through this approach.

I’m sure this is not the optimal way to approach this, it’s a new thing for me too. I will try to learn more about this since it already proved useful.

dimitarvp

dimitarvp

Sure, but I don’t know Lean 4. Any examples on how does it eliminate bugs, exactly? F.ex. compare against property tests? Sure enough, PBTs still rely on us to define, ahem, properties / laws, I wonder how much farther does Lean 4 go.

Oh, absolutely, but comparing deterministic techniques with LLMs outputs is a bit of a low bar. I am looking for a comparison of Lean 4 vs. other techniques (property / mutation tests), if you or @mudasobwa are willing to indulge.

mudasobwa

mudasobwa

Creator of Cure

Lean4 (or Cure on that matter) can prove that compiled code cannot get a reciprocal value for the currency exchange rate when crossing through several other currencies. No test can do that.

It can prove that the sum of two values cannot get a value beyond some interval. Etc.

There are people who think they can come up with tests covering all the corner cases and those who already know they cannot.

dimitarvp

dimitarvp

Alright, this is helpful.

But this bit in particular sounds like something we could do with PBTs today?

…provided we’re talking about calling a function or two, of course, and not fuzz CPU instructions and dig into the deep trenches where the Rust team spent years to make APIs for safe arithmetic operations.

Also, how easy it is to hook up to your own test suite, or is this something you periodically run, like a fuzzer?

Where Next? Top

Trending in AI / LLMs Top

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
OndrejValenta
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly) AI dream has many faces, but general...
New
preciz
I like to find performance optimizations and hidden bugs in Elixir codebases with coding agents. If I just ask them directly to find tho...
New
spasm-myelixlabs
Hey everyone, We’re a tiny dev team, and we wanted to share something we’ve been building and dogfooding internally for months: Synapse ...
New
AstonJ
AI tools and services seem to be the new JS framework - with new ones popping up every 5 minutes - hence it might be worth posting one of...
New
caleb-bb
So I’ve got this RAG project called Cake that I’ve been working on a good long while. For this topic, the RAG part is less important than...
New
nathanl
Anthropic: Launching an opt-in vulnerability-finding service for open-source software We’re launching OSS Scanner, an opt-in vulnerabil...
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
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
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
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
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
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

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews