22

Edit:

How do you manage individual tasks when working on multiple languages

In day to day task handling, how many different programming languages do you work with?

  • Do you make a mental shift when working on each language?
  • Do you Prioritize them and keep each task per language separately.
  • Do you code in stages based on progress of each task switching seamlessly between languages/IDE/Environment
  • Do you apply the same coding style/conventions on all the languages (not syntax)?

Related:

Is it normal for programmer to work on multiple projects simultaneously

3

14 Answers 14

25

Today I've written Java, Python, C++, and SQL (if it counts). And I've been at work for less than 2 hours.

If you do this regularly, then the mental shift becomes negligible. It has nothing to do with multitasking. It's just like walking for a while, then driving a car, then driving a bike, then swimming. No problem, because they're sequential things.

Regardless, the point is to complete one task before moving to the next. I tend to define tasks in terms of a concrete functionality, fix, or such. Often that task is accomplished with only one language, but it may require several of them. For example, when working with JNI, you'll typically make changes to both the Java and native sides in parallel.

Some answers:

Do you code in stages based on progress on each task switching seamlessly between languages/IDE/Environment

It's important to be able to switch seamlessly between IDEs, editors, environments. Usually I keep them all open all the time.

Do you apply the same coding style /conventions on all the languages(Not syntax)?

If it's an interface over which two languages are talking, then yes - variable names and such must be similar. Otherwise, I try to apply the typical coding style of that language.

4
  • 8
    sounds like amazing race
    – setzamora
    Apr 6, 2011 at 9:06
  • I usually try to complete one task before moving to the next, but a single task may well require using more than one language. Using a polyglot IDE such as NetBeans, and/or keeping all the needed editors and environments open all the time is a must. Then you don't need to care much about the language (which is just an "implementation detail"), and you can concentrate on the task (which is part of what you're really supposed to accomplish - a working program). Apr 6, 2011 at 9:09
  • It would be nice if you can add the above to your answer and adding a bit about how you deal with coding /conventions programming styles.
    – Aditya P
    Apr 6, 2011 at 10:58
  • @AdityaGameProgrammer: Added some points. Apr 6, 2011 at 13:15
19

There's a pattern forming here:

  • Front end: whatever runs on a browser (javascript, html and css)
  • Business Logic: any of the whole plethora of general-purpose languages
  • Backend: SQL
  • Build Script: Some scripting language

So for me its: javascript, HTML, and CSS, C#, Transact-SQL, and Windows Powershell.


Do you apply same coding style /conventions on all the languages(Not syntax)?

No, I make a point of programming according to the convention of the language. A simple example:

   // C#
   int MyFunction() 
   {
       return 0;
   }

   // Javascript
   function myFunction() {
      return 0;
   }

Employing visually different coding conventions helps me make the mental shift between languages. Conversely, if my code looked the same in each language, I'm going to make syntactical errors from forgetting which language I'm coding in.

3
  • 1
    +1 Good answer.Its great you are able to maintain the language specific coding conventions and style.
    – Aditya P
    Apr 6, 2011 at 10:38
  • Well.. in some cases Javascript forces you to work this way due to the nasty implicit semicolon. But otherwise I'd see no reason to do that... Apr 7, 2011 at 4:49
  • Other than coding style, another way to ease up the mental shift between languages is to set up different color schemes for each language in your editors/IDE's.
    – Spoike
    Apr 14, 2011 at 6:30
5

As indicated by SK-logic the mental shift should not be a problem if you use well-choosen domain specific languages. But often you cannot choose the language, so it sometimes takes a moment to switch. In my experience the difficulty is more in switching syntax than in switching programming style. The only annoying shift that I always experience is the comment style shift: If I just open a file to quickly change a line of code, it often goes:

#  what
// the
;  f***
%  is
-- the one-line comment character or sequence?
4

In my last job: Java, C++, C#, JavaScript and VBScript.

But thankfully, all of the above were in very different contexts (and across a few products) - so once you knew each codebase well enough, the mental switch to different contexts was actually quite easy and logical.

In truth, what bothered me more was interruption by client support issues. Internally switching to a task in another language was never a problem in itself.

2

I work with 2 languages: c# and python.

I use them both in the same project, but obviously for different tasks.

When I'm working on a task, I work on that task until it is in a complete state, or until I can't concentrate on it any more. This means, if I have to switch between languages, there is little to no cognitive dissonance as I'll have already come out of thinking in either language when I'm done with the last task.

Admittedly I will take a short break when I come out of a task, which probably helps a lot.

2

As few as possible. It generally involves 1. Python, plus 2. HTML templating, 3. HTML+CSS and sometimes 4. Javascript. Switching from Python to JS definitely requires a mental shift, also because I need to use different tools.

I add HTML+CSS as separate from HTML templating even though the might not be languages per se (or they might, depends on your religion), because it also requires a mental shift and usage of other tools, although not so bad as switching to Javascript. Fiddling with HTML+CSS from a design perspective, to make the page look like the requires mockup, is a different mindset from making HTML templates. But it's more orthogonal to Python than Javascript, which means I need to switch out my programming mindset for another one. :)

2

Daily I use:

  1. HTML/CSS
  2. Javascript / JQuery
  3. VBScript / JScript
  4. PHP
  5. SQL
  6. C# / Asp.Net

I also use Python, Java and XML (does that count?) occasionally. My job involves editing various websites, which could be built in any web language (even had a Perl one once) and use wildly different paradigms/templates (procedural, MVC, OOP etc).

To answer the question - I mostly use Notepad++ as my IDE for the first 5 listed, then Visual Studio for Asp.Net.

It can be a pain switching quickly between each language - remembering whether or not you need semicolons at the end of lines, or whether if loops have braces or not. Switching from VBScript to JScript is the absolute worst for this - the files both end in .asp and look fairly similar at first glance, so it takes a while to work out why I'm getting errors.

1
  • Hey, you must work here, too! (j/k) We're rewriting out ASP and .NET codebase in PHP, exposing us to the same selection of languages.
    – greyfade
    Apr 6, 2011 at 16:11
2

At the moment I'm writing Ruby, PHP, Java, C and JavaScript and will write for a minimum of 1 hour in each of these each day. The main problem is really a matter of finding the time as they are all for unrelated projects.

Mental Shift

My work style is such that I like to work for large periods of time. Unfortunately, this means if I only have a single thing on, when I encounter a mental block with a piece of code, it will take a me a long time to get over it. I don't find taking a break helps either. By having other projects, and in particular other languages, to switch to whenever I get stuck means by the time I get back to the original language, I immediately have a solution.

Therefore, yes there is a mental shift and I think it makes me much more productive.

Prioritizing Tasks

I use a task manager (gTasks for Android) and have a separate todo list for each project. If a project requires multiple languages then I don't separate them. This is usually because they will be strongly related in some way. For example, JavaScript and Ruby for doing some AJAX stuff. If the languages are technically for the same project but the project is so large that they are essentially unrelated then I will likely count them as separate projects.

Generally, my priority is "whichever list has the most tasks" but I will always switch if I get stuck on a problem.

Coding Conventions

Its a bit of a mix:

  • If the project is developed with others then obviously I will conform to whatever conventions have been decided on for that project.
  • If the project is personal then I like my code to look consistent with the dominant style in the community/standard library for a given language. I find it hard to read Java code if all of the users functions are in snake_case, for example. Equally, camelCase methods in Ruby look weird and out of place.
  • For conventions which aren't made obvious from simply using a language, such as indentation, I will tend to adopt my own standards and use them in all languages I use. In the case of indentation, I always use 2 spaces. For brace style, I always use what Wikipedia is currently deciding to call the Compact Control Readability Style.

Aside: The biggest challenge for me is actually switching between style languages. It is very difficult to be racing along when coding SASS alongside Ruby and then having to switch back to CSS for everything else. To a lesser extent, I have the same problem with HAML/HTML and JSON/XML.

2

