Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scala - console based development workflow

Tags:

scala

Over the last 10 days, I've been reading "Programming in Scala" and writing some Scala code.

As you can see in my GitHub Scala playground, I am starting to really like this language - it is as fast as OCaml (thanks to JVM's HotSpot technology), protects me from my typos (and bugs!) with its strong and static type system, and best of all: enterprise-wise, it doesn't live in a remote "island" (like Haskell and OCaml) ... because it has the huge ecosystem of the JVM.

My only problem so far:

Even though I've figured out how to develop my Scala code under VIM with sbt-quickfix, or under Emacs with Ensime (and thus have autocompletion and error navigation), I have so far failed to find a way to debug my code, with the same ease that I do for Python:

bash$ python -m pdb ./someCode.py

All the entries Google points to, are basically saying: "use this IDE that I really like..."

There are reasons however - no point in enumerating them, you either know them or you don't - that people like me prefer (a) programmable editors and (b) a standalone debugger, available outside their editor.

If you are one of the few like-minded people that dislike IDEs and happen to use Scala, I'd be really interested to know how you debug - in fact I'd be interested to hear your entire workflow.

Mine, so far is:

  • Add the sbt-quickfix to my SBT's project/ folder (just look at my code in this GitHub repos)
  • Spawn sbt in a terminal, and run ~compile so that it automatically builds when I change something in my sources
  • VIM automatically receives errors and shows them.
  • When compilation is green, hit ENTER in the sbt terminal, type run
  • etc

Ensime is even better, allowing auto-completion as well:

  • sbt gen-ensime
  • Spawn emacs editing one of my .scala files, and M-x ensime
  • Use ensime-typecheck-all (mapped to F7 in my dotfiles) and when all is OK...
  • ensime-sbt-do-run

Here's to hoping I am not alone - and that someone out there will help me with standalone debugging, too... the last challenge before I fully embrace Scala :-)

like image 351
ttsiodras Avatar asked Dec 09 '14 17:12

ttsiodras


1 Answers

Turns out ensime has a debugging mode, which I somehow missed. Paired with Emacs/evil, I've spent the last couple of days inside Emacs and Scala - and it all works perfectly... autocompletion, spawning sbt in a buffer when I want to run, and debugging.

My only remaining problem is about working with Ensime from inside screen-ed sessions, which is my usual modus operandi (over SSH connections). The markers of Ensime debugger's current line and breakpoint set are placed on the left fringe - which works fine in graphics mode Emacs, but isn't visible in text-mode Emacs. I've opened a ticket and the guys there apparently have a plan for a solution.

like image 179
ttsiodras Avatar answered Oct 13 '22 09:10

ttsiodras