tags:

views:

231

answers:

8

Hi,

This is obviously a subjective question. But I think many people would relate to this. One of the main problems I face as a developer is that I can only keep one language (Java or C++) in my head.

What I mean is that if I have to work on 2 projects: 1 Java and 1 C++ simultaneously then I have a very bad time managing the two. I use the syntax of one in another. I assume some things in C++ when actually those things are only true in Java etc. etc.

Any suggestions in handling this problem and maintaining proficiency in C++ and Java simultaneously.

Thanks Ajay

A: 

Excellent question. In many (non-intro) CS courses, the instructors fully recognize this problem and allow the tests to be open-book, open-notes, so students can look up things like is it "Stack.Count() or Stack.Size() ... ?" .

In Ruby, this problem is solved by implementing most variations that you can think of. That is, for the "Stack.Count() or Stack.Size() ... ?", both (and most everything else you can think of) will work wonderfully.

But, to answer your question, there is really no good answer except to keep those reference books (or websites) handy. As a time reliever, you can try to always write your algorithms in pseudocode and then go back and implement it in the proper language (rather than writing it all out in C++ painstakingly and then realizing it needs to be Java). As time goes by, you'll adapt to the situation better and commit more of each language (and the differences therein) to memory.

But really, as the saying goes "Jack of all Trades, Master of None".

rlb.usa
+3  A: 

You need to find a way to remind yourself constantly what you're working on. The best way is to have your editor or IDE do that for you. The IDE can know what you're working on and, through syntax and error highlighting, tell you when you've violated the rules of that language.

If that's not good enough or not available, try some things that will help trick your mind into keeping the information about using the two languages separate. Use different color schemes in your editors to correspond to the language. If possible, code from different workstations or different monitors at the same workstation.

Also, different languages can have different standards for code. For example, Java has very specific recommendations for capitalization of classes, methods, and variables. Make sure you know the standards for each language and use the appropriate standard for each. If you try to make one language look like the other, you'll be much more likely to mix them up in your head.

But, as with everything, the best thing is practice. The more you code in multiple languages at once, the better you'll get at doing it and not mixing them up. But, you're going to do it lots and lots in the process, so don't treat yourself too badly about it.

Erick Robertson
Are there good IDEs for C++ ? That I can use for managing projects, has intelli-sense, syntax highlighting etc ?
ajay
I've heard both good and bad things about both Eclipse and Visual Studio.
rlb.usa
@ajay You are not writing your C++ code without an IDE are you? Well, you can do that if you want of course, but there are lots of (free) IDEs for C++ that will make life easier.
anon
+1 to Butterworth about that. While it's great to learn the basics with ye ole' text editor typing out `public void main( ... ` by hand, it's much more productive once you're past this stage to pick up an IDE. Syntax highlighting, auto complete, debugging, hover-over information, etc will all make your life easier and more efficient.
rlb.usa
ajay
@ajay well, Eclipse can be used to program in C++ too (though it would not be my choice).
anon
I used emacs for c++ development for many years. It does syntax highlighting and auto-indenting. I have never used an IDE for C++ except for a couple minutes when I tried Visual Studio.
Erick Robertson
@Erick So by your own admission, you don't really know what you are missing out on, do you.
anon
With Visual Studio, or with IDE's in general? I use Eclipse for Java and it's awesome. Every version of Visual Studio I used always had too much overhead for the machine to deal with. It was slow, and crashed a lot. What IDE's do you recommend for C++?
Erick Robertson
@Erick For low overhead try CodeBlocks at http://www.codeblocks.org. But seriously, Eclipse is lean and mean compared with VS? I would not have said so, but then I use neither of them myself. And anway, if you like Eclipse for Java, why not for C++?
anon
I don't know. I haven't needed to use C++ since I started using Eclipse. It's worth a try.
Erick Robertson
Visual Studio is an amazing IDE. Any computer that is intended for serious development can run it flawlessy. I don't know why there are so many MS haters.
Itsik
@Itsik You can disagree with the path that MS has pursued for VS since VC++ 6.0 without being an irrational MS hater.
anon
When I write code, I like to know what it's compiling into, and what that code has to go through to be executed. Windows is partially black-box, layers of unavailable code, and hidden API's. That is the #1 reason I don't do Windows development. An effective requirement to use Visual Studio is #2.
Erick Robertson
A: 

Why would you want to do projects in both languages simultaneously? Isn't it better to become an expert in one and then stick to it? I might be young and inexperienced, but as I see it there's to much going on in IT currently to be proficient in too many things. Sure you can be a professional java programmer, who knows this and that about C++ (and actually stuff I learned while learning C/C++ like linked lists, what are pointers etc. help me out even during Java interviews), but I doubt it's possible (and necessary!) to be really really proficient in both languages all the time (on the other hand I also doubt you'll forget everything as time goes by, programming is like riding a bike, once you learn it you never forget it). I mean do you really expect a brilliant violinist to be a brilliant cello player? Sure the instruments seem pretty similar, but they are two different instruments!

