SerVB's blog

By SerVB, history, 8 years ago, translation, In English

Hi! An empty program uses around 20 MB and 61 ms.

Codeforces, what's wrong with you?..

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

»
8 years ago, # |
  Vote: I like it +12 Vote: I do not like it

An ultimate proof that Java is slow.

  • »
    »
    8 years ago, # ^ |
      Vote: I like it +11 Vote: I do not like it

    Can you elaborate?

    • »
      »
      »
      8 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Java is often slower than C++ so I like making fun (example) of using Java in competitive programming, where the running time is (sometimes) crucial.

      • »
        »
        »
        »
        8 years ago, # ^ |
          Vote: I like it +17 Vote: I do not like it

        BTW, I have a problem where Java solution works for 0.8 sec, and C++ solution — 1.0 sec. Solutions are identical and use only arrays and primitive types. There are a lot of floating-point calculations in that problem.

      • »
        »
        »
        »
        8 years ago, # ^ |
          Vote: I like it +51 Vote: I do not like it

        So the only metric you think is important is runtime? Well, from what I know pure C is a bit faster than C++, why you are using C++ then?

        • »
          »
          »
          »
          »
          8 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          Of course it isn't the only metric (why would you suggest so?). I also like built-in pairs and C++ provides that.

          I know that sometimes Java is a better choice, e.g. because it supports big integers. I can't say that Java is a worse language because it's better than C++ in some cases. What I always say is that it's slower (what hurts me often during the problem preparation) — and this is what I say in my trying-to-be-funny comments.

          Regarding your last question. Many contests support only C++ and Java, so I'm not going to use C. It's hard for me to find more reasons for not-using-C because I don't know C (and thus I can't compare it with C++).

          • »
            »
            »
            »
            »
            »
            8 years ago, # ^ |
              Vote: I like it +6 Vote: I do not like it

            Java is often slower than C++ so I like making fun (example) of using Java in competitive programming

            One can read this to suggest that if language is often slower than another that's the only thing that matters

            As for other points I do not see how built-in library matters nowadays in personal contests as you can have any prewritten code you want. And problems with problemsetting may be alleviated by basing your limits on unintended solutoions rather than intended ones, but that's topic for another discussion.

            Finally, barring edge cases you can usually submit your c source as c++ ;)

            • »
              »
              »
              »
              »
              »
              »
              8 years ago, # ^ |
                Vote: I like it 0 Vote: I do not like it

              Ok, my words may indeed suggest that, my fault.

              I don't know if anyone agrees with me but it isn't that fun to maintain an own library (I'm not sure about this word — I mean a big set of prewritten codes). I understand that there are many cool problems requiring something complicated prewritten (ofc. you can also write it yourself during the contest) but I prefer hmm... simpler problems? Ones that you can code starting from an empty file. Similarly, I would want to read the input without anything pasted into the code. I see that I didn't show here any arguments — I simply don't have any (other than not being used to using much prewritten code). And of course it isn't anymore related to the Java vs. C++ discussion.

              Hah. Nice idea with submitting C as C++. Maybe I will even check out C one day. I still want to learn something about SSE first.

»
8 years ago, # |
  Vote: I like it +6 Vote: I do not like it

It cost 81ms on my laptop...

Java is a language running on virtual machine, so this behaviour is expected.