views:

506

answers:

14

At home I'm working on a large personal project written in Java. I recently found employment as a C# developer.

After an 8 hour workday reading C# code, I find it very hard to switch back to Java at home. Actually, my home project stalled almost completely since I've been employed.

At first I thought I'd have to wait for vacation to actually switch back to Java, but even after a week of not having C# on the brain, I did not manage to come into Java-mood again. I do not want to admit that my home project died, but I can't really see a way to overcome this issue.

+11  A: 

If it's that bad, can you start the project again in C#? It may be quicker than waiting for your java-mood to return. It should be quicker than starting from scratch, as you've coded the logic and domain already, so you may be able to translate-and-type your way through that bit.

harriyott
Possible, but besides the time required to port the existing code I also do not want to *resign*
mafutrct
@mafutrct: Exactly, "You don't change horses in midstream!" (but seriously, why not think of it as a re(de)sign instead of a resign)
Erich Mirabal
if (java_mood) { WorkInJava();}else { if (want_to_continue_project) { SwitchLanguage(); } else { Admit(IsDead(Project)); }}
harriyott
OK, so comments can't be formatted :-|
harriyott
java_mood seems more like an enum than a boolean. shouldn't it be if (in_a_java_mood) ...
Erich Mirabal
Probably should. Maybe best to think of it as pseudo-code...
harriyott
Turns out it took me only 20 hours to translate 90% of the code (115kb). I don't like this solution but hey, at least the project did not die. And I get to know C# better.
mafutrct
+9  A: 
  1. Use a good (and comparable) IDE in both. I switch between C# and Java, and find the combination of Visual Studio with JetBrains ReSharper for C# and IntelliJ Idea for Java makes this straightforward.

  2. Celebrate the differences - I find a spell in C# helps my Java and vice versa. Differences in, for example, the collection frameworks just help you understand the implementations in each language more deeply.

  3. Use the similarities to your advantage. Syntactically, the differences are not great. You should be writing code, not writing C# or writing Java. As Steve McConnell would put it, "code into the language and not in the language" (or something like that - think it's from Code Complete).

In fact, read Code Complete if you haven't already - great training for flipping between languages.

David M
Im not sure that would stop me trying to use the Java API in PHP :P
Aiden Bell
I really need to dig out my Code Complete book -- it's at the bottom of a pile of books. I didn't read past like the first few pages, lol.
Zack
@Aiden: I think he meant look for syntax similarities. I've found myself using about 3-5 languages within a week's time. C#, C++, PHP, etc.
Zack
+7  A: 

I suppose you could call this the habitual time to recovery,.

It can help to generalize to: programming logic knowledge + syntax and API = Language Knowledge ... because ...

Human beings are creatures of habit and build efficient work methods, memories and psychology based on environments and tasks we perform most often. This is a good thing.

I recently spent alot of time programming in Python, after being almost 100% C for a long time. I picked up Python quite easily and now am switching back to C. To my surprise, the problems I thought I would encounter (missing semi-colons, the random impulse to indent) were not there.

I concluded this is because:

  1. While I was programming Python, I was frequently (daily) looking at the C source of other projects to remember the ones I didn't document too well. Because my C projects fit in with the Python stuff.
  2. I was always looking at the C implementation of some of the Python stuff

I guess the trick is to relate new skills to old skills so that when you conduct tasks in the new skillset, your brain is still thinking about the old skills and how they related. Many theorise that learning is based on this relational foundation in your mind, and knowing about it can help you reduce the learning curve and time to recovery.

Think of it like a relational database. When you do something new, create a forign key and normalize things out. Don't create a whole new table or database.

Learn a generalization of programming logic and build on that with just the changes between languages. You will learn/switch faster.

Sorry for the bad RDBMS analogy

Aiden Bell
+4  A: 

Switching between two different frameworks is very hard to do. It's even harder if you haven't been doing them for very long.

The question, I think, has to come back to you in that you should ask yourself what you prefer now. If you still like Java and want to keep your skills up in Java, you will probably need to spend more time with it on a semi-daily basis. Working with it on nights and weekends and making sure there are no long breaks in between.

If you prefer C# now and really have no interest in persuing Java, I would convert the project at home to C# as that can only make you a better C# programmer and make you better at your day job.

TheCodeMonk
+2  A: 

