• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Android and Java, is it still OK to start with Java?

 
Greenhorn
Posts: 28
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know that Google is now prfer Kotlin. I'm a beginner and would like to learn Abdroid development. I started with Java fundamentals and now learning about collections. Should I stop and move to Kotlin? or ia it OK if I continue with Java if my goal is to build Android apps? I'm just worrying that I may face issues in Android tutorials with Java? they could be outdated for example?

Please advise.
 
Saloon Keeper
Posts: 7585
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch.

It's perfectly OK to use Java. All the core Android libraries, as well as Google's Jetpack/AndroidX libraries, is fully compatible with Java as well as Kotlin, and will remain to be so for the foreseeable future. That's why you'll see code examples in both languages in the Android documentation, for example in https://developer.android.com/topic/libraries/architecture/workmanager/basics
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch, Sami!

Unfortunately, since Android doesn't adhere as strongly to Java's backwards-compatibity mindset as "real" Java does and mutates radically quite frequently, it's pretty likely that even Kotlin examples can be out of date. Especially anything that comes to asynchronous processing.

Conversely, there are still some good books and sites using Java that are still valuable.

Yes, in the long run, Kotlin would be the better way to go, but one good thing about Android Studio is that you can write in Java and have it automatically convert to Kotlin you you can get a good intro to Kotlin based on your own code as examples.
 
Sami radwan
Greenhorn
Posts: 28
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:Welcome to the Ranch, Sami!

Unfortunately, since Android doesn't adhere as strongly to Java's backwards-compatibity mindset as "real" Java does and mutates radically quite frequently, it's pretty likely that even Kotlin examples can be out of date. Especially anything that comes to asynchronous processing.



In this case which one should I focus on?
 
Tim Moores
Saloon Keeper
Posts: 7585
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java. As Tim H said, you can always convert Java to Kotlin if necessary (whereas the reverse is not generally true). And there are many more Android books and examples out there than Kotlin ones, so it'll be easier to get started with.
 
Sami radwan
Greenhorn
Posts: 28
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Moores wrote:Java. As Tim H said, you can always convert Java to Kotlin if necessary (whereas the reverse is not generally true). And there are many more Android books and examples out there than Kotlin ones, so it'll be easier to get started with.



But I'm wondering if I will fcae any issues? for example I may follow a video tutorial and dfind something nkt working because it is outdated?
 
Tim Moores
Saloon Keeper
Posts: 7585
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Stuff on the net isn't always up-to-date, that's just a fact of life. But that's always a risk, no matter what language or technology you use. In most cases it's not hard to find more current material.
 
Sami radwan
Greenhorn
Posts: 28
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any good reason why to pick Java other than finding tutorials?
 
Tim Moores
Saloon Keeper
Posts: 7585
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just a few off the top of my head:

Because you're already familiar with it

Because you can use it elsewhere more easily than Kotlin

you can always convert Java to Kotlin if necessary (whereas the reverse is not generally true)



...
 
Tim Holloway
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I should mention that the app that I wrote for grocery shopping is still in Java.

I had to change a LOT of the java code, since the original version ran somewhere back around Cupcake, but as of the moment, I haven't bitten the Kotlin bullet.
 
Ranch Hand
Posts: 606
11
Android Python Open BSD VI Editor Slackware
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sami radwan wrote:I know that Google is now prfer Kotlin. I'm a beginner and would like to learn Abdroid development. I started with Java fundamentals and now learning about collections. Should I stop and move to Kotlin? or ia it OK if I continue with Java if my goal is to build Android apps? I'm just worrying that I may face issues in Android tutorials with Java? they could be outdated for example?

Please advise.


if you want to work with Android, make some basic java as you did, and then switch to kotlin, is the best way to find a job as junior, you need to learn a lot of other stuff, i met well paid android programmers that never programmed in java, although can recognize of course the more verbose syntax
 
Tim Holloway
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Android platform is so slippery that I cannot say with any confidence that Kotlin examples won't be just as out of date.

I am personally very irritated that standards come and go in Android faster that I can keep track of them. Java was designed to "write once/run forever" (not really, but close), whereas Android reminds me of the Database Interface of the Week aspects of Microsoft Windows.

This is not due to language-related obsolescence, it's due to a lack of quality in architectural definitions. Indeed, Android is probably carrying a lot of bloat by now, since it does at least tend to support obsolete services of several different generations.

