DEV Community

Sahil Dua
Sahil Dua

Posted on • Originally published at hackernoon.com

Unconventional way of learning a new programming language

Note: This article was originally published on Hackernoon

There are more than 500 programming languages. Hence, it's pretty normal for you to start learning a new programming language today. It's possible that you know C++ and Java but your work requires Python or you are well versed in Python and you need to code in Java at work. Or maybe you want to learn that cool language just to expand your expertise.

What are your options if you want to learn a new programming language?

  • Learn from some online tutorial or
  • Learn from some online (MOOC) course

Some of you may even argue that the best way of learning a new language is actually as follows:

  • Learn syntax of the new programming language and
  • Build some personal project using that language

Fair enough! This makes sure that you apply the knowledge you gain from learning the syntax of the language you want to learn.

I have developed more than 20 mini projects while learning different languages. Trust me, when you write code for your personal project which may be a weekend project or an overnight quick hack, you write code to get something done. All you care about is – “Does my code work?”. You hardly care about the quality of the code.

“Any fool can write code that a computer can understand. Good programmers write code that humans can understand.”
– (Martin Fowler)

So, how do you learn good practices of the new programming language that you are trying to learn?

Contribute to an open source project in that language.

Surprised? Some of you may be thinking – “But wait, open source is hard. We can contribute to an open source project only if we are expert in that language, right?”. The answer is No.

Let me tell you a story.

Last year, I got an offer for full-time job from Booking.com and I knew that I'd be working on Perl (which is their primary language for backend). In June 2016, when I got done with my college degree, I started learning Perl so as to prepare myself for my first job after college. Since I was to join in second week of the July, I had roughly one month.

I started reading about syntax of Perl and started understanding some of the common patterns of the language. Now, I really wanted to build something using Perl so that I could apply my knowledge of the language and practice various concepts of the language. While I was looking for ideas to build something in Perl, I came across DuckDuckGo's open source organization on GitHub. I noticed that some of the open projects were written in Perl. I had a look at the issues and found a lot of “beginner” issues. I immediately started working on them and submitted a couple of pull requests. Fast forward to today, I am one of the main contributors for a couple of their open projects and also one of the 20 Open Source Community Leaders for DuckDuckGo.

So why did it work?

Right after I learnt the syntax of Perl, I started contributing to open source projects. While doing so, I always used to look at the existing modules. I used to notice the patterns being used in Perl. Hence, I started picking up those good practices in my own code and it helped me in learning how to write good code in Perl.

That wasn't just a coincidence; let me tell you another story to derive more correlation.

Recently, while working at Booking.com, I picked up some task which included working (adding a new feature) on one of the services written in Go language. This was the conversation I had with my teammate –

Me: I really like this task. I want to work on it. What do you think about it?

Him: Yes, it's indeed an interesting one. However, it requires knowledge of Go. Do you know Go?

Me: No.

Him: Do you want to learn Go?

Me: Yes!

Him: *smiles* There you go!

So there I was – at the verge of learning another programming language – Go!

I started reading about the syntax of Go and found an awesome beginners language tour on their official website. It was good enough to get me acquainted with all the basic concepts of the language.

Once again, I started looking for open source projects in Go which had some “beginner” or “easy-fix” issues. I found a project by Google which is basically a Go wrapper for GitHub's REST API.

I had my first PR on that project 2 days after I started learning Go.

