Someone sent me an email asking how I use multiple programming languages and how I keep them straight. I thought I’d write my answer here in case someone else had the same question.
I’ve learned programming languages out of a mixture of curiosity and necessity, maybe more of the latter. I’d rather use fewer languages, or at least use more languages out of curiosity.
Alan Perlis once said
A language that doesn’t affect the way you think about programming is not worth knowing.
In the spirit of Perlis, I’d say that it’s worthwhile to learn some programming languages just to expand your thinking. Learn a language outside your comfort zone, even if you don’t foresee any practical use for it. Expanding your mind is practical enough.
Another reason is to use multiple languages is to pick languages optimized for different tasks. For example, you might use SQL for interacting with relational databases, C++ for fine-grained control and efficiency, Perl for text munging, etc.
But keeping track of the differences between similar languages is just drudgery. When languages are very similar, there’s little educational or engineering reason to use both. But there may be good business reasons, such as preserving legacy code or serving different clients. Given a choice, I’d rather not use two similar languages, but often I do out of necessity.
So, how do you keep different programming languages straight?
- Try not to use similar languages in the same niche. Learn one system programming language, one scripting language, one markup language, etc. If you have to use two languages in a niche, pick one to learn well.
- Try to use one language at a time. Load that language’s syntax into your mental RAM and use it as long as you can before switching languages.
- Keep notes and save sample code.
Some of the more popular pages on my website are notes that I wrote for my own reference. Years ago I was confused about all the different kinds of strings I had to use in C++ and wrote these notes. And when I was learning PowerShell I wrote a cookbook of sorts.
Here are some more examples.
Regular expressions in:
Probability distributions in:
I’m glad people have found these notes useful, and I did have in mind that other people would read them, but I mostly wrote them for my own reference.