What is the advantage of "companion object" vs static keyword

No. I meant within the same language. For example for C, the transitions from K&R C to C90 to C99 to C11, with similar transitions for Fortran 77, Fortran 90, and for Java 1, 2, 3, 4, 5, 6, 7, 8, 9. AFAIK, none of these transitions broke source code. Yes, you may have needed to use compiler switches to stop warnings, but the source code was upward compatible. Swift 3 was not source compatible with Swift 2, and Swift 2 was not source compatible with Swift 1. I believe Swift 4 source is “largely compatible” with Swift 3, but that’s like pregnancy - you either are or you are not.

And AFAIK, unlike Objective-C, C++ was never upward compatible with C - it was similar, but not compatible.

And Kotlin is not the same language as Java and Kotlin does at least maintain compatibility since 1.0 (it actually did not prior to 1.0). So your point does not seem relevant.

It was compatible enough that I was not going to split hairs with you on the level of compatibility. I would certainly agree that compatibility or similarity was indeed important for the C to C++ transition and does support your argument, but that is really the only example that I see.

Well the kotlin language lead has said many times they have been thinking about removing companion objects because they’ve been used like statics.

Kotlin no static keyword, so they use companion object instant of static keyword, if you want to use static keyword as Java code must be use annotation in Kotlin to know static keyword.
Kotlin:

  1. Create class type object no need companion keyword
    object NetworkUtil {
    fun callMe(){}
    }
    we can call direct from class object.
    access: NetworkUtil.callMe()
  2. Create class by create companion object inside class
    class NetworkUtil{
    companion object {
    fun callMe() {
    }
    }
    }
    access: NetworkUtil.callMe()
  3. Create class type object after add Annotation keyword top of fun want to use.
    object NetworkUtil {
    @JvmStatic
    fun callMe(){}
    }
    access: NetworkUtil.callMe()

Is this not the way that we define companion object methods?

Check out this topic: Please close the mega topics (ternary and companion objects)

This recent post is a post in response to the 35th post in this thread and is a really good example of how a mega thread isn’t able to end naturally:

The topics aren’t ending naturally
These topics are interesting and people will have an opinion on them. This is great until the topic becomes a place to petition for/against a position. Even though everything has been said, another user will come in support/against the feature of discussion without communicating anything new.

The original link is far enough up in the thread history that there’s a good chance people won’t see it and resume commenting on this thread.

Reposting hoping this link remains at the bottom :slightly_smiling_face:

Thank you, we have decided to close this topic. You can read the quick summary here.