frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

Swift-erlang-actor-system

https://forums.swift.org/t/introducing-swift-erlang-actor-system/81248
217•todsacerdoti•6h ago

Comments

cyberax•6h ago
One thing for which I can't get a clear answer: Swift uses automatic reference counting. It seems that it needs atomic operations that are expensive.

Does this allow somehow to sidestep this? Since the data is all thread-local, it should be possible to use non-atomic counters?

dizlexic•6h ago
Never done it, but I hope this helps.

https://stackoverflow.com/questions/25542416/swift-with-no-a...

liuliu•6h ago
Only "class" object is reference counted (to some extents, class-like objects too). Int / struct (value-semantics) objects are not reference counted. These are copied eagerly.

Swift introduced bunch of ownership keywords to help you to use value objects for most of the needs to sidestep reference-counting and minimize copying.

Of course, to my understanding, "actor" in Swift is a "class"-like object, so it will be reference-counted. But I fail to see how that is different from other systems (as actor itself has to be mutable, hence, a reference object anyway).

brandonasuncion•5h ago
And for times you need a fast heap-allocated type, Swift's Noncopyable types have been pretty great in my experience. Especially so for graph data structures, where previously retains/releases would be the biggest slowdown.

Example here: https://forums.swift.org/t/noncopyable-generics-in-swift-a-c...

An added plus is that the Swift compiler seems to stack-promote a lot more often, compared to class/ManagedBuffer implementations.

llm_nerd•5h ago
The Swift compiler does lifetime and ownership analysis to eliminate many/most ARC overhead, beyond when things are truly shared between threads and the like.

https://g.co/gemini/share/51670084cd0f - lame, but it references core concepts.

cyberax•3h ago
I'm not sure how it can detect that outside of trivial cases. Any object that is passed into a library function can escape the current thread, unless the compiler can analyze all the binary at once.
slavapestov•3h ago
> Any object that is passed into a library function can escape the current thread,

In Swift 6 this is only true if the value’s type is Sendable.

llm_nerd•3h ago
Many (and increasingly most) Swift libraries are largely Swift modules delivered as SIL (Swift Intermediate Language). The compiler can indeed trace right into those calls and determine object lifetime and if it escapes. It is far more comprehensive than often presumed.

Though the vast majority of cases where ARC would come into play are of the trivial variety.

elpakal•2h ago
username checks out
Someone•5h ago
In addition to what others said, even if counts have to be updated, that need not always use atomic operations.

See https://dl.acm.org/doi/10.1145/3243176.3243195:

“BRC is based on the observation that most objects are only accessed by a single thread, which allows most RC operations to be performed non-atomically. BRC leverages this by biasing each object towards a specific thread, and keeping two counters for each object --- one updated by the owner thread and another updated by the other threads. This allows the owner thread to perform RC operations non-atomically, while the other threads update the second counter atomically.“

(I don’t know whether Swift uses this at the moment)

carson-katri•5h ago
I worked on this project, thanks for sharing it! This is part of a larger otp-interop GitHub org with projects for things like running BEAM on mobile devices, disterl over WebSockets, filtering messages sent over disterl, etc. Happy to answer any questions about the project.
__turbobrew__•5h ago
I have read the erlang/OTP doesn’t work well in high latency environments (for example on a mobile device), is that true? Are there special considerations for running OTP across a WAN?
carson-katri•5h ago
In our use-case, we're running the client and server on the same device. But if you're connecting a mobile device to a "server" node, you would probably want to be careful how you link processes and avoid blocking on any calls to the client.
bcardarella•5h ago
I hate to say this but usually when I hear that people have problems making Erlang/Elixir fast it comes down to a skill issue. Too often devs explore coming from another language and implement code as they would from that other language in Elixir and then see it's not performant. When we've dug into these issues we usually find misunderstandings on how to properly architect Elixir apps to avoid blocking and making as much use of distribution as possible.
__turbobrew__•2h ago
Ok, I just ask because I recently read the “BEAM book” and it explicitly calls out that OTP is designed to only run within a single datacenter.
bcardarella•1h ago
You'd have to refer to all of the applications running on the BEAM that are distributed across multiple datacenters. Fly.io's entire business model is predicated on globally distributing your application using the BEAM. I'm not sure what that book said exactly perhaps the original intent was local distribution but Erlang has been around for over 30 years at this point. What it's evolved into today is architecturally unique compared to any other language stack and is built for global distribution with performance at scale.
dplyukhin•51m ago
I was curious about this claim, so I tracked it down: https://blog.stenmans.org/theBeamBook/#_distribution_in_a_la...

