Live data from Hacker News

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

news.ycombinator.com

11–20 of 45 posts

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

#11

Lots of different techniques. 1. Write a program in the language that I've done before just to get familiar with the tooling. My go to for years was a better Eliza clone. From 1991-2008, I wrote it in AppleSoft Basic, GW Basic,HyperCard, VMS DCL, Visual Basic, C#, PHP, and JavaScript. 2. On the job. I hate hobby side projects. I'm not creative enough to come up with anything interesting and I feel like it's a waste o…

Point 2 is spot on. I sometimes make projects that nobody will ever use, not even me. I heard this advice from someone. Make lots of throwaway projects to get familiar with the technology. But I took it too far. I only used it to make throwaway projects. Now will make something that is useful. Thanks for all the insights. Very helpful.

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

#12
post #7

Usually I’d suggest picking up a small project and shuffling between books and working on that project. Say read about the language fundamentals and then try to build up from there. However this doesn’t really work when you’re switching to a different paradigm. When I switched to Haskell, I realized that even the way you think about things must change and diving into a project just isn’t the way to do this. You’ll ke…

I make this mistake a lot. When learning new language, I think just learning syntax is enough. I had to forget PHP to work with Node, as Node is asynchronous & when I was working with PHP it was synchronous. Just couldn't get my head around async code. Very helpful insights.

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

#13

Watch YouTube videos

The problem is you don't know what to watch. Earlier there was a problem when there was no YouTube & now it is problem because there are like tons of videos on a same thing & you can't be sure what to watch. Popularity is sometimes a flawed metric too. I have watched few awesome videos but the views for that were very low & I have watched some videos in which the view count is high but the content is mediocre.

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

#14
post #4

Yes. I usually do one or several projects to learn how a new language works. The projects I do depend on the language. I hate reading books and even moreso watching videos about a specific programming language, but thats prolly just my ADSD self. Here's a project I'd do for Swift. 1. Write a chat server / client. (this will quickly let you see how async/threads/channels works and how good the networking libs are). Yo…

The problem is it gets really irritating building the same thing again & again in multiple different languages. The only application I have repeated is a Todo App. But nice advice, I will apply it while learning Swift.

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

#15
post #8

Read the docs, read good code, build things, stackoverflow, ship.

This is exactly what I do now minus reading the docs. I never read the original docs for anything except React. I don't know what made me do that but I remember I tried reading it but it was too big & I felt intimidated. Although, the docs nowadays are good enough & not scary like Vue, React, etc...

I guess I should start reading the docs because sometimes the answer I find Googling is already present in the docs :)

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

#16
post #6

I had the same question when I wanted to learn C++. I was already quite practiced at Java and had written C and had read books on C++ off and on for years, but I still could not program in C++. So I got a copy of Stroustrup "The C++ Programming Language" and started to do his exercises, but the author clearly had never done them himself, some were quite long and tedious and did not teach me anything (never put exerci…

Wow this is so inspiring. This is something I'll do it with Swift what you did with C++ :)

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

#17
post #6

I had the same question when I wanted to learn C++. I was already quite practiced at Java and had written C and had read books on C++ off and on for years, but I still could not program in C++. So I got a copy of Stroustrup "The C++ Programming Language" and started to do his exercises, but the author clearly had never done them himself, some were quite long and tedious and did not teach me anything (never put exerci…

> SECRET SAUCE HERE: The key here was to actually write the program even if I was sure I had nothing to learn from it because the feature in question was so conceptually simple: you think you know something, but then when you go to actually type it in, you find out whether know it was well as you thought you did.

This is what I've done in my admittedly small time of programming. I have Learn Python the Hard Way and whenever I'm in between my personal projects, I grab one of the beginning chapters and just redo it. Rote memorization is not easy for me, but the more I do something over and over, the more engrained it is and the easier it is for me to recall and build on later for different things.

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

#18
For me, it's always writing an actual application...no toy or example programs. I suggest rewriting something you've implemented before, rather than new. The reason for this is that you've already solved the problem, you're just left to language semantics. Trying to tackle a new application is fine, too, but may cloud your judgment on the language if it becomes a hard problem to solve, or just plain boring.

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

#19
I usually write something small that I've written multiple times before. I try to write it exactly like I would in whichever my currently most-used language is. It gets really painful in parts because languages differ. Sometimes the writing is the difficult part. Sometimes writing it in the same way is easy but the runtime performance is bad. Sometimes the tooling just doesn't support what I am trying. Finding these pain points helps me develop an intuitive sense for which of my habits I should steer clear of with the new language. After I consider how the new language would allow or encourage me to write it differently, I re-write it. Then I diff my original and final implementations.

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

#20
It helps to have a stock project or two that let you exercise I/O, data structures, standard library, benchmarking and so on.

For me I have a couple:

1) A nonlexical phrase extractor. Read in a lexicon of words, read in a narrative document, subtract words from the lexicon from the document, collect all remaining strings with word length > 2. Voila, most of them will be names of people.

2) Build an on disk bloom filter. Pretty straightforward, the most complicated part is finding suitable hash functions and figuring out how the local mmap library works and working out the arithmetic for bit flipping amongst a big array of bytes.

Neither of these are very complicated or require lots of work to set up. But when you're done you'll know most of the operators, how to read in and write out things, how to interact with the standard library, control flow and so on. I can usually hammer both of these out in an afternoon.

A few people I know have more advanced "simple" projects, like ones that require figuring out the local threading system, sockets and so on: e.g. write a simple web server. It kind of depends on what kind of work you generally do.

Post reply on HN