views:

231

answers:

9

Does anybody have any tips for utilizing multiple languages at the same time? I use objective-c, c, perl, ruby, bash, ksh, rails, and other proprietary languages every day and am finding increasingly difficult to go back and forth between them on a daily basis. As a trivial example when switching between perl and ruby I constantly forget to use semi-colons in perl and find myself using $ for local vars in ruby. Things are even worse going from objective-c to c: I use function calls (instead meesage invocations) in objective-c. Does anybody have any tips on making working in several languages more productive?

For those of you suggesting IDEs as a solution, although I agree in principle with using an IDE to increase productivity. I tend to do all my coding in vi

+4  A: 

In my personal experience it's horrible to do this kind of task and technology switching, it totally messes up your brain, at the end of a day you're more a cabbage than a tired programmer. Don't do it. If your company forces you to do it start searching another job, if you are doing it for yourself, think once more if you really want this.

fritzone
@fritzone yes I agree completely! many of my clients have systems that are written in a haphazard way and while I suggest standardizing on a particular platform and then mention the cost they are reluctant to do so
ennuikiller
I find it relatively easy to switch between several languages - Python, Perl, PHP and bash scripting. I definitely make more mistakes than usual, but it's a fun challenge (sadistic?) to keep track of what I'm programming in :)
jonstjohn
Sometimes you don't have a choice. Look at having to develop webapps with php/python/sql on the server side, and ajax on the client end.
Alan S
oh, yeah, not to mention javascript, then switching between jQuery and mooTools. Then there is SQL/MySQL - typing 'ls' instead of 'show tables'. And stored procedures and functions, oh my! Next try to speak english sensibly to your colleagues!
jonstjohn
+1  A: 

While it gets better in time, the ability to do this kind of switching between a lot of languages on a daily basis is not for everyone. You should try "clustering" your work in such a way that you finish what you have to do in one language before taking a short break and moving on to the next. This would prevent you going back and forth and impose a schedule that will be easier to follow if you stick to it.

luvieere
+2  A: 

I use Java, Python, C, C++ and PHP(!) almost daily, and also trying to learn some more like Clojure and Perl. The best thing to do is to use a good, language-aware, syntax-highlighting, autoformatting editor/IDE that reveals trivial syntax mistakes right away. It definitely helps in switching the language mode of the brain.

I don't think that being able to code in multiple languages is much different from being able to move with a bus, car, bike or foot. The details differ, but the main idea is approximately the same.

Joonas Pulakka
+6  A: 

A couple of tips:

  1. Slow Down! We're used to working at a frenetic pace as developers. Switching between languages requires some more conscious thought and focus.

  2. Use a good IDE - that shows your errors as you type them. This will be a gentle reminder that you are missing that semi-colon or leaving out a '$' (in many cases)

I have the same issue from time-to-time, but these two things help!

jonstjohn
A: 

Frequently in my current job I will use different languages, the key for me to making this easier is to get the right tooling. There are some very good general purpose editors out there, which already have a long list of Syntax highlighters, checkers and even autocompletion. Most of which can be further customised. If you set these up to recognised the file extensions then a lot of the pain can be removed. I generally use these in addition to IDEs, as most IDEs won't support ksh or other scripting, and are harder to customise so having another tool setup makes it easy to flick across. Ideally get one that runs both on Windows and the nixes I've been using these for some time now jedit nedit
emacs textpad

Wiretap
+1  A: 

To issue a less abstract suggestion:

There are lots of plugins for Eclipse, and you can make it do most programming languages known to mankind (and probably a few not). However, many of those plugins are less than perfectly integrated. One is annoyingly full of advertisement for its creating company, another one is a memory hog...

For those who haven't heard about it: IntelliJ IDEA has gone (partially) Open Source, and in my experience it's very good at multi-language. I saw a demo a year ago where one of their developers built a program in 6 different languages. A toy, yes, but the IDE did a fine job on language-aware syntax highlighting, refactoring and so forth.

It won't do all your detail work for you, but it can help with some of it - and with good quality.

Carl Smotricz
+2  A: 

Human memory is very context sensitive. Instead of going for one IDE/editor that covers all languages and helps you with error detection and syntax highlighting, you might want to consider going for one editor per language. I know this sounds like overkill and it probably is, so an alternative might be different themes for the editor that you switch when you switch languages. As a drastic example consider yourself using a red background when writing bash scripts and a blue background for your Python programming. With visual clues like that it should be much easier to distinguish what you are currently doing and after a little while this might work without any conscious effort.

innaM
Nice idea. I'm working on some language-switch intensive work these days (between python and C++) and sometimes get confused. I've just changed a couple of details in the color scheme for both. So hopefully, my brain will learn that "girly purple and dark red" is C++, and "peaceful teal and green" means python.
Kena
+1  A: 

My recommendation is to give yourself a 15 minute break between switching languages. If you can't do that since you flip between client / server apps, then I would recommend dual screens. Separate client on left and server on right. As someone has already stated, the human mind is context sensitive. Therefore, the way you think and analyze things has a lot to do with it. Any way you can seperate the different contexes would help in making minor oops on a regular basis.

0A0D
+1  A: 

Bullet point summary of things I've tried that have helped me:

  • Whenever reasonable & possible, take a break when you're switching languages
  • Use languages which are synergistic
  • Use consistent coding styles across languages

More detail from personal experience:

Switching like this can be very difficult. I've been in similar circumstances - earlier this year I was developing a web app at work with PHP, IDL (Interactive Data Language), JavaScript and some Bash and then doing some projects at home with Python. I found myself making lots of mistakes with syntax when switching from one to another.

The mistakes happened most commonly at work: E.g. when I'd been doing IDL for a while and then would switch to the PHP, I would forget to put dollar signs on the front of variables and semi-colons at the end of the lines. I didn't seem to have as many problems at home; I believe that was at least partly because it was always a few hours between getting home and starting my Python work, so the break probably helped my brain re-set from the languages I was using at work.

One thing that can help is finding languages with certain synergies: I've found that I can switch relatively easily between Python and Java ... yeah, I am still more likely to forget semi-colons at the end of my Java lines if I've been doing Python, but the two languages "sync" well in my brain, so switching isn't as difficult as going from Python to Perl, for example. I've also found it relatively easy to switch between Perl & PHP. YMMV, of course, and I expect different people will find synergies between different sets of languages.

Also, as much as you can, it may help to maintain a consistent coding style between languages. An example: for years I put an opening brace on the line after an if, for, etc. in Java, C, Perl, etc. However, after using Python as my main language for a few years, I've found that I no longer like that style, and have switched to putting opening braces at the end of lines. For me, this has helped create a more consistent appearance across languages, which I find helps ease the switching. Again YMMV.

GreenMatt