Scala of course. A brainy relative sent me a link to a chat about how the Guardian has shifted its website from java to scala, and I'd spotted Programming In Scala
Anyway, armed with scala 2.9.1 & Intellij IDEA's scala plugin, I ploughed through the Scala chapter in Bruce Tate's Seven Languages in Seven Weeks
def getPageConcurrently() = {
val caller = self
urls.foreach{ url => actor { caller ! (url, PageLoader.getPageSize(url)) } }
for (i <- 1 to urls.size) {
receive { case (url, size) => println("Size for " + url + ": " + size) }
}
}
Now you can't tell me that's not beautiful!There's a lot I don't understand. For instance, my first though was to optimise out that 'caller' var, and just inline 'self' - but that didn't work. Why ever not? How many threads is it using? Does the thread pool expand if messages need to be sent but all current threads are busy? Maybe it contracts when they're idle.
Oh, and the foldLeft operator - that's going to be lots of fun.