Does anyone know of languages that are built aroun...
# thinking-together
n
Does anyone know of languages that are built around event-driven concurrent transactions on shared state? It sounds like I'm just asking for a database engine, but I'm looking for something more general purpose. Take the OO concept of "everything is an object" and change it to "everything is a transaction" as a starting point. Supporting concurrency is the key thing here, otherwise I would be basically describing an actor (whose execution is not individually concurrent).
g
lasp comes to mind: https://lasp-lang.readme.io/
👍 1
i
Maybe.. Tuple Spaces?
👍 1
n
I watched a video on Lasp but nothing about it really stuck out to me.
@Ivan Reese I'd forgotten about tuple spaces! I'm putting them back on my reading list.
I've realised that this approach to writing programs (transactions on shared state as opposed to message passing) is also heavily pushed within the Clojure community (though Clojure isn't event-driven by default). See: https://clojure.org/about/state
Though more recently, Clojure's core.async library goes against this grain with a message-passing architecture.
i
core.async is a bit of an oddity. It was (IIRC) mainly the project of Tim Baldridge, who is no longer at Cognitect and no longer working on it. It was never properly finished, and has a bunch of bugs and shortcomings. I think there have been a handful of community projects that have done a better job at cracking the same nut. I'm not sure that I'd describe it as message passing. It's CSP, which is a more specific thing. If you say that CSP is a form of message passing, then you might as well lump in the actor model and Pi-Calculus and a few other things, and at that point a lot of meaning has been lost. After all, the interesting thing in core.async isn't the messages & inboxes, it's the use of queues and the coordination mechanisms.
g
TBH I think the early clojure concurrency stuff (refs, agents, STM) is near useless, just based on how many times I've reached for it on some complex clojure projects. I think it does attract a lot of people, but it's not really necessary for most work.
👍 1
but it checks the box of 'concurrent transactions on shared state'
n
@Gary Trakhman Is that so? What constructs do you use when you want to write concurrent Clojure programs?
g
core.async for concurrent but not shared state
atoms are generally fine for shared state in most programs, and even so, you're only ever using a handful. I've never done or had to use the transact across multiple refs STM thing. I did use agents once before core.async came along, but I think it's clearer to use core.async and an atom for that case.
I think the more valuable concurrency tool is using immutable data structures by default, so you can write small-scale isolated code and reuse it effectively later in a concurrent context with no changes.
👍 1