Zenzen
At my current Job i maintain 2 services, one is in java and other in C++. And there are good reasons for them to be in those languages.
ajay
I suspect you have not much work experience - in many places most work is on existing systems and you have to use the tools they started with and decisions will have been made to do different projects in different languages and thus your programmers have to switch depending on priorities
Mark
I agree with Mark. Avoiding leaning new things is never a good philosophy to take.
rlb.usa
I'm not saying, that things like that don't occur (I am fully aware of this situation). What I mean is that wouldn't it be better do get someone to take care of the C++ part and someone to maintain the Java code? I know there are many talented coders out there, but are they really able to keep up with the trends in both technologies? In a company I worked last year there was a transition from one language to another one, but there were 2 different teams (one for maintenace of the old stuff and one which was supposed to write the new one).
Zenzen
For small companies, especially, programmers are expected to be both versatile and talented. Often, I am assigned multi-language projects and expected to do as the specs say. I can't really "hand it off" to another co-worker.
rlb.usa
What do you do when you need 5 people to fix a C++ issue this week and 7 people to do new java work the next week. Also what do you do if you have a C++ client talking to a java server - much easier for one person to debug a issue there.
Mark
@rlb.usa - large companies (e.g. > 2000 IT staff) do that as well
Mark
Yes but can you call yourself a profesional in all those languages? Sure I can also say I could work with Java, C/C++, Flex, databases, heck even some ASM, but OP asked about being "proficient" in both those languages, and as the dictionary says "Having or marked by an advanced degree of competence, as in an art, vocation, profession, or branch of learning. An expert; an adept." Can you really be an expert in multiple languages?
Zenzen
@ZenZen Yes, you can be.
anon
@Zenze - yes - or at least job adverts ask for experts in several languages
Mark
Seeing Neil's comment - look at people on Stack Overflow with large reputation - they often answer for several languahes
Mark
And consider languages like ASP.NET and SQL - if you are an expert in one, you are probably an expert in the other. Some languages just go hand-in-hand like that.
rlb.usa
You don't need to "keep up with trends" in a language to be proficient in it. Most trends aren't even worth keeping up with - otherwise they would be called standards.
Erick Robertson
A: 

I can certainly understand the feeling. I'm currently working on a project where I need to write both Java and Python code. And while Python is a relatively easy language to learn, it's further from Java than C++, in my opinion. I can also recall taking a CS course using C#, and the TA was helping me and started trying to type out System.out.println...

The easy answer is "don't do it" -- get a second (or more) person on the project and use distribution of labor to get things done. But that's not always possible. After that, the answer could be "suck it up", and learn to death with the switching, which is what I'm doing on my Python/Java project.

In general, though, I think you should be fine with a reference book or two, the internet, and programming smarts.

Brian S
The "don't do it" philosophy doesn't agree with The Industry very much >_o
rlb.usa
Unfortunately true =/
Brian S
+5  A: 

Almost all projects I've worked on have involved multiple languages. a typical mix might be:

  • Legacy C code
  • C++ for the new server
  • Java or VB or C# for the GUI and for test harnesses
  • SQL for defining and querying the database
  • Transact-SQL for stored procedures
  • UNIX shell scripts for glue

And you have to be good at all of them I'm afraid - that's what being a programmer is all about. I really don't have any problems switching between them, but one will of course prefer some languages above others.

anon
I don't have problems with any other language because they have very different syntaxes.It is only C++ and Java together that causes problems.
ajay
@ajay I must admit I've never thought of Java and C++ as being similar.
anon
@Neil Absolutely agreed.
DeadMG
Even in comparison to VB, Perl, and Python?
Erick Robertson
@Erick I think Java is far more similar to VB and Python than it is to C++.
anon
Interesting. I always think of C# as a fusion of Java and C++...
Brian S
Java and C++ both are known quantities as far as what they compile into. Java byte code is similar to machine code. If C# appears to be a fusion of the two, it must only be in language construct. The end product is nowhere near.
Erick Robertson
+2  A: 

Time and Persistence. :)

This used to bite me when I was transitioning from a C++ role to a Java/C++ role. 5 years on, its ingrained. You get used to it.

tholomew
A: 

Great information that Eric provided! I'm currently jumping back and forth from JAVA to C++, the compiler reminds me if I do something I'm used to in C++. Eclipse and visual studio are very different and are very helpful when going back and forth between the languages.

Also like Erick mention, the more you program between different languages the better you will get at it.

Coder
A: 

I have had to do the same thing and its all phooey when someone says you can be proficient in both languages:

  1. For things like method names and classnames libraries etc., let the IDE be your friend.
  2. For deeper things like how the language works, the subtle differences of datastructures, multi-threading etc., keep a quick lookup running list. This is what I do. Its not only java, C++- it could be some new language that I am learning. Or something that I switch to for one project and then dont go back for a couple of years. That way a perusal of your list will do a memory refresh. It has worked so far. I am back to java now after a two year hiatus, things have changed a lot in some ways.

It helps me to remember things better when I know the WHYs of things, like why a certain thing works that way rather than how it works.

my two cents

unmaskableinterrupt