ttsiodras ttsiodras - 1 year ago 162
Scala Question

Scala - console based development workflow

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 ./

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
    to my SBT's project/ folder (just look at my code in this GitHub repos)

  • Spawn
    in a terminal, and run
    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
    terminal, type

  • 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
    (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 :-)

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download