Better HN
topnewbestaskshowjobs
Log inSign up

bartblast

112 karma · joined Jun 19, 2022 (4y ago) · 75 submissions

Building Hologram, a full-stack Elixir web framework https://hologram.page
Submissions

1.

Local-First Means Three Different Things(hologram.page ↗)

2 points · by bartblast · 3w ago · discuss

comment 1mo ago · link · parent

Author here. Hologram is a web framework where the browser-side code is Elixir too. v0.11.1 couldn't build a sponsor's 9,000-module app. It ran out of memory. I went looking for the one big bug and there wasn't one, just about two dozen places where the compiler did work it didn't need to, like encoding the same function to JS once for every page that used it. Shoot me any questions.

3.

Hologram v0.12: Faster Compiles, Smaller Bundles, and More(hologram.page ↗)

5 points · by bartblast · 1mo ago · 1 comment

4.

Hologram v0.11: Regular Expressions, Client Stacktraces, and More(hologram.page ↗)

3 points · by bartblast · 3mo ago · discuss

comment 4mo ago · link · parent

Local-first is simmering! :)

comment 4mo ago · link · parent

There's Jido Assembly that uses Hologram under the hood: https://github.com/agentjido/jido_assembly

comment 4mo ago · link · parent

Hologram author here. It's the opposite, really - the whole thing is built on web technologies. The compiler builds an IR from your Elixir code, analyzes the call graph, and spits out per-page JavaScript bundles. In the browser it's regular JavaScript patching the real DOM, and transport is plain HTTP (POST + Server-Sent Events) - no canvas rendering, no WASM. It uses Web APIs directly, and the goal is to make the whole Web API surface available from Elixir. The only thing being swapped out is the authoring language, same as with TypeScript or Elm.

comment 4mo ago · link · parent

There's no easy out-of-the-box way yet. But you can do it today with JS interop as a workaround. For small files: read the file and send the bytes directly in a Hologram command payload. For big files: fetch-POST the file to your own Phoenix endpoint, or directly to S3 with a presigned URL (no extra endpoint needed, since presigning can happen in a regular Hologram command or in the page's initial state), then pass the returned reference to a command for processing.

A proper Hologram-way file upload is planned as part of a high-level forms abstraction, which comes after Local-First support lands.

comment 4mo ago · link · parent

Mobile's part of the plan - one Elixir codebase across web, mobile and desktop, with local-first as the groundwork. Covered in the post and roadmap (https://hologram.page/docs/roadmap).

10.

Hologram v0.10: Events and middleware for Elixir running in the browser(hologram.page ↗)

3 points · by bartblast · 4mo ago · discuss

11.

Hologram v0.9: Realtime for Elixir running in the browser(hologram.page ↗)

5 points · by bartblast · 6mo ago · discuss

comment 8mo ago · link · parent

Creator here. Quick context: Hologram lets you build interactive web apps in pure Elixir by compiling to JavaScript on the client side.

This release brings JavaScript interoperability - the most requested feature since the project's inception. Hologram's premise is that you shouldn't need to write JavaScript, but cutting yourself off from 3 million npm packages and hundreds of browser APIs isn't realistic. v0.8.0 bridges that gap: call JS functions, use npm packages, interact with Web APIs, instantiate classes, and work with Web Components - all from Elixir, with zero client-side latency.

AMA!

13.

Hologram v0.8.0: Elixir Gets JavaScript Interop(hologram.page ↗)

13 points · by bartblast · 8mo ago · 1 comment

comment 9mo ago · link · parent

Gleam is written in Rust but compiles to Erlang (BEAM) or JavaScript - I mentioned the JS compilation in my previous comment. The WASM point was a response to your bytecode interpreter suggestion, not about Gleam.

comment 9mo ago · link · parent

Oh yeah, I remember! We'll get there :) Hope you'll give Hologram another spin sometime soon!

