[ANN] Magic.jl — A Simple, Data-Centric Web App Framework for Julia

Nice work!

The question everyone is probably asking: why another Genie.jl?

Could you please compare the features of the two frameworks?

2 Likes

Thanks for the question!

How does Lit.jl compare to Genie.jl?

They are very different, and most of their differences arise from their different execution models.

Genie

Genie adopts a reactive component model, similar to React’s component model.

  • Traditional request/response architecture: Genie works with traditional request/response architecture, where the developer implements the response for each endpoint request.
  • Declarative UI: The UI is implemented in a declarative way, almost as if writing HTML (and sometimes literally writing HTML) but with Julia constructs.
  • Reactive model: Simple UI updates happen automatically through reactive variable binding, but custom logic in response to user interactions is implemented exclusively via callbacks.

These characteristics makes Genie very flexible, giving the developer a lot of control on how things look and behave, which makes Genie suitable for developing any kind of web app really. But they also make implementing simple interactivity that goes beyond UI updates less straightforward, especially because of the hard separation between the UI placement and the UI behavior (which resembles the separation between HTML and Javascript).

Lit

Lit adopts a top-to-bottom rerun model, like Streamlit.

  • Script rerun model: The entire app script runs from top to bottom on every user interaction, making the execution flow intuitive and easy to reason about.
  • Imperative UI: You build the UI using simple imperative Julia code - just call functions like button() and text() in the order you want them to appear.
  • Implicit reactivity: State management and UI updates happen automatically through the rerun mechanism - no need to define reactive variables or wire up callbacks (although that’s also possible).

These characteristics make Lit more approachable for scientists and researchers who want to quickly turn Julia scripts into interactive web apps, without needing to learn web development concepts like callbacks, reactive programming, or the separation between UI and behavior. But since each UI event triggers a rerun of the script and a rebuild of the page layout, Lit’s execution model can also make interactions feel less responsive for expensive reruns (although it provides mechanisms like fragments that can help with that).

Summary

  • Genie trades simplicity for flexibility and control, which is the opposite tradeoff that Lit is trying to make.
  • Their execution models are optimized for different scenarios. Genie is more suitable for traditional websites and web apps that need to provide multiple, maybe unrelated, complex functionalities that require a high degree of control. Lit is more suitable for highly specialized web apps that are focused on a single or a few tasks, and most user interactions are somewhat related to those tasks, so the script rerun model makes creating these kinds of apps really simple.

Hope that helps!

19 Likes

I think Genie, as well, tries to be simple for simple tasks. (I am biased :wink:) All callbacks on the client side are automatic and hidden from the user. The user has to define a button variable and write a callback on the backend, but that doesn’t look very different from the Lit-code, to be honest.

Add block: Latest developments are precompilable apps via packaging and startup times from shell to the functional webpage of 4s.
Moreover, these days AI tools can easily write a Vue-based UI that can be directly hooked into Genie.

2 Likes

Thanks for the balancing comment, because I’m also biased :sweat_smile:

On another topic, I’ll soon change the name of the package so I can register it. I was wondering if I should “reannounce” the package with the new name, since I can’t edit neither the title nor the original post, or just comment here on the name change.

What do you guys think?

4 Likes

I (and other users with at least “Regular” status) can edit the title. So adding a comment to this thread is definitely an option

2 Likes

:rocket: v0.4.2 - Package rename and registration: Magic.jl

  • New: Package renamed from Lit.jl to Magic.jl
  • New: Magic can be installed by running pkg> add Magic
  • New: Introduced lifetime argument to
    gen_resource_path().
  • Bug-fixes: see CHANGELOG.md for details.

Can a Regular+ discourse member do a Lit => Magic search-and-replace in my first post, please? Thanks!

4 Likes

Editing posts is not something a regular can do but I fixed the title. Can’t you edit your own posts? Or does that stop after some time has passed?

3 Likes

Thanks! Yes, I can’t edit after a while.