> Even though Erlang’s asynchronous message-passing model allows it to handle network latency effectively, a process does not need to wait for a response after sending a message, allowing it to continue executing other tasks. It is still discouraged to use Erlang distribution in a geographically distributed system. The Erlang distribution was designed for communication within a data center or preferably within the same rack in a data center. For geographically distributed systems other asynchronous communication patterns are suggested.

Not clear why they make this claim, but I think it refers to how Erlang/OTP handles distribution out of the box. Tools like Partisan seem to provide better defaults: https://github.com/lasp-lang/partisan

__turbobrew__•20m ago
Thanks for getting the quote
bcardarella•5h ago
I'm involved with this project and wanted to provide some context. This is an extraction for a much larger effort where we're building a web browser that can render native UI. Think instead of:

`<div>Hello, world!!</div>`

we can do:

`<Text>Hello, world!</Text>`

I want to be clear: this is not a web renderer. We are not rendering HTML. We're rendering actual native UI. So the above in SwiftUI becomes:

`Text("Hello, world!")`

And yes we support modifiers via a stylesheet system, events, custom view registration, and really everything that you would normally be doing it all in Swift.

Where this library comes into play: the headless browser is being built in Elixir to run on device. We communicate with the SwiftUI renderer via disterl. We've built a virtual DOM where each node in the vDOM will have its own Erlang process. (I can get into process limit for DOMs if people want to) The Document will communicate the process directly to the corresponding SwiftUI view.

We've taken this a step further by actually compiling client-side JS libs to WASM and running them in our headless browser and bridging back to Elixir with WasmEx. If this works we'll be able to bring the development ergonomics of the Web to every native platform that has a composable UI framework. So think of actual native targets for Hotwire, LiveWire, etc...

We can currently build for nearly all SwiftUI targets: MacOS, iPhone, iPad, Apple Vision Pro, AppleTV. Watch is the odd duck out because it lacks on-device networking that we require for this library.

This originally started as the LiveView Native project but due to some difficulties collaborating with the upstream project we've decided to broaden our scope.

Swift's portability means we should be able to bring this to other languages as well.

We're nearing the point of integration where we can benchmark and validate this effort.

Happy to answer any questions!

Jonovono•5h ago
Is there somewhere to follow this project? Sounds really interesting
bcardarella•5h ago
* The working name of the browser is Crane: https://github.com/liveview-native/crane/tree/ios

* our vDOM: https://github.com/liveview-native/gen_dom

* selector parsing: https://github.com/liveview-native/selector

* compile Elixir to ios: https://github.com/otp-interop/elixir_pack

Jonovono•4h ago
Wow, unreal, thanks! I was playing around with Liveview native awhile back. Will definitely be following this along
bratsche•3h ago
How does elixir_pack work? Is it bundling BEAM to run on iOS devices? Does Apple allow that?

Years ago I worked at Xamarin, and our C# compiler compiled C# to native iOS code but there were some features that we could not support on iOS due to Apple's restrictions. Just curious if Apple still has those restrictions or if you're doing something different?

bcardarella•3h ago
https://github.com/otp-interop/elixir_pack

we compile without the JIT so we can satisfy the AppStore requirements

victorbjorklund•4h ago
In what way will this be different from Liveview Native?
bcardarella•3h ago
We're delivering LVN as I've promised the Elixir community this for years, from LVN's perspective nothing really changes. We hit real issues when trying to support live components and nested liveviews, if you were to look at the liveview.js client code those two features make significant use of the DOM API as they're doing significant tree manipulation. For the duration of this project we've been circling the drain on building a browser and about three months ago I decided that the just had to go all the way.
arcanemachiner•1h ago
I hope I'm not reading into this too cynically, but your phrasing makes it sound like the project is not going as well as originally hoped.

It's pretty well-established at this time that cross-platform development frameworks are hard for pretty much any team to accomplish... Is work winding down on the LiveView Native project, or do you expect to see an increase in development?

