REPL vs. Debugger

Status
Not open for further replies.

zeotherm

Ars Legatus Legionis
10,960
Moderator
So I am laying in bed pondering things (full disclosure this could be the pain relievers talking :p) and I find myself wondering what is better for someone learning to program: a full debugger (like VS' C#/C++ tooling) or a REPL ala Python or F#...

I can see the benefits of both, and the number of new engineers I have seen over the years (usually ChemE or MechE, so not exposed to a lot of programming outside an intro class and some Matlab) that are blown away by what a full debugger can do makes me wonder which is better.

REPLs let you play at will, but don't give that full level of control/introspection that a good debugger does. When I learned programming we had neither, so it was white box testing all the way. I hated gdb (no GUI when I learned it) and it wasn't until I was doing Fortran development on an SGI system at an internship in grad school that I learned the true beauty of an integrated graphical debugger.

I find myself torn as to which I would have rather had starting out. What do others think?
 

hanser

Ars Legatus Legionis
43,847
Subscriptor++
There's a C# REPL in VS 2015. View > Other Windows > C# Interactive

zoidberg-why-not-both.jpg
 

hanser

Ars Legatus Legionis
43,847
Subscriptor++
If you couldn't have both, I think "best" is dependent on how you're approaching programming. I found a debugger useful when I was working on e.g. data structure problems. ("Implement a binary tree" where being able to expand nodes after ingesting data was useful.) I.e. design-level problems, where being able to explore the interrelationships between data structures visually was very useful in a way that print statements can't give you.

When I was just plunking around with a new language, doing stuff that wasn't hard, using standard library components (Java, C#, whatever), I found a REPL more productive, because most of the things I got stuck on or wanted to try were were one-liners. ("How do I parse a DateTime? Will this formatted text work OOTB?") I.e., statement-level problems.

As a professional programmer, I use the debugger much more than I use a REPL, but that's because I know my bread and butter language pretty well. (You can write some pretty gnarly LINQ queries in the Autos window. :cool: )

Learning a new language, I would take a REPL
Learning something bigger, I would take a debugger

Ideally, I would have both.
 

Apteris

Ars Tribunus Angusticlavius
9,589
Subscriptor
I'm currently finding a good debugger indispensable. Especially when you need to debug on more than one machine (JVM in my case) at a time. Bonus points if your graphical debugger is integrated with a decompiler, because at times you really do need to see what library classes are doing.

But even when I was learning Python, for instance, the interactive mode didn't help me that much in understanding the strange result my method was returning; the debugger did.
 

ramases

Ars Tribunus Angusticlavius
9,015
Subscriptor++
debugger++

As long as it does not lead to overreliance on it: If you cannot reverse-trace control flow in your head, either because you've never learned it or because you've unlearned it by relying a bit too much on attach-debugger-and-retry, your life will suck should you encounter a bug that is not amenable to attaching a debugger. For example because the issue always arises in the middle of a 5-hour processing run. Or because you cannot simply attach the debugger to the process, because it only is reproducible on the prod environment, and for whatever reason the prod-build is hardened against reverse engineering, including not being able to ptrace it (don't ask).

Additionally, in languages with manual memory management, attaching the debugger to a process can cause the appearance of Heisenbugs.
 

david_a

Ars Scholae Palatinae
819
Subscriptor++
I wonder how effective those 'workbook' systems (integrated code and documentation, like Xamarin Workbooks or IPython) would be for teaching someone. Seems like it could be a friendly first-step intro instead of static text (although I suppose there is value in forcing someone to type out the code too).

Another related idle thought - the C# REPL doesn't seem to be available in VS Code yet; at least I couldn't find anything in a quick search. VS Code feels like a good pairing for it, especially if they implement some kind of workbook-ish saved sessions for it.
 

david_a

Ars Scholae Palatinae
819
Subscriptor++
[url=http:/civis/viewtopic.php?p=32177727#p32177727:1vstpy7y said:
hanser[/url]":1vstpy7y]I dunno what the vision is for VS Code. It's meant to be a lightweight editor, not Visual Studio, but the line between the two is fuzzy. Unless the REPL functionality is pluggable and provided by a non-Code source, I would tend towards not including it.
I think it's optimized for languages that don't require a compilation stage. I guess? It's not built around the strict solution/project concept of the full VS, that's for sure. The editor portion is also shared code with the various MS websites that include an editor.

The C# REPL doesn't seem to be as stand-alone as they want right now but I don't see why that wouldn't change in the future. The evolution of .NET Core will probably drive some of this. Maybe when Web Assembly is finally a thing they'll write a C# compiler for that so you can use C# for both the web frontend and backend and do some kind of magical REPL debugging thingamajigger for it that can cross the boundary :p
 
Status
Not open for further replies.