fedor.birjukov's blog

By fedor.birjukov, 14 years ago, translation, In English
The purpose of this article: To shed some light and to summarize all the discussions about programming languages. It touches more sphere of sport programming. But I try to make the remarks more and more clear and right from time to time during my evolution and evolution of programming languages. Today is the 18th of April 2010.

 

Pascal (imperative, structured)

Pro: very simple and strict language – easy for beginners – it’s easy to write and debug code.

Contra: no standard libraries (in comparison with C++ and Java ones).

 

C++ (multi-paradigm: procedural, object-oriented, generic)

Pro: STL (standard templates’ library) – many standard data types and algorithms. Great “freedom” – you can write the same things in many ways. Good performance of compiled sources. C++ is widely supported nowadays.

Contra: No BigInteger and BigDecimal (which are available in Java and C# libraries). Chance of different errors, which are caused by incomprehension between compiler and coder. You can find many discussions about them, but it’s not the problem of the language. But because of this great freedom it can be sometimes difficult to read the code or to debug it.

 

Java (object-oriented, structured, imperative)

Pro: more strict syntax than in C++ – it’s easier to read the code – fast and easy debugging. Notifications about errors and unused code. Plenty of libraries. Garbage collector. New features in the latest version of java (eg.: variations of cycle for).

Contra: Slower performance of programs(3 or 4 times slower than C or C++), longer (uniformly long) source code, but coding (typing of code) is fast because of auto-completion.

Opinion of Petr: I think Java/C# (I don't see much difference between them except speed) are best suited for programming contests, since it's so much harder to make a mistake and so much easier to find and fix a mistake in a Java program than in a C/C++ program.

Much more strict type checking (implicit casts from long long to int and from int to bool??), out-of-range checking, code flow checking (allowing to read from uninitialized variables? why would a language allow that?), fantastic IDE which finds a lot of other mistakes for you, fantastically convenient debugging, more explicit syntax (a language with less power actually leads you to writing more readable programs), more explicit error messages (and the errors are always reproducible!) - to name a few advantages, but I've probably missed some more.

I think that writing correct programs and fixing them quickly when they're not correct far outweigh the disadvantages mentioned above (slower execution, longer programs). Even a 2x slowdown is almost never important in programming competitions, while a WA always is :) And I believe that most of the time at a programming contest is spent in thinking (including the thinking you do _while_ writing code), not in writing code, so the length of the program (or the typing speed, for that matter) is irrelevant.

And I believe the availability of various libraries is also not that important. So if I were to choose between C++ and Pascal, I'd choose Pascal because of the same argument (much more strict checking of everything).

 

C# (multi-paradigm: structured, imperative, object-oriented, event-driven, functional)

Pro: Faster than Java. The latest version of C# default libraries includes classes and algorithms for long arithmetic as well as in Java, but in C# you can use them as basic types (in Python it’s also so): c=a+b, etc. Linq.

Contra: The latest version of .NET is still not available at most of programming competitions.

 

VB (object-oriented and event-driven, procedural, component-based)

Difference from C#: Programming language is Visual Basic and not C#.

Opinion of alliumnsk: VB.NET is just C# with syntax inherited from VB to ease porting of VB apps. So there is no reason to even think about VB.NET.

 

Python (multi-paradigm: object-oriented, imperative, functional, reflective)

Opinion of _ph_:

Pro: Pythonlanguage of wide function. Man can write almost all types of programs in Python, except real-time programs. Python is unofficial language #3 in Google.

Python is well right for solving of easy-medium tasks thanks to short syntax and built-in means:

·         built-in long arithmetic (integer and decimal as well)

·         built-in list (aka vector<>), set, dict, tuple (aka struct)

·         regular expressions (re)

·         function sorted() for any sequences

·         nice string operations

·         nice constructers of lists

·         functions sum(), max(), min() wich can work with lists etc.

Contra: From point of programming competitions:

·         slow performance of programs (6x slower than С++) and especially slow input-output (you can’t read 10^6 of numbers in 1 sec without special tricks)

·         not enough good IDEs (I know only one good - PyDev for Eclipse)

 

PHP and other languages.

I don’t see any sense to use them at competitions. If I’m wrong – tell me.

 

Conclusion:

It is best to learn and practice as much languages as possible, to collect the knowledge, to know the nuances, but it’s not so easy and isn’t always possible. We are humans and we can’t change our nature, but we can try to make it better. Each language has its own pros and contras and you can choose one of them to solve different problems more efficient.

You must decide for yourself what you prefer: freedom and flexibility or simplicity of coding-reading-debugging-maintaining; what speed do you need and so on.

I hope this tutorial helped you to understand and systematize all these languages for yourself.

 

Additional and used information:

Links:

Lisp as an Alternative to Java: http://norvig.com/java-lisp.html

Choosing the weapon discussion: http://codeforces.com/blog/entry/254

C# - why is it not mono? : http://codeforces.com/blog/entry/229

A bit about C# and Linq: http://codeforces.com/blog/entry/245

Definitions:

Pascal: http://en.wikipedia.org/wiki/Pascal_(programming_language)

C++: http://en.wikipedia.org/wiki/C%2B%2B

Java: http://en.wikipedia.org/wiki/Java_(programming_language)

C#: http://en.wikipedia.org/wiki/C_Sharp_(programming_language)

Visual Basic: http://en.wikipedia.org/wiki/Visual_Basic

Python: http://en.wikipedia.org/wiki/Python_(programming_language)

 

Tags: java, c++, vb, c#, pascal, python, the best language, programming languages.

 

Thanks to: MikeMirzayanov, Petr, alliumnsk, OSt, dAFTc0d3r, _ph_, Peteris, ktuan, SkidanovAlex, Nerevar, dev_il, valergrad and to everybody who has taken part in discussion.

  • Vote: I like it
  • +1
  • Vote: I do not like it

| Write comment?
14 years ago, # |
  Vote: I like it +4 Vote: I do not like it
About other languages, "I don’t see any sense to use them at competitions" - this sounds almost like flame bait. You said pretty much the same thing about Python in your earlier post, but in this one you have radically revised your assessment. is it not possible that there are languages out there, which have useful features for contests that you are not aware of?

Other languages include languages like Ruby and Perl, which have pretty much a similar set of advantages/disadvantages as Python, and dismissing them all as "no sense to use them in contests" sounds rather harsh and uninformed. Perhaps revising that line to something a little less dismissive, or omitting it altogether might be a good idea?

Apart from that, this is really a great article. +1 for the effort.