To improve coding skills

A student wrote to me: “My girlfriend learns how to program in just few days then she write code right away but it takes me three weeks just to write a few lines of code. We are currently learning JavaScript and for me it seems to be taking forever just to understand the basics. How can others learn things so fast and I am too slow? I am so embarrassed and even envy with her. Is there any technique by which I can improve my programming faster?

Answer: People learn things differently. As long as you are learning something, it does not matter how fast or slow. Maybe your girlfriend has stronger foundation in high school so she may learn things faster but you need to know that it is the quality that counts, not the speed. For this reason it is important to learn by doing then reflect on your work and improve it. You may focus on writing few sentences at a time and make sure they are corrected then you will find it easier to learn the structure of a language because it relates to an actual experience. One of the best ways to keep code consistent and organized is to group functionality together. For example, rather than dumping all your JavaScript into one main.js file, you may want to group them into separate files based on functionality, then concatenating them once you reach your build step.

After write code, you should take time to review your own work or ask other friends to review it for you. The code review is to show your code to few friends so that you can explain what you have written, why you do it that way and based on their feedbacks, you learn how to write better. The goal of code review is to find errors and learn to improve your coding skills. Of course, if you do not want others to see your code, you may use tools such as jslint or SCSSlint to check your code for errors. Another way to improve your coding skills is to read others' codes, examine their data structures and algorithms and ask yourself why they are doing that way? By review more good code, you will learn more and get better with your own code and will enable you to write better in the future.

Learning programming language requires practice; the more you write codes the better is your skills. When you have been doing it long enough, you will know all the structures of that language and it will become easier. Basically, you learn which choices are made from your own knowledge as well as the exceptions. By having the skills then you can write high quality codes faster. Few years ago, a musician friend told me that learning programming language is similar to playing an instrument. You start slow to make sure that you learn all the basics then you learn to play accordingly to develop your skills before you can play with others in a band. He told me that after you have played long enough, you know all types of music then you can play them in different ways and be a good musician.

My last advice: Do not compare yourself with others, especially with your girlfriend. Be yourself but respect others as you are still learning and growing.

Sources

  • Blogs of Prof. John Vu, Carnegie Mellon University