Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Android Java Open Source Programming

Google-backed Kotlin Gains Adoption in Open Source Android Apps; Scientists Say It Has Improved Code Quality (theregister.co.uk) 86

Kotlin, which Google blessed last year as an alternative to Java for programming Android apps, has already made its way into almost 12 per cent of open source Android apps, and in so doing has elevated their code quality. From a report: So we're told by computer scientists Bruno Gois Mateus and Matias Martinez, affiliated with University of Valenciennes in France, who observed that Google at the end of 2017 said Kotlin had infiltrated more than 17 per cent of Android apps developed with its IDE, Android Studio 3.0. Kotlin is an open source statically typed programing language that targets the JVM, Android, JavaScript (transpiling to ES5.1) and native platforms (via LLVM). JetBrains, the company that created it, contends Kotlin is more concise and more type-safe than Java. It estimates that apps written in Kotlin require about 40 per cent less code than they would with Java. With fewer lines of code, in theory, one can expect fewer bugs. In a paper distributed through pre-print service ArXiv, "An Empirical Study on Quality of Android Applications written in Kotlin language," Mateus and Martinez describe how they gathered 925 apps from the open source F-Droid repository, measured the amount of Kotlin code in each, and analyzed the code for "smells" as an indicator of code quality.
This discussion has been archived. No new comments can be posted.

Google-backed Kotlin Gains Adoption in Open Source Android Apps; Scientists Say It Has Improved Code Quality

Comments Filter:
  • by Anonymous Coward

    At least link the source which is the Arxiv paper here [arxiv.org].

    We don't come to /. to read a summary of a headline which links to a summary on another site summarizing someone elses summary.

  • by account_deleted ( 4530225 ) on Thursday August 02, 2018 @10:26PM (#57061070)
    Comment removed based on user account deletion
  • Can you use this without Jetbrains?

  • by NextApp ( 564188 ) on Friday August 03, 2018 @12:45AM (#57061382)

    Android app dev here. Learning Kotlin, I started off being thoroughly excited about it, especially the nullity checking and other general code safety features. Then I got to the bit about it not having checked exceptions and now have a very mixed opinion.

    The arguments against checked exceptions seem to be that 1.) most languages don't have them, 2.) bad programmers will just throw and catch the base "Exception" class everywhere, and 3.) bad programmers will screw up interfaces and the like by putting implementation-specific exceptions in the contract rather than writing appropriate exception classes.

    Bad programmers write bad code, and will continue to write bad code. I guess if we "fix" the problem by having good programmers write bad code too, it will technically make the bad programmers average.

    Going to try using it on a new project (that won't have checked exceptions as a key component of its design, like my existing stuff) and hope for the best. I still can't get over this seeming like two steps forward, three steps back. I hope I'm wrong, as it otherwise appears to be a great improvement compared to Java.

    • Re: (Score:1, Troll)

      by AuMatar ( 183847 )

      CheckedExceptions have been considered a language flaw in Java for a very long time by a large percentage of its users. Examples of problems with them:

      *Writing throws statements on each function causes propagation up the chain and leads to either being forced to catch Exception or have functions with a half dozen throws on it.

      *Removing the necessity of throwing on any function in the change causes massive changes to all callers, which is time consuming and causes unnecessary churn. Especially bad with lib

      • Those users are wrong, they are mainly people who don't want to think about errors, and deal with them by pretending they don't exist. If you want to write secure code you need to know if the function you are calling is going to throw an error or not. There is a better way to deal with the unwieldiness of exceptions: always throw "Exception" (with an appropriate human readable error message), unless there is something the programmer can do at runtime to handle a specific exception (like an interrupt except
        • by AuMatar ( 183847 )

          You didn't describe checked exceptions, you described typed exceptions. Nobody complains about exceptions having type that can be compared against. Checked exceptions are the list of exceptions in the throws argument that are checked against at compile time.

          • You didn't describe checked exceptions, you described typed exceptions. Nobody complains about exceptions having type that can be compared against

            You obviously misunderstood. I was explaining how to solve your problems with checked exceptions.

            Checked exceptions are the list of exceptions in the throws argument that are checked against at compile time.

            There are people who don't like checked exceptions because they would rather pretend errors don't happen. You can't write reliable software if you live in this kind of fantasy world. You need to think about what happen if there's an error.

            • by AuMatar ( 183847 )

              No, you were showing you didn't know what you were talking about. You tried to defend a feature while describing a totally different feature.

              • Are you going to attack a strawman, or are you going to address my main point? You can't write reliable software if you don't consider all possible exceptions when you are writing the software.
                • by Raenex ( 947668 )

                  You can't write reliable software if you don't consider all possible exceptions when you are writing the software.

                  That's bullshit. Worst comes to worst the program crashes safely. with a nice stacktrace to tell you what happened. Checked exceptions are valid in a few, very few cases. In all other cases, all they add is clutter.

                  Let's take something like SQLException. Ok, what are you supposed to do if your SQL is fucked up? You can't recover from it, so you either wrap it in a non-checked exception or you throw it up the chain, exasperating the crud code that needs to deal with it.

                  What do you do if you get an IOExceptio

                  • Yeah, I can already imagine how bad your software is. If you aren't considering what can go wrong when you write code, you better not put it on the internet either, because it's not going to be secure. Somone will hack you.
                    • by Raenex ( 947668 )

                      Ok, I gave you the benefit of the doubt the first time when you mentioned security and then switched to reliability. But now here you are again talking about security. Java is not C. In Java, when you get an exception your program crashes. In C, if you don't check return codes your program silently continues running.

                      You complained about the other poster ignoring your argument, and that's exactly what you did to me. I never said you should ignore what can go wrong. I said in the vast majority of cases, check

      • by NextApp ( 564188 )

        Most of those complaints are due to developers being unwilling to write their own exceptions when they write code. If you tried to use checked exceptions without being willing to author your own, they would be an absolute nightmare.

        Let's say you're writing a library that transfers data from an XML file to a database. If you have client-facing methods that throw SAXException, IOException, and SQLException, you're doing it wrong. When you design your interface, you also need to write your own exceptions, e

      • by cen1 ( 2915315 )
        I don't remember the last time I've read so much bullshit. Checked exceptions tell you that something is expected to go wrong and you should deal with it in some way. If that's not the case, use a runtime exception. I love the choice.
      • How do unchecked exceptions fix the things you mentioned? Sure, it's a pain to do proper error handling, but I have never seen any programming language in which error handling is effortless. At least with checked exceptions, the compiler will alert you to unhandled situations.

        Deciding that you won't bother to do proper error handling is fine if you're working on some tool that you only use yourself. But if your code is going to be part of a large complex system, you're trading a bit of development speed now

    • by Anonymous Coward

      I personally think checked exceptions have made me a better programmer, forcing me to think harder about all the things that could go wrong. The argument you hilighted about "bad programmers" abusing the exception handling with a catch-all is just dumb, grasping for an excuse and agree that bad programmers will always find ways to mess things up. It's not like exception handling is rocket science.

    • The only thing wrong with Java checked exceptions is that the mechanism is provided by the exception type definition instead of the usage of the exception. Declaring that an exception can be thrown from a method is an indication from the API designer that this is something important and should be considered by the caller. The caller should simply receive a warning from the compiler, which can be suppressed, or the caller should be able to throw the exception out as unchecked. The latter is possible today, u
  • by Anonymous Coward

    Why not write in Haskell and eliminate ALL bugs?

This file will self-destruct in five minutes.

Working...