While it would be easy to blame the people behind Android for sloppy design, I think that it's possible that a core architectural decision may have a lot to do with it.

Specifically, in Java desktop GUI apps and many other desktop GUI platforms, the actual control and graphics rendering is done by an auxiliary thread and the actual application logic is done by the main thread. In Android - and in JavaScript - the priorities are reversed. The GUI is handled by the main thread and the other services must either be friendly to the GUI timing and resource requirements or relegated to secondary threads. In practice this can get VERY messy. In Android, it is responsible for many of the variant evolved versions of things like database interfacing. In NodeJS, you get afflicted by "promise" callbacks with often layer to insane depts.

So having vented my rage. No, I don't think that Kotlin will protect you against obsolete code sources and practices. Only the oldest code examples are Java-only these days.
 
Giovanni Montano
Ranch Hand
Posts: 606
11
Android Python Open BSD VI Editor Slackware
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:This is not due to language-related obsolescence, it's due to a lack of quality in architectural definitions. Indeed, Android is probably carrying a lot of bloat by now, since it does at least tend to support obsolete services of several different generations.



This is changed there are good chances using a pure Kotlin stack we will be able to code mainstream in iOS in a couple of years, already few important companies are using KMM Kotlin Multiplatform, that has definitive chances contending with JS, Dart and Python to become the language for everything. Java was great but and I love the verbosity, but since there are Streams is evolving in a completely different direction to survive in my opinion.

The View.java that was obscene will be soon deprecated because of the new declarative way to write reactive Views with Jetpack compose ,
with Flow  the reactive paradigm is much simpler than was with RXJava and coroutines are really powerful
Clean architecture that is now largely adopted does the rest

Today Android is much better, and all the hassle we took to learn made us better developers,  the stack i mentioned is far to go away and is really SOLID, so are becoming the APIs/SDK full of functional flows.
 
Tim Holloway
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Up until now, I've been answering the question, "Is it still OK to start with Java". And (so far) my answer is yes.

However, Kotlin the language has been adopting constructs to make Android development less warty. It's still at the point where there are Java equivalents, but the Kotlin counterparts are more streamlined. Some of the improvements do have the intent of making it easier to deal with the sideways tasking model that Android is based on.

So after all of the above, if you have serious intentions of becoming an Android developer and you don't have a Java legacy to leap from, there's a good case to be made for starting with Kotlin. Again, Kotlin is being tuned to be Android friendly and Java (for the most part) is not. Plus a lot of the move to Kotlin has been made to ensure that Oracle doesn't someday win a lawsuit that makes it prohibitive to use Java for Android development. They haven't done well so far, but the US Justice System is no longer very consistent. Well, less so even than before.

I still maintain that regardless of the language, an architecture where the GUI is the main thread and the business logic has to hang off of it as opposed to the other way around is a really horrible concept. But Android is stuck with it.

 
Giovanni Montano
Ranch Hand
Posts: 606
11
Android Python Open BSD VI Editor Slackware
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:Up until now, I've been answering the question, "Is it still OK to start with Java". And (so far) my answer is yes.

However, Kotlin the language has been adopting constructs to make Android development less warty. It's still at the point where there are Java equivalents, but the Kotlin counterparts are more streamlined. Some of the improvements do have the intent of making it easier to deal with the sideways tasking model that Android is based on.

So after all of the above, if you have serious intentions of becoming an Android developer and you don't have a Java legacy to leap from, there's a good case to be made for starting with Kotlin. Again, Kotlin is being tuned to be Android friendly and Java (for the most part) is not. Plus a lot of the move to Kotlin has been made to ensure that Oracle doesn't someday win a lawsuit that makes it prohibitive to use Java for Android development. They haven't done well so far, but the US Justice System is no longer very consistent. Well, less so even than before.

I still maintain that regardless of the language, an architecture where the GUI is the main thread and the business logic has to hang off of it as opposed to the other way around is a really horrible concept. But Android is stuck with it.


Agree on all, often I wonder how would have been our android devs life if did not have the lawsuit you mention. I remember I did not want to learn a new language, and found more re-insuring the java verbosity, because of the difficulties of the Kotlin constructs, his idiomatic forms, and mostly because i had to cover so many other concepts that learning 2 languages was really challenging.
Some years later I am really happy I learned Kotlin because now I can read failry easy a lot of other languages, especially the functional ones.
 
That is a really big piece of pie for such a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic