Advice for learning to code from a Stanford CS major
Learning how to ride a bike is terrible in the first few hours. No matter how much you try, you can’t seem to balance your weight. You fall down, get bruised, maybe even cry out in pain. But you get up and try again. Because you like the fresh summer breeze rushing past your ears for the split second you succeed.
Learning to code is not much different. Except that you keep crashing (and your code keeps crashing) for maybe weeks or even months before you get a hang of things. Crashing is not biking. Struggling at something does not mean that you cannot experience the exhilaration it promises. Things get better as you improve. Frustration, anger, and pain only means you are growing. Growth is meant to be uncomfortable.
My journey at programming was similar. I did terribly in my first two courses and for a while thought I’m not cut out for software. But I loved writing these units of logic that culminated into something beautiful — like finding the cheapest cost to connect cities to electric grids or writing code to transform any smartphone picture to impressionist art.
Reflecting back on my experience, from knowing nothing about coding to taking AI courses at Stanford, I wanted to share some advice to new programmers below —
Concepts over language
In the tech world, new frameworks and libraries are always coming out. The returns on learning every new language that’s hot is low. You should focus on solid fundamentals. Focus on broad concepts and mastery of data structures, algorithms and object oriented programming. Once you have good intuition of the fundamentals, you can pick up new languages quickly. For example, the way a for-loop is written in every language is different but the concept of iterating over a finite length vector remains the same. Similarly, instead of trying to learn React, Vue, Gatsby, Next.JS simultaneously, you should start with a deep understanding of JavaScript and then picking additional frameworks.
Set boundaries
This is important when you’re starting out. In STEM, we are told to think long about a problem before asking for help. But when you are starting to learn the syntax of a new language, you should not waste more than 15 minutes before asking for help. Beginners often don’t know what they don’t know. And hence, they need external advice to get unstuck.
It’s never worthwhile to think long about knowledge questions. If you lack knowledge about something, for instance, how to do basic sorting, no matter how hard you think, it is unlikely that you will come up with a reasonable algorithm in an hour. It’s more efficient to just search it and fill in the gaps of your knowledge.
I would like to distinguish skill based questions from knowledge questions. If you are slow at an algorithm or cannot apply it in different problems, then you have a skill problem. You should definitely think more about how you can apply the theory/knowledge of this category of the problem to this specific problem. But more often than not, we err on the side of wasting time before asking for help.
Think of school as a timed investment. You want to maximize knowledge and skills in a fixed amount of time.
Quantity of problems over quality
When learning anything new, don’t fret over the difficulty of the problem. Solve as many problems as you can and once you feel comfortable with the basics, solve tougher problems. There’s nothing more demotivating than being stuck on a super hard problem in your first few hours of learning something.
There’s a classic case study of quantity of practice vs quality of practice for learning gains. Two groups were asked to make pottery but Group A was told to make as many pieces as they can and Group B was told to make one piece of pottery as well as they can. Eventually, Group A made pieces of higher quality because with every bad piece they produced, their overall skill improved faster.
Get help sooner
If you are at school, take the lowest friction path to help. If your class has Piazza or Ed, shoot up questions. Make sure to Google the problem first. In 2022, you should never ask a question to someone that you can google first. The best explanation is probably there. Go to office hours. Email the professor, TAs. Form study groups and shoot them a message.
Take project based classes
If your school offers classes on web dev, React Native (for cross platform mobile development), Android or iOS development, I would recommend doing these as early as possible. Doing so will increase your motivation to grind through CS when you see your code’s direct applications. Secondly, it will give you a portfolio that will help you to avail internships or help people. Finally, they are an amazing way to stay in touch with fundamentals of data structures, algorithms and object oriented programming.
Happy coding! Remind yourself that you are an exponential function and a slow start doesn’t mean a slow end. You are more than your grades.
—
(Reach me at thisIsSrijon@gmail.com)