First Libretto killer-app #79
Replies: 1 comment
-
The idea of Libretto for UI programming is about testing (my) hypothesis that session types are a good fit for UI state management. The reactive (data-flow) approaches are weird in that the data-flow is uni-directional. An event that goes against the flow is modeled as coming from outside the system. As such, it has to be validated that it even refers to existing entities in the application. That is, we fail to make illegal state unrepresentable. We reach for crutches like global IDs to even route an event that originated from a UI element to that very element. 🤦 I haven't used Laminar specifically, but I assume it does not solve that problem. Now, I realize that even if my hypothesis proves correct, it won't be a killer app. Simply because most people don't even recognize the above as a problem. They are fine with global IDs and with assuming the illegal state, although representable, will never be reached. It might matter, though, for a small number of complex, highly interactive applications (think an IDE). Or not 🤷
Although I have never interacted with Netty directly and don't have a clear idea about the details, I think something in this neighborhood might be an excellent use case!
I wouldn't set the goal of matching Netty performance from the get go. Or more generally, I want Libretto to prove itself useful regardless of performance. I am quite confident that we can make it fast later, but at this moment I am more interested in expressivity, static guarantees and developer experience (and there's still a long way to go in this regard).
It's good to start by thinking what interface the library should provide, and then see if/how Libretto could make it more typesafe. Or bring me an example problem and we bounce ideas and try to model it in Libretto. |
Beta Was this translation helpful? Give feedback.
-
I've seen some idea around to create an UI framework on top of Libretto. But this doesn't look like an end-user relevant "killer app". There are already so many UI Frameworks out there and even the space for data-flow based ones is quite populated. (In Scala you have for example already Laminar.)
But something where Libretto could really shine would be imho as base for a Netty replacement.
Every did any Netty development? It's horrible! Very low-level so your "business logic" (usually a protocol model) drowns in nasty implementation details. Everything get assembled at runtime so it's almost impossible to understand what's actually going on just form the code. Mutable state everywhere, "hold together" by mutable runtime created "wirings" (everything consists just of "Channels", because there are no higher abstractions on the Netty level), additionally complex runtime semantics based on nested fully dynamic event loops… Not to mention the manual resource (and memory!) management, so everything may leak everywhere… And this mess is marketed a "good way" to build implementations of complex protocols. YMMV…
From the web-site:
Replace above Netty with Libretto and likely this would stop being a marketing lie. 😆
Especially for something like network protocols session types would come in really handy! Also moving the "wirings" of the stream processor components from runtime to compile time would be already a killer improvement over Netty! Plus compile time resource safety, WOW!
Not to mention proper declarative code in contrast to the usual imperative Netty spaghetti in Java "OOP" sauce.
Libretto would "just" need some low level runtime that can beat Netty in the performance field. That's not trivial thought as Netty is indeed quite optimized in this regard. (Of course at the expense of making it very nasty and difficult to use!)
What do you think? Would Libretto really fit in here as I imagine? If so, how to start? I'm keen to look into that.
Beta Was this translation helpful? Give feedback.
All reactions