kirjuri's blog

By kirjuri, history, 9 years ago, In English

I have been experimenting with Kotlin lately, and it's a very simple and comfortable alternative to Java (at least in the scope of programming contests, I cannot find a case where some solution written in Kotlin would be uglier than the Java equivalent). Moreover, Codeforces supports Scala, which also runs on JVM, it's a much more expressive language with more advanced features, although they are useless for the competitive programming context: thus is makes more sense to add Kotlin (also|instead).

I would like to know what people think about it, and if I can contribute anyhow to make it possible, I would like to know as well. Thanks!

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

| Write comment?
»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Totally agree! This way, we can learn not only coding skills but also a programming language on Codeforces. If possible, please also consider Julia too.

»
9 years ago, # |
  Vote: I like it +1 Vote: I do not like it

Well, creating several dimension array (3d for example) is (or at least was) uglier than in Java

  • »
    »
    9 years ago, # ^ |
      Vote: I like it -25 Vote: I do not like it

    Why Java is ugly?

    C++:

    int threedim[5][10][4];
    memset(threedim, 0, sizeof(threedim));
    

    Java:

    int threedim1[][][] = new int[10][5][8]; // (1)
    int[][][] threedim2 = new int[10][5][8]; // (2)
    

    C#:

    double[,] twodim = new double[10,9];
    double[, ,] threedim = new double[10,9,5]; // (1)
    
    double[][] twodim2 = new double[10][]; // (2)
    for (int i = 0; i < twodim2.Length; i++)
    	twodim2 [i] = new double[5];
    

    Python:

    w, h = 8, 5. 
    twodim = [[0 for x in range(w)] for y in range(h)] # What the hell
    
    • »
      »
      »
      9 years ago, # ^ |
        Vote: I like it +13 Vote: I do not like it

      Scala:

      val threeDim = Array.fill(10, 5, 8)(0)
      

      Kotlin: ?

      • »
        »
        »
        »
        8 years ago, # ^ |
          Vote: I like it +8 Vote: I do not like it
        val threeDim = Array(10){Array(5){IntArray(8)}}
        

        The Kotlin alternative is very flexible, it works for any kind of nested datastructures.

    • »
      »
      »
      9 years ago, # ^ |
      Rev. 5   Vote: I like it -7 Vote: I do not like it

      tda = [[[0] * d1] * d2] * d3

    • »
      »
      »
      9 years ago, # ^ |
      Rev. 3   Vote: I like it +13 Vote: I do not like it

      C'mon I said 'than in Java',

      What does these languages do with the topic?

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

It would be a great idea. It was already supported in the surprise language contest before so it won't be a huge work :D