fedor.birjukov's blog

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.
  • Vote: I like it
  • +5
  • Vote: I do not like it

| Write comment?
15 years ago, # |
  Vote: I like it 0 Vote: I do not like it
While I mainly code in C++ myself, I would object in defense of other languages. Many people are using them to their advantage (Petr or the SPbSU ITMO ICPC'09 team are good examples). And they have some obvious pros. C++ currently does not have bigintegers, regular expressions, garbage collection, etc. Even if you like C++, these are good reasons to switch when the running time can be sacrificed, and there are plenty more.
15 years ago, # |
  Vote: I like it 0 Vote: I do not like it
As you want to use them in programming competitions, it's better to choose a language which is widely supported. C++ is the answer.
Sometimes, it's just a personal preference. Sometimes, it doesn't matter as the programming language is just a tools to express what we've done.
15 years ago, # |
  Vote: I like it +3 Vote: I do not like it

Java was *NOT* inherited from C++. It was only marketed as remake of C++ because there were many C++ coders around. C is the divergence point between Java and C++.

and, from here: http://norvig.com/java-lisp.html

The variance for Java was lower than for C or C++. (Cynics could say that Java forces you to write uniformly slow programs.)

So blame the language, not coders. We know many clever people use Java. It would be a lot of good Java apps if it was possible to write them.

About C# : At times, I look at some stats at Topcoder and it looks like picking C# in Topcoder algorithm seems to be superior over C++ and Java. (which, on other hand, might be not statistically significant because sample size is too small and biased because *you-know-who* uses C#).

Maybe Topcoder doesn't gives away stats per languages to avoid holy wars :D

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.

15 years ago, # |
  Vote: I like it +6 Vote: I do not like it
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.
  • 15 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it
    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).
    • 15 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it
      That is why I use Borland C++ Builder for programming contests. It has internal tool CodeGuard - it checks many things in runtime: out-of-range, pointers and so on.
  • 15 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it
    Which is faster?
    • 15 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it
      I don't understand what are you asking about.

      Could you explain your question?
  • 15 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    allowing to read from uninitialized variables? why would a language allow that?

    Sometimes compiler is unable to determine if reading from uninit var will occur.

    int foo(int arg) {
        int[] x;
        if(arg<0) return -1;
        if(arg==0) x = new int[1];
        if(arg>0) x = new int[2];
        x[0]++; // Bogus error here

    C was intended for people who are smarter than their compilers. Vice-versa for Java.

    • 15 years ago, # ^ |
        Vote: I like it +14 Vote: I do not like it
      I believe this is a an example of how using Java makes you write more readable code :) I think if-elseif-else is more appropriate here.

      I don't think this has anything to do about "smarter". I'd call this "with more attention to tiny details". And I'm perfectly happy to admit my compiler has more attention to tiny details :)
      • 15 years ago, # ^ |
          Vote: I like it -6 Vote: I do not like it

        if-elseif-else is nothing but just a hint for compiler.

        In mathematical notation - intended for humans - it is rarely used.


15 years ago, # |
  Vote: I like it +1 Vote: I do not like it
Who has written English text? It is terrible.