Earlier quoted context omitted.
Are you saying that Thread.sleep() will still be blocking its OS-thread completely so that this thread executes no other code until the end of the sleep call? Because otherwise your claim "sync calls don't change" is wrong - since this is how it currently works.
That's the very definition of what sleep() does, and the reason why, if you're calling it in an async context, you need to dispatch it in a special "blocking" dispatcher, as opposed to the other regular async calls.
Scala isn't fun anymore
311–320 of 394 posts
Re: Scala isn't fun anymore
#312Earlier quoted context omitted.
I have personally spent so much time fussing with runtime ClassDefNotFound and MethodNotFound errors in Java that I am no longer able to respond to assertions that Java is type-safe with anything but an incoherent stream of cursing and rage tears. But Scala somehow seems to take all of that and intensify it. I have heard that Scala 3 is supposed to improve this, but I don't anticipate being able to adopt Scala 3 befo…
Those sorts of java runtime errors largely depend on programmers' insistence on doing things via reflection, and it will be the same in any programming language: Like most drugs, at first reflection seems you've opened a new door into enlightenment, until eventually you find yourself sleeping in a gutter with half your teeth missing and wondering why it didn't work out as expected. A lot of Java open source is addict…
Re: Scala isn't fun anymore
#313Earlier quoted context omitted.
Okay, are you going to give reason or is it more of a Thought leader style pronouncement?
Haha, I guess you are right. The reason why it is a mistake is because it is essentially trying to solve the rpc problem once again even though it has been tried many times without success. There just is a difference between making a synchronous call within your own OS thread vs. making such a call against anything else (the filesystem, the network, ...). Because you can assume that a synchronous call either succeeds…
Re: Scala isn't fun anymore
#314Earlier quoted context omitted.
On any platform?
It has the ability to make real-world concurrency scenarios trivial e.g. * 3 fibers - each fetches from remote storage, local storage and in-memory cache. * Race them, kill the two slowest and give me the result. * Free the resources safely including if any of the connections fails for an unforeseen reason. That's a few lines in ZIO. Pain to get working properly in Java, Rust, Go, C++ at least.
Re: Scala isn't fun anymore
#315Earlier quoted context omitted.
Haha, I guess you are right. The reason why it is a mistake is because it is essentially trying to solve the rpc problem once again even though it has been tried many times without success. There just is a difference between making a synchronous call within your own OS thread vs. making such a call against anything else (the filesystem, the network, ...). Because you can assume that a synchronous call either succeeds…
Doesn't the problem you mention for Loom applies equally to OS threads? What's the difference? Loom just lets you create more threads but with OS threads you are doing IO too.
Re: Scala isn't fun anymore
#316The Akka BSL is a big disappointment to me as well but a better name for that would be LightBend isn't fun anymore.
Re: Scala isn't fun anymore
#317Earlier quoted context omitted.
This is actually trivial in Go as well, with a context (cancellation) and a WaitGroup or channel (waiting for the first one to finish).
I think maybe you've misread the intent. I do not want to wait for the three fibers to finish. I want the whole process to stop the minute any of them have returned i.e. get me my data as quick as possible no matter its source.
You wait for the first result using i.e. a shared result channel, then you cancel the context.
Re: Scala isn't fun anymore
#318I actually think Scala is in the best position it's ever been. There is a commitment to making the language simpler, easier and cleaner. On the backend, ZIO ( https://zio.dev ) is the best concurrency library on any platform. On the frontend you have really interesting Scala.js projects like Laminar ( https://laminar.dev ). The biggest issue really is the tooling. SBT is simply awful.
> The biggest issue really is the tooling. SBT is simply awful. It's like they sat down and said "Maven has a bunch of problems. Let's fix none of them and introduce a few new ones."
Re: Scala isn't fun anymore
#319Earlier quoted context omitted.
And not just goroutines. The whole Go runtime is basically what Loom aspires to be. All functions async by default and preemptible. Writing code that looks like it's blocking but is in fact async. "Await" as the default action to do with an async function, and "go" being the optional action. So far the reception has been very good and it works very well in practice. To me it's a pain now to work with languages that d…
"All functions async by default and preemptible." Really? I thought functions were sync by default unless you add the 'go' keyword.
You can think of it this way, to use terms from other languages: in Go, every function really returns a Future. But every function call has an `await` implicitly. Using the `go` keyword signals that you don't want that `await`. The call-site action doesn't change whether or not the function itself is asynchronous or not (it is).
However, if you use a mutex in Go, or wait on a channel, or try to write to a TCP connection, those calls won't block an OS thread. Additionally, if a goroutine goes on too long and others are waiting, it will be stopped and the OS thread will work on a different goroutine for a while.
Re: Scala isn't fun anymore
#320Earlier quoted context omitted.
"All functions async by default and preemptible." Really? I thought functions were sync by default unless you add the 'go' keyword.
The `go` keyword means you want to run this function concurrently to what you're doing right now. You can think of it this way, to use terms from other languages: in Go, every function really returns a Future. But every function call has an `await` implicitly. Using the `go` keyword signals that you don't want that `await`. The call-site action doesn't change whether or not the function itself is asynchronous or not…