DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป

Josh Ghent
Josh Ghent

Posted on • Originally published at blog.joshghent.com on

How to learn a programming language in record time

How to Learn a Programming Language in Record Time

Note: This article is aimed primarily at beginners who perhaps know a single language but are looking to start learning another.

When picking up a new programming language your first port of call might be the documentation, maybe itโ€™s reading through some code on a project you admire or perhaps you learn most effectively by building. Whatever the case, we can apply the Pareto principle to learn 80% of the language from 20% of itโ€™s features. If youโ€™re coming from a background where you know design patterns and common programming features (control flow, loops et cetera) then this is more than possible.

When I initially thought of this idea I didnโ€™t think that it would be possible to boil down a language to such a degree. But then again, when was the last time you used clz32 or bzflush? Programming languages have grown over time to implement features that, in day to day development, you mostly wonโ€™t need. Learning a new programming language can therefore seems a daunting prospectโ€Šโ€”โ€Šbut it need not be.

I applied this exact pattern of learning when trying to learn Java and it worked relatively well. There was things I didnโ€™t know from this, such as exact patterns of inheritance but at a very basic level, I could hold my ownโ€Šโ€”โ€Šand thatโ€™s the purpose. As you dive deeper into your new programming language of choice, you will get to know the nuances, why and how it solves specific problems and whatโ€™s best practise. This will, at the very least, give you a good grounding in a language in an efficient manner.

Hereโ€™s my list of things to prioritise so you can pick up a new language in record time:

  1. Variable creation โ€Šโ€”โ€Šif itโ€™s a strongly or statically typed language, then this extends to how to declare variables of different types (integer, string, object, array). If the language has the feature then we can learn how to create a constant too.
  2. Loop โ€™nโ€™ number of timesโ€Š โ€”โ€ŠIn Javascript this would be achieved byโ€Šโ€”โ€Šfor(var i = 0; i \< n; i++) {}
  3. Loop over a key:value storeโ€Š โ€”โ€ŠKey:value stores are called Objects in Javascript in other languages they are called Hashes (Ruby) or Dictionaries (Python). Nonetheless, they are all the same, and usually there is a particular method to iterating over them because they are referenced by โ€œkeysโ€ and not index numbers (as with arrays).
  4. Referencing items in array โ€Šโ€”โ€ŠIn javascript you can reference arr[1] for the second item of an array. In addition to basic referencing, there may be special methods like end() to get the final element of an array.
  5. Functions โ€Šโ€”โ€ŠHow to create them, with or without arguments.
  6. Add to an array โ€Šโ€”โ€ŠHow can we add an element to an array?
  7. Remove from an array โ€Šโ€”โ€ŠLikewise, how can we remove a particular item (of index โ€™nโ€™) from an array?
  8. Class creation and constructors โ€Šโ€”โ€ŠThis is where I find languages differ wildly in particulars of the syntax. PHP, for example, has a special __construct function that you must use to construct the class.
  9. StdOut method โ€Šโ€”โ€ŠIn javascript this is console.log in PHP itโ€™s print. This is probably my most used method when debugging.
  10. Comparison operators โ€Šโ€”โ€ŠHow do you check if a variable is false or true? How do you compare a larger number against a smaller number?
  11. Length of a string โ€Šโ€”โ€ŠA must have for any language. I find myself using this all the time but a common use case is checking whether we should truncate a string before displaying it to a user.
  12. Length of an arrayโ€Š โ€”โ€ŠCrucial when working with loops as 99% of the time, you will be iterating over an array for however long the array is.
  13. Public and Private methods โ€Šโ€”โ€ŠAll languages (especially those with classes) should have this, and is essential when you want to disallow access to functions outside the class.
  14. Tryโ€ฆcatch blocks โ€Šโ€”โ€ŠI only ever use these when integrating Stripe payments but they can be handy other times, perhaps when you are testing for a bug and want to capture it for your bug tracking software.
  15. Returning from functions โ€Šโ€”โ€ŠNot all languages use return! (See Rust).

And thatโ€™s it! This will by no means teach you a language per se but it will provide a good base level to become familiar with the syntax.

This learning pattern relies on knowing concepts and design patterns; It goes to show how your learning can be transferred from one language to another!

Remember the core concepts and features of a language are what matters.

Additional Reading/Resources

https://tim.blog/2009/01/20/learning-language/โ€Šโ€”โ€ŠThe original article this is inspired by.

https://learnxinyminutes.com/


Top comments (0)

๐ŸŒš Browsing with dark mode makes you a better developer.

It's a scientific fact.