comment 9mo ago · link · parent

To clarify - Hologram's runtime is heavier than Gleam's, but that doesn't mean it's heavy. The compiler does tree-shaking, bundling only the code your app actually uses, so you're not shipping the entire reimplemented runtime to the browser.

As for the WASM bytecode interpreter idea - you'd run into the same problems I described in my earlier comment. Even a minimal interpreter compiled to WASM tends to land in the multi-MB range once you include enough of the runtime to be useful. You still can't touch the DOM from WASM, so every UI update crosses the JS bridge with serialization overhead. You lose the ability to surgically call native browser APIs (like built-in Unicode support) instead of bundling your own. And you lose readable output, which matters for debugging.

comment 9mo ago · link · parent

It depends on what you're doing. I've been in Elixir web dev for about 7 years and never really needed to write or understand Erlang, outside of my work on Hologram. That said, Erlang is always there under the surface - it "leaks" into Elixir in places if you look at the stdlib, and understanding it gives you a better mental model of the whole platform. I'd say you don't need it on a daily basis for most Elixir work, but the runtime and OTP are incredible pieces of engineering, and getting to know Erlang better will only make you stronger in this ecosystem.

comment 9mo ago · link · parent

Two big reasons: bundle size - few hundred KB uncompressed vs multiple MB already compressed with WASM. And the DOM lives in the JS world - WASM can't touch it directly and has to cross the JS bridge with serialization overhead every time.

On top of that, since the browser platform has different characteristics, you can surgically drop down to native JS functions instead of compiling and bundling everything. For example, things like Unicode code point databases are already built into the browser - no need to ship them in your bundle when you can just call into the native APIs. The compiled output is also readable which helps with debugging.

For web apps generally JS is the better target IMO - you want the smallest possible bundle and the app reacting as quickly as possible on load.

comment 9mo ago · link · parent

Both! Right now the focus is on enabling rich UIs with pure Elixir running in the browser. But eventually Hologram could be able to act as an Erlang node in the cluster as well.

comment 9mo ago · link · parent

Not currently, but expanding to Erlang is definitely possible down the road. I've actually been considering adding an Erlang compiler since some Erlang functions that the Elixir standard library depends on could be compiled automatically instead of being ported by hand.

comment 9mo ago · link · parent

Really appreciate it! Would love for you to give it another go - a lot has improved since then. If you run into any issues or have ideas for how things could be better, don't hesitate to reach out. Happy to help!

comment 9mo ago · link · parent

Thank you! The Elixir -> JS compiler is currently coupled with the framework - it's a custom thing, not a separate dependency.

Re the Gleam comparison: I don't know Gleam's implementation in detail so someone correct me if I'm wrong, but as I understand it - Gleam compiles to fairly readable JS with a minimal prelude, and deliberately treats the two targets as having different concurrency semantics. It doesn't try to replicate BEAM processes or OTP in JavaScript, instead using JS's native promise-based async. The upside is zero runtime overhead and clean JS interop.

Hologram takes the opposite approach - we're iteratively reimplementing the Erlang runtime in the browser, with the goal of having full semantic parity eventually. The tradeoff is a heavier runtime, but the benefit is that the same Elixir code can run on both server and client with consistent behavior.

23.

Hologram v0.7.0: Milestone release for Elixir-to-JavaScript porting initiative(hologram.page ↗)

107 points · by bartblast · 9mo ago · 29 comments

comment 10mo ago · link · parent

Hologram's journey just took a significant leap forward: Curiosum is coming on board as the Main Sponsor, and I'm joining their team to work on Hologram full-time.

Hologram compiles Elixir to JavaScript to run in the browser, enabling full-stack development in pure Elixir - and soon, Local-First applications.

I'm deeply grateful to Curiosum's founders for believing in this vision and going all in.

Read more about what this partnership means for Hologram: https://hologram.page/blog/hologram-partners-with-curiosum

123