Concurrency, Interactivity, Mutability: You Can Only Choose Two
Concurrency, interactivity, mutability, choose two
I explore the fundamental trade-offs in software design where you must sacrifice one of three desirable traits: concurrency, interactivity, or mutability. Dropping interactivity ensures safety in languages like C and Rust, while abandoning concurrency via locks in Python or Ruby preserves interactivity at the cost of speed. Alternatively, embracing immutability as Erlang does allows safe concurrency and interaction but introduces significant performance overhead through data copying. Ultimately, every language forces a choice, and even Common Lisp's claim to have it all carries the risk of runtime instability.
Common Lisp developers will of course brag about how they can have it all, but they will always have to keep in mind that anything they do in their REPL can potentially break their program.
- my-next-account
You can have it all in the vast majority of cases. It just requires a lot of work. See: The Hotspot JVM.
- roenxi
> But again, there is no free lunch: copying data is slow. Very slow. Of course you can optimize data representations, avoid copying binary blobs (they are ref-counted in Erlang) because it would be untenable. But it will still be horribly slow.
You don't have to copy the data; it is immutable. Why copy something that isn't going to change? Are we being charged for empty RAM? Different objects can share the same structure. Famously, this is what Clojure does. Theoretically it can be faster than mutating objects because you only have to write the parts that are changing (which is the same as a mutable object), you lose something to overheads (might be nearly negligible) and have enormous gains in situations where you might need a copy of an object for some reason because that is free; there isn't any reason to actually do a copy unless the data itself is going to be mutated.
- okkdev
That linked benchmark feels weird. The discrepancy is way too big. I'll need to take a look into the slower contestants.