r/learnprogramming • • Mar 07 '23

Is it normal as a junior programmer..

To spend hours looking over the same block of code, trying to sort out ‘why the f*ck isn’t this working!?’, only to realize the error you made is so monumentally, and stupidly obvious that it leaves you feeling like a completely useless moron? Lol

1.6k Upvotes

297 comments sorted by

View all comments

Show parent comments

16

u/patternboy Mar 08 '23

I'm experienced with R but a relative novice with python. I've never done any programming without an IDE, but yesterday I was reminded of the limitations of IDEs quite painfully. I spent hours trying to solve a problem with a set of dictionaries not being populated properly using a set of nested for loops. I understand this is a relatively simple task for any professional developer/data person. I'd never done such a complicated set of nested loops before though, iterating through several different lists/dictionaries of different lengths to be consolidated (all originating from a powershell subprocess stdout string).

It turned out that a totally correct line was just indented one loop too deep and this was messing up the loops. Literally a backspace solved the whole thing. But the IDE didn't help any as there was nothing wrong with the syntax. I of course felt the excitement once it finally worked, but also felt frustrated and stupid, and retired to bed at 4am and had recurring dreams about solving problems with key:value pairs that I had already solved.

17

u/chaoticbean14 Mar 08 '23

Yeah, there may be some instances where the IDE doesn't alert you - but I would say for the vast majority of typical issues that catch developers up for hours (sometimes days) an IDE will generally be a huge help. Red squiggles, grey text, lots of visual queues of "something here isn't right" as well as lots of things in the problem pane.

I'm glad you got it solved! Staying up late is almost never worth it, for me personally. A good nights sleep is so helpful to me. Come back in the AM with some coffee and a clear head - I usually have a whole handful of things to try.

7

u/patternboy Mar 08 '23

My immediate thought is why are developers not using IDEs? I genuinely assumed everyone used them, especially in tech. I did a bioscience PhD and we rarely saw anyone use R itself - we opted for RStudio specifically because it was much easier to read and write code, install packages, etc., and helped with highlighting errors and displaying graphs quickly. I've never opened the python app - have always used either PyCharm or VSCode. I thought this was all standard stuff?

But yeah I agree about the sleep. I even started noticing my ability to solve these problems and think clearly just reach somewhat of a stone wall during the night itself. It comes on gradually but I keep catching more of myself zoning out and losing track. I've very rarely had the motivation to stay up so late learning/solving complex problems so have never experienced this gradual onset of fatigue so vividly. It's been a learning experience!

3

u/mandradon Mar 08 '23

Anyone not using an IDE for R deserves what they get! Rstudio is great for what it does. It smoothed the learning process out for me when I was in grad school that I never through of R as a language and just thought of it as a stats package with really poor UI tools.

I've seen people recommend using just the python terminal to learn, or IDLE, but I think those people are insane. I get doing things simple from the start, but text editors and ides exist for a reason.

Also, with Python, it's error messages can be less than helpful for novices, though. A missed closing parenthesis will often throw an error on the wrong line, depending on the version or LSP/linter that's being used. Tab mistakes can take a long time to track down if you don't know what you're looking for, too.

2

u/patternboy Mar 08 '23

I agree with everything you said about R and IDEs. I don't think I'll ever understand why anyone prefers to "start simple" when it opens the door for so many more problems, never mind monotone code with no formatting.

Also I'm so glad you said it - the biggest thing I've found with python is the errors are often really cryptic! And sometimes even if they reference the correct line, it's unclear which part of the line is the issue. I'm just now getting to the point where I can half reliably work out what an error actually means.

5

u/dehin Mar 08 '23

The new Python 10 compiler I believe now checks for some logic errors as well, not just syntax ones. Although, I'm not sure if it would have caught your issue.

3

u/lordheart Mar 08 '23

If I start having to nest to many loops I’ll pull out the inner loop into a function, and repeat till it’s cleared up.

1

u/patternboy Mar 08 '23

That sounds like a really good solution. I've just recently started writing functions so it didn't occur to me. Come to think of it, a reusable function could be hugely useful for processing subprocess outputs more quickly going forward. Thanks for sharing!