My First Bug

I had done coding before. I don’t know if the little I had done in MS-DOS batch files and command line menus qualified as “programming” or “development” beyond just “coding.” And I had made mistakes but didn’t consider them bugs (at least I didn’t call…


This content originally appeared on DEV Community and was authored by Alvaro Montoro

I had done coding before. I don't know if the little I had done in MS-DOS batch files and command line menus qualified as "programming" or "development" beyond just "coding." And I had made mistakes but didn't consider them bugs (at least I didn't call them that way.)

My first bug (although some people may not consider it as such) was during Programming I in college. And it was the silliest thing that you could imagine. Still, it stuck, and I still remember the error because of the lesson that came with it.

We were learning Turbo Pascal (I just aged myself with that, but I have to say, it is a phenomenal language to learn because it uses a more "natural English" than most others I've learned since). During our first lab, we had to create a small program, I don't remember what it was, but the general idea was to read some input, run some math calculations, and show the results on the screen.

After fixing a couple of missing semi-colons, the program compiled and ran! It could read the inputs, pass the arguments to a function, run the calculations, and return the value... but the result would not display on the screen. I ran the program again and again—no problem reading the inputs. Still no result.

After including some writeln I could confirm that the function ran just fine, but the result was not on the screen for some weird reason.

I called the professor, who checked the code. It was not long, but longer than it should be –at the time, we enjoyed having the program with the highest number of lines possible, like that proved we were "more of a developer."

I guess he expected a compilation error or something typical from new developers, but to his surprise, he couldn't find an obvious mistake.

Then he did something that blew my mind (considering that I was a first-year CS student): he ran the debugger and executed the program step by step. We saw how the process ran as it should, observed the values being calculated correctly, exiting the function, the value was correct outside of the function... and no result on the screen.

He rolled his eyes and looked at me, "Alvaro... where are you writing the result on the screen?" And as I pointed to the last line of code, I could see my error: I forgot to output the variable with the result!

writeln('The result is ');

The professor was unhappy about losing 5-10 minutes looking at such a ridiculous issue. Or maybe he was a little ashamed about not realizing sooner.

Either way, he spent the last 20 minutes of the lab explaining how to debug in Turbo Pascal... and asking to please, please, please not ask him for help unless we had debugged the code before. A request that we ignored most of the time.

Still, that was a great lesson and a great lab. And I remember it as one of the days that I fell in love with coding.


This content originally appeared on DEV Community and was authored by Alvaro Montoro


Print Share Comment Cite Upload Translate Updates
APA

Alvaro Montoro | Sciencx (2023-03-01T03:41:33+00:00) My First Bug. Retrieved from https://www.scien.cx/2023/03/01/my-first-bug-2/

MLA
" » My First Bug." Alvaro Montoro | Sciencx - Wednesday March 1, 2023, https://www.scien.cx/2023/03/01/my-first-bug-2/
HARVARD
Alvaro Montoro | Sciencx Wednesday March 1, 2023 » My First Bug., viewed ,<https://www.scien.cx/2023/03/01/my-first-bug-2/>
VANCOUVER
Alvaro Montoro | Sciencx - » My First Bug. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2023/03/01/my-first-bug-2/
CHICAGO
" » My First Bug." Alvaro Montoro | Sciencx - Accessed . https://www.scien.cx/2023/03/01/my-first-bug-2/
IEEE
" » My First Bug." Alvaro Montoro | Sciencx [Online]. Available: https://www.scien.cx/2023/03/01/my-first-bug-2/. [Accessed: ]
rf:citation
» My First Bug | Alvaro Montoro | Sciencx | https://www.scien.cx/2023/03/01/my-first-bug-2/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.