Hacker News new | ask | show | jobs
by pjmlp 4641 days ago
> I'm surprised nobody has mentioned Android yet. When you add in the Android factor, Java is probably still one of the most widely used programming languages today.

Except that Oracle was right into suing Google, after all.

Google hasn't improved the language level beyond Java 6 grammar.

So nowadays one is forced to write in Java 6 when targeting Android, which is really a pain, specially when writing libraries.

This will only get worse when Java 8 gets released. No lambdas or other Java 8 goodies for Android developers.

Plus, they haven't bothered to improved GC and JIT on Dalvik past the Android 2.3 release.

They seem to care only about pushing libraries for Google APIs nowadays.

3 comments

> Google hasn't improved the language level beyond Java 6 grammar.

That's because Oracle has been suing them over it. Dalvik hasn't changed in years thanks to that lawsuit. Google was steadily improving Dalvik right up until that lawsuit happened, then it came to a screeching halt. That's not a coincidence.

And really, what Java 7 language level features were there that makes it problematic that Android still runs Java 6? The good stuff was dropped from 7 and pushed to 8. 7 is boring.

> That's because Oracle has been suing them over it. ...

Sun just did not sue them, because they lacked the money. James Gosling confirmed this.

> And really, what Java 7 language level features were there that makes it problematic that Android still runs Java 6? The good stuff was dropped from 7 and pushed to 8. 7 is boring

- Strings in switch

- Try with resources

- Multiple exceptions in catch

- Simplified IO

- Diamond type inference

- invoke dynamic optimizations

Any Java library targeted for Java 7, even without the new language features, is also not usable in Android projects, because Dex cannot understand the new Java 7 bytecodes.

Google is a corporation like any other.

Two can play that game,

http://news.cnet.com/8301-1035_3-57423754-94/java-creator-ja...

<quote> In his testimony last week, Schwartz explained his "grit our teeth" strategy after Android had its public debut as an incompatible variant of Sun's Java. "We saw a handset bypass our brand and licensing restrictions...we decided to grit our teeth and support it so anyone supporting it would see us as part of the value chain," he said. Apparently, continuing to seek a way to work with Google -- to turn lemons into lemonade, as Gosling wrote -- was preferable to engaging in a costly lawsuit. </quote>

So Sun chose not to sue Google, because it would be costly (and because they knew they'd lose). They could have afforded it, but they chose not to.

History shows that was probably the right decision - As previously mentioned Google kept Android Java close to Sun Java, while now they have stopped updating it and may be considering other platforms.

BTW, you realise Gosling isn't exactly an impartial player here, right? He's always been against open sourcing Java (and open source generally: the EMACS wars probably had something to do with that), and sees what Google did as justification for his opposition. Others (including myself) see Google's actions as vindication of the Java Open Source strategy: it expanded the Java ecosystem into new fields, and made Java more important, not less.

Simplified IO is a library feature, not a language feature, and Android has its own IO stuff anyway.

Diamond type inference is cute, but hardly important. You could do the same thing with a save macro in your IDE.

Try with resources is about the only thing in that list that would be actually useful in Android.

> Any Java library targeted for Java 7, even without the new language features, is also not usable in Android projects, because Dex cannot understand the new Java 7 bytecodes.

So target Java 6 if you're making a library. Which is what people do anyway, because not everyone has immediately jumped to 7.

And none of them will run on J2ME which Sun/Oracle never upgraded past 1.3 for Pete's sake. If not upgrading Java was worthy of a lawsuit, we should be class action'ing the hell out of Oracle for the crime against humanity that was J2ME.

BlackBerry was also 1.3 right up until the end.

Android right now is only using a version of Java that's ~1 year out of date. That's still a shitload better still than Sun ever managed to do on mobile.

> Google is a corporation like any other.

Cows go moo.

Saying irrelevant facts is fun! You're on to something here I think.

Actually, you can use the following on Android from Java 7 and 8:

- Case/Switch Strings

- Auto closing files handlers (via adding a few classes/interfaces). Also known as "try with resources"

- Integer literals

- Multiple exceptions in a catch block

- Lambdas via RetroLambda[2], which compiles Java 8 bytecode into 7 or 6

Used them all in several projects with 20-100k+ downloads with no user reported errors related to their usage. New Android projects though, I rather just use Scala, but older things I don't want to convert, I use the above to make Java easier to manage.

[1] https://github.com/yareally/Java7-on-Android (small guide I set up to explain how to add all the features above)

[2] https://github.com/orfjackal/retrolambda

It is not official part of Android SDK, which only supports Java 6 officially, so not possible to use in our enterprise projects.

Thanks for the tips, though.

You have cause and effect backward. Oracle created a hostile environment for developing Java as an Android language.

Secondly, Android's base classes and AIDL are a significant advance in Java.

What?!?