I write applications for ISP side of things, there is also a culture of "do what you are comfortable with", often written by a lot of network engineers who dabble in programming. I have to deal with on a weekly basis, programs that are quite well written, to the truly horrific. What I will often encounter, and work on...

  • Perl, Often quickie one-off scripts, or often used by people who only know (or like) Perl. More of the legacy stuff is written in Perl I find. Some of the worst stuff is written in Perl, not because the language is bad, but because it's easily misused by beginning programmers. I still use this myself for certain types of one-off programs. I rarely use it for anything larger.
  • PHP, Lots of this around, often a starter language for the dabblers. Some very well written programs, some schlock. For certain types of web applications, I'll chose PHP because I can get it to ground quicker.
  • Shell Scripting, Mostly use it for running other programs or tasks like reading logs.
  • Expect, still encounter this (and zealots who insist it is nirvana for executing commands on network devices). I work on it when I have to, but a baby kitten is killed somewhere in the world when I encounter one of those many thousands of lines long programs without a single function in sight, just one long iterative pasta farm.
  • C, Rarely used because of portability issues, but I will use it to perform specific tasks.
  • Java, I use this often because of extensive library support, and easy deployment. We have a very heterogeneous network, and a IT staff that has an agenda different than mine. With Java I can include libraries and not be concerned that IT has to "upgrade" something on the system I need to deploy the program. Most often this is my programming language of choice.

There are also other languages (.net, VB, Phyton, Rails, etc) out there in the company, but I haven't had to work on them...yet.

Edit, for the edit...

You do have to mentally shift when you work between languages. Most often what I'll lose track of is the syntax. I keep a collection of reference books at the ready. I'll find it takes about a half-hour to get back into the mindset of the other other language. The more obtuse the syntax for the language, the longer the shift. I find that shifting from doing Java to doing Perl probably takes the longest if I haven't touched Perl for a time. The more you do this, the easier it gets.

1

I am often using six or more languages within one project. Most of them are usually specific to that project only.

Mental shift is only required if you're using a language that is not appropriate for a task. Otherwise it is natural to use the best fit. Different sets of languages are used for different stages of a project.

3
  • Are you project manager or do you code in them?
    – Aditya P
    Apr 6, 2011 at 8:40
  • @AdityaGameProgrammer, I code in them.
    – SK-logic
    Apr 6, 2011 at 9:29
  • Mind explaining a downvote?
    – SK-logic
    Apr 7, 2011 at 9:39
1

I use C (embedded), C++ (desktop), Python, Matlab and VHDL (a sort of hardware programming language) on a frequent basis, often all in the same day. In my environment, this sort of language dexterity is essential in my view.

I often can't get everything I need to on a particular project done in one language efficiently. For example, both embedded C and VHDL are pretty low-level, so I often use Python to parse their results (or even generate code).

Switching between them rapidly is not an issue after a while, it's like switching from a hammer to a screwdriver - right tool for the job.

1

It really depends on how working is defined... I use C# for developing Microsoft Surface applications every day. Java I also use every day for my Android applications. But I try to educate myself and started using R, Ruby and Objective-C. Sometimes I also need some SQL and if you include script languages and other languages into your question then also JavaScipt, SPARQL and BeanShell.

Do you apply the same coding style /conventions on all the languages(Not syntax)?

I try to follow the coding conventions of each language but especially between Java and C# I have some difficulties because of the curly braces and the upper case method naming in C#:

public void test() {
   ...
}

vs.

public void Test()
{
   ...
}
1
  • Either style of curly braces is acceptable in C#. Don't spend too much time taxing your brain about this. :-)
    – Cody Gray
    Apr 6, 2011 at 15:43
0

I build web apps. So currently its:

  • XHTML
  • JavaScript
  • C# as part of the
  • ASP.Net Framework (this sort of is a language too)
  • T-SQL for database communication
  • English for communicating with humans.

Editors: Sublime Text (out of choice), Visual Studio 2010 (no other feasible choice when it comes to ASP.Net)

0

At my job I use Java, C, Python, Django, and small bits of PHP. I also worked on a really small project in Microsoft's C++.

I don't use all of them everyday, but some days I do use them all with no problem. On a typical day I only use one or two. The programming I do at home usually involves working with different technologies than I use at work like Qt or Ruby on Rails.

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