bcardarella•1h ago
The LVN Elixir libraries are pretty much done and those really shouldn't change out side of perhaps additional documentation. I have been back and forth on the 2-arity function components that we introduced. I may change that back to 1-arity and move over to annotating the function similar to what function components already support. That 2-arity change was introduced in the current Release Candidate so we're not locked in on API yet.

What is changing is how the client libraries are built. I mentioned in another comment that we're building a headless web browser, if you haven't read it I'd recommend it as it gives a lot of detail on what we're attempting to do. Right now we've more or less validated every part with the exception of the overall render performance. This effort replaces LVN Core which was built in Rust. The Rust effort used UniFFI to message pass to the SwiftUI client. Boot time was also almost instant. With The Elixir browser we will have more overhead. Boot time is slower and I believe disterl could carry over overhead than UniFFI bindings. However, the question will come down to if that overhead is significant or not. I know it will be slower, but if the overall render time is still performant then we're good.

The other issue we ran into was when we started implementing more complex LiveView things like Live Components. While LVN Core has worked very well its implementation I believe was incorrect. It had passed through four developers and was originally only intended to be a template parser. It grew with how we were figuring out what the best path forward should be. And sometimes that path meant backing up and ditching some tech we built that was a dead end for us. Refactoring LVN Core into a browser I felt was going to take more time than doing it in Elixir. I built the first implementation in about a week but the past few months has been spent on building GenDOM. That may still take over a year but we're prioritizing the DOM API that LiveView, Hotwire, and Livewire will require. Then the other 99% of DOM API will be a grind.

But to your original point, going the route of the browser implementation means we are no longer locked into LiveView as we should be able to support any web client that does similar server/client side interactivity. This means our focus will be no longer on LiveView Native individually but ensuring that the browser itself is stable and can run the API necessary for any JS built client to run on.

I don't think we'd get to 100% compatibility with LiveView itself without doing this.

arcanemachiner•51m ago
Oh wow, that actually sounds very promising! Thanks for the follow-up.
ksec•4h ago
>If this works we'll be able to bring the development ergonomics of the Web to every native platform that has a composable UI framework.

Holy this will be much bigger than I thought! Cant wait to see it out.

aatd86•3h ago
I believe swiftUI doesn't give access to the UI tree elements unlike UIkit. So I assume you're not allowing the use of the xml-like code to be in control of the UI? It's rather just an alternative to write swiftUI code? How do you handle state? Isomorphically to what is available in swiftUI? Is your VDOM an alternate syntax for an (Abstract) Syntax tree in fact? Is it to be used as an IR used to write swiftUI code differently?

How is it different from Lynx? React Native? (probably is, besides the xml like syntax, again state management?)

Quite interesting !

bcardarella•3h ago
That's correct, but we can make changes to the views at runtime and these merge into the SwiftUI viewtree. That part has been working for years. As far as how we take the document and convert to SwiftUI views, there is no reflection in Swift or runtime eval. The solution is pretty simple: dictionary. We just have the tag name of an element mapped to the View struct. Same with modifiers.
bcardarella•2h ago
As far as how it is different from React Native. That's a good question, one that I think is worth recognizing the irony which is that, as I understand it, without React Native our project probably wouldn't exist. From what I understand RN proved that composable UI was the desired UX even on native. Prior to RN we had UIKit and whatever Android had. RN came along and now we have SwiftUI and Jetpack Compose, both composable UI frameworks. We can represent any composable UI frameworks as a markup, not so much with the prior UI frameworks on native, at least not without defining our own abstraction above them.

As far as the differentiator: backend. If you're sold on client-side development then I don't think our solution is for you. If however you value SSR and want a balnance between front end and backend that's our market. So for a Hotwire app you could have a Rails app deployed that can accept a "ACCEPT application/swiftui" and we can send the proper template to the client. Just like the browser we parse and build the DOM and insantiate the Views in the native client. There are already countless examples of SSR native apps in the AppStore. As long as we aren't shipping code it's OK, which we're not. Just markup that represents UI state. The state would be managed on the server.

Another areas we differ is that we target the native UI framework, we don't have a unified UI framework. So you will need to know HTML - web, SwiftUI - iOS, Jetpack Compose - Android. This is necessary to establish the primitives that we can hopefully get to the point to build on top of to create a unified UI framework (or maybe someone solves that for us?)

