This is a question for anyone who has the pleasure to work in both Java and C#.
Do you find that you have to make a mental context switch of some kind when you move from one to the other?
I’m working in both at the moment and because the syntax and libraries are so similar and yet subtly different I’m finding it frustrating when i move from one to the other.
This is more so than I’ve experienced moving between any other programming languages.
Does anyone have any tips for making your brain work differently for languages that are so similar?
Yes, I have to make a mental context switch – because LINQ isn’t available in Java 🙁
Beyond that, there are little things like
foreach (X x in y)vsfor (X x : y)which often trip me up, but not a huge amount otherwise.As for a tip to make your brain work differently: don’t give into the temptation to use the naming conventions of the other language. I find that using camel-cased method names in Java is a good nudge to my brain, for example.
EDIT: The differences in terms of generics are important and can occasionally be brain-warping, too.