Emerge & Solve - a GUI framework for Elixir

Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.

They are GUI (Emerge) and State management (Solve) libraries that form a framework when put together even though they don’t depend on each other.

Currently only Linux is supported, to be precise Wayland and DRM (Nerves). MacOS and Windows support is planned sometime in the future. Tested only with AMD (Wayland and DRM), rpi5 and rk3566 nerves devices (DRM)

There is also a Solve LiveView adapter in the works, you will have to ask @ken-kost for the timeline on that.

If you want more details check out on hex and github. Rest of the post will be on hows and whys of development.

Getting artificial elephant out of the room

Before I get any further, this project was a successful experiment on how far I can push gen AI coding. 90%+ of the code in those repos is LLM generated and I could maybe credit it for about 5% of the engineering behind that code, there were sessions with 50+ prompts in plan mode before implementation. I have a pretty good understanding of how incapable AI is. That being sad I still have some coding standards and these projects don’t meet them but that is a future me cleanup problem. If this has made you lose all interest I fully respect that. However this post is 0% AI. I will not even use it for spelling & grammar. I have enough trauma of trying to use LLMs to write the docs and I still hate current state of docs. We can start a new thread if anyone wants more details on AI usage, I would like to keep this one focused on GUI.

Motivation

I use nerves both Professionally and all my hobby projects are tied to it, all of those require UI running on nerves devices and I need/want them to be both easy and fun to develop and high performance at the same time. I also have aspirations to develop a mix of OBS and real-time Davinci Resolve using this system on top of membrane, foundation for video pipelines is already in there.

I have spend half of my career building UIs. Using native Android/iOS, meteor.js, Elm, React, ReactNative, Flutter, Surface/LiveView, Keechma-next(Clojure/Script) in various combinations of state managements and different css frameworks/UI toolkits between all of it.

Most of these tools share a common trait. They are painful to use or turn painful to use as UI becomes complex, each set of tradeoffs falls apart in one way or the other. These 2 are most pleasant from both sides:

  • Elm-ui is only lib where I could basically one shot full page from the design without ever running it and it would turn out mostly correct. Emerge API is based on it. When used in Elm this lib becomes painful because elm pushes you into prop drilling.
  • Keechma-next had the most pleasant state management solution of them all. It achieves full decoupling of UI and state without prop drilling while having explicit and declarative data flow in a way that scales very well with complexity. Solve is an attempt at 1:1 elixir re-implementation.

It boils down to me wishing for a combination of those 2 every time I have to write an UI. Last time I was building a larger feature in flutter for nerves device just tipped me over and I have decided to just go for it.

Implementation

Emerge is mostly a Rust NIF backed by skia.

You declare a recursive struct in elixir via function based DSL. Struct is diffed with previous version in Elixir, diff is then serialized into binary and sent over to the Rustler NIF.

Rust side consists of the layout engine, renderer and event engine.
Different back-end implementations need to provide renderer with surface to render into and they need to provide output to the event engine.

Hope some of you find this project useful even as it is in this initial version. There is a lot of essential features still missing. More backends and features are coming in the future along with performance optimizations as there is some low-hanging fruit on that side.

If you try it out and are unable to implement a UI feature you want using Emerge feel free to reach out and propose a new feature.

9 Likes

So far it looks really cool, do you have any examples which showcase most of the available features? What coding agents have implemented the library, what setup was used?

Checkout GitHub - emerge-elixir/emerge_demo: Example showcase app built with Emerge and Solve · GitHub. There is a showcase app in there that covers all of the components and attributes.

I tried lot of models and harnesses in the beginning, settled on Opencode + 5.3Codex, 5.4 later.

1 Like

So how much, if anything, is written by AI? 90%+, 5%, or 0%?

Sorry, words got lost there, edited. This post is 0% AI. Code is mostly written by AI but it ended up being more of an automatic text editor because I had to have it refactor same thing for 10 times and sometimes I had to do it from scratch in the end. For example there was no way to describe events system that I have imagined to AI, had to give up after hundreds of prompts. In the end it was still a lot faster then doing it by hand. Once there is concrete pattern to follow it can do the remaining 75% of implementation without a problem.

2 Likes