4 ms·
> but your Java .class files are portable. No, they aren't, they regularly have non-portable dependencies or assumptions about the environment. For example, i
by kllrnohj 6y ago
> but your Java .class files are portable.
No, they aren't, they regularly have non-portable dependencies or assumptions about the environment.
For example, it's more or less impossible to write a Java program that runs on Windows, Android, and iOS - the 3 most popular OS's. You have completely different UI support between Windows & Android, and there's not really any JVM for iOS (there's AOT, but now you're not even pretending to run a .class file)
So to make a "portable Java" program you're already stuck compiling it 3 times for the 3 major OS platforms, but without anything helping you to actually specialize for a platform like exists with C++. Making Java less portable in practice than C++.
Toss in that other popular platform, web, and the "portability" of Java gets even worse compared to others like C++.
- hota_mazi 6y ago> For example, it's more or less impossible to write a Java program that runs on Windows, Android, and iOS Not only is it possible, it happens all the time. The entire Maven Central repository, which contains tens of thousands of JVM libraries, is usable on all the platforms you just listed. If that's not portability, I don't know what is.
- kllrnohj 6y agoMaven runs on 1 out of the 4 mentioned platforms. There are no Android, iOS, or web builds of Maven. Maven is used to ship dependences for the other platforms, but it is not run itself on those other platforms. Shipping an Android-specific library on Maven isn't magically portable (which is what's common here - OS-specific libraries on Maven). It's still Android-specific.
- hota_mazi 6y agoAll Android builds use Gradle and download their dependencies from Maven Central. I have no idea what you're talking about. Let me repeat this: all Windows, macOS, Linux, and Android apps that use Maven or Gradle to build ALL download their dependencies from Maven Central. These are the very same libraries, same bytecode. For example, do you use Mockito? You will download that exact same library from Maven Central regardless of the platform you are building on.
- kllrnohj 6y agoWhen you build Android you're not building it on Android, you're building it on Windows, MacOS, or Linux. Maven itself is not being run on Android or iOS. The Java code that powers Maven isn't portable. The AndroidX code hosted on Maven that everyone is pulling down for Android isn't portable, either. Your claim would be like saying that PHP is portable because every platform has a web browser that can talk to the server running modphp. That's not what portability means. > For example, do you use Mockito? You will download that exact same library from Maven Central regardless of the platform you are building on. Mockito only runs on 2 of the 4 platforms (doesn't run on iOS or web).
- hota_mazi 6y agoWho cares about Maven-the-app, we are talking about the portability of the JVM bytecode. There are gigs of JVM bytecodes stored on Maven Central and these bytecodes are being downloaded and run on macOS, Windows, Linux, and Android on a daily basis without a single change. The very same libraries. Unchanged. That's the very definition of portability. I don't understand why you keep shifting topics by bringing up irrelevant observations.
- kllrnohj 6y agoThere's no portability requirement to being on Maven Central. Maven Central regularly hosts non-portable bytecode - like every AndroidX library. And, again, none of those libraries run on Windows, Android, iOS, and web - the 4 major platforms by market share. At best you get half of those, but typically you don't even get that, and that's still only libraries. None of them are portable applications. It's trivial to write semi-portable C++ snippets, too, that's not a major achievement.
- hota_mazi 6y agoNow you're being intentionally obtuse and moving the goal posts from your original claims just to score points. You're not arguing in good faith. Feel free to stick with your invalid views on portability, the rest of us JVM developers will keep enjoying the portability that this wonderful technology provides us.
- jsight 6y agoWhen people call .class files portable, they mean between platforms that have a JVM available and can pass the TCK. Platforms that do not aim to do that are not really relevant.
- kllrnohj 6y agoThat's like saying C++ exe's are portable if you just ignore all platforms that don't have an NT kernel. Market share determines a platform's relevance to portability claims, not its intention towards the JVM.
- jacques_chester 6y agoI see that your goalposts in this discussion are also highly portable.