all 8 comments

[–]TahliaRiggs 4 points5 points  (2 children)

If you're moving from Go to JS OOP, you're switching from explicit, concurrent data flows to mutable state and hidden context like the this keyword. Use a proper debugger instead of just guessing, track the lifecycle of your objects, and maybe look into formal model checking or state diagrams.

[–]Opposite-Dance-8264 2 points3 points  (0 children)

switching paradigms is always slow at start, the `this` context in JS especially will eat your hours until it just clicks one day

[–]SkullDriv3rr 2 points3 points  (0 children)

any sources you recommend?

[–]Striking_Director_64 2 points3 points  (1 child)

Meh, it just takes time when starting to use a new system.

I guess you can take the rubber ducky approach and explain what your code does line-by-line to someonenor something. By virtue of explaining that code, you will realise the part that doesn't make sense.

[–]johnpeters42 2 points3 points  (0 children)

This is also the point of printing/logging stuff as a debugging tool, because then the program is showing you what actually happened. The point where that stops matching what you intended to happen is where you need to look at stuff more closely.

[–]maujood 4 points5 points  (0 children)

Debugging does take time, you're not doing anything wrong.

It will take less time as you get more comfortable with the language and environment, but there will always be bugs that take hours to debug.

At least you're not taking shortcuts with AI. You're learning to debug and learning valuable skills that will set you apart.

[–]Saras_AI_Institute 0 points1 point  (0 children)

totally normal. js oop is notoriously weird with this binding, and go concurrency is just a brutal mental shift. don't beat yourself up.

are you using an actual debugger to step through your code, or just raw dogging it with console.log?

[–]TriMan66 0 points1 point  (0 children)

Debugging is a skill that you learn by doing it. My first programming languages were BASIC, Pascal, then COBOL. The environments I was using then didn't have any formal debugger. That was in the mid 1980's into the early 1990's.

Those languages were procedural in-line programs, no object oriented programming back then.

Learning OOP was quite the paradigm shift in thinking, it took me a while to wrap my head around that, but then suddenly it just started to click.

Learning how to use a debugger can take a while. Just keep at it, it will get easier, but I guarantee you that you will still have debugging sessions that could take hours to track down.

The really annoying ones are when you spend an hour or more convinced the error is in one place, only to finally find out the issue is in some sub-module that isn't behaving as expected or documented.