Parallel Universe, the company behind Quasar, writes about JVM concurrency, lightweight threads, and functional programming.
HN commenters praise the Little's Law post as one of the best on its subject and debate its effects-versus-monads and Java advice.
> see my blog post, http://blog.paralleluniverse.co/2015/08/07/scoped-continuati..., with references to work by Oleg Kiselyov on typed continuations.
So a theoretical type system extension that Kotlin doesn't actually have could solve this, and looks ok in simple examples. That's not terribly reassuring and not much help to anyone writing Kotlin today; anyone wanting to do the equivalent of something basic like traverse or, I don't know, cataM will still have to either copy/paste their code or give up type safety.
> On top of that, Scala can't restrict effects, either.
In theory no. In practice I use traverse all the time without worrying about whether the function I called was secretly throwing an exception or modifying a global variable, and it hasn't caused a bug yet; the community and culture can mostly work around the lack of hard restrictions at the language level.
> Which, BTW, Java discourages. Option is mainly recommended for use in functional composition in streams.
I know that's the official line, but it still works in a first-class way in practice (which to my mind is the sign of good language design; you can't expect language designers to anticipate all your needs, so it's important that things continue to work even if used in unexpected ways).
> I believe that the pure functional paradigm in general suffers very strongly from this in a way that's very essential to the core of the paradigm (because typed monads introduce a dependence of code structure on a…
I've prototyped UIs with RxJS (the javascript version of reactive extensions) both by itself and with Cycle.js. I've also used reactive programming in Perl 6. There are a lot of things to like about reactive programming, but anymore I'm not sure if it's the right answer. Let me first preface this by saying that I'm building upon thoughts presented (by someone else) here: http://blog.paralleluniverse.co/2015/08/07/scoped-continuations/
One problem with reactive programming (and also with promises), is that you are essentially using monadic composition in an imperative language. Because of the lack of special support for monads that you have in a language like Haskell, you have.to.chain.flow.control.methods. As a result of this, you lose access to the standard flow control the imperative language provides you, and you also generally end up with mangled stack traces. Now I know that rxjs5 is working on the stack trace problem through the usage of a recursive scheduler, but I'm not sure how this works on the Java side of things.
An alternative approach can be found in languages like Go and Erlang. In these languages you generally do not need to worry about exhausting a thread pool because they have made creating "threads" extremely cheap. As such, you can write normal imperative code that blocks, potentially indefinitely, and also still preserves stack traces and which uses the plain flow control structures (and error handling) of imperative programming.
Furthermore, if you…
> any library it's used with needs to be retrofitted/wrapped to make it work with Quasar.
True, but 1/ to see how easy it can be to integrate a pre-existing library with Quasar, just have a look at the OkHttp integration in Comsat's master and at this post http://blog.paralleluniverse.co/2014/08/12/noasync/ and 2/ the integrations provide an API identical to the original ones, not new ones, which makes the transition (and the opt-out) easy. Further so considering that fibers have API and usage practically identical to regular threads. So there's no API proliferation when integrating Quasar and the integration implementation itself can amount to just few lines of code.
> The article makes it seem like Akka cannot be used from Kotlin
Akka can surely be used from Kotlin (or even Clojure probably, for that matter), yet it lacks an idiomatic wrapper for it, which Quasar is starting to provide (and has offered for quite some time now for Clojure). Both Kotlin and Clojure are good at using existing Java APIs conveniently but, especially in Clojure's case perhaps, I think the lack of an idiomatic wrapper would be felt as an important minus, especially considering how concise and lean Clojure idiomatic APIs usually are.
> I'm unsure if Quasar can't be used from Scala because of the Bytecode manipulation that you're doing being incompatible with the Bytecode that the Scala compiler is putting out.
Quasar's bytecode manipulation amounts to user stack management in order to…
There have been several attempts of porting actors to the
JVM. Quasar and Pulsar’s main contribution — from which
many of their advantages stem — is true lightweight
threads[1]. Lightweight threads provide many of the same
benefits “regular”, OS threads do, namely a single, simple
control flow and the ability to block and wait for some
resource to become available while in the meantime
allowing other threads to run on the CPU. Unlike regular
threads, lightweight threads are not scheduled by the
operating system so their context-switch is often faster,
and they require far less system resources. As a result, a
single machine can handle millions of them.
http://blog.paralleluniverse.co/post/49445260575/quasar-pulsar
Excellent area to contribute to. In 2006-2008 there was Kilim, which uses some code-rewriting to accomplish similar greenthreading on the JVM to support an actor system with extremely lightweight lock-ree message massing.
Kilim comfortably scales to handle hundreds of thousands of actors
and messages on modest hardware. It is fast as well – task-switching
is 1000x faster than Java threads and 60x faster than other lightweight
tasking frameworks, and message-passing is 3x faster than Erlang (cur-
rently the gold standard for concurrency-oriented programming).
from https://github.com/kilim/kilim/raw/master/docs/kilim_ecoop08.pdf
Kilim: https://github.com/kilim/kilim
Basecamp and Harvest were both written in Rails. For standing up simple SaaS, Rails is a great choice.
However, for a complex SaaS (any SaaS can get here really), you will need to make some sane choices around modularity and building separate, loosely coupled services before things get out of hand. Node.js (or any of its lightweight frameworks on top) is probably a little stronger than Rails in this regard.
This service-based approach is more difficult with Rails as the community hasn't blessed any consistent conventions around doing it. Any custom convention you create to integrate multiple Rails applications will likely break compatibility with future Rails framework upgrades. There are many companies that are paralyzed and stuck on older versions of Rails because they ran into this problem.
All that being said, Java is still a great choice if you make some modern choices and will help you move forward without being slowed down by learning a new framework. Check out the Modern Java Series here: http://blog.paralleluniverse.co/2014/05/01/modern-java/
I'm going through that right now, and finding it incredibly good, but still fairly outdated. It was written for Java 6, while Java 7 and (especially) 8 have more or less re-written the language. All of the advice is still really great, but some of the items are workarounds for weaknesses in the language that have since been strengthened. I'm working through Java 8 in Action[0] in parallel, and it's been a good experience.
I've also been enjoying this Modern Java blog series, which is book-ish[1].
In a similar vein, I really enjoyed Effective Modern C++[2].
I think The Ruby Way[3] is still the best ruby book, and a new edition just came out earlier this year.
I'm looking for a good book about modern javascript if anyone has any suggestions.
[0]: https://www.goodreads.com/book/show/20534354-java-8-in-action
[1]: http://blog.paralleluniverse.co/2014/05/01/modern-java/
[2]: https://www.goodreads.com/book/show/22800553-effective-modern-c
[3]: https://www.goodreads.com/book/show/4514.The_Ruby_Way