Have you ever been in a supermarket, finished all your shopping, everything done – and then suddenly realized you forgot your money? Or lost it? And then you retrace your steps, walking back exactly the same way you came, slowly, almost methodically. Eyes fixed on the pavement, as if the ground might offer clues. Was it in your jacket pocket? Slipped out between two thoughts? Or even got stolen while you were answering that question of a stranger who lost their way? Maybe you never really had it with you at all. Gone or forgotten – hard to say which.
Of course, I know how to check my belongings and always close my jacket zippers before I even think of running for the bus. And to avoid running anyway. Why not be there early and then linger on the sidewalks enjoying the view or do some window-shopping?
Sometimes, a compiler acts just like you in that situation I mentioned above. Lost, but not knowing exactly where.
You may have forgotten a tiny little comma on line 7 and there in line 42 it says like what the (insert some utterance here) is going on there. Wild guessing but usually no mention of that line 7.
Back when coding was new
Before I was starting to study at the university, I had the chance to participate in a little introductory course (I guess it took one week) about Linux, computer algebra systems, and a typesetting system called LaTeX. This course made me use a computer in a completely different way than I knew.
Suddenly I could write prompts!
Well, I am not talking about AI prompts here, but things like plot(sin(x), x=0..pi);
or chmod 700 filename.sh.
Soon I regularly used LaTeX to transform a writing full of curly braces and backslashes into a pretty-printed PDF output full of 2D math expressions.
But then, it was not always easy, especially when something went wrong. LaTeX compiler is good at uttering sharp criticism such as File ended while scanning use of \foobar{ …
and all you could do is watch out for the mentioned line where it happened, or rethink your last amendment.
On its worst days, it uttered things like Fatal error occurred, PDF is not finished!
In most cases, there was not any kind of hint of what you were perhaps trying to achieve and where to fix it.
We have to be a bit lenient with the compiler, as after all, it’s just a little machine parsing some syntax.
When I started using C++, I did not understand the compiler messages there at all first. Much better with C# and IntelliSense nowadays, but yet, when you are editing a piece of code, you have to ignore the red wiggles appearing.
Here is a screenshot showing some Flutter code while I am editing something near line 126. The code parser wants to tell us that on lines 128ff there is a big mess, such as there are three issues at line ~138, but it was just a little thing near line 126 like a missing or extra `)`. In fact, the code that you see above and below the message box is correct and was not touched this time.
The answer is not in the desert of details.
As a beginner, you can easily get distracted, discouraged or overwhelmed. But usually it’s only a misplaced bracket, a forgotten semicolon or comma. The compiler doesn’t care why or where – only that something happened.
The compiler does not think (or work) like we do. It looks at every line and decomposes it into tokens, delimiters, variable names, positional parameters, objects, all kinds of things. It doesn’t care what you meant to write. It only sees what’s actually there. If we had to do that, too, what an effort!
The best way to search for something you lost is not by moving around and turning everything upside down, like that compiler has to do, but by first standing still, thinking of the bigger picture, going through your memories one by one about what you did.
Imagine you change your glasses for reading. Suddenly they are missing. So instead of moving around unsteadily, worried, and getting distracted by something else along the way, you just stand there for a moment, and think:
“When did I use my glasses the last time, and where have I been?”
Then it clicks.
“Okay, first I was doing this, then I went into the kitchen, to prepare the list for shopping, then the phone rang… so I … ah, there they are!” This way, you draw connections – this can help you memorize or retrieve information in learning and life, too!
Also with coding!
Better than turning every variable upside down, look away from the screen for a moment and just focus on your intentions and your last changes. Now, review the code snippet and the approximate position you were editing.
In some situations, walking back and watching every step is even impossible or unrealistic. Forgot to pack your sunglasses? Did you carefully review that corner where you put them in while you were thinking of something different? I know what I’m talking about…
Don't let gaps in your knowledge get you down, but grasp every foggy thought that comes up. It can lead you to the answer.
🌳🌲🌳🌲🏡🌳🌲🌳🏡🌳
I miss when coding used to light me up!