Learn to code: The Unexpected Friend
Talking to a computer. That's what programming is. We write lines of code, we run it and a machine does what we want. Learning how to code is a step many people take to transform their careers. I've watched women during workshops (WebMuses and RailsGirls). The enthusiasm is there but then it becomes frustrating and many give up. Here's one skill that can make it or break it for you.
I has an opinions.
Before I solve the mistery, let me state a fact, computers are not very smart. They can process lots and lots of date very fast but what we tell them must be grammatically correct so they can understand us. My not-so-wild guess is that you understood I had an opinions. It may be confusing if I have one or more opinions but you know that I have at least one.
If I wrote a scrip which would contain typos, the execution of the program would fail. There are many user-friendly programming languages - see Ruby, Elixir, Python as examples. However, the fact that they look like broken English doesn’t mean that they are as flexible as a natural language. Their syntax requires discipline and correctness. I mean who has never forgotten to add ), , or ;? This is a typical struggle at the beginning of learning to code.
For you, a human (if you're a robot, you're welcomed here too!) with a mind wired to understand languages, absence of a punctuation mark or a grammar mistake, maybe confusing at times but for a computer lack of correctness makes the whole script incomprehensible.
Early in my career, I was working alone in a project for a software house, I discovered a bug. Half of the web app didn’t work. I spent a whole day debugging, running tests, injecting flags into code to discover what a problem was. Unsuccessfully. It was a draining experience. All colleagues who had worked on that project were gone or too busy to help. Pressured by the customer to have it done by the end of the day, I finally decided to do turn to the last resort. I called a friend. He was kind enough to have time for me before 9am. He asked me to send him a screenshot of the file in question and explain how it worked. It was way before zoom times. While I was guiding him through the code, we discovered that
was missing. Yes, a colon. I added it and puff! the bug was gone.
Error messages everywhere
Coding is exciting. You write some commands, save the file (always remember to save the file!), refresh the server. Anticipation fills the room. You check if it works and, yes, oh no the screen is red with errors.
Am I too stupid for this? you may ask. You won't be alone since I've asked myself this many times and heard others do the same. As I stated in the beginning the machine is stupid, too strict about the grammar. Instead of insulting your abilities, pose a different question:
Where’s the miscommunication?
This puts the problem in the spotlight. You're trying to learn something, investigate a mistery, use a narrative that will inspire you to search for answers, not shame or judge your effort.
Error messages are your friends
Error message's goal is to inform you what went wrong. Instead of getting frustrated, take a deep breath and read the error message. Answer these questions:
- What’s the name/type of the error?
- What does is say?
- What does it mean?
- Does it point to the line in your code? What happens there?
- Is there anything missing? Is there a typo?
When you understand more or less what happened, but still can't fix the code, ask the internet. Docs, StackOverflow and Github issues seem to be the most helpful.
Become the error collector
Not to confuse with a garbage collector (although you can find treasure in the trash). When you’re done fixing a bug, instead of moving fast to writing more code, I suggest you stop for a moment and write down:
- the error name,
- the meaning of it,
- the solution.
Over the time your error collection will grow. Whenever you come across an error, you can check if you already have it in your collection. If so, then your notes will help you solve an issue faster. Otherwise, you will add a new entry to your set. It might sound boring or needless but trust me, it will help you mature your coding skills. The intention behind the error collection is for you to gain proficiency with solving coding problems. You'll notice, that some of errors you have mastered so well that you don't need to search for them in your collection.
Even though the name suggests something sophisticated, you don't need much to create an error collection. It can be a note you keep on your laptop or on Github. I created my collections on slack sending messages to myself. It made searching easy. Thinking about it now, I wish I had a copy on Github. Trust me, it would not be a small museum of web development (who remembers Backbone, js?).
Learning how to program can be challenging. We all make mistakes no matter the work experience. To be completely fair and honest, I think we all make worse mistakes the more advanced we are. The more complex the system, the more dependencies, unexpected events thrive in complex systems. Between queues and workers. Part of being a professional developer is to familiarise yourself with the thought that things can go South even if you work at the South Pole.
Thank you for reading! Share your opinions with me on Linkedin or Twitter.
PS. If you know someone, who is learning how to code, please share this blogpost with them. It is something I wish I had known when I was at the beginning of coding path.