Debug_trainer tool for practicing debugging skills

This isn’t an Elm-specific tool, but it was made with Elm, and I’m pretty pleased with how it worked out and wanted to share. I used Elm with elm-cli-options-parser and some TypeScript to make a CLI program that introduces random bugs into files so newer coders can practice debugging. Big thanks to @dillonkearns for all the Elm for CLI tools and examples!

9 Likes

This is really nice!

This isn’t an Elm-specific tool, but it was made with Elm

But it works for Elm code too! From what I could tell, at the moment it’s a lot of errors that the Elm compiler catches quickly (:heart:), but not changes in the business logic which might be more interesting for Elm developers, at least the ones who have grown familiar with the language and the compilation errors.

I noticed that one of the introduced changes can be to change a word in a comment, or a code sample inside a comment.

--- {-| Create a singleton list with the given element.
+++ {-| Create a singleton list with The given element.
-}
nonemptyList_fromElement : a -> Nonempty a

This will be very hard to track down, as there is nothing that break will in practice :smiley:

From what I understand, you do not try to parse the source file and try to understand whether something is a comment or not, and this helps you stay language-agnostic, but I think this would be a useful addition anyway. You could maybe add detection for comments in languages that you know, and for the other languages do as you are currently doing.

I do wonder who the target audience is here. Because anyone who uses Git can instantly see how you broke the code (and thankfully so!). So is your intended audience people who don’t use Git, or do you expect your users to not use Git (or an editor which shows you the changed lines) during the practice session?

Anyway, this is very cool, I’ll try it out more, but I’ll likely keep Git next to me, just in case a comment gets modified :smile:

1 Like

I noticed that one of the introduced changes can be to change a word in a comment, or a code sample inside a comment.

Yeah, comments and strings are both a problem this way, unfortunately. I think the next step in developing it may be to add some genuinely language-specific logic to deal with those. With different string interpolation techniques in particular, it seems much harder to keep it general for strings.

I do wonder who the target audience is here. Because anyone who uses Git can instantly see how you broke the code (and thankfully so!). So is your intended audience people who don’t use Git, or do you expect your users to not use Git (or an editor which shows you the changed lines) during the practice session?

I did want it to be useful for people who may not have learned Git yet, although yeah, you’re right that the reset and hint functions can be somewhat superceded by Git. I teach people who are very new to programming, and since Git is fairly scary for them at the outset, I wanted to make it work with or without it.

Anyway, this is very cool, I’ll try it out more, but I’ll likely keep Git next to me, just in case a comment gets modified :smile:

Sounds legit! And thanks! It was fun to work on!

Just added some stuff for ignoring strings and comments. The comment detection only works for Ruby, Python, and JS at the moment, but should be easy for me to add more over time.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.