Slashdot Mirror


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

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.

4 of 86 comments (clear)

  1. As a big fan of software quality by raymorris · · Score: 3, Insightful

    As a big fan of software quality, who has long studied how to make better quality software, my experience is that they can be a pretty good indicator.

    The smells don't always indicate a problem right there where the smell is (though they often do), they often tell you something about the skill and care with which the software was developed.

    To stretch an analogy, the smell of rotting meat is largely due to the aptly named putrescine. That's the smell that tells you something is wrong. Putrescine isn't particularly toxic. Putrescine, the smell, is an indicator that something dangerous such as serratia is likely present.

  2. Very good tests are very good by raymorris · · Score: 3, Insightful

    Testing is a great thing. Unit tests typically can tell you that something seems to work under a particular set of conditions, with particular inputs, ignoring concurency and all those other annoying little real-life inconveniences. That's very useful.

    Most commonly, unit tests let you confirm that given normal, anticipated inputs that are supposed to work, under the normal, anticipated conditions that the programmer had in mind when he wrote the code and tests, it more or less works. What we frequently fail to test is failure. What if the input is empty? What of it has multiple values? What if the person's name is a million characters long? You CAN write unit tests for such cases; most people don't.

    A useful excercise is to make a table of all possible inputs to a small function, including empty or null inputs, with the expected result. Then test every possible set of inputs. Obviously, that's only feasible for functions with a small number of inputs, and ideally one output. That level.pf testing can guarantee correctness. Any less cannot. It can only ensure that what the programmer was thinking when they wrote the test matches with when they wrote the code.

  3. "Scientists"? by Anonymous Coward · · Score: 0, Insightful

    Uh, computer scientists aren't scientists...

    (Source: Am a computer scientist.)

  4. Re:It depends on how you get fewer by AuMatar · · Score: 4, Insightful

    Yeah, nobody writes Java write that. Its unreadable and unmaintainable. You write a freaking if statement and a loop. That way people can understand what you're trying to do, and can easily edit it if what the loop needs to do changes. You example would be immediately rejected in any code review.

    --
    I still have more fans than freaks. WTF is wrong with you people?