back to article You're not still writing Android apps in Oracle's Java, are you? Google tut-tuts at dev conf

Google released Android Q beta 3 to developers this week, though more significant was word that the company wants developers to write their Android apps in Kotlin rather than Java or C++. Already more than half of the Chocolate Factory's professional developers are using Kotlin and Google is keen for the trend to continue. …

  1. Anonymous Coward
    Anonymous Coward

    maybe that Java lawsuit wasn’t so great after all, huh?

    Java’s loved by its core constituency but not much liked by others.

    No worries, everyone’s forced to use it, for Android.

    Oh wait.

    Now if only The Supremes kick that dumbass copyrightable API ruling into the cesspool where it belongs then there’ll be little reason outside The Enterprise to touch it and Larry won’t be able to afford a new yacht.

    AbstractStrategyFactoryInjectors will be sorely missed. Not.

    1. Doctor Syntax Silver badge

      Re: maybe that Java lawsuit wasn’t so great after all, huh?

      "Java’s loved by its core constituency but not much liked by others."

      That applies to any programming language. It's one of the great traditions of IT.

      1. Yet Another Anonymous coward Silver badge

        Re: maybe that Java lawsuit wasn’t so great after all, huh?

        > The Supremes kick that dumbass copyrightable API ruling into the cesspool

        I was hoping that they would reinforce it.

        Then Oracle get a call from IBM's nazgul about a little thing called S Q and L

  2. Denarius
    Black Helicopters

    nice maybe, however

    How much do the next tools and languages help manage privacy for both developers and end users ? Are the libraries checked for snoopware ?

    Secondly, does any of this allow any OS to finally backup and restore an Android phone locally to a PC or external disk without using some cloud in a commonly accessible format ? I have tried a few that made such claims. All failed in either backup or restore unless new device == old device and even then were mostly unreliable.

    1. Anonymous Coward
      Anonymous Coward

      Re: nice maybe, however

      Are the libraries checked for snoopware ?

      Yes, Google have made sure it's in there.

      1. Anonymous Coward
        Anonymous Coward

        Re: nice maybe, however

        Yeah -- less Oracle, more Google.

    2. slartybartfast

      Re: nice maybe, however

      They want us using cloud backup services because there's a monthly fee attached.

  3. druck Silver badge
    Thumb Down

    K&R Braces

    I went to the Koltin site to have a look, but as soon as I saw it was still using the gawd damned awful K&R style braces formatting in this day and age, I walked away.

    1. Dan 55 Silver badge

      Re: K&R Braces

      Give an example of a language which delimits scopes in a better way and explain the advantages.

      1. Anonymous Coward
        Anonymous Coward

        Re: K&R Braces

        He's going to say Python and we're going to laugh

        1. Anonymous Coward
          Anonymous Coward

          Re: K&R Braces

          Python.

          Damn.

      2. druck Silver badge
        Facepalm

        Re: K&R Braces

        You've missed the point, it's the braces style.

        It has to be Allman or all vomit.

        1. Dan 55 Silver badge

          Re: K&R Braces

          Oh, well, I think we can agree on that.

          But is there anything stopping you using Allman with Kotlin?

        2. Anonymous Coward
          Anonymous Coward

          Re: K&R Braces

          Allman? Ew, God no.

          K&R with mandatory braces ( and a 4-space tab indent )

          However there's nothing stopping you from using Allman in Kotlin.

        3. Anonymous Coward
          Anonymous Coward

          Re: K&R Braces

          I don't trust people that user anything other than Allman

      3. Marco van de Voort

        Re: K&R Braces

        I like the Modula2 solution most. Textual BEGIN END like in Pascal (IMHO better readable, harder to look over), but skip all BEGIN's except function start.

        So always a end of block terminator, no single vs multistatement blocks

    2. DrXym

      Re: K&R Braces

      Personally I prefer braces over explicit do/end blocks or indentation. Aside from being relatively terse they're a point of familiarity for anybody used to them in C, Java, Javascript etc.

      That's probably why the new wave of languages such as Go, Swift, Rust, Kotlin all use them.

      1. Marco van de Voort

        Re: K&R Braces

        Depending on keyboard, they are verbose as braces require modifier keys to type. Textual delimiters, even not overlong multicharacter ones are actually easier and quicker to type, as they are two hand typed in the center of the keyboard.

        The preference for braces only shows that programmers can count, but not know much about typing.

        1. j.bourne
          FAIL

          Re: K&R Braces

          Perhaps typing 'BEGIN' for you is easier than typing {} but I know which I just typed quicker and took less keystrokes. Once you've graduated out of typing with two fingers while staring at the keyboard and can properly touch type you'll realise why it's much easier to type {}.

          1. Marco van de Voort

            Re: K&R Braces

            See my other comment. Usually there is no begin, there is only END. That's 3 characters in the alphabet part of the keyboard versies 2 outside of it requiring ALT-gr on many keyboards.

    3. John Brown (no body) Silver badge

      Re: K&R Braces

      "gawd damned awful K&R style braces "

      Why? Are they red?

      1. TimMaher Silver badge
        Coat

        Re: K&R Braces

        Yup.

        Plus they are over a blue and yellow striped shirt with a punch through, white collar and white, double cuffs; made in Jermyn St.

        This ensemble is under a wool cashmere, double breasted suit in a red over charcoal fine stripe; tailored in Savile Row.

        The whole lot is bottomed out with a highly polished pair of black Oxford brogues from John Lobb in St James.*

        I’ll get my coat. It was made by Aquascutum before they went bust.

        *Other fine bootmakers are available.

    4. OldSoCalCoder

      Re: K&R Braces

      Ya - it's way too much to type a { and }, and it really screws up my cut/copy coding style. I just can't take the time to see if my logic's structured correctly and all the new ultra bitchin languages let you slopshit CIP all you want! (CIP - Code In Panic)

    5. JimBob42

      Re: K&R Braces

      This is also one of the worst things about JS.

    6. Anonymous Coward
      Anonymous Coward

      Re: K&R Braces

      Anyone who thinks it's logical that pairs of braces spanning more than one line should NOT align vertically is an illogical freak.

    7. Jamie Jones Silver badge

      Re: K&R Braces

      I agree about the braces format, but what's worse is their website used the "word" "webinar"

  4. Anonymous Coward
    Anonymous Coward

    I really hate any OS that is strongly tied to a single language...

    ... and moreover keeps on changing it at will.

  5. DrXym

    Lock-in

    Nothing against Kotlin personally but it really stinks that Apple and Google think the best way to maintain market share is to force devs to pick sides about their choice of language.

    1. Anonymous Coward
      Anonymous Coward

      Re: Lock-in

      It's a nice language that runs on the JVM. It's like what Java might have been if Java's designers didn't own shares in replacement keyboard companies.

      1. DrXym

        Re: Lock-in

        As I said, nothing against Kotlin. It's just an observation that these platform holders are trying to make it harder to write portable code.

        Apple wants you to use Swift. Google wants you to use Kotlin. Microsoft wants you to use C#. While they may provide support for alternatives, it's almost always inferior to what they want you to use.

        I also think Java has become a victim of its own success. Oracle *can't* change the language much even if they wanted to. Too much code already runs on it to change the language. That's probably why they opened up the JVM to properly support things like Scala, Groovy, Python (Jython) and now Kotlin which can interoperate with Java without requiring existing code to be rewritten.

        I think Kotlin plans to be rid of the JVM entirely though. They already have a Kotlin native in beta and I assume the plan is to dump dependencies on Java completely at some point.

        1. Anonymous Coward
          Anonymous Coward

          Re: Lock-in

          DrXym - while your comments around platform holders and languages are interesting, they miss the 1000lb elephant in the room which is the Oracle v Google JVM battle. Kotlin is as much around freedom from Oracle as any of the other arguments Google makes.

          And if you're not able to freely make design decisions around your platform due to language limitations or worse, technical or financial challenges imposed by others, do you really want to stick with that language?

          1. devTrail

            Re: Lock-in

            I see it in a slightly different way. The two giants battle each other and get just a few bruises, but in the meantime they smash everything around. Java is not just the language, there is a huge community with tons of open source code out there. In the battle between Google and Oracle all those open source projects are the ones that will get hurt.

            1. Anonymous Coward
              Anonymous Coward

              Re: Lock-in

              If you were in Googles position, would you make the some decision? That may not be the right decision for the wider Java community, but it is an understandable decision being made by Google given the financial risk or potential for sales of Android devices to be halted based on the result of a legal case.

              1. devTrail

                Re: Lock-in

                That may not be the right decision for the wider Java community, but it is an understandable decision being made by Google given the financial risk or potential for sales of Android devices to be halted based on the result of a legal case.

                But still Java will remain an fundamental part of Android, the shift to Kotlin is not going to reduce the risk. Furthermore the legal action is about money, even if Google looses sales of Android wouldn't be halted.

                1. JLV

                  Re: Lock-in

                  (disclaimer: IANAL).

                  The Oracle Google lawsuit has had many incarnations but Oracle’s current legal advantage is tied to Java language API copyright, rather than Dalvik vs JVM considerations.

                  If Google moves to Fuchsia (OS) + Kotlin and Dart, they’re effectively out of reach on their new platform.

            2. MacroRodent

              Re: Lock-in

              > with tons of open source code out there. In the battle between Google and Oracle all those open source projects are the ones that will get hurt.

              Why would that happen? As far as I know, Oracle has never threatened to go after open source projects that use Java as provided by Oracle, IBM, or now the OpenJDK (which is the official open source Java implementation). Google got into trouble because of their Java implementation that Oracle did not like, not their Java code itself.

              There are reasons to dislike Java, but fear that it may disappear is not one of them. It is the new COBOL...

              1. devTrail

                Re: Lock-in

                Why would that happen? As far as I know, Oracle has never threatened to go after open source projects that use Java ...

                No, but this policy eventually will harm participation, it's the usual divide and rule.

                There are reasons to dislike Java, but fear that it may disappear is not one of them. It is the new COBOL...

                It seems you never worked in the enterprise environment. Polyglot programming is increasing its presence, but Java does have a role in this picture. The backend where code is written to be used on a long term and maintainability is a strong requirement still is heavily dependent on Java. Python and Javascript are chosen for shorter lifecycles.

                1. MacroRodent

                  Re: Lock-in

                  It seems we actually agree about the role of Java. Like COBOL before it, it is stable and widely used in the software that keeps enterprises going, and therefore keeps being used.

                  (I think I have actually worked in an "enterprise environment", for more than 30 years)

  6. karlkarl Silver badge

    Luckily in my industry, for ports to Android we can cut the bullsh*t and use a C++ cross compiler (clang or gcc) and develop for Android in exactly the same way as all other platforms, including iOS, Switch, HTML5/WebGL and (RIP) Blackberry.

    Programming language has never been a hard problem to solve. Choose one that can compile for *everything* (i.e NOT Java)... Why do people make such a big deal of it?

    1. Anonymous Coward
      Anonymous Coward

      "we can cut the bullsh*t and use a C++ cross compiler"

      Having endured cross platform development in C and then C++, I dread to think how buggy, unstable and unreadable your code is. Even the STL doesn't help save you from memory errors, and the amount of tests you need to be even reasonably confident the code works reliably is appalling.

      1. Anonymous Coward
        Anonymous Coward

        Says more about your C++ than his.

        Perhaps your code is buggy and not memory safe.

        @El-Reg, how do I fix the formatting ?

        Concurrent, Threadsafe, Memory safe, and easy to write.

        #include <atomic>

        #include <algorithm>

        #include <utility>

        #include <functional>

        #include <iostream>

        #include <thread>

        #include <numeric>

        #include <vector>

        struct worker

        {

        template <typename T>

        worker(T && callable)

        : m_thread{

        std::move(callable)

        }

        {

        }

        ~worker()

        {

        m_thread.join();

        }

        std::thread m_thread;

        };

        int main()

        {

        constexpr int max_workers = 4;

        constexpr int slice = 1024 * 64;

        size_t v1[ slice * max_workers] = {0};

        size_t v2[ slice * max_workers] = {0};

        std::fill(v1,v1+sizeof(v1)/sizeof(*v1),1);

        std::fill(v2,v2+sizeof(v2)/sizeof(*v2),2);

        {

        std::vector< std::shared_ptr<worker> > workers;

        for(int i = max_workers+1; (--i); )

        {

        workers.emplace_back(

        std::make_shared<worker>(

        [&v1,&v2,slice,i](){

        int end = i * slice;

        int begin = end - slice;

        while(begin != end)

        {

        v1[begin] *= v2[begin];

        ++begin;

        }

        })

        );

        }

        // implictly join all threads

        }

        std::size_t dot_product = std::accumulate(std::begin(v1),std::end(v1), 0);

        std::cout << "Got dot product of v1.v2: " << dot_product << "\n";

        return 0;

        }

        1. Bronek Kozicki
          Trollface

          Re: Says more about your C++ than his.

          show off

          1. Anonymous Coward
            Anonymous Coward

            Re: Says more about your C++ than his.

            Mea culpa ;)

        2. JLV

          Re: Says more about your C++ than his.

          This brilliantly misses the point. Kotlin is being used as an application programming language, not as a system language.

          _You_ may be brilliant enough to have the discipline to avoid common bare metal C/C++ coding bugs leading to buffer overflows and ilk.

          But I know I sure as heck don’t want to have to rely Joe Random mobile coder’s skills matching your claims of brilliance because his mobile platform _requires_ C++.

          edit: yes, game coding is C++ based. But that’s because performance is key. And I consider good game coders a large cut above the rest of us, me included.

          I wonder if Rust can have a cross-platform role here. I suppose it depends on its suitability and on the vendors propensity for lock-in.

          1. Anonymous Coward
            Anonymous Coward

            Re: Says more about your C++ than his.

            Leave off, I'm not any better than average. I'm down right mediocre, and all I'm doing is using the stock facilities provided. Conversely you have to be much better than average in the other languages, due to the deranged removal of RAII.

            C++ simply has a lot better people than me, bothering to rigorously specify how the various libraries work. Huge number of people test, and evaluate the C++ and C standards.

            Pretending that using the STL is some sort of god level technique undermines your argument.

            1. JLV

              Re: Says more about your C++ than his.

              Yes, but most of the time you don’t need C++ speed but you always need security. You need a certain level of skill at C++ to reliably not screw up security. Saying that C++ is a prereq to application coding, which is what you are implying, is unrealistic.

              There’s only a certain level of complexity developers can handle, so specialization comes at the expense of wider skill sets. Mine are ANSI SQL, Python, dynamic code generation, automated regression testing, Ansible and dabbling in JS and HTML as well as more esoteric crap. Plus, a lot of what I do relies deeply on runtime introspection and dynamic object composition.

              C++, C and perhaps in the future Rust, are all perfectly suited to system level coding. I still want to learn Rust someday, but I don’t have the time to become a safe C++ coder.

              The reason I fancy Rust is that they seem to have aimed squarely at fully leaving memory allocs to the dev (no GC) coupled with tasking the compiler to reject memory mismanagement. It seems most of your pain is in dealing with the compiler, but then you can expect safety.

              BTW, I am not actually calling you a god. Blowhard, perhaps ;-)

              1. JLV

                Re: Says more about your C++ than his.

                since you were such a cutey with your C++ (damn, this is one time all you {} lovers have a point):

                s = "not so much a god as fear less cut ter and pas ter of .h fi les".split()

                def grab(num):

                . grab.start = getattr(grab, "start", 0)

                . res = s[grab.start:grab.start+num]

                . grab.start += num

                . return res

                di_haiku = {"line %s" % ix: (grab(num)) for ix, num in enumerate([5,7,5])}

                for k, v in di_haiku.items():

                . print("%s (%s): %s" % (k, len(v), " ".join(v)))

                Guess what it says when you sed /^\./ / or somesuch and run it?

                I'm tired but I think a iterator with smart splitting in it would sillable-split "fear-less" as 2 from the base string, but yield words and allow for a proper join of those words in the representation. No need to store anything on grab.start, the iterator will do manage it without state. And, yes, storing data on Python functions is hardly idiomatic Python. But it safe :-)

                1. Anonymous Coward
                  Trollface

                  Re: Says more about your C++ than his.

                  It says the problem with languages with significant white-space, is that copy and paste breaks everything.

                  I think this is perfect, remember the OP's point was about clarity. I don't think I've seen a less clear example.

                  I'll leave this as a monument, and only say "I did it much better than Failing Grayling would have"

                  For the record, list comprehensions, and lambda exist in other languages.

                  1. JLV

                    Re: Says more about your C++ than his.

                    Captain Obvious says

                    Dense is 8 line haiku

                    Whoda thought, genius

              2. Anonymous Coward
                Anonymous Coward

                Re: blowhard

                Yes, but most of the time you don’t need C++ speed but you always need security.

                I didn't mention speed or security, the point I responded to alluded to the idea that cross-platform code cannot be clear. I offered a counterpoint.

                You need a certain level of skill at C++ to reliably not screw up security. Saying that C++ is a prereq to application coding, which is what you are implying, is unrealistic.

                I didn't imply anything other than C++ is a lovely language when written clearly, and offers cross-platform results due to a rigorously specified library.

                There’s only a certain level of complexity developers can handle, so specialization comes at the expense of wider skill sets. Mine are ANSI SQL, Python, dynamic code generation, automated regression testing, Ansible and dabbling in JS and HTML as well as more esoteric crap.

                I'm unable to add anything, it's now my new favourite word salad.

                Plus, a lot of what I do relies deeply on runtime introspection and dynamic object composition.

                I'd love to understand what you mean, and how you think that somehow this is a technique locked away from us po' po' native language users.

                C++, C and perhaps in the future Rust, are all perfectly suited to system level coding. I still want to learn Rust someday, but I don’t have the time to become a safe C++ coder.

                Let's be honest, if you don't have time to write secure code, you code will be insecure, not a language issue, it's independent of language, C++ just requires you actually bother to learn the language, rather than pretend.

                The reason I fancy Rust is that they seem to have aimed squarely at fully leaving memory allocs to the dev (no GC) coupled with tasking the compiler to reject memory mismanagement. It seems most of your pain is in dealing with the compiler, but then you can expect safety.

                In the example I provided, no explicit allocations, no explicit thread management, so I respectfully submit, you are somewhat ill informed as to the capabilities being employed. E.g. RAII.

                BTW, I am not actually calling you a god. Blowhard, perhaps ;-)

                I think you need to revaluate C++ with a less jaundiced view, it offers safety, clarity and portability.

                The STL, Boost and really some of our community's finest engineering work, this sort of bun-fight is just unseemly.

                1. dajames

                  Re: blowhard

                  Plus, a lot of what I do relies deeply on runtime introspection and dynamic object composition.

                  I'd love to understand what you mean, and how you think that somehow this is a technique locked away from us po' po' native language users.

                  "Runtime introspection" is what interpreted languages do instead of RTTI. It can generally tell you a bit more about a type than RTTI can, but once you know what type something is you generally know what you need to.

                  "Dynamic object composition" is all about adding behaviour to an object after it has been created -- maybe even down to changing its class behaviour (a la Javascript). It's the antithesis of type safety but is useful in some languages that aren't properly type-safe anyway. In C++ you'd probably compose type-safe classes at compile-time using template metaprogramming, so you wouldn't need to do it dynamically.

                  C++ has nothing to fear, here.

                  1. Anonymous Coward
                    Thumb Up

                    @dajames

                    Thank you that is helpful.

                    Upvoted.

      2. karlkarl Silver badge

        Perhaps you should give it another shot.

        You realize that C++ is pretty much the industry standard for game development right?

        If it was so "hard" to get memory management right, do you really think it would be so popular?

        Check out std::shared_ptr... RAII is what all the cool kids use today.

    2. Anonymous Coward
      Anonymous Coward

      The problem is not the code generation...

      ... it's the OS API access. OS that have APIs that can easily accessed by any language because their ABIs aren't built on a specific language/VM whatever are better than those that strongly depends on one. Kotlin is still built on Java - and I'm sure the trend is that in a few years someone will get tired of Kotlin and another language becomes fashionable. Good for throw-away applications, not good for those who keep their usability and value for several years. You have to rewrite or get Frankenstein ones with pieces written in different languages as the fashion of the year changes.

    3. devTrail

      Choose one that can compile for *everything* (i.e NOT Java)...

      Why not Java? There are tools that can generate Android, iOS or HTML5 code also from Java.

      1. karlkarl Silver badge

        Java (and mainly its massive VM / runtime system (written in C++)) are too large to really be effective to port to other platforms. Yes, you mention there are a few tools which can partially do the job but they are extremely poor at doing so. I.e I will never see Java code running on a console. Partially the reason why Minecraft had to be rewritten in C++ for example.

        Because everything goes through a native (i.e the OS language) first. To use Java (or .NET, Python, Limbo, etc...) you need to make a binding. By the time you have made a memory safe binding for your fancy high level language of choice, the tight deadlines I am often under have already passed weeks ago :/

        Also, imagine I made a really cool library in Python but you use Java. How would you call Python code from Java? You need to go through sodding C (or C++), and so you will be effectively be writing a double binding layer... Error prone, messy and full of memory errors. So I am a nice person. I write my library in C++ and then all language can just write a single layer of binding. You can be a nice person too and write in C++, so we can eliminate all this binding bullshit, get the actual job done and make this world a better place XD

        From my experience, there is *never* a good reason not to use a (safe) native language like C++ for software engineering projects. If you are using anything else, you are either doing it for fun, or you are wasting time. Other languages are an "illluuussiioon" ;)

        1. Bronek Kozicki

          I just happen to work with TensorFlow, PyTorch and Horovod at this moment. These are written in C++ but meant for consumption in Python. That is, the Python bindings are part of the interface around which these projects are designed, from the inception. And it makes sense, given that users of these libraries are data scientists who are unlikely to know C++ but are likely to want to use many other Python libraries in the same project.

          It just sometimes makes sense to use, and write in something else than C++ - even if it happens to be ones most preferred language. It is actually perfectly normal that the language is bound to domain, and not all domains have affinity to C++ (or C).

          Having said that, I do agree that a VM for a language (JVM CLR and beam) is a very annoying waste of CPU cycles. Sadly we are not going to get rid of them in the foreseeable future, so might as well learn.

        2. dajames

          How would you call Python code from Java?

          Use Jython?

    4. JohnFen

      This is what I've done for my own Android development that isn't intended for wider distribution.

  7. Kez
    Big Brother

    IoT Farce

    "Google put its Home products under the Nest brand and announced the end of its Works with Nest developer program, which will shut down on August 31, 2019"

    Reading this from other sources, I understand that Google is effectively removing support for existing third party integrations for Nest hardware that people have already installed in their homes. Why is this allowed? You can buy your Things™, adorn your home with them, but they will never truly belong to you - at Things™ inc. we reserve the right to render Things™ useless with OTA updates. Just another page in the book documenting the never ending farce that is IoT.

    1. Gene Cash Silver badge

      Re: IoT Farce

      Eh, remember what Google did to Revolv? Bought 'em and turned them off after less than a month?

      That killed IoT/smarthome/etc for me.

      The only viable smarthome stuff is now Alexa, because Amazon is (so far) not stupid enough to turn off it's customer's products.

  8. Zarno
    Facepalm

    Random MAC

    Ain't that the cheese...

    I tend to like my phone having the same address(s), makes it easier to whitelist it to my network, and makes bluetooth connections work right.

    Tracking and data harvesting is getting heavy enough that we now have to fake things that really shouldn't need to be faked to begin with.

    1. Jamie Jones Silver badge

      Re: Random MAC

      The bigger issue is the routers MAC. That's how they track location wifhout GPS.

      However, the solution is really to stop "apps" having access to such low level information.

  9. Gene Cash Silver badge

    "Google is encouraging Nest customers to convert their Nest accounts into Google accounts"

    Did they not fucking learn with Google+/YouTube? Apparently not...

    I wouldn't touch Nest with someone else's 10ft pole.

  10. Doctor Syntax Silver badge

    "the company wants developers to write their Android apps in Kotlin rather than Java"

    Coming next: Oracle sues them for abandoning Java.

  11. JohnFen

    To be fair

    I couldn't care less what Google approves or disapproves of.

  12. GrapeBunch
    Childcatcher

    Didn't want to cut in line.

    OK, I'm brain-dead, but I do find the first example of a Kotlin programme in the Wikipedia to be confusing. My first but not only confusion is the variable name, which seems to be scope. To me, that word wants to be a keyword. If it is not a keyword, then don't use it.

    // Hello, World! example

    fun main() {

    val scope = "World"

    println("Hello, $scope!")

    }

    fun main(args: Array<String>) {

    for (arg in args) {

    println(arg)

    }

    }

    The discussion so far has been remarkably blood-free, considering that it is about religion.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon

Other stories you might like