Got the exact same feeling writing my latest app with Laravel Livewire. The ability to use backend state seamlessly on the frontend without explicitly passing state back and forth reduces complexity so much it's like writing 1 application instead of 2. I was able to build rich, fully interactive apps with minimal JS -- I'll never go back to React again.
- crash on error - functions are just functions
The first one is counter intuitive to many programmer. Basically you use pattern matching aggressively, like this:
def full_name(%{first_name: <<a::utf8, _::binary>>, last_name: <<b::utf8, _::binary>>}) do
"#{a} #{b}"
end
This code will work only if a map/struct with the correct non null field are passed. The pattern match utf8 string of at least 1 valid utf8 character. Any other argument will crash.Crashing in elixir is the way to handle unexpected things. For example, you will do:
{:ok, myobject} = DB.get....
And if the DB fails (something unexpected), it will crash, the process will be restarted and the live view connected remounted and it will start again from a clean state.Of course, error that are expected should be handled.
The second thing with elixir, is that functions are decoupled from data. You can move them around easily. For example, the above function will work on any struct with the correct fields and a plain map. But you can pattern match on specific struct too, which makes the code more like OOP, but it is more rarely done.
The key idea is to restrict code paths to something you expect, and always be explicit about what to expect.
The javascript is minimal (like to manage selection in text field or to handle copy/paste). Everything else is in elixir. Tailwind is used for CSS.
Having the full client state available on the backend is really incredible. It is so much easier, no more ajax/graphql... You just have all your backend data "under your fingers".
I can only recommend giving it a try.
Also, if your app is offline first, phoenix channels are great for sync. It is not live view, but it is easier to use than ajax calls.