Clojure Concurrency Tutorial
purelyfunctional.tv
Clojure Concurrency Tutorial
1–10 of 43 posts
Re: Clojure Concurrency Tutorial
#2Futures and Promises and core.async don't allow you to totally avoid planning out your project (I've been bitten slightly by core.async's `go` blocks behaving differently than Go's goroutines), but they are a godsend compared to dealing with manual mutexes and semaphores.
I still need to play with manifold; I hear that it helps deal with the IO-heavy stuff that core.async chokes on.
Re: Clojure Concurrency Tutorial
#3I get to do Clojure about ~60% of the time at work now, and it never ceases to amaze me how much easier it is to deal with concurrency than in vanilla Java. Futures and Promises and core.async don't allow you to totally avoid planning out your project (I've been bitten slightly by core.async's `go` blocks behaving differently than Go's goroutines), but they are a godsend compared to dealing with manual mutexes and se…
Re: Clojure Concurrency Tutorial
#4I get to do Clojure about ~60% of the time at work now, and it never ceases to amaze me how much easier it is to deal with concurrency than in vanilla Java. Futures and Promises and core.async don't allow you to totally avoid planning out your project (I've been bitten slightly by core.async's `go` blocks behaving differently than Go's goroutines), but they are a godsend compared to dealing with manual mutexes and se…
Re: Clojure Concurrency Tutorial
#5I get to do Clojure about ~60% of the time at work now, and it never ceases to amaze me how much easier it is to deal with concurrency than in vanilla Java. Futures and Promises and core.async don't allow you to totally avoid planning out your project (I've been bitten slightly by core.async's `go` blocks behaving differently than Go's goroutines), but they are a godsend compared to dealing with manual mutexes and se…
I was reading somewhere that the core.async lib has not been updated in awhile...is this correct? (generally curious if the lib is actively updated)
There isn't someone actively trying to enhance it or add more features to it.
So my understanding is only major issues gets addressed.
Re: Clojure Concurrency Tutorial
#6I get to do Clojure about ~60% of the time at work now, and it never ceases to amaze me how much easier it is to deal with concurrency than in vanilla Java. Futures and Promises and core.async don't allow you to totally avoid planning out your project (I've been bitten slightly by core.async's `go` blocks behaving differently than Go's goroutines), but they are a godsend compared to dealing with manual mutexes and se…
[1] - https://vertx.io/
Re: Clojure Concurrency Tutorial
#7I get to do Clojure about ~60% of the time at work now, and it never ceases to amaze me how much easier it is to deal with concurrency than in vanilla Java. Futures and Promises and core.async don't allow you to totally avoid planning out your project (I've been bitten slightly by core.async's `go` blocks behaving differently than Go's goroutines), but they are a godsend compared to dealing with manual mutexes and se…
What's the difference between core.async go blocks and goroutine please, I thought they would be the same to a reasonable extent?
Since core.async go blocks aren't fully preemptive, long-running things can eat up the whole thread pool. core.async allocates "number of cores + 2" number of "real" threads to do its work.
For example, say I have a program that downloads hundreds of giant files running on an 8-core server. The naive implementation would have a goroutine/go block for each concurrent download. In Go, this would work more or less ok (assuming you have plenty of memory), but in Clojure it would block all the other go blocks after 10 until the download is done.
Normally, it's not an issue, but it's a small gotcha if you're not paying enough attention.
Re: Clojure Concurrency Tutorial
#8Earlier quoted context omitted.
I was reading somewhere that the core.async lib has not been updated in awhile...is this correct? (generally curious if the lib is actively updated)
It is maintained, but not actively. Like the last year there was two issues fixed in it. There isn't someone actively trying to enhance it or add more features to it. So my understanding is only major issues gets addressed.
After a while libraries and tools stabilize and the community just maintains it.
Re: Clojure Concurrency Tutorial
#9I get to do Clojure about ~60% of the time at work now, and it never ceases to amaze me how much easier it is to deal with concurrency than in vanilla Java. Futures and Promises and core.async don't allow you to totally avoid planning out your project (I've been bitten slightly by core.async's `go` blocks behaving differently than Go's goroutines), but they are a godsend compared to dealing with manual mutexes and se…
I still do quite a bit of Java work. Nowadays, most high-concurrency Java apps use async tools like Vert.x [1], not explicit mutexes & semaphores. In that respect, modern Java is not that dissimilar from core.async, etc. [1] - https://vertx.io/
Re: Clojure Concurrency Tutorial
#10Earlier quoted context omitted.
What's the difference between core.async go blocks and goroutine please, I thought they would be the same to a reasonable extent?
To a reasonable extent, yes, they're the same. The biggest issue is that goroutines are (more or less) fully preemptive (for all intents and purpose) with their thread pooling and go blocks in core.async are not. Basically, in Go, you can have as many blocking IO thing taking millions of seconds to run, but it won't block the thread pool, and your other goroutines will run fine. Since core.async go blocks aren't full…
edit: Oh but there might be no "core.async sleep" in most of clojure libraries like IO/net stuff, which would explain why async go blocks hold the thread more often than they should, whereas Go has "goroutines sleeps" everywhere.