Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do you change the way you think when moving between Java and C#

Tags:

java

c#

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?

like image 404
Omar Kooheji Avatar asked Oct 08 '08 13:10

Omar Kooheji


People also ask

Is C or Java easier to learn?

It's a general consensus that Java is easier to learn because its syntax is closer to natural language than C.

Is C similar to Java?

C is a procedural, low level, and compiled language. Java is an object-oriented, high level, and interpreted language. Java uses objects, while C uses functions. Java is easier to learn and use because it's high level, while C can do more and perform faster because it's closer to machine code.

Why is Java better than C?

Java is more data-oriented. C is a middle-level language because binding of the gaps takes place between machine level language and high-level languages. Java is a high-level language because translation of code takes place into machine language using compiler or interpreter.

What are the differences between Java and C#?

C# uses CLR (Common Language Runtime), whereas Java uses JRE (Java Runtime Environment). It is also object-oriented, functional, strongly typed, and component-oriented, while Java is only object-oriented. C# supports operator overloading for multiple operators.


1 Answers

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) vs for (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.

like image 173
Jon Skeet Avatar answered Sep 18 '22 05:09

Jon Skeet