3 ms·
I'm not clear what your last sentence has to do with anything else? What does immutability have to do with Async/sync conversions?
by XorNot 3y ago
I'm not clear what your last sentence has to do with anything else? What does immutability have to do with Async/sync conversions?
- throwaway0665 3y agoyou can fearlessly run code on another thread if you're not worried it's going to cause a data race or mutate anything
- XorNot 3y agoThis is very much not free though. Predicting memory usage in Haskell programs is notoriously tricky (and all the memory copies aren't free either).
- c-cube 3y agoIt's also the case with OCaml, Elixir, clojure, etc. Non lazy languages can also have a rich collection of immutable data structures and have more predictable memory usage than Haskell. On the other hand, Go doesn't have a culture or features that encourage immutability.
- bippihippi1 3y agoit's not free, but it is explicit. it's nice for the code to explicitly define how the memory is being modified. there are copies in java too, you just have to know how the runtime works to know what each line does.
- ric2b 3y agoCopies in haskell are not explicit at all, though?
- whateveracct 3y agoPredicting memory usage in Haskell programs isn't actually tricky. At least, I stopped thinking so once I became an intermediate Haskeller. It's not that hard to have a mental model of the Haskell RTS the same as you'd have the JVM. Having the ability to do so generally is tablestakes for being an intermediate professional programmer imo. In university, I had to draw diagrams explaining the state of the C stack and heap after each line of code. That's the same thing. And I was 19 lmao. It's not hard. Maybe you're referring to space leaks? I've run into like 2 in my ten year Haskell career, and neither hit prod I've actually seem more Go and Java space leaks/OoM bugs hit prod than Haskell - despite having fewer total years using those languages than Haskell! Nobody blamed the language for those though :/
- polygamous_bat 3y agoImmutability is great for multithreaded/async programs because every thread can rest assured knowing no other thread can sneakily modify objects that they are operating on currently.
- candiddevmike 3y agoGo can prevent this with the race detector among other things
- stouset 3y agoSometimes.
- binary132 3y agoThe race detector needs to actually encounter a race in order to detect it, it's not a complete static analysis.
- omginternets 3y agoDetectors detect, they don’t prevent. All detectors suffer misses.
- IlliOnato 3y agoHow Haskell deals with access to shared resources which are mutable by their nature, like file system, or the outside world? (A honest question, I start to think that I'd like to learn more on this language)
- andyferris 3y agoAFAIK they tend to operate through the IO monad, which serves to order read/write events and mark parts of your code as interacting with the global mutable state that lives outside your program. So the mutable (or is it “volatile”?) environment is there, but you explicitly know when and where you interact with it.
- whateveracct 3y ago