fedor.birjukov's blog

By fedor.birjukov, 15 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.net/blog/entry/254

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

A bit about C# and Linq: http://codeforces.net/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.

Full text and comments »

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

By fedor.birjukov, 15 years ago, translation, In English
It will be great to summarize all the discussions about programming languages and using them at programming competitions.

I worked on many languages and in many environments/ides, on some more, on some less, almost in this order:
QBasic, VBasic, VFoxPro, Pascal, ide Delphi, ActionScript(script language in Flash), (books about C++ and Java), PHP+JS+css+xml+html+MySQL, C++, a bit in Java, courseworks in C#, a bit in python, a bit in C++ with QT libraries.

Pascal - very simple language for algorithmization and programming competitions. The most suitable for school programming olympiads, because there(in school) you need efficiency and speed of writing, but not vice versa.
C++ - after Pascal I advice using C++ at school olympiads in informatics(and other programming competitions). And in general, I like C++ more than anything else for its "freedom". However, because of it, in the same time, there are many discussions about possible errors that are not caught by the compiler, etc. In C++ you can write the same things in many ways. This remark is good for every c-like language. And almost all named languages are c-like and it says about C beforehand. Almost everyone knows C or about C. There are many good libraries in stl, but nobody forbids writing it self (eg.: as in Pascal). Speed of coding grows in C++ because you can write many things much shorter. Of course, it depends on the choosen style but this possibility is directly on the surface.
Java - I've read some discussions about Java on CodeForces. And I don't think about using it at olympiad, whatever happened, whatever the task may appear.
I've picked up a couple of books on Java and I've seen, understood for myself that Java is cool language, but it is suitable only for development and maintenance of large projects. I can cite a couple of quotations about Java, they do not contradict my opinion.

“Fine, Java MIGHT be a good example of what a programming language should be like.  But Java applications are good examples of what applications SHOULDN’T be like.”
(pixadel)

“Java is, in many ways, C++–.”
(Michael Feldman)
You can find more quotes here: 101 Great Computer Programming Quotes.
C# - I wrote only courseworks for students in it, I wont recommend it for olympiads or say smth else.
VB - I wrote on it very long time before and I'm not eager to continue, because I do not remember the syntax and do not see the benefits.
Python, PHP, ... - A bunch of scripting or other languages with C-like syntax. I don't see any sence in using it at programming competitions. All of them are useful/created for using in different situations.

Full text and comments »

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

By fedor.birjukov, 15 years ago, In English
LAST UPD:
I deleted my calendar because I've found a better solution. Darnley wrote a script wich parse Top Coder's schedule and export it into Google calendar. Now script works correctly. I hope it wont change. :)
Thanks, Darnley.

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By fedor.birjukov, 15 years ago, translation, In English
For this moment, I almost did not compete in the Top Coder. And now I improve this situation.
When I practiced, then for some reason did not participate in the TC, because I had a lot of other contests wich were more similar in style to the school competitions, and I hadn't enough time for training, because I was in school with excellent marks, and it is also time ...
I have a certain number of questions about TC) And a couple of general questions to the top participants.
1) How best to write in TC? Use plug-ins from this page: http://www.topcoder.com/wiki/display/tc/How+to+install+The+Arena+plug-ins?showComments=true#comments  ? Or write directly to the default competition window?
I wonder if you write a complete program, it's library, and then the tests for it and test it?
Or rapidly write the
library code in standard editor and test it there?
2) Do you use any code-snippets?
This question is not only about top coder but about other competitions where people submit tasks with 3-5 minutes interval? Is it possible to read the task, to understand it, to solve it(even if you see the solve directly), to code and send it in 3 minutes?
3) How to organise your time? Maybe it's better to start from the more "expensive" tasks?
4) Maybe you have some rules or recommendations? Some general advices about competitions and how to prepare to them. And, in particular, the differences between TC and other competitions. These are my questions.

UPD: And how do you, in particular, approach the various competitions and preparing for them?

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By fedor.birjukov, 15 years ago, translation, In English
To be honest, it can make every foreigner at his own risk: using Google Translate. But he will know in advance that the translation could be bad and more simple and convenient solution for him - not to read this page. In fact, translation from Russian into English and back in google is pretty good. Translation, e.g., from Dutch into English is even better.
In particular, translation can be improved by competent placement of words in the source text, writing more simple sentences or using of such phrases that are well and adequately could be translated by Google automatically. I'm, in particular,
satisfied with such a translation or a pretranslation. It is quite good and very fast. I propose to use Google Translate at least for the rough translation of the text, to make its work implicit to the eyes of users. User who won't translate everything on his own would have more confidence, would be more interested in looking at any materials on the site, it will be more comfortable for him. Yes, just hiding the foreign-language commentaries - also a good way. But, as I understand, modern society comes to a complete blurring of lines and barriers, even language. This community is also an evidence of it.
As an example of such a translation you can go to my blog and compare the Russian and English versions, or simply translate any web page as follows:
1) Add to bookmarks this link
English. Or, for translation into Russian from any other language Russian.
2) Open any page and click on this link.
But this doesn't remove the need to translate all...
In the same time we could control the translation more and more in the process, preserving translate certain phrases. That's, in fact, more closely monitoring of what you write. Play by the rules of the Russian language, which is clear for the translator.
And parallel I ask a question:
Everyone who leaves a comment can translate it into English, if he has a little time and a comment is not very long. But how? Comments can be left in one of the two languages, but not both at once. +It would be nice to make the group of active users and give them the right to write pre-translations.
Although, the already done work is great.

Full text and comments »

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