logoalt Hacker News

tancop • today at 11:10 AM • 2 replies • view on HN

You can extend this with "linear type" message passing where you transfer ownership of an object. That avoids physically copying memory and the sender loses write access to enforce the one writer at a time constraint.

It means a pipeline of actors can process a file with the same memory usage and only a tiny bit more CPU than a monolithic program, but it stays isolated and hot swappable.

This might already be implemented in the OS but the post doesn't mention it.


Replies

dugmartin • today at 1:03 PM

The BEAM on Erlang sort of does this with its global binary heap so you can have multiple readers. The binary must be larger than 64 bytes so it's stored on the global binary heap instead of copied onto process heaps. Its not really linear type though as there is no transfer since all data is immutable.

ch4s3 • today at 1:10 PM

Implementing linear messages at the OS level is a cool idea. I’ve loved building linear types in my language, they’re super nice to work with and give you some good tooling and compiler options. I’ll bet an OS could do a lot with the idea.