8 points · by confused_coder · 11y ago · 9 comments
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.
http://www.jsoftware.com/help/jforc/contents.htm
That's not to say that it will redirect your career from C programming to J programming (my impression is that there are not a huge number of all day every day J programming jobs). But rather, J is one of those languages that requires people to change the way they think about programming languages. It's pretty amazing in my opinion, but I've been drinking the Kool-Aid ever since coming across the book.
It's much like switching from Qwerty to Dvorak. When you first do it, if you do it right, you will forget how to type in Qwerty. It's only after switching between them a couple times, re-learning the previous layout, that you'll become fluent in both. Switching does become easier after the first few times, though.
For example, when doing python, don't write cli tools (although you can very well do that with python). Write a web app or learn Django and try and build something using the framework. Focus on the spaces where people claim the language is best suited for. When switching back to C, do systems level programming.
Also, set your goals (ie: what you'd like to build using the language) according to the strengths of the language. Off the top of my head, here's something I would suggest:
Ruby -- Build a webapp -- possibly a complex enough app. Aim big -- like gitorious perhaps. Focus on learning rather than completion.
Python -- Build a game
C -- Contribute to the linux kernel :)
...you get the drift, I guess