Learning to code from the perspective of a linguist
Learning to code is just like learning to speak a language. Obviously human languages are very different from coding languages, but both are languages and have more similarities than they have differences. If you are interested in learning a human language, learning to code, or both, I have put together a short list of similarities between the two with suggestions of study habits that can be helpful.
A little background on me:
Tips to learn a language and/or learn to code:
1. Practice every day:
If you don’t practice, you will forget! This is probably the most import part of learning a language, especially at the beginner stages. You can spend a month learning a language and learn a lot, but stop using it for a month or two and you will find yourself having to start all over again when you go back to it. Do yourself a favor, be persistent and keep practicing; don't start as a beginner over and over again because that way you will always remain a beginner. Even 10-15 minutes a day of practicing will make a huge difference compared to 0. It is a little bit different for advanced languages speakers and coders as it does come back like riding a bike (although it will be rusty at first).
2. Put yourself in a place without distractions:
This is the most obvious study tip that everyone knows but many people don’t actually practice. Spend as much time as you can focused on learning the language or coding. The more exposure you have to it, the more you will learn. And as you get used to using it frequently, you become fluent. When you are fluent, using it becomes much more effortless and more fun. Once you’re having fun, the sky is the limit (or – your imagination is your only limitation).
3. Go somewhere to learn:
4. Decide what you want to use the language for (or what you want to code for):
There is almost endless vocabulary in any language and almost endless information about coding. For the best results, the vocabulary you learn (or the code you learn) should be directly related to the purpose that you want to use it for. Do you want to learn a language for conversational purposes? Learn vocabulary related to topics that you like to talk about. Do you want to learn to code to make web pages, mobile apps or something else? Find out what coding languages/concepts you need to learn to complete your goals and projects.
Also, knowing what you want to use it for allows you to practice (using it for what you want to use it for). Real world conversation or real world coding is infinitely better than just practicing in a classroom type situation. Practice makes perfect and real-life use is the best practice!
5. Learn to think in the language:
To learn a language you have to learn to think like a speaker of that language. In the case of code, you need to learn to think like a computer (or think like a coder). Language isn’t just about learning vocabulary and grammar; every conversation has a context and to communicate with someone, you have to be thinking on the same level (in the same context). Therefore, to speak a language well, you need to think like a speaker of that language.
To learn to code, it isn’t just learning how to write code, it’s also how to think like a coder. Before you can code an idea (write the syntax), you need to work out the logic that will make it work. All the knowledge in the world about coding is useless if you can’t use logic to solve a problem first. One of the best coding skill I learned just recently is to write out the logic in plain human language first. Once the logic makes sense, write it into code.
6. Surround yourself with the language:
Surround yourself with people who speak the language or are also interested in learning the language. Social interactions having to do with what you want to learn will greatly help your progress. When learning a language, being around people who speak the language gives more exposure to the language and helps you improve. In the case of code, try to surround yourself with other people who “speak code” (people who code), talking with them will help you learn more (not to mention having people who can help you when you are stuck or have a question).
7. Make mistakes:
Making mistakes while learning a language can be the best teacher. When you make a mistake, you learn very quickly not to make the same mistake again. I had a personal experience that is a perfect example of this while I was learning Spanish. I was with some friends and I wanted to ask a taxi driver if we could squeeze four people in the back seat of a taxi. I asked, “podemos meter cuatro por atras?” which roughly translates to “can we put four in your rear-end”. Everyone immediately broke out laughing when they heard what I said and based on their reaction I realized what I had just said. Needless to say, I have not and will not make that mistake again; it was a great lesson for me.
Making mistakes while coding is the same. You can learn a lot from mistakes, as well as learning how to debug, which is a vital skill no matter what computer language you’re learning. When you have that bug in your code that takes you hours or days to fix, you will definitely remember that experience and catch that same error right away the next time. Also, learning and practicing how to find or fix mistakes is just as important as any other skill when writing code.
8. Get out of your comfort zone:
If what you’re doing is easy, then you’re not really learning or advancing. The best way to learn is to always push yourself to do something that you never thought you could do before. Doing things that are difficult or uncomfortable is what really brings the most satisfaction and feelings of accomplishment. If something is easy, there is little or no sense of accomplishment when it is completed. Completing something that is difficult or uncomfortable (or that you thought you could never do before) is also a great confidence builder. Accomplishments and confidence become a part of who we are and make us better people.
While you are getting started, don’t be afraid to copy ideas and other people. Before you start getting creative with a language, build a foundation. Nobody learns a language by making it up; people learn language by copying speakers of the language. Looking at someone else’s code/project is a great way to get started with coding. Reading a dictionary or a textbook about a language can teach you a lot, but talking with a native speaker will teach you a lot more and a lot faster. In the same way, reading documentation about code online is helpful, but finding a project that interests you and using it as a reference to make your own project will teach you how to actually use the code. So don’t be afraid to copy ideas from other people’s code or even the code itself. No matter what people do or what skills they have, people who are the best at what they do are always copying those who were the best before them.
*Side note - don’t just copy and paste code, try to understand it before you copy it. Also, rewrite it yourself, as that will help you understand it better and learn how to write it in case you need to code the same or similar code later.
A good trick that a friend taught me is to rewrite code and only look at the original code when you’re stuck. Once you finish, erase your code and write it again doing the same thing (only look when you’re stuck). Each time you write it, it should get a little bit easier and make a little bit more sense. Keep doing this same process until you can rewrite the code without looking at it. Technically you have copied the code, but if you can complete this task; you should fully understand how each piece of the code works and you can probably reproduce it if you ever need to in the future. It is copying, but it is also learning.
10. Be creative:
Once you build a foundation, start getting creative and making your own. Don't always just copy what you see; use what you know to try to create something you have never seen before. Sure you will make errors, but again, errors are great for learning. The more you play with a language, the more you learn it and get a deeper understanding of it on many levels. When learning a language, a huge step is the ability to create “novel” language, which refers to creating language that was not previously known or learned. For example, making a sentence or a phrase that you created yourself (that you never explicitly learned before using it). Using “novel” language means that you have moved beyond translating or repeating phrases that you have been taught, to having a deeper understanding of the complexities of the language so you can actually use it creatively.
With coding, once you have developed a good foundation based on examples of other projects, start creating “novel” coding projects. Creating “novel” code is reaching the next level of ability and that is when all the hard work starts to pay off. Learning to code is also useless if you don't aspire to reach the level of creating “novel” code. Having the ability write code creatively is the whole reason for learning it to begin with.
11. Have fun:
Having fun is important for many reasons. First, if you’re not having fun, you’re going to burn out. All work and no play is a recipe for failure. In addition to that, people learn more and learn faster while having fun. Studies have shown that when you’re having fun, your brain is more active and your memory functions work better, which is obviously conducive to learning. You can probably see this in your own life/education: how much do you remember from your favorite class in school (even if it was gym class or recess), probably a lot. How much do you remember from your least favorite class (whatever subject that might have been)? You probably don’t remember much from that class and feel like it was a waste of your time.
There are many other reasons why having fun and enjoying yourself is helpful when you’re learning, but most importantly; why do it if it’s not fun??? We only live once, and we don’t have enough time to waste doing things that we don’t enjoy. If learning a language or coding starts to not be fun, think about why you started learning it in the beginning; that will usually help remind you why you enjoy doing it. Sometimes it can be frustrating learning a language and you feel like you are putting in so much work and you still have so much to learn. But having one good conversation with a person in that language can be so satisfying to see that you are becoming proficient. Similarly, it can be hard to enjoy coding sometimes when your code isn’t working; it can make you get stressed out and go crazy (and maybe even not sleep well at night), but how sweet it is when you get your code to work – glorious!