r/learnprogramming • • Aug 04 '20

Debugging Debugging should be in every beginner programming course.

It took me a few years to learn about the debugging button and how to use it. I mean it's not that I didn't know about, it's literally in every modern ide ever. I just categorised it with the /other/ shit that you find in and use that you can pass your whole coding career without ever knowing about. Besides, when I clicked it it popped all of these mysterious scary looking windows that you aren't really sure how they can help you debugg shit.

So I ignored them most of the time and since I apparently "didn't need" them why should I concern myself? Oh boy how I was wrong. The day I became so curious that I actually googled them out was one of the happiest days in my life. Debugging just got 100× easier! And learning them didn't take more than an hour. If you don't know about them yet this is the day that changes. Google ' debugging "your respective language" ' and get ready for your life to change.

2.3k Upvotes

155 comments sorted by

View all comments

306

u/Star_Skies Aug 04 '20

From what I've seen though, the guides on how to use a Debugger aren't aimed at beginners.

If there is a good guide that shows one how to use a Debugger for Javascript, I would really be interested to see it.

320

u/Digicrests Aug 04 '20

My JavaScript debugger is just a thousand console.log()s 😭

99

u/VoodD Aug 04 '20

And then you have to debug those console.log(‘here’) because you can’t find where they are anymore.

40

u/Dasaru Aug 04 '20

Sometimes I'll set breakpoints next to my print lines to find them.

37

u/Kallory Aug 04 '20

Lmao it's like using a hundred GPS devices as physical markers to keep from getting lost.

17

u/STAY_ROYAL Aug 04 '20

Do I step into this? Oh shit where the fuck am I?

As if step out even works

14

u/BatchFileMaster Aug 04 '20

Until recently I still had to use batch files pretty heavily at my job and this is absolutely how you have to debug those. They're the worst.

7

u/alcohall183 Aug 04 '20

Question? Would you pat someone to do this for you if you could ve off doing something else?

3

u/BatchFileMaster Aug 04 '20

Possibly, but usually if I'm debugging in DOS it's because the process is still a WIP, so at that point it wouldn't just be the debugging that'd need to be done but the actually programming too.

Luckily that's not too much of an issue anymore since we've moved a lot of our legacy processes over to C# in the last 18 months.

9

u/kstamps22 Aug 04 '20

Don't forget your rubber duck!

5

u/sprinklesleeves2152 Aug 04 '20

Chrome and Firefox developer console, you can basically do everything a modern ide debugger can do

3

u/titsmcgahee Aug 05 '20

100% this. Going into the source tab in devtools, drilling down to the relevant files and setting break points in the browser is the way to go for frontend debugging

→ More replies (1)

2

u/Godunman Aug 05 '20

what about debugger?

→ More replies (2)

10

u/[deleted] Aug 05 '20

In your JS code you can use ‘debugger;’ when your app calls on that function it will pause the execution, you can go into the console on the webpage and do a step by step breakdown of your code. Very useful to keep track of how every step in your code manipulates data, and if your dealing with an error you can usually spot where the code goes wrong and focus on there.

I do this when reading a new library if I’m confused how a function or event works.

Hope this helps!

3

u/notkraftman Aug 05 '20

Why not set breakpoints so you don't alter the code?

→ More replies (7)

9

u/[deleted] Aug 04 '20 edited Aug 04 '20

I think I agree but from what I've seen the terminology isn't very unfimaliar and new concepts are thoroughly explained so the guides might not be aimed for beginners but a higher can shoulder himself in just fine.

2

u/1337GameDev Aug 05 '20

If you have questions, I use it daily. Ask away!

0

u/[deleted] Aug 05 '20

[deleted]

3

u/1337GameDev Aug 05 '20

I use the web browser debugger, as well as webstorm.

The in browser debugger can even prettify minified Js files if the map file isn't found.

It's pretty convenient.

→ More replies (1)

2

u/[deleted] Aug 05 '20

In the edx C Programming With Linux certificate program they basically taught the whole class using something like a debugger(they called it a "memory visualizer tool", but it provided basic variable tracking and step-based execution, in addition to the memory visualizing), but they never explicitly related it to a debugger in an IDE, nor did they go over a methodology for debugging. I fully agree with OP! More beginner courses could lean a little more heavily into the debugging process. After all, it's kind-of foundational for identifying, understanding, and correcting a lot of run-time and logical errors in code.

2

u/rsag19 Aug 05 '20

"Python tutor " is also a visualisation debugger, if you would like to check it

→ More replies (6)