
Show HN: Bolt: A research language with finer-grained concurrency than Rust - mrathi12
https://github.com/mukul-rathi/bolt
======
comex
So the features that the dissertation claims Rust doesn’t have are:

\- Single-threaded mutable aliasing

Actually, Rust supports this in the form of the `Cell` type. It’s admittedly
not very ergonomic, though. Also, Bolt runs on the JVM and thus has a garbage
collector. This pattern is more powerful in a garbage-collected environment,
because merely reading a pointer is enough to guarantee it won’t be collected.
Suppose you (1) read a mutable field of type string, (2) call some other code
that might write a different string to that field, then (3) access the string
you originally read. With garbage collection, this is safe; without it, your
string might have been freed by the time you access it. You can also make this
safe with reference counting – most interpreted languages do this, Swift does
it with class fields, and there are libraries to do it in Rust – but fiddling
with reference counts every time you access an object is fairly slow.

> Concurrently mutate disjoint parts of object

Out of the box, Rust lets you take mutable references to disjoint parts of an
object and send them to different places, including different threads. Bolt
also apparently lets you pass these around as linear capabilities; translated
to Rust terms, it’s like if you could take a Box<(Foo, Bar)> and split it into
a Box<Foo> and Box<Bar>. Rust doesn’t support this out of the box, but you can
get something equivalent with the owning_ref crate (again, a bit less
ergonomic, but still safe).

> Concurrently mutate object, locking overlapping state

You can easily do this in Rust with Arc<Mutex<Foo>>. Bolt apparently inserts
mutexes automagically where needed, but other than that I don’t see any
ergonomic difference. Most Rust programmers would probably not appreciate
mutexes being inserted automatically; locking is expensive and creates the
possibility of deadlocks, so for both a performance and correctness standpoint
you want to understand where mutexes are being used.

~~~
mrathi12
> Also, Bolt runs on the JVM and thus has a garbage collector

No, Bolt targets LLVM IR

As for your other points, whilst there _are_ escape hatches in Rust that do
let you do it, it's not in the core ownership type system. That's what is
being compared - the type systems.

The escape hatches mean you lose some of the guarantees the type system gives
you - Bolt's approach still gives you the guarantees. That's the difference.

~~~
whyever
I'm not sure what you mean by bypassing the type system. The types mentioned
are part of the type system. Some of them move checks from compile time to run
time. `unsafe` could be seen as an escape hatch, but as far as I understand
that wasn't part of the discussion?

------
TheAsprngHacker
Discussion on r/ProgrammingLanguages:
[https://www.reddit.com/r/ProgrammingLanguages/comments/gg0cm...](https://www.reddit.com/r/ProgrammingLanguages/comments/gg0cmd/bolt_a_new_language_with_datarace_freedom/)

