Hacker News new | ask | show | jobs
by te_chris 1051 days ago
Honestly, I've just finished 5 years as CTO with an e-com company with our CMS built on Elixir and I can't tell you how wrong you are. Jamstack, headless CMS and SPA frontends etc are just a massive waste of time. There's no joy in having separate code for your API and frontend.

Our pages rendered in 20ms.

3 comments

I worked at an ecom that used Elixir instead of an spa, with the backend being the older legacy app, and elixir rendering pages based off API data from the backend. This was well before live view

It worked amazingly fast. Some things were painful, and would have been better served with some progressive enhancement via a dollop of frontend js, but they were rather small exceptions

When I left a few years back they'd undergone some leadership turnover and the new wanted to migrate to some messy jamstack thing. They had millions of SKUs. Last I heard they migration hadn't gone anywhere

Tale as old as time lol. Elixir is uniquely great at content sites due to the fast template rendering - but it’s really not about Ex at all. Just don’t drown in unnecessary moving parts and build tools. It’s just a website.
LiveView wasn’t ready yet when I started our startup (react on front, Elixir and Hasura on back).

But man, I wish it had been. React is nice enough but the idea of not having to redefine my types at several different layers and fight with npm sounds like a dream.

We were in a similar position. CMS ran on dead views with a bit of progressive enhancement first, and then we had a couple of react apps around for interactive parts. When liveview was released we tried it out and it basically “just worked” as much as a software lib can, so set about getting rid of the react.
honest question: sounds like a cool architecture! care to give some insights how you achieve this?
Sure: key idea is pages are documents. Each page contains a JSON blob which specifies the blocks it's made up of and the content for each block. Each block is just a module with a schema specifying the data it takes and an associated template and a render function. Rendering a page is a URL resolution -> Controller -> DB lookup for the page -> pass the block list to a master render function and done.

The thing some people don't realise is EEx is compiled to a function call, which means no string interpolation, regex whatever. Getting a bunch of HTML is just a function call.