My contribution graph for last 1 year (https://github.com/sahildua2305)


How Does Open Source Help?

So now you may be wondering about how open source contributions can help you in learning good practices of a language. There are various aspects of it. Let's discuss them one by one.

Code Quality

Most of the good open source projects have strict coding guidelines which you have to adhere to in order to get your code merged. This will help you in adapting those guidelines and hence writing good quality code even though you are just learning the language.

Not just that, you have a chance to look at the rest of the code and see how well it's written and/or documented.

Code Reviews

The best part about open source contributions is code reviewing. When you push your code, you get feedback from the experts associated with that project and hence it gives you a chance to improve your understanding of a language.

This is like getting a free-of-cost personal guidance about how to write good code.

Appreciation

First comment on my first PR in Go Lang (https://github.com/google/go-github/pull/497)

We, as software developers, really need appreciation for our work; and open source community makes sure you have enough of that. In my whole experience with open source contributions, I have never received even a single comment which was insulting or demotivating. Everyone is super encouraging and helpful.


So next time you want to learn a new language, go ahead and take the plunge! Find an open source project to contribute to and march ahead on the path to learning that language and its nuances ;)

Do let me know how this unconventional way works for you. Also, please recommend (❤) this post if you think this may be useful for someone.

Feel free to share any other way that worked for you really well. Tweet/follow me @sahildua2305.

Top comments (21)

Collapse
 
g2theg profile image
Garrett Galow

I thought a lot about this problem in an HCI (Human-Computer Interaction) project in my graduate studies. Most professional developers end up learning languages at work. Unfortunately, not everyone has a team of developers to lean on and code bases to develop and learn a new language in. The approach you exactly described stood out as one of the best options that exists today to emulate that approach. I'd recommend this to anyone looking to build their skills in a new language. It also doesn't hurt that contributing to open-source will be something you can later show off if needed!

Someone really should build a site that can help people find a good open source library to contribute to.

Collapse
Collapse
 
codemouse92 profile image
Jason C. McDonald

YES! I find that I learn a language fastest and best when I'm reading through code written in that language...assuming it is halfway decently intent-commented and/or documented so you know what it was supposed to do. :3

That said, I also watched one of my teams learn a LOT about C++ by reading through some very poorly documented spaghetti code and working out what it was doing, and why. (Their efforts later led to the open source project being able to refactor a performance-critical part of the code.)

Collapse
 
rubyandcoffee profile image
Alexandra Wolfe

Really great article, surprised many others (including myself!) hadn't thought of this before. I've been programming for a while and still haven't really contributed to open source - but I suppose you're right, you don't need to be an expert, you can just start on simple pull requests.
Thanks for writing - this was really interesting.
In fact, I'm going to contribute to something tonight!

Collapse
 
olivercole profile image
Oliver Cole

The difficulty is in finding a good quality project. I nearly learned Python just to contribute to a project I liked using and believed in - then I found a whole bunch of discussion on Reddit about how the maintainer didn't know what they were doing, refused to update dependencies, esoteric coding style, wasn't open to debate, etc etc.

So I never learned, and never made the pull request :(

Collapse
 
llexical profile image
Lizzie

I don't do it on open source projects, but I have always found the best way to learn a new language is to find a project and add to it. It also makes you an awesome employee because you are happy and able to learn on the job

The only thing time I would say it is different is if the inheritance pattern or some other major feature is very different from what you know OR it is your first programming language. Then it's best to do some research on differences or learn the basics before you dive in! I have learned multiple languages this way.

I think I am going to start with open source next time I want a new language though, it sounds fun!

Collapse
 
gregorgonzalez profile image
Gregor Gonzalez

That is the best idea, learn by studying other people code.

When I started to work, they had a really big ERP system and I started by following their patterns and methods. Was hard because there wasn't documentation and every one was so occupied and no one could explain anything to me. Reading the code I realised that I don't needed the documentation because methods/functions are really simple and self explanatory. I followed the pattern blinded till I realised why they need it.

All pieces fit and now I do the same study everytime and any project.

Collapse
 
kaverigoj profile image
Kaveri Patil

"I have never received even a single comment which was insulting or demotivating. Everyone is super encouraging and helpful." --This is the only reason I love open source community and I want to be part of it.

Collapse
 
srebalaji profile image
Srebalaji Thirumalai

Very good article. I used to always wonder how to find those open source projects to get started. Is there any way to find the suitable open source projects to contribute ?
Thank you.

Collapse
 
timwillsie profile image
Willi 👨🏼‍💻

I once came across this twitter account which showed github projects and their beginner issues for your first PR:

twitter.com/yourfirstpr?lang=de

Maybe it's worth a look.

Cheers, Tim.

Update:

Here are other sources for the first PR:
open-source.now.sh/
up-for-grabs.net/#/

found in this german blog post:
t3n.de/news/open-source-einsteiger...

Collapse
 
dennisfen profile image
Denis Borisevich

Thanks for the links, Willi! I always had hard time finding entry-level issues to work on when learning new tech.

Collapse
 
trustnoone profile image
Giovanni Caporaletti

Anyone here who learned haskell or scala or rust and contributed to a project after 2 days? :)

Collapse
 
souravbadami profile image
Sourav Badami

Good read! Thanks, Sahil!

I've done an article on First Contribution to Open Source!, bit.ly/first-contribution.
Do give it a pass if you are a new contributor and just want to get started.