Anki-android: Switch developement Language to Kotlin

Created on 10 Jan 2020  Â·  9Comments  Â·  Source: ankidroid/Anki-Android

Have you tought about slowly transitioning the codebase to Kotlin? It's the new standard nowadays for Android Developement and recommended by Google too. Personally I also think it's Kotlin is a much more pleasant experience to write Code in compared to Java.

Research

Enter an [ x ] character to confirm the points below:

[ x ] I have read the support page and am reporting a bug or enhancement request specific to AnkiDroid

[ x ] I have checked the manual and the FAQ and could not find a solution to my issue

[ x ] I have searched for similar existing issues here and on the user forum

Most helpful comment

This sounds like exactly the sort of thing that volunteers that don't even do native Android development full time would never get around to, or would never finish, and I think that describes all our programming resources here.

So it was considered maybe a year ago and dismissed for roughly that reason. I think this project will be a late adopter if anything, and it's important to mention that while it's "the new standard" and "recommended" I can only think of one library we use that has converted even (okhttp), so from my perspective it's a long game, and only just starting. For resource-constrained projects like this one I see no benefit personally

All my opinion

All 9 comments

This sounds like exactly the sort of thing that volunteers that don't even do native Android development full time would never get around to, or would never finish, and I think that describes all our programming resources here.

So it was considered maybe a year ago and dismissed for roughly that reason. I think this project will be a late adopter if anything, and it's important to mention that while it's "the new standard" and "recommended" I can only think of one library we use that has converted even (okhttp), so from my perspective it's a long game, and only just starting. For resource-constrained projects like this one I see no benefit personally

All my opinion

Well the neat thing about Kotlin is that it blends nicely with Java and everything in the Java ecosystem is available for you in Kotlin. You could start adding new code as Kotlin code and just slowly transition to the new language over time. If you know Java, Kotlin is really easy to get started with and in my opinion it makes you much more efficient. So especially on a resource-constrained project like this you could be more efficient with the resources you have.

I'm not trying to persuade anyone to switch, was more a question on my side, because when contributing to Anki in the future, I would love to write Kotlin.

you're not wrong, just the first rule of software is use the tools your team knows. And right now I think we're all java with no motivation to learn another android language because android isn't our day jobs. So the per-LOC efficiency would be illusory as we'd all be fumbling with a new language to do any LOCs

But the most important thing to note is that the lion's share of the work here from my perspective is stability and forward-porting to new Android APIs. 100x more of that than new features, on my end at least.

Transitioning the codebase would actually make that worse I think. Software engineering in the large, and maintaining distributed systems has cost structures which generally make me not care much at all about implementation language, in the same way that whitespace is just an convention everyone has to agree on then stop debating so real work may be done ;-)

Fair enough. I think we should close this issue then :)

the first rule of software is use the tools your team knows

I've heard many “first rules” of programming but never this one hehe

I recently switched development to Kotlin in one of my projects. I never did any Kotlin before. In an hour I was writing actual code, and it was already better than what I would do with Java. In a day, I knew enough Kotlin to write, so to say, Java in Kotlin. In a week, I was writing Kotlin in Kotlin.

Kotlin does look scary and can appear hard to read for someone who only knows Java. But you can learn it very fast. If used right, you will be getting extremely readable code with no boilerplate. You lose a day or two learning Kotlin, sure, but in the long run you gain it back many times over. By continuing using solely Java, you are increasing your technical debt, as Java itself is one.

I can only think of one library we use that has converted even

IMO it makes sense for a library to be Java- or Kotlin- only. Although few, Java-Kotlin interop issues are not non-existent. Many Kotlin methods parallel those of Java and by using both you unnecessarily bloat your codebase. Probably there are other issues. These might be insignificant on app level, but not in case of a library that's used in many other projects. So it's not surprising that libraries choose to stay Java-only. Converting the whole codebase to Kotlin can be a daunting task.


I think it would be reasonable to at least allow writing new code in Kotlin.

P.S. How cool is being able to write something like this?

val <T> List<T>.lastIndex: Int
    get() = size - 1

val list = listOf(1, 2, 3)
println(list.lastIndex)  // prints 2

Contribute a large amount of effort to the app, then lobby for fundamental changes

What did I say that warranted a rude answer like that?

Do not mistake direct for rude, my answer contained no rudeness, it was reality
That is the reality of working in teams, especially distributed teams working on a massive pile of old software
That is what I mean by first rule of software, I should have been more precise: when turning up to work as a new member of a large-ish team working hard on a big pile of old software? Learn how to use their tools, learn how they use the tools and why, then after feeling it for a bit, suggest change

I would reverse your assumption, that I am being rude. Who shows up to work first day and says let's change up how you do your work? That's ridiculous! I am very direct in answering that, yes

I didn't start this topic. I wasn't lobbying anything. I only wanted to suggest that some of the issues with allowing writing in Kotlin might not be issues at all. You don't have to agree with this, but saying that your opinionpersonal experience is irrelevant because who even are you? Yeah it's just as rude as it is “direct”

I'm out

Was this page helpful?
0 / 5 - 0 ratings