Scala with SublimeText
Three weeks ago, one of our cats set its mind to beat its long-distance jumping record on my desk, accross my laptop. Unfortunately for my laptop, there was a cup of tea standing next to it, and our cat didn’t care too much about adjusting the height of the jump.
As a result, I am now working for the past 3 weeks with my old MacBook Pro Early 2008 (which I kept in a shelf for this purpose exactly). As a side effect though, I can’t work anymore with IntelliJ IDEA, because coding with Scala on this old machine (with little RAM) needs quite a bit of resources, and the IDE is too slow.
SublimeText to the rescue
I had heard of SublimeText before, and tried working with its ENSIME integration (which didn’t quite work at the time). This time, I set out to try something lightweight, and so the only thing I installed was the Play2 package for syntax highlighting. Scala syntax highlighting works out of the box.
It did take me a few days to get used to not having type-sensitive auto-completion and the presentation compiler reporting errors when typing, but after a while, I got close to my normal level of productivity again. This is what I learned on the way:
- it’s actually possible to work without code completion. Or at least it’s possible when you know the language and APIs well enough, or have the API documents at reach
- working with a simpler editor made me type more, but also distracted me less: instead of getting constantly distracted by the IDE reporting typo errors, proposing completions & imports, I could (or had to) focus solely on the code at hand. As a result I am now working in longer stretches, eventually ending in a “make it compile” phase in which I am switching back and forth between the SBT console and SublimeText.
At this point I should mention that I always run SBT in the background when working with Scala / Play projects, often running with live reloading (
play ~run) together with the Play auto-refresh plugin by James Ward. I also use the terminal for
git (zsh has good git support).
Here’s a list of extensions I installed so far in order to make things a bit simpler:
- the sbt-sublime SBT plugin downloads library sources & generates all kind of things that can be used by SublimeText. Apparently, it should also generate special files for symbol lookups for SublimeText 3, but I haven’t really understood yet how this is supposed to work (or maybe it doesn’t work yet with my setup). Update: I found out that symbols can be accessed via “Goto => Goto Symbol in Project” (or Shift + Command + R on OS X) - this is very nice!
- package control is a must-have extension for SublimeText, that allows easy installation of packages. In my opinion it should be pre-installed
- SublimeHighlight is a very nice plugin to copy-paste code with syntax highlighting as RTF. This is really useful when doing presentations, like this one
- the ChangeList package provides a list of changes that has been done on the file. I was looking for a way to jump back and forth between changes like IntelliJ IDEA has and this package does provide a similar functionality, only it is limited to the file level. SublimeText 3 however has this feature built-in, and I bound the keyboard shortcut to mimic the behavior of IDEA:
Yesterday a message came from the Apple reseller that the destroyed computer looks like it could be saved, which is good news. I’m not sure yet whether I will continue using SublimeText when I get back my more powerful machine, but so far I am tempted to stick with it a bit longer.