

How To Write Your Own Java / Scala Debugger - javinpaul
http://www.takipiblog.com/2013/09/24/how-to-write-your-own-java-scala-debugger/

======
xwowsersx
This is the second time this has showed up on the front page and I'll say the
same thing I said last time. The title of this post is totally misleading. The
article presents a very high level overview of some concepts that could be
important to consider if you decide to write a scala/java debugger, but you
won't have any idea how to write a debugger after reading this.

------
werner34
I am a fan of python. when developing python and needing a breakpoint I just
write >> import pdb;pdb.set_trace() in the respective line and can then
execute the code till that point and have all the current variables available
in the console.

This was missing for me when I started doing stuff in scala, so I hacked
something to be able to do the same in Scala and jump straight to the
REPL(unfortunately variables need to be passed explicitly here, but most of
the REPL functionality works:

[https://gist.github.com/anonymous/7693857](https://gist.github.com/anonymous/7693857)

~~~
babs474
I always wonder why more languages don't have this, which I call repl at
point, or repl with context. Not sure if there is a more standard name. Even
clojure with its generally awesome repl support doesn't have it.

I created a library a while ago that does something very similar to what you
did, for the groovy language.
[http://aaronbabcock.blogspot.com/2011/11/groovy-
debugging.ht...](http://aaronbabcock.blogspot.com/2011/11/groovy-
debugging.html)

It avoided having to pass in variables explicitly by using groovy's AST
transform ability (macros) to examine the code for which variables would be in
scope and pass those into the repl automatically. I wonder if something
similar would be possible in scala?

~~~
_pmf_
> I always wonder why more languages don't have this, which I call repl at
> point, or repl with context.

Users of gdb call it "debugging".

~~~
babs474
No I think they are related but different. For instance with pdb or the
clojure repl I"ll add entire new functions or classes and try them out.

With gdb or jdb that might be theoretically possible but it certainly is not
convenient or commonly done. Typically your stretching things with a
complicated one liner expression.

But you are right concepts are pretty close, its just that I find a lot of
things that call themselves "debuggers" don't have the ability to add new
code. Things that call themselves "repls" dont' have the ability to stop at a
point or context like a debugger. pdb being the exception. Why can't we have
tools that do both things well.

