I program in C++ and often I find myself spending hours trying to fix stupid mistakes I make.
I'd say I can write the code I need at a good pace, but when I compile it sometimes gives an error. And when I try to figure out how to fix it, it can literally take a few hours.
Should I be worried? I'm unsure of how long it's normal to spend trying to just debug code rather than write it. However, I do enjoy coding a lot and I'll code from morning to bed time. Once I start I can't stop.
Examples of my mistakes that took really long to fix:
I wrote "vectorName.empty()" thinking the empty() member function clears the whole vector of all the elements. But it's actually the clear() member function.
I didn't read my own prompts of what values to type in, and I kept typing in letter characters which caused an infinite loop. The prompt said to only write numbers. This took me so long to realize.
I forgot to write ".txt" at the end of opening a file. I was looking through my logic in code trying to figure out what I'm doing wrong. But, of course, took over an hour for me to scroll up and see that ".txt" was missing...
Chase Stewart
The docs. Read'em.
Liam Bailey
Yeah I do but often it's not obvious what I don't know.
What I meant to ask in my post is if this is a sign that programming may not be for me and therefore something I shouldn't spend my time pursuing. I obviously want it as a career, but I'm also aware that intelligence has a lot to do with being good at it.
Chase Morgan
>Should I be worried? Only if it bothers you to have those mistakes. I've noticed the main thing that separates people who are more serious about programming and do it for a living vs. people who say they want to learn but never get anywhere is how much tolerance you have for tracking down and resolving minor details like the ones you mentioned. Normies generally have no patience at all for that sort of thing and will give up even with very simple computer use basics like filling out fields in a user interface at the very first instant anything happens that runs contrary to their expectations of what should happen. A programmer on the other hand will easily blow an entire day trying to figure out how to get past some obscure obstacle to accomplish a task they didn't really need to accomplish in the first place. It's more a matter of whether you care about figuring out autistically nuanced systems details than it is a matter of how smart you are.
Jaxson Richardson
>I'd say I can write the code I need at a good pace, but when I compile it sometimes gives an error. And when I try to figure out how to fix it, it can literally take a few hours. That is very, very normal. Debugging, even of embarrassingly stupid mistakes, generally takes *at least* as long as writing your program in the first place.
>Should I be worried? No.
>I'm unsure of how long it's normal to spend trying to just debug code rather than write it. Three hours of getting something to work that took one hour to write a first version of is pretty common.
A classic situation that has happened to every experienced programmer is hunting several hours for what turned out a one-character bug, that the next person you showed it to saw immediately.
>What I meant to ask in my post is if this is a sign that programming may not be for me and therefore something I shouldn't spend my time pursuing. Certainly not. No worries.
Jackson Gomez
try reading the documentation user
Ayden Clark
I bet you losers read instruction manuals when assembling home appliances too.
Chase Cooper
One thing I can say is that I will sit for hours until I figure out what is causing a bug. I won't give until I get it, and so far, I've gotten them every time. And I very much enjoy going through my code trying to solve a problem. It frustrated me in a very fun way.
>A programmer on the other hand will easily blow an entire day trying to figure out how to get past some obscure obstacle to accomplish a task they didn't really need to accomplish in the first place. This really hit home when I read it because I enjoy balancing the efficiency and readability of my code. So, I end up doing things that won't necessarily change the what the program does, but makes code run faster and/or look neater. The only reason I stop improving it is because the assignment has a due date, and I gotta do work for other classes.
Well, I think I'm doing pretty well then. I noticed I don't often make mistakes in the logic part of my code - it's mainly stuff like missing brackets, semicolons, or some other stupid shit. I also have a strict rule that I won't write any code that I don't understand. Thought if it's something like a function from a library then I don't think I need to understand anything more than what the function accomplishes. Those library functions are like thousands of lines long.
Thanks a lot for the responses, guys, It made me feel much better.
Ethan Rodriguez
>I wrote "vectorName.empty()" thinking the empty() member function clears the whole vector of all the elements read the documentation
>and I kept typing in letter characters which caused an infinite loop it takes 2 lines of code to prevent that infinite loop. google "infinite loop if i input a letter"
>But, of course, took over an hour for me to scroll up and see that ".txt" was missing... that's why you're taught to spare 1 line of code to check if the file open was successful or not.
you can find that code in examples section commonly found in ....... yup, you guessed it... the documentation
Back in the day you'd have had to painstakingly leaf through thousand-page tomes. Your IDE shows you prototypes on mouse over, you hit F1 and get a full doc complete with examples and pitfalls to avoid. If that doesn't help you can just google it and wonderful sites like cplusplus.com or stack overflow will almost always have the answer. If they don't you can just ask it and some seasoned veteran will respond to you in under a day most of the time. And kids are still too lazy to look at the docs or use sound practices like error checking
Benjamin Williams
>Should I be worried? I'm unsure of how long it's normal to spend trying to just debug code rather than write it. However, I do enjoy coding a lot and I'll code from morning to bed time. Once I start I can't stop.
Most of the work is always debugging. Learn how to use visual studio's debugger.
>I didn't read my own prompts of what values to type in, and I kept typing in letter characters which caused an infinite loop. The prompt said to only write numbers. This took me so long to realize.
Throw in basic error checking.
>I forgot to write ".txt" at the end of opening a file. I was looking through my logic in code trying to figure out what I'm doing wrong. But, of course, took over an hour for me to scroll up and see that ".txt" was missing...