Recently I was asked to write a few posts for the Safari Books Online blog. They were looking for Scala content, so I suggested Akka as a central theme. I wrote these posts with an audience in mind that hopefully would have been exposed to Scala (or could, at least, read a short Scala tutorial), but who had not yet written any Akka code. These posts will be nothing really new for experienced Akka developers, but clearly that’s not the point.
My main motivation in doing this has been that I’ve consistently noticed a need for a very simple introduction to Akka. I’ve seen this at PDXScala meetings, in the #akka IRC channel and through a variety of other forums. It’s not that there aren’t other good introductions out there (the one included in the Akka documentation itself is quite good). But it helps to provide more. In particular, I wanted to present them without overloading the reader with inessential details that might complicate the understanding.
Here are the posts I wrote in the order I had originally intended them. I made the mistake of not being terribly explicit in my final submission, so they were actually published in a slightly different order.
The other day, I found myself in a series of discussions with some fellow developers, in part about the performance characteristics of large numbers of threads in a JVM running on a Linux system. While I would not claim to be any sort of expert on the subject, it was clear that some of the information I had thought was fairly well known, was not nearly as pervasive as I assumed. Later on, I was asked for some recommended reading on the subject and had to confess that I didn’t know of much good material. As so often happens, though, I soon remembered a handful of resources that I feel are worth investigating.
And so, here’s my recommended reading list for developers who find themselves working in a JVM-based environment who need to understand the characteristics of that environment, particularly as it pertains to performance and concurrency issues. I can’t, with any honesty at least, claim to have read all of these in whole. That said, after the previously mentioned conversations, I have decided it is worth my time to fill in the gaps in my knowledge, and am attempting to read and learn from each of these, as much as reasonable possible. It’s fundamental to my beliefs that if you have any sense of dedication to craftmanship, it is imperative that you constantly seek to learn more.
Java Performance is a relative new-comer to the scene — it was just released in October — that appears to be a serious treasure-trove of good information. While it covers the obvious tools and techniques (profiling, benchmarking, tuning, etc.), it also includes in-depth information about less commonly considered items (OS-level tooling and monitoring, JIT and GC details, etc.) and even goes into areas such as considerations when dealing with JAX-RS based web applications.
Java Concurrency in Practice is the go to guide for anyone wanting to understand the complete details about the built in concurrency primitives and structures that are part of the Java standard library. Even if you won’t be working with this directly, you really should understand the principles described here.
What Every Programmer Should Know About Memory (here’s an alternate HTML version) is a really thorough introduction to what is going on inside your systems memory. You’ll learn far more than you probably want to know, but it’s a good kind of suffering. Trust me. ;~)
Linux Kernel Development (3rd Edition) may not be an obvious choice, but the reality is that if you’re developing server-based applications, chances are it will be running on a Linux system. This seems to be the best book out on the subject, but I’m no expert. Anyway, it’s worth understanding what’s going on inside the kernel. I would not suggest you try to read all of this, unless you’re really compelled to — it is a really well written book, after all — but at least read the chapters on process management and process scheduling. The chapters on the virtual filesystem and I/O are likely worth at least a skim, as well.
Some less obvious, but still useful, reads:
Effective Java, while being essentially Java-based, is of use even for Scala and, quite likely, other JVM language programmers. Much of what applies to Java is going to be of use, or at least have an impact on, your choices as you design you system. If nothing else, it will give you good information to know about while you evaluate third-party libraries.
Inside the Machine, despite being a few years out of date, is perhaps the best, accessible introduction to (nearly) modern processor architecture. While it doesn’t cover the latest technology, it does give a good introduction to the x86 processor and the general direction it was heading as of late 2006. This book is out of print, but you can buy it in various ebook formats.
The Java Virtual Machine Specification, may not be your first choice for light reading, but much of the material here is really essential to understand.
JSR 133 (Java Memory Model) FAQ was, for a long time, the best place to get a readable understanding of the Java memory model without having to dig into the details of the specification itself.
With that, you should have plenty to keep yourself busy for a while. I welcome suggestions for other material and hope to create additional reading list posts in the future — as most of my friends know, I read a lot.
A couple days ago I was playing around with my Emacs configuration a bit and decided to see if I could find ways to make it a more direct part of my flow (whatever the hell that means). For a quick sample of sorts, I threw together this little hack that let’s me popup a quick Emacs window with a buffer that’s already running haskell-mode (I assume here that you already have it installed, if not, you can find info on the haskell-mode page). This is really a pretty silly hack and it lacks some niceties, but it has already proven handy in the last day or two.
You’ll want to add the following Elisp code somewhere in your Emacs config (I have mine in a file called
(defun make-quick-haskell-frame ()
"Creates a new frame running haskell-mode."
(make-frame '((name . "Quick Haskell")
(width . 120)
(height . 40)))
(select-frame-by-name "Quick Haskell")
You can test this by running
M-x make-quick-haskell-frame within Emacs. If you see a new window with a buffer that is already in haskell-mode, you’re all set. From here you can use the all the nice keybindings of this mode to play around as much as you want (e.g., type in some Haskell fragment and then hit
C-c C-l to run load it into GHCi).
Next you’ll probably want to set up a global hotkey so you can bring up this window from anywhere. I personally use Alfred with the Powerpack option that gives me the ability to set up hotkeys, but I’m sure something similar will work for other options.
You’ll first need to create an Applescript file with contents similar to this (you’ll need to adjust the path to the
emacsclient binary you use):
do shell script "/usr/local/Cellar/emacs/HEAD/Emacs.app/Contents/MacOS/bin/emacsclient -n -e '(make-quick-haskell-frame)'"
From there you can open up Alfred, go to Features > System > Global Hotkeys and click the plus sign to create a new hotkey. I used
Ctrl-Shift-h for mine, but use whatever you think makes sense and is unlikely to interfere with other applications or system utilities. In the “Action:” field, click on Browse and navigate to wherever you stored the Applescript file you created earlier.