4 ms·
Has anyone ever used the cross platform capability of java? Java is cross platform in the way c is cross platform, you can compile to many target platforms. But
by cm2187 4y ago
Has anyone ever used the cross platform capability of java? Java is cross platform in the way c is cross platform, you can compile to many target platforms. But aren't pretty much all java applications intended to run on one specific platform only? Developers like the idea of cross platform but they pretty much never use it. I think javascript is the only language that is truly used in a cross platform way.
- ridruejo 4y agoIt was (and is) very common to develop on a Windows desktop / laptop and deploy to a Linux server
- cm2187 4y agoExactly, that's the "c is cross platform" way. What java offers is that you compile once and you can run the same binaries on any platform (hence freely switching OS as Bill Gates feared). But who uses that in real life? Because compiling on windows and deploying on linux/unix/etc, that was posssible 20 years before java in c/c++.
- Beltalowda 4y ago> Because compiling on windows and deploying on linux/unix/etc, that was posssible 20 years before java in c/c++. "20 years before Java"? That's 1975 we're talking about. Was it possible to build a program on Windows 95/NT and then deploy that to a Unix system? Probably. But given that today this can still be quite a pain to cross-compile C code I bet it wasn't easy. Besides, "it compiles" doesn't mean "it works" or "it works on this other platform" (quite likely with a different CPU architecture), especially not in C. And few people were writing any tests in the 90s. Java abstracted a lot of details like endianness, platform-specific APIs, etc. away. > who uses that in real life? There's quite a few cross-platform Java desktop apps; the IntelliJ IDEs are a good example (although they've since developed Kotlin, it's still the same Java VM). DBeaver is another example, openoffice.org used quite a bit of Java back in the day (although I think that's mostly phased out now) – I'm sure there are more. And of course in the 90s you had Java Web Applets. Java is a bit less popular for this than it was, but I've run plenty of Java programs on my FreeBSD machine back in the day, and I'm pretty sure "FreeBSD" wasn't really something the developers really thought of when they wrote it (I can't remember which off-hand, it was a long time ago but I have "fond" memories of dealing with the manual installation bruhhaha because of the license at the time).
- cm2187 4y ago> Java abstracted a lot of details like endianness, platform-specific APIs, etc. away. Well POSIX dates from the late 80s. That's not cross-CPU, but at least cross-OS, which is what Gates was really concerned about.
- pjmlp 4y agoAnyone doing POSIX in the mid-90's has the scars to prove how "portable" POSIX is in reality, autoconf wasn't created out of coding pleasure.
- Beltalowda 4y agoIt's not like POSIX was universally adopted the day it was released; that took a long time. And not all systems were Unix/POSIX in the first place (e.g. Windows, VMS, the IBM s/3.., and on the consumer side Amiga, Mac OS, BeOS, etc).
- heffer 4y agoThere are a few examples of where this is done. One that comes to my mind would be JOSM: https://josm.openstreetmap.de/ https://josm.openstreetmap.de/ You download one JAR file for any platform you intend to run the application on. There are installers for convenience but the JAR file works just as-is.
- pjmlp 4y agoWe use it all the time, the JARs compiled on Windows get deployed on the cloud without changes, instead of microservices one gets modules (binaries) that consumers cannot mess with unless they are into binary hacking, compiled just once. Nowadays we do the same with .NET code as well, when using .NET Core.
- kaba0 4y agoC is cross platform for a hello world. Anything more complicated and you are deep in OS-specific system calls/libs.
- bpodgursky 4y ago[flagged]
- cm2187 4y agoBut there are hardly any java desktop apps aren't they?
- JonathonW 4y agoJava + Swing was doing cross-platform desktop apps long before Electron was a thing; my editor of choice for years (before moving to Sublime, then Atom and VS Code) was a Swing-based cross-platform editor called JEdit. And the JetBrains IDEs are still Java/Swing applications. (There were other options out there, too— for example, SWT’s the widget toolkit used by Eclipse which feels a bit more native on some platforms than Swing.)
- numpad0 4y agoMinecraft. Macs were always missing games, and Minecraft was "the only game" that ran on MacBook without Bootcamp in late 2010s. Other than that, I'm sure have seen it happen but not sure...
- aeturnum 4y agoYes! Especially in the 90s. The multi-platform story for most things was SO BAD for SO LONG. Now we have better toolchains and we can deploy to most systems easily, but that's a historical aberration. We spent a lot longer struggling in the dark. That's not to say that Java provided a "good" cross-platform experience by our current standards - but the fact that it provided it at all was huge!
- Ksienrzycowy 4y agoAll of my Java backend applications can run seamlessly on Windows and Linux. My small desktop apps also run on Linux and Windows just the same. (with small exceptions) I can reuse my Java code on Android, but since approach to UX on mobile is completely different, the UI front needs to be separate anyway. But I once wrote a game with LibGDX that essentially had the same core codebase.
- askvictor 4y agoC is not cross-platform; you need to compile for each target platform. Java compiles to byte-code which runs on a Java VM, of which there is an implementation on different platforms; you only compile your program once and it will run anywhere there is a JVM. For console/server/webapps applications, this is pretty easy, but for GUI applications it's a bit trickier as each OS has a different look, which is more difficult to abstract. So some applications might have the core running in Java, and a native UI wrapper that provides a native look and feel. But they can be completely Java based (and it's gotten a lot better at dealing with multiple GUI system over time). While they run on a different VM (Dalvik), Android programs are (mostly) written in Java, and provide a cross-platform function - namely different CPUs (Android can come in ARM, ARM64, x86, x64, MIPS), and all run the same binary (except if there's native extensions... which negates all of that)
- kaba0 4y agoJava is the only language I have seen reliably developed from multiple OSs as a team. Even JS fails at this, as plenty of its packages are wrappers over native tools, which more often than not fail to run/run the same way on different OSs. Java on the other hand is basically 100% pure, dependencies/tooling doing FFI is very rare
- bmacho 4y agoI don't understand the question. Some java programs I know run on linux and on windows as well, does that count?