With our wasm compilation, we may even be able to compile React itself and have it emit native templates. No idea if that would work or not. The limits come when the JS library itself is enforcing HTML constraints that we don't observe, like case sensitive tag names and attributes.

What about offline mode? Well for use cases that don't require it you're all set. We have lifecycle templates that ship on device for different app states, like being offline. If you want offline we have a concept that we haven't implemented yet. For Elixir we can just ship a version of the LV server on device that works locally then just does a datasync.

wahnfrieden•50m ago
Apple allows shipping code over internet for many years now. They just don’t allow dramatically changing the purpose of the app etc
bcardarella•39m ago
Apple also doesn't allow JITs, and you cannot hot load code to modify the application.
tiffanyh•2h ago
Would this be like XAML?

Didn’t Firefox build its UI in XAML long ago?

https://en.m.wikipedia.org/wiki/Extensible_Application_Marku...

https://news.ycombinator.com/item?id=8730903

bcardarella•2h ago
XAML will be a target as we intend to build a WinUI3 client. Of the big three native targets: Apple, Android, Windows the later may be the easiest as from what I've seen nearly everything is in the template already
wmanley•2h ago
How does this compare to hyperview? https://hyperview.org/
bcardarella•1h ago
Not sure as I haven't done any work with it. On a cursory glance it could have some overlap but it appears to not target the 1st class UI frameworks. It looks to be a UI framework unto itself. So more of a Flutter than what we're doing is my very quick guess. We get major benefits from targeting the 1st class UI frameworks, primarily being we let them do the work. Developing a UI native framework I think is way way more effort than what we've done so we let Apple, Google, and Microsoft to decide what the desired user experience is on their devices. And we just allow our composable markup to represent those frameworks. A recent example of this is with the new "glass" iOS 26 UI update. We had our client updated for the iOS 26 beta on day 1 of its release. Flutter has to re-write their entire UI framework if they want to adapt to this experience.
arcanemachiner•1h ago
> some difficulties collaborating with the upstream project

Can you elaborate on this?

junon•1h ago
Sounds like things are converging more or less where I thought they would: "websites" turning into live applications, interfacing with the native UI, frameworks, etc. using a standardized API. Mainframes maybe weren't the worst idea, as this sort of sounds like a modern re-imagining of them.

The writing was more or less on the wall with WASM. I don't know if this project is really The Answer that will solve all of the problems but it sounds like a step in that direction and I like it a lot, despite using neither Swift nor Erlang.

sghiassy•35m ago
I prototyped this exact thing by parsing the DOM, building corresponding UIKit elements and styling them via CSS.

My output looked exactly like an embedded WebKit UIView though - so then the problem became - what was I making that was appreciably better?

rozap•4h ago
This is neat. I'm not a swift user, but I did work on a project where we made heavy use of JInterface (which ships in OTP), which is effectively the same thing but for JVM languages. It worked great and allowed easy reuse of a bunch of Java libraries we already had. Pretty painless interop model, imo.

Purplestack: Build Nostr-enabled flutter applications in one prompt

https://getstacks.dev/stack/naddr1qvzqqqrhl5pzqun2rcnpe3j8ge6ws2z789gm8wcnn056wu734n6fmjrgmwrp58q3qq9hqatjwpkx2um5v93kkujvqf4
1•sak5sk•26s ago•0 comments

The Ps, the Qs, and the War

https://libertiesjournal.com/articles/the-ps-the-qs-and-the-war/
1•Hooke•2m ago•0 comments

Show HN: Which parts of Seattle have the most pets?

https://alexdean.io/seattle-pets-by-zip/
1•alexanderdean•3m ago•0 comments

US Nuclear Weapons Agency Breached in Microsoft SharePoint Hack

https://www.bloomberg.com/news/articles/2025-07-23/us-nuclear-weapons-agency-breached-in-microsoft-sharepoint-hack
1•xqcgrek2•4m ago•0 comments

How to Spot North Korean Scammers in the American Workforce: Look for Minions

https://www.wsj.com/lifestyle/north-korea-despicable-me-minions-2966cc66
1•nradov•4m ago•0 comments

Why Metaflow?

https://docs.metaflow.org/introduction/why-metaflow
1•savin-goyal•5m ago•0 comments

Amazon to buy AI company Bee that makes wearable listening device

