Skip to main content

Scala environment in Emacs

At work we have been doing most of our development in Java, and it has been serving us quite well. For a new project that we started, we looked at other JVM based languages, that would help us develop a little bit more efficiently, as well as leverage the big code base that we have.

Since a couple of people on the team knew Groovy and Grails, and have used it in the past to develop web applications, we went with that choice, and so far it has served us well. Development became a little bit more pleasurable, and we got rid of some of the Java boilerplate.

Out of curiosity I started experimenting with other JVM based languages, and since a lot of my friends at other company were singing praises for Scala, I decided to play with that.

The first step is setting up a Scala development environment, and with a couple of additions to my .emacs file, I got just that:

For Scala development in emacs, you need a couple of things:

  1. scala-mode
  2. ensime

You can download scala-mode from http://lampsvn.epfl.ch/svn-repos/scala/scala-tool-support/trunk/src/emacs/

Then move the directories under your elisp directory, and add the following lines to your .emacs file, changing the PATHTOELISP accordingly

;; scala support
(add-to-list 'load-path "/PATHTOELISP/scala-mode")
(require 'scala-mode-auto)

You can download ensime from https://github.com/aemoncannon/ensime/downloads

After expanding the zipped tar archive, move the directory to your elisp directory, and add the following lines to your .emacs file

(add-to-list 'load-path "/PATHTOELISP/ensime_2.9.2/elisp")
(require 'ensime)
(add-hook 'scala-mode-hook 'ensime-scala-mode-hook)

And now you have syntax highlighting, auto-completion, and a Scala REPL and debugger inside of Emacs.


Comments

Popular posts from this blog

Virtual machine could not be started because the hypervisor is not running

I wanted to experiment with TensorFlow, and decided to do that in a Linux VM, despite the fact that Windows Subsystem for Linux exists. In the past I used Sun’s, and then Oracle’s VirtualBox to manage virtual machines, but since my Windows install had Hyper-V, I decided to use that instead. The virtual machine configuration was easy, with disk, networking, and memory configurations non-eventful. However when I tried to start the virtual machine to setup Ubuntu from an ISO, I was greeted with the following error: “Virtual machine could not be started because the hypervisor is not running” A quick Internet search revealed that a lot of people have faced that problem, and most of the community board solutions did not make any sense. The hidden gem is this technet article , which included detailed steps to find if the Windows Hypervisor was running or not, and the error message if it failed to launch. In my case, the error was: “Hyper-V launch failed; Either VMX not present or

Why good customer service matters?

I am not an Apple fan, but I do like their computers, and recommend them to colleagues and friends for a variety of reasons. They are well designed, and in addition to an excellent user interface, they run a flavor of Unix--which makes the life of computer programmers a lot easier. But most importantly, Apple's customer support is impeccable, that despite all the hardware issues I experienced in the past, I still recommend Apple computers. Let me explain why. A year and a half ago, I bought a Mac Book Pro for work. At the time it was the first generation unibody laptop, that had an i7 processor, lots of memory, and lots of disk space. Alas, like first generation models everywhere, it also had a lot of hardware problems. The most annoying of which was the screen randomly turning dark, with the hard drive spinning out of control. The only way to get out of this state was by forcing a reboot by holding down the power button, and losing everything I have been working on. At first

MacOS Catalina, OneDrive, and case sensitive file systems

Over the weekend, I dusted off my old Macbook Air to search for some old family photos. I have not used the laptop for a long time, and it was completely out of charge. I plugged it in, and it quickly booted. Shortly after, I got bombarded with notifications that many of the applications needed updating, and that a new version of the OS was available.   I waited till I found the photos I was looking for, before attempting to upgrade anything. I also wanted to install OneDrive to get my old files to the cloud, so that I can access them from any of my devices, instead of dusting off old computers to get to them. The MacOS upgrade experience has always been fantastic, and this one was no different. The OS upgrade files downloaded quickly and after a restart and a quick install, the Macbook Air was ready to go.   Upgrading the installed applications was also a breeze, however in the process I discovered that a large majority of the applications installed were not compatible with Cata