Hacker News

Ask HN: What is your best way to learn a new programming language?

I want to learn Python for web development. Programming is totally new to me.

So what's the best way to learn it and maybe the fastest?

What would be your learning methods? Do you have any tips/hacks etc that works for you?

7 pointsat_n posted 3 months ago8 Comments
8 Comments:
pandaRage said 3 months ago:

1. Do some research and look for a good book on python, or possibly a MOOC/set of videos.

2. Follow the content, make sure you understand the concepts. Don't just read the material, it's recommended to code what you're reading so you spend time understanding what you're coding.

3. Solve some exercises.

4. Once you've covered the fundamentals, go and start off with a project. Start with a small project, then create bigger ones.

Essentially, cover the fundamentals and understand them, then go ahead with a project. The real learning is in the projects you'll build as you'll find gaps in your knowledge that you'll cover on the way. But it's good to study the fundamentals so you have a starting point and aren't completely lost.

There are a lot of good books for an introduction to Python, "Automate the boring stuff"[1], "Think Python"[2], and many more. These two are actually available for free online. Someone here can probably recommend some better books or you can look up other recommendations online.

EDIT: formatting

[1] https://automatetheboringstuff.com/

[2] https://greenteapress.com/wp/think-python-2e/

sn9 said 3 months ago:

My recommended route: Harvard's CS50x on edx -> Think Python 2ed -> https://www.obeythetestinggoat.com/pages/book.html#toc

You don't need to take CS50, but it's the probably the best introduction to programming available online and will give you a strong foundation that will make the later books easier to work through.

hackermailman said 3 months ago:

My method is always make yourself small examples to study as you read. So if you're reading a Python book chapter on lists, stop reading and open emacs or whatever editor and write yourself some lists. If it's a section on stacks/queues, make a toy stack or queue model. This is the only way I was able to read some difficult texts in programming theory, by making sure I understood what I was reading before continuing the chapter, sometimes this took a few days stuck on one topic. My course recommendation after that green tea press introduction is https://www.cs.cmu.edu/~112/schedule.html notice that each topic has video buttons to watch a short youtube lecture, and notice the 'weekly practice' 'hw' and 'labs' on the right side. These are all open and come with a linter to enforce class scope and a solution test suite.

gvand said 3 months ago:

If you have never programmed before I wouldn't care about the fastest, you risk learning nothing fast.

Avoid any hacks, shortcuts or methods more appropriate for less practical subjects.

Find a good and definitely not concise book or a good MOOC that explains all the basic concepts with lots of examples you can try in a Jupyter notebook. The more you code the more you learn.

algaeontoast said 3 months ago:

I recommend by first reading through a high-level style guide. Guides produced by larger orgs like FaceBook, Etsy etc are usually a good starting point - high level but without too much technical mud.

After that, depending on whether you like getting your feet wet or taking a more formal approach my two go to methods are either: 1) reading through a "code by example" for the lang or 2) finding a cool relatively simple project written in the lang and stepping back to the very first commit and reading diffs from there (I also recommend this technique for picking up design pattern / design strategies in general)

ohboyya774 said 3 months ago:

you can read all the books you want, cover all the moocs you want, but in the end nothing gets your noodle working more than working on a project of interest

zzo38computer said 3 months ago:

My way to do it is: Read all of the instructions, and then write a program. If the program is wrong, then correct it. If something is unclear, see if there are examples, and possibly parts of other programs can also be used as a example.

slipwalker said 3 months ago:

my 2 cents: write unit tests in it. go check some simple code out there ( github ) and cover it with tests, rinse and repeat...