https://www.cnbc.com/2025/07/22/amazon-ai-bee-wearable.html
1•dkgs•6m ago•0 comments

Ephemeral video premieres – who might care?

1•onetimeshowapp•17m ago•0 comments

The Perils of an .xyz Domain

https://www.spotvirtual.com/blog/the-perils-of-an-xyz-domain
2•PaulHoule•18m ago•1 comments

How not to go about fundraising

https://www.instagram.com/p/DMbgBSkzCMY/
1•zcaudate•19m ago•0 comments

Show HN: Lossless Semantic Matrix Analysis (99.999% accuracy, no training)

2•AyodeleFikayomi•21m ago•1 comments

Show HN: 3D Go Game

https://3dgo.club
1•lukas•28m ago•0 comments

US House speaker shuts down chamber to block Epstein vote

https://www.bbc.com/news/articles/cgjg9j0l7j9o
12•southernplaces7•33m ago•7 comments

Check Out GitSnap

https://www.gitsnap.xyz/
1•erregea5•37m ago•4 comments

How Much Do Podcasters Earn? One Star Pulls Back the Curtain

https://www.nytimes.com/2025/07/22/business/media/joe-budden-podcast-finances.html
3•pseudolus•43m ago•2 comments

Rokoko Mocap federal fraud lawsuit: bricked devices on purpose and stole data

https://old.reddit.com/r/gamedev/comments/1m6u4d9/rokoko_mocap_hit_with_federal_fraud_lawsuit_solo/
1•IvanAchlaqullah•47m ago•0 comments

Firefox dev says Intel Raptor Lake crashes are increasing during heat wave

https://www.tomshardware.com/pc-components/cpus/firefox-dev-says-intel-raptor-lake-crashes-are-increasing-with-rising-temperatures-in-record-european-heat-wave-mozilla-staffs-tracking-overwhelmed-by-intel-crash-reports-team-disables-the-function
3•consumer451•49m ago•0 comments

The 'Smart' Restrooms That Can Solve America's Public Bathroom Crisis

https://www.wsj.com/tech/personal-tech/america-public-bathroom-crisis-218f6e57
1•fortran77•50m ago•1 comments

CAMARA: Open-source API for telecom and 5G networks

https://www.gsma.com/solutions-and-impact/technologies/networks/operator-platform-hp/camara-2/
5•teleforce•50m ago•0 comments

Claude Code Spec Workflow (Inspired by AWS Kiro)

https://github.com/Pimzino/claude-code-spec-workflow
2•jonathanberi•52m ago•0 comments

Newly discovered photos and shed fresh light on Trump's ties to Jeffrey Epstein

https://www.cnn.com/2025/07/22/politics/kfile-trump-epstein-photos-footage
8•bediger4000•58m ago•5 comments

How the crypto industry bought Trump (and by extension DC)

https://www.publicnotice.co/p/genius-act-crypto-trump-corruption
9•pulisse•1h ago•0 comments

A media company demanded a license fee for an Open Graph image I used

https://alistairshepherd.uk/writing/open-graph-licensing/
69•cheeaun•1h ago•30 comments

Why Does Raising the Retirement Age Hurt Young People?

https://www.governance.fyi/p/why-does-raising-the-retirement-age
14•daveland•1h ago•12 comments

MIT: A new way to edit or generate images with AI

https://news.mit.edu/2025/new-way-edit-or-generate-images-0721
1•lampreyface•1h ago•0 comments

China's abandoned buildings draw urban explorers despite risks

https://www.japantimes.co.jp/news/2025/07/06/asia-pacific/china-abandoned-buildings/
3•PaulHoule•1h ago•2 comments

Why you can't color calibrate deep space photos

https://maurycyz.com/misc/cc/
28•LorenDB•1h ago•13 comments

Cracking the Code: Realtime Debugger Visualization Architecture – BSC 2025 [video]

https://www.youtube.com/watch?v=_9_bK_WjuYY
2•kelseyfrog•1h ago•0 comments

Roots of the Republic

https://literaryreview.co.uk/roots-of-the-republic
2•pepys•1h ago•0 comments

SoftBank and OpenAI's $500B AI Project Struggles to Get Off Ground

https://www.wsj.com/tech/ai/softbank-openai-a3dc57b4
4•ent101•1h ago•0 comments