r/programming • • 2d ago

Beyond Memory Safety: Verifying Structured Concurrency with [Scala's] Type System

https://virtuslab.com/blog/scala/beyond-memory-safety-verifying-structured-concurrency-with-the-type-system
8 Upvotes

10 comments sorted by

2

u/simon_o 1d ago

The blasé way with which the language collects more syntax (the blog post made me aware of ^{...}) is really something.

0

u/RiceBroad4552 1d ago

You should see other languages…

Scala has some of the smallest syntax surface of all mainstream languages. We have a lot of "budget" to spend, actually. Just that wouldn't be the Scala way which prefers minimal but general solutions.

0

u/simon_o 1d ago

"Actually", no.

0

u/RiceBroad4552 1d ago

LOL, clueless people speaking…

https://github.com/e3b0c442/keywords

Scala 3 grow a bit, but it's still considerable small; especially given that other languages grow massively in the meantime.

I don't find it right at the spot, but there is a similar comparison for spec size. Scala is really tiny compared to other languages! Fact.

1

u/simon_o 22h ago edited 21h ago

To be honest, I heard these idiotic takes 15 years ago already. Seems like some things never change. 😂

a) Scala is not a mainstream language, why compare it with languages that are? Why not compare it to other non-serious languages?

b) Good to see that "counting number of keywords" is still Scala people's favorite metric, I guess?

c) Spec sizes are not comparable between languages. There are languages defined by a specification; and there is Scala, where people can be happy if the specification and the implementation happen to agree by accident.

1

u/robert_7524 2d ago

Which concurrency invariant does the type system prove directly: child-task lifetime, cancellation propagation, or both?

0

u/RiceBroad4552 2d ago

Child-task lifetime, a.k.a. structured concurrency.

Cancellation propagation would need some form of "protocol safety". Something like multi-party-session-types can give that if paired with explicitly cancellation. No language ships that as of today, AFAIK.

Scala would have in theory the building blocks if all the other stuff comes into full existence, but it would be a next step beyond what was shown here.

0

u/simon_o 1d ago

if all the other stuff comes into full existence

Judging on the past dozen announcements Scala made, that's probably a "no".

0

u/RiceBroad4552 1d ago edited 1d ago

The building blocks are mostly there. They exist as of today, just still marked "experimental".

All the demos in that blog post can be easily reproduced, that's the beauty of Scala-CLI.

If they are going to be stabilized, the capability stuff is almost there, separation checking is still cooking, even already shaped out in some larger parts.

I should have said "when that stuff is there, one could start thinking about building session types (or some other form of 'protocol safety') on top".

And it's not like you couldn't have "protocol safety" as of today; just it's not in a shape that can be used in mainstream: https://alcestes.github.io/effpi/