I wonder if it's related to the similarities between those particular languages. Granted I've not actually used C#, but it seems pretty similar to Java. The similarities might make it difficult to context switch from work to hobby. Maybe you could learn and switch to Python, Haskell, Lisp, etc. for your personal project.

zimbu668
I thought the same. I bet there would not be as much confusion if they were not both c-style languages. I've found the same trouble moving back and forth with c++ to c#.
JimDaniel
+2  A: 

You could try spending some time programming in a completely different language in your spare time. For example, write something in Haskell, Prolog, Mercury, Oz, or Factor.

When (if?) you come back to Java, its similarities to C# will be much more striking than its differences.

Nat
A: 

I have a similar thing at work. I write code in JavaScript and c# but at home I write code in Python and JavaScript.

I have sometimes caught myself writing python style code in c# and then getting my tests failing. I agree with Nat that working in a language that is totally different from your work language will help you see the similarities and that they only differences will be where the libraries exist!

AutomatedTester
A: 

I think java is for the diligent, and .net is for the lazy. Perhaps someone would be angry for that,but I wanna say I am a .Neter.The .net syntax is less strict than the java's.In fact in the source code of .net,there is some simplify. for example,we can use Convert.toDateTime(string) to Convert a String to DateTime directly. But in java,we should make the difinition of the string's format such as "yyyy-dd-mm" then we can convert.

Edwin Tai
.NET gives you a choice. DateTime.ParseExact("yyyy-dd-MM") does an exact format conversion.
Jimmy
Another way of saying that is Java is for the repetitive, .NET is for the efficient :)
Erich Mirabal
Also, how does this tie back to the original question? Are you saying that the guy is lazy?
Erich Mirabal
+4  A: 

Firstly, if you've put in an 8 hour day programming in any language, it may not be switching languages so much as just needing a break from programming. I can only speak for myself, and I know some SO'ers may feel otherwise, but I often need a break from programming after a full work day of doing it.

Currently I prefer to program in Python, but my job wants me to do shell scripting, Java, JavaScript, PHP, and IDL (that's Interactive Data Language, not Interface Description Language). So, I try to do some Python at home to keep those skills from atrophying. What I find (in addition to often needing a break as mentioned above) is that I get my languages confused a lot when I first switch from one to another. It's easy at that point to give up, but I find that as I get mentally deeper into programming with a given language I make fewer mistakes from the language confusion. So, maybe if you can just push past that first reluctance to use Java, you'll have success. YMMV, of course, and good luck!

PTBNL
+5  A: 

This is because of something in psychology called the interference effect, or Stroop Effect. The two tasks are closely related (programming) so the knowledge brought into your mind by one language interferes with the knowledge brought into your mind by the other language.

Here's a cute example of a simple task that is hard to do because of this effect:

http://www.apa.org/science/stroop.html

Larry Watanabe
+2  A: 

That is normal. It may be a problem of Cognitive Flexibility and Inflexibility. It happens with human speech too.

Check yourself. If you are getting too tired to work at home after your regular 8 hour workday reading C# code, and also you want so much to finish your project, and now you find difficult to code in java, you may be suffering from anxiety. If you take some energy drink, coffee, cola, then you are favoring anxiety.

There are exercises for keeping yourself Cognitive Flexible. One of them is to switch for a while (couple of minutes) to Java instead of spending so much time in C#. It is like when you are programming in Java and have to switch to SQL, then to HTML. You are being flexible and switching.

Good luck.

dde
Sounds interesting. A short mental switch, not to actually be productive, but to keep the mind agile.
mafutrct
+5  A: 
Lance Roberts
+2  A: 

As I answer this i feel I need to make some assumptions here based on personal experience. I write code in C++ or c# on side projects while at work am forced to dangle between php and python There was a time i was without a steady day job and kept pretty busy on side projects.

When i landed my day job the enthusiasm i had for my side projects dwindled based on two major factors... Like you i was at my job 8 to 9 hrs a day.

2ndly i had an increased steady source of additional revenue so the motivation to code just to earn a living drastically reduced and i found myself more and more opting not to take up any new projects after work coz i jus wasnt in the mood anymore.

I also discovered that with this new attitude i started making rookie mistakes when coding in c++ unlike before. After changing my attitude things picked up again.

My best guess is that you are going through the same thing that i was going through. I suggest you find new ways to get motivated once you leave work and you will find it easier to continue programming in java.

Steve Obbayi
A: 

You know when you are overworked: it's when you try to find F1 key in the elevator cabin to launch it up!

Thevs