Scala - Console Based Development Workflow

Over the past 10 days, I read Scala Programming and wrote down Scala code.

As you can see on my GitHub Scala playground, I really like this language - it works as fast as OCaml (thanks to JVM HotSpot technology), protects me from my typos (and errors!) With its strong and static type system, and best of all: humanly, he does not live on a remote "island" (for example, Haskell and OCaml) ... because he has a huge JVM ecosystem.

My only problem:

Despite the fact that I found out how to develop Scala code for VIM using sbt-quickfix or for Emacs with Ensime (and thus have autocomplete and error navigation), so far I have not been able to find a way to debug my code, with the same ease as for Python:

bash$ python -m pdb ./someCode.py 

All the posts Google points to basically say, "use this IDE, which I really like ..."

There are reasons, however - it makes no sense to list them, you either know them or don’t know - 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 who do not like IDEs and use Scala, I would be very interested to know how you are debugging - in fact, I would be interested to hear your entire workflow.

Mine, so far:

  • Add sbt-quickfix to my SBT project / folder (just see my code in this GitHub repository)
  • Spawn sbt in the terminal and run ~compile so that it automatically builds when I change something in my sources
  • VIM automatically receives errors and displays them.
  • When the compilation is green, press ENTER on the sbt terminal, type run
  • etc.

Ensime is even better, allowing also autocomplete:

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

Here, to hope that I am not alone - and someone there will help me with autonomous debugging, too ... the last call before I fully embrace Scala :-)

+6
source share
1 answer

Turns ensime has debug mode, which I somehow missed. Paired with Emacs / evil, I spent the last couple of days inside Emacs and Scala - and it all works fine ... autocomplete, create sbt in the buffer when I want to run, and debug.

My only remaining problem is to work with Ensime from inside screen -ed sessions, which is my usual modus operandi (via SSH connections). Markers from the current Ensime debug line and the set of breakpoints are placed on the left side, which works fine in Emacs graphics mode but does not appear in Emacs text mode. I opened a ticket , and the guys seem to have a plan for a solution.

+1
source

Source: https://habr.com/ru/post/979342/


All Articles