segmentio / analytics-kotlin

The hassle-free way to add Segment analytics to your Kotlin app (Android/JVM).

Repository from Github https://github.comsegmentio/analytics-kotlinRepository from Github https://github.comsegmentio/analytics-kotlin

Can you explain what the advantages are of using the Kotlin SDK over the Android SDK?

martymiller opened this issue · comments

commented

I would like to use this, but I currently don't see any advantage.

My team integrated this into the app I'm working on and here are some observations.

  • Switching to the Kotlin version breaks the code and requires a completely different implementation. This makes switching to Kotlin very inconvenient. Why couldn't you make it so the Kotlin version had all the same functions as the Android SDK?

  • You have to build JSONObjects. I don't like building JSONObjects in code (does anyone?) It seems like a very outdated way to build a data structure. Plus, some of my events have JSON Objects inside of them, which makes this even more complicated. The Android SDK offers a simple way to add properties to an Event. Why doesn't the Kotlin version?

  • The events don't show up as "Pretty" anymore on the web site. They looked fine before, and now they don't. My Analytics team will look at the Pretty tab.

  • This library doesn't seem to have the support or adoption rate of the Android SDK (perhaps because of the reasons listed above)

Not trying to be too critical here, but I can't see a single advantage to using this. What am I missing?

  • the architecture is completely different, thus the apis are different. it's also built more idiomatic in kotlin instead of java.
  • when you talk about JSONObject I assume you're talking about org.json.JSONObject. you're right it's a pain to build it. but the new apis take JsonObject instead of JSONObject. it's the one from kotlinx.serialization.json. building it in kotlin is much more easier than building a map/dictionary. looks to me that you're using this library in a java codebase, referring to the java compat page and migration guide for more info. if you internally have a JSONObject, it should be fairly easy to write a utility method to convert it to JsonObject
  • the pretty view is broken because we don't have a kotlin renderer in the segment debugger webpage yet. that's not something caused by sdk. the team is currently working on that.
  • the library is just out for general availability not long ago. the adoption rate is increasing everyday.

if you don't see any advantage, hopefully this performance benchmark will change your mind.

commented

Thanks for the response, but I still think the Android and Kotlin versions should have the same exact functions. Making the implementation very different from the Android SDK seem like the wrong direction to me. If you want people to use this, you should make it easier to integrate, not harder.

you definitely have a point here. I actually agree with that. I guess there are things such as the builder pattern no longer necessary with the optional parameters in kotlin, that brings us to make that decision. besides that, the kotlin sdk is now more in parity with the swift sdk, as well as the other new libraries.