6 ms·
Write code in it. Lots of code. And not all your own code. Find books that give clear 'type it yourself' examples that you can follow along with, or books that
by jarcane 12y ago
Write code in it. Lots of code. And not all your own code.
Find books that give clear 'type it yourself' examples that you can follow along with, or books that test your ability to think in the language by giving you problems that need idiomatic code to be solved (perhaps the best example of a book like this that I've seen is The Little Schemer).
If there are 'koans' or 'katas' or similar interactive exercises for the language, find them and do them. All of them. I learned so much about basic style of a language from these. Try sites like Project Euler and Codewars.
Find tutorials like 'how to build an X in Y' and follow the whole thing from start to finish. It doesn't even necessarily matter, IME, whether the code is particularly good or idiomatic: once you've made a project of any considerable size you'll start to see the strengths and weaknesses of the code and the advantages of the native idioms.
Finally, find yourself at least two non-trivial personal projects to write in your new language, and just write. Write big code, that needs proper maintenance and bug-checking and testing. Don't worry so much about idioms yourself though, just write: when you go back over your code again, you'll see where you've gone wrong, and do better next time. Your first big project in a new language will be terrible. But you'll know exactly why it's terrible by the time it's done, and you'll do better next time.
This is what's helped me, anyhow; obv. everyone is different, I am not an expert, etc. etc. The important take away is that ultimately: "idioms" are just ways that people have found work best in the language; the best way to drill on the style of the language is just to use the language a lot and read the language a lot. Idiomatic code comes from practice, more than anything.