Hi everyone I have just started taking part in online coding competitions.I would like to know which language would be better as regards efficiency and ease of debugging. I tend to avoid c++ and generally go with java. 1. Would some other language be suitable? How about c sharp or python or some other (No issues with learning a new one.) 2. Is proficiency in C++ necessary to do efficient programming? 3. And out of java & c# which is better for algorithm competitions?

  • 6
    Use whitespace or brainf*ck or just choose the one you know better. – zerkms Jul 24 '11 at 3:00
  • 5
    x86 Assembly is still supported in the ACM regionals and World Finals – Jesus Ramos Jul 24 '11 at 3:04
  • Clojure, anyone? – Job Jul 24 '11 at 13:54
  • 1
    Second vote for Clojure if you are comfortable with Functional Programming. – Chiron Jul 24 '11 at 17:50

12 Answers 12


I think this should be posted on programmers SE but this are my two cents:

  1. I would suggest you to be proficient with C. Simplicity, examples and the thing that is the base of Java and C# will serve you as preparation for futures. Also, lots of example and demos are C based. See statistics at this site as an example.

  2. I don't think c++ knowledge is necessary. But believe C one is.

  3. Between Java and C# I'll go with C# for flexibility.

  • 1
    Do you feel hamstrung by the lack of built in data structures -- what if you need a linked list, self balancing tree, or hash table or something? Do you find it annoying that you'd have to be diverted spending time debugging these secondary building blocks that C#, Java, or C++ might give you? – Doug T. Jul 24 '11 at 12:40
  • @Doug - IMO, it's easier to work with links directly that to use a linked-list library, for basic operations at least. For more complex data structures, library containers usually win - but with the reservation that typically it's impossible to augment them, or to add extra operations that need internal access to the structure. Boost intrusive containers may be a good answer to that, but I haven't played with them enough to be sure. – Steve314 Jul 24 '11 at 15:09
  • @Steve314 -- Do Boost intrusive containers work in C? Boost is strictly a C++ library AFAIK. – Doug T. Jul 24 '11 at 16:30
  • @Doug - right - I should have said "for C++". – Steve314 Jul 24 '11 at 19:39

Use python

Firstly, python is shorter which in a competition scenario is a significant advantage.


std::map<string, int> foo;
std::stringstream str(input);
      std::string x;
      str >> x;
      foo[x] += 1


foo = Counter( text.split() )

Its not just that python eliminates useless typing, but it provides more powerful constructs which enable you more rapidly create your code.

Secondly, debugging works well.

Objects print out in a helpful way. Your can "print" any object. Containers will show their contents. This can be helpful when doing print style debugging. If you use a graphical debugger (I use winpdb), the introspective and dynamic capabilites of python give it the ability to easily view and manipulate all aspects of an object.


The biggest problem is that contest has to support python. Things like the ACM typically require C, C++, Java, or similiar. However, many of the online contests do support python.

The second issue is speed. However, this is typically not that much of a concern because your algorithm is not supposed to suceed based on the speed of execution but rather on cleverness of algorithm. I.e. C++ may let you execute your O(n^5) algorithm better, but the whole is really to find the O(n) algorithm. If you find the right algorithm, the language doesn't matter.


I participate in the ACM competitions in the US and some online ones as well. For the competition's I choose Java for ease of debugging and coding. For online Judge's I tend to use c++/C because the judge computers are slow and I would rather just code the algorithm than spend time using different input/output methods in Java to get it to run (as some time limits are ridiculous and Java is a little slower at handling I/O sometimes). This is just my opinion but you're free to use whatever you want. The most popular language's are C++ and Java for competitions if you look at the final results language categories so you probably can't go wrong with either of those (obviously many others are supported just not used often).


I'd go with either java or C# both are very easy to debug with. In Java you have to find a good IDE which supports in debugging like

breakpoints call stack watched variables watched locals.

But in C# you don't have to worry about anything all this already is built in the Visual C# IDE

  • ACM Regional is done on linux machines sometimes so you have MonoC# (MonoDevelop), Emacs, and Eclipse at your disposal – Jesus Ramos Jul 24 '11 at 3:06
  • Oh snap yeah Visual C# won't work on linux, MonoDevelop is pretty good for cross-portability – SSpoke Jul 24 '11 at 3:10
  • It's about the same, I haven't seen any submissions in it because at the regionals it was c++ and java (my team uses both) and at WF it was mostly C++ – Jesus Ramos Jul 24 '11 at 3:11
  • Don't forget gdb for powerful C/C++ debugging. There are also some good GUI debuggers to interface with gdb. – Chris Jul 24 '11 at 3:13
  • @Jesus your region allows C#? In SoCal it's C, C++ or Java -- same as finals. – Daniel Lubarov Jul 24 '11 at 3:56

Functional languages like F# and Haskell are worth a look if you're doing algorithms. Features like discriminated unions and pattern matching make mathematical/computational tasks a lot easier to conceptualize, prototype and polish.

