Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I know Java, C#, C++. I have used Perl, and am picking up Python and Actionscript 3.

This is certainly a path others have trodden, so I am asking how do you keep all these languages straight in your head?

share|improve this question

migrated from stackoverflow.com Jul 19 '11 at 20:38

This question came from our site for professional and enthusiast programmers.

13  
I don't. I use a debugger ;-) –  PengOne Jul 19 '11 at 20:37
1  
Practice makes perfect. Languages generally employ the same set of computer science constructs, so it's a simple matter of remembering syntactic differences and feature offerings. –  retrodrone Jul 19 '11 at 20:37
15  
editor with syntax highlighting. keep editing until it changes color... –  thorsten müller Jul 19 '11 at 20:51
2  
I don't. I use Google. –  Job Jul 19 '11 at 22:28
1  
@John, give us some examples of things you tend to confuse or forget across languages (builtin method names? operator precedence? libraries? idioms?) How frequently do you switch between languages (monthly? hourly?) –  smci Jul 20 '11 at 1:35

14 Answers 14

up vote 15 down vote accepted

Your brain only remembers what it considers important, with heavy bias towards the recent. So, just rotate pet projects in those languages and you'll be alright. Just like spoken languages, you'll do better if you: start early and keep your use active.

share|improve this answer

I used to post a 1-sheet railroad-style syntax diagram plus quick reference for each language on the wall until my memory kicked in sufficiently.

Still have to do that for any programming languages I haven't used in many months.

share|improve this answer
3  
+1 for not being all, "Well if you're a real programmer, you won't have any problems." If you program in enough different languages, syntax references are a must. –  Satanicpuppy Jul 19 '11 at 20:47
4  
Could you please post that "1-sheet railroad-style syntax diagram plus quick reference" for C++? I'd really like to see such a beast. –  sbi Jul 20 '11 at 9:31
    
Or one for Perl. That would be a sight to see. –  Zhehao Mao Jul 25 '11 at 16:09
    
If you need more than you can fit on one page, you probably shouldn't be using those language features yet, until you remember the language better. –  hotpaw2 Jul 25 '11 at 20:27

Have you looked into cheat-sheets for the languages and libraries you use regularly? I have a couple on my wall here, one for VIM and one for PL/SQL. This website: http://devcheatsheet.com/ seems to have many cheatsheets.

I suggest cheat-sheets because there's only so much the brain can easily remember. A language you use on a daily basis will become very easy to remember. Syntax and later certain libraries and functions and frameworks if you use them often enough and you won't need to look anything up in any reference material. The less you use something, the harder it is to remember, though you'll usually be able to regain your former abilities with a little practice. Which is why I keep some cheat-sheets up on my wall: for the functions/features I don't use often enough to remember quickly.

share|improve this answer

The human brain is an amazing thing. If you learn each one well enough, you should be able to look at code, recognize the language, and ramp back up to speed fairly quickly. It's never been a problem for me... but it does take time to ramp back up to speed.

share|improve this answer

I have little trouble separating languages in my head, apart from a few typing automatisms (such as having to suppress the end-of-line semicolon in Python or VB).

I guess the thing that helps me the most is that whenever I learn a language (programming or human), I also try to pick up and embrace the culture and ecosystem into which it is embedded. I'm not merely switching languages, I'm switching mindsets (something along the lines of the popular 'wearing the X hat' metaphor).

share|improve this answer
    
+1 for following conventions for a language. It can be tempting to just code every language with the same style but that makes it look very "foreign" to "natives." Someday, a "native" programmer will be maintaining our code. So we must write it in a way that feels natural for them. –  gMale Jul 20 '11 at 6:38
    
@gMale: It's not only a matter of being nice to others; embracing a language's culture is also necessary to use it to its full potential. A culture grows around a language because certain ways turn out to work better than others, and those solidify in the culture; by learning these, you can benefit from others' mistakes. –  tdammers Jul 20 '11 at 6:44

It helps that all the languages you mention are relatively similar (ie imperative).

If you are just learning to use these languages they are all very similar. They basically all have the same features and all you are learning is a slightly different syntax.

Now when you come to learn the usage (not just the syntax) then it becomes way harder. Learning to use Java like a Java Programmer is not that simple for a C++ programmer (the syntax is easy the usage idioms are difficult).

Now if you had listed different styles of language (declarative/functional/logical) then I would be more sympathetic. As moving between languages were the paradigm completely shifts becomes a lot harder.

But using a language is the key. If you use a language everyday then you will not have a problem. Stop using a language and it will fade (not fast at first). But the further the language is from the language you use daily the faster it will fade. The secret is to keep practicing the languages you like (stop using the ones you dislike your brain will make room for other stuff).

share|improve this answer

That's were the IDEs come for a rescue ;-) only thing changes in all these languages is to either have a 'if-then-else' or a 'if-else'. some will have '(' and some won't. Its as simple as that :)

All we care is the logic and the easiest readable implementation.

share|improve this answer

I don't. I confuse them all the time, so I've worked out a set of compensating behaviors and tools.

  • I'm working in the codebases of large projects, so I will check the code around me.
  • I use a syntax highlighting editor (quick, does Perl use elsif, elif, or else if? I don't remember, but the editor will keep me on track.)
  • I use the language idioms -- if I'm coding in C#, I use lambdas, linq and var. That makes it look less like Java than it would if I was only using objects and classes.
  • I use a different environment for each language: C# -> Visual Studio, Java -> Eclipse, Perl -> Vim. The different visual styles keep me on track.
share|improve this answer

One way would be to use a distinct style for each language in which you write. By loose analogy, in speaking Spanish or French, one might try to emulate the inflection of a native speaker.

I've seen people that will maintain a distinct bracing, indentation, etc., for each language to help their brain "shift gears" properly when switching between them

share|improve this answer

Think of it like music. The languages you learn are just different instruments in an orchestra that ultimately produce the same notes. Remembering how to play the instruments takes practice, but eventually you'll be able to pick one up you haven't played in a while and like magic the notes just fall into place. Similarly, as you continue to broaden your knowledge of music (programming), picking up a new instrument and learning to play it becomes easier and easier each time.

Cheesy analogy, but at the end of the day, practice makes perfect. Spend some time with each instrument in that orchestra every now and then so that your ability to play the notes doesn't fade.

share|improve this answer

I'm mainly a PHP developer. So forgive my biased opinion.

I have recently discovered just how similar C code is to PHP (Or the other way around depending on how you feel ;) )

My suggestion would be to perhaps stick to a family of languages (if they apply to your work or projects) and as you develop your skills further then branch off and learn new things.

share|improve this answer

i'am using javascript and HTML/CSS mainly also i love c++ when i need a little helping tool with using QT and i use VB and f# sometimes i know it's a little bit crazy but when i feel that i started to lose a language of those especially when thay have different syntax (VB and F# and c++/javascript) so i get my brother and told him that i am gonna teach him then i just start making examples from scratch and when i find that i dont remember how exactly to do something(once i forgot how to do IF ELSE in VB)i just google it;

share|improve this answer

Lately, I've been using google codesearch a lot. I go there and type in a regular expression that loosely describes what I'm trying to do and find dozens of examples of production code. When I forget a language's syntax, this is the fastest way for me to get answers.

This approach becomes even more powerful if you're good with regular expressions. Note: This is a great resource to refresh regex skills.

share|improve this answer

Actually: I don't worry much about explicitely trying to build any kind of structure within my head.

This doesn't differ a lot from other scenarios in daily life. I have to remember how to drive a car, how to read a book, how to play tennis, and so on. Just trust your brain and don't think a lot on the metalevel.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.