Get Time
Search | Watch Thread  |  My Post History  |  My Watches  |  User Settings
View: Flat  | Threaded  | Tree
Previous Thread  |  Next Thread
3.1.? Choosing Right Programming Language for Marathon competitions | Reply
This is actually sidebar, not a recipe.

TopCoder marathon competitions support 5 programming languages: C++, C#, Java, Visual Basic.NET and Python. What language to choose as main language for competitions, and when it's worth to temporary switch language for particular marathon match?

First, let's look at the stats for last 20 marathon matches (Marathon Match 46 - Marathon Match 67, only regular marathon matches were considered, and matches 57 and 66 were skipped because they have too many first-placed submissions).
|             |  C++ | Java |  C# | VB.NET | Python |
| 1-st places | 12 | 6 | 2 | 0 | 0 |
| Top 3 | 37 | 16 | 6 | 1 | 0 |
| Top 10 | 128 | 51 | 19 | 2 | 0 |
| F1 score | 1271 | 532 | 201 | 16 | 0 |
The last row is score according to the recent Formula One World Championship points scoring system.

Of course, the table results are biased towards more popular languages, but they probably gain their popularity for a reason.

About Python. Although Python is more popular (has more submissions) than VB.NET, it earns zero points. The main reason for that is that unlike TopCoder Algorithm competitions, in Marathon marathon matches speed of a solution does play a huge role, and Python is the only interpreted language from five supported languages (besides, TopCoder doesn't support Psyco - a Python extension module which can greatly speed up the execution of a program). So even if Python is officially supported in Marathon competitions, it's really not an option if you want to win or take prize place (unless your algorithm is really superb, but there is no historical evidence of such case and you probably would have even bigger advantage using faster language).
Well, if you are Python expert sometimes it may be handy for you to write a prototype program in Python and then rewrite it in a faster language.

In the above table C++ language has more points than all other languages summed together. The main reason is speed again: C++ is considered the fastest of all five supported languages (and usually you can use MMX, SSE and inline assembler to speed up it even more). So in the long run C++ is probably the language of choice if you want to win in TopCoder marathon matches.

Unlike Algorithm matches, particular features of some language like arbitrary precision numbers or regular expression support in Java will not give a huge advantage, because Marathon matches are long enough to implement needed piece of functionality in any language (although it can be handy to have it in standard library of a language). Other minor advantage of Java language - in some Marathon matches pieces of visualizer code (provided by organizers) can be reused because it is written in Java.

On the other hand, Marathon matches programs are much bigger and much more complex compared to Algorithm matches solutions, and are more like real production programming. C# and Java are more high-level languages than C++, so they can help to manage complexity better because of higher level of abstraction (and TopCoder doesn't support popular Boost C++ Libraries that extend the functionality of C++). So some problems - problems that require more complex implementation and are not very computation-heavy - may favor using Java or C# over C++.

As for non-standard, specific marathon matches, the above considerations also apply, but choices are usually more limited. Many specific marathon matches require to use C/C++ only (Intel Multi-Threading Competition series, AMD Multicore Threadfest, Linden Lab OpenJPEG).

So in conclusion:
- you can't really use Python for your final submissions if you want to take high place
- you can use C/C++ in every Marathon match (including special format contests)
- you may want to use more high level languages like Java or C# for some problems that require complex implementation and are not very computation-heavy.

Also when considering different languages find in the rules or ask in the forums of the particular contest about what specific versions of compilers/interpreters server uses, in that environment and with what options, what libraries are allowed: this information may greatly affect your choice.
Subject Author Date
3.1.? Choosing Right Programming Language for Marathon competitions kit1980 Jan 18, 2011 at 4:38 PM EST