F# is probably more approachable since it's multi-paradigmatic (it's also just as fast and often faster than C#), but Haskell is a fun challenge.

  • 1
    +1, but I'd suggest Objective CAML rather than Haskell. I'm not going to say Haskell is a bad language (though I have been an idiot about it in the past), but things like being in-place and order of execution are important in algorithms. Monads are very interesting, but the imperative-to-functional-and-back-again means you're pretty dependent on the optimizer to preserve your performance claims, and there are oddities with things like expressing a while loop (the condition must be within the monad) that strongly encourage a recursive style and make some things a tad awkward. – Steve314 Jul 24 '11 at 15:28
  • 1
    @Steve I left out OCaml because F# is a dialect of OCaml (it also supports monads) -- so they kind of fill the same needs, minus non-Windows interoperability if you really hate Mono. There seem to be some algorithms that are more natural to express in Haskell due to the powerful type system and lazy evaluation, such as some kinds of parsers. At the same time, there are some that are easier to express in F#/Caml due to its fundamentally imperative nature -- most famously Quick Sort. I think although Haskell is more challenging and slightly less practical, it's a good language to learn. – Rei Miyasaka Jul 24 '11 at 20:41
  • Absolutely Haskell is a good language to learn, I just have some odd criticisms. Very few compared to most languages, and I still can't really claim to know how significant they are in practice, but they really give my principles a hard time. Quicksort is a good example - pure functional code for Quicksort is commonly given as an example of how good Haskell is, but that code is not in-place and doesn't give in-place performance. Working with immutable arrays rather than the usual linked lists (!), you'd get O(n log n) expected array copies, for O(n^2 log n) expected performance. – Steve314 Jul 24 '11 at 21:17
  • Obviously that point basically means that you should use lists rather than immutable arrays, or use a monadic quicksort in a mutable array. But the lists version has a storage overhead for the links, and maybe a locality issue too. And the monadic version gets you beaten up for not writing properly functional code. – Steve314 Jul 24 '11 at 21:20
  • @Steve Totally. That's why I say F#/ML are better for things like Quick Sort. I honestly think that the immutable Quick Sort frequently used to demonstrate pure functional programming should really have a different name. – Rei Miyasaka Jul 24 '11 at 21:58

If the competition is timed, and any language is permitted, I would choose Perl. Java is far too verbose, and the C standard library is much too limited. Perl is so much better for programming competitions that it was banned for the UCLA Undergraduate Computer Science Association competition in 1998.


I've already upvoted...

This is kinda stuff that should be in comments, but there's too much of it...

C gets rid of a lot of the unnecessary large-system stuff that's supported by C++, C# etc. You don't need OOP, templates etc to write small algorithm-centric systems.

That said, C++ has it's plus points - if you know it and you know how/when to avoid data hiding and other layers-of-abstraction-getting-in-the-way issues, use it.

Once upon a time, I'd have suggested Modula 2 (or a non-standard Pascal, possibly even Ada) as an alternative to C. There are some advantages to stricter typing, some disadvantages to the less rich set of operators, yada yada. These days, the world has mostly left these languages behind, though, so they're probably not real options any more.

Python will probably give you a much faster development speed, depending on what you're doing. It has OOP, of course, but it's easier to avoid it when you don't need it than C# or Java. The issues are (1) that the run-time performance may not be there if you're doing all the low-level stuff yourself (rather than use libraries that were written in C), and (2) there are times when you may want to manage memory yourself in low-level code - keeping things on the stack rather than cluttering the heap, not relying on garbage collection etc.

Python generators/iterators are also a very useful tool that you don't see in many other languages.

Writing critical components in C modules for use in Python is an option, but I'd be very nervous about getting into multi-language development with the time-constraints of a contest - there's at least twice the scope for things to go disasterously wrong.

Objective CAML is an impure functional language. It can do all the things a normal imperative language can do, and it has some very useful tricks from the functional world too. I'm not that experienced with it, but I certainly believe claims that it eliminates a lot of clutter, letting you focus on what you're doing - pattern-matching supports that claim for a start. And it's a native-compiled language that runs fast - though the "may want to manage memory for yourself" probably applies to Objective CAML (and F#) too.

Haskell - absolutely learn it, but not with the goal of using it for contests with a strong algorithms focus - but if you reach the point where you think it'll be a good choice, and you've understood my criticisms and rejected them (or found them valid but unimportant) - don't fight it either.


I think most easy to debug and language is C# (VS has many things to do is better.)

  1. Is proficiency in C++ necessary to do efficient programming?

Not so! You should also know mechanism of machine.

  1. And out of java & c# which is better for algorithm competitions?

C# but java is not so bad too. If you worked more with java in NetBeans, choose java. Because after NetBeans its hard to get use VS.


Some competitions have a specific set of allowed languages, you don't have the luxury to use what ever your want.

For competitions I prefer a scripting and dynamic language, You need to code fast and see the result faster. More important you need to change code quickly.
Python, Ruby or JavaScript are strong candidates.

I participated in Google Jam in the past and Java wasn't the best choice.

If you are really comfortable with Functional programming (and I mean really comfortable), then I recommend this route.
Lisp, Haskell or Erlang are my personal choices.


I participated in IOI a couple of times, and coded in C. At the time, I did not know of OO, or even how to allocate memory on the heap (I allocated all memory I needed on the stack). All focus was on the algorithm.

However, nowadays, I'd stick to Java, because of the large library of algorithms and data structures available. But, of course, take into consideration that at IOI, you are not allowed to bring any prepared code, so a huge library of algorithms and structures is a great advantage. Online competitions is probably another matter...


The problem you have is that different developers prefer different languages and this isn't always about a sound technical argument, rather which style of development they feel most comfortable in.

Personally I would hold a competition which has a category for each language. The competition for each language should be set by someone who is a fan of that language (so the task will be something which appeals to other fans of that language)


I would use Common Lisp, because it is very pragmatic and expressive.

  • 1
    Care to elaborate on that. – Dynamic Jun 19 '12 at 15:19

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