r/programming • • Oct 21 '17

Using Java 9 Modularization to Ship Zero-Dependency Native Apps

https://steveperkins.com/using-java-9-modularization-to-ship-zero-dependency-native-apps#.Wes5IMWbUWE.reddit
310 Upvotes

109 comments sorted by

View all comments

213

u/[deleted] Oct 21 '17

Can we have a talk about what "native" means?

Maybe I am old fashioned but I don't consider a jar and a jvm together comprising a native application.

77

u/SizzlingVortex Oct 21 '17

From the article, I think the author describes native as:

  • Being able to bundle the JVM (versus having the user install Java separately)

  • Not having to embed a web browser like, for example, Electron -- which is called a web-hybrid app in the article

68

u/BadMoonRosin Oct 21 '17 edited Oct 21 '17

Yup... it's a good discussion topic, and I definitely wrestled with the phrasing. Having studied Pascal back in university, and starting out my career as a C++ dev, I too have always thought of "native" as being "a standalone executable".

However, I would run into issues when playing with cross-platform GUI libraries such as wxWidgets, GTK, or Qt. I always wanted to compile my apps down to a statically linked, standalone executable. I didn't want to have to ship a bunch of shared libs, or depend on them being present on the target machines! Yet more knowledgeable developers would calmly try to explain to me that dynamic linking is often technically superior (or with Qt, necessary due to licensing).

Also, last year I went to a Java conference and sat through a few sessions on profiling and JVM tuning. It was a lightbulb moment, that left me considering the possibility that a runtime VM with a JIT compiler really IS a technically superior approach over full AOT compilation.

So anyway, if you're having to ship to tens of megs of dynamically linked libraries with your "native" app... then is it really THAT far removed from an app that's linked to an embedded runtime? I'm not so sure. And I would strongly argue that you have no less claim to the "native" label than Electron has.

43

u/doom_Oo7 Oct 21 '17

Native == the executable you run is a sequence of ASM instructions for your cpu / os without run-time interpretation of algorithms or code necessary for your software's execution.

Also, you can link Qt (and any lgpl stuff actually) statically, as long as you provide object files (not source) upon request.

4

u/xandoid Oct 21 '17

My definition of native is an app that does not replace anything the OS supplies with cross-platform alternatives.

So a Java app using JavaFX to paint its own widgets is not a native app just because it happens to be AOT compiled down to a PE binary on Windows.

8

u/doom_Oo7 Oct 21 '17

My definition of native is an app that does not replace anything the OS supplies with cross-platform alternatives.

I don't think that's a good definition: a lot of OSes provide nothing in the GUI department per se. VxWorks, GenodeOS, Linux... does this mean there can't be native apps in them ?

5

u/bloody-albatross Oct 21 '17

Under Linux its more fine grained. E.g. those Gtk applications don't feel native under my KDE desktop (god I hate the Gtk file chooser).

2

u/The_Jare Oct 21 '17

Strictly speaking, if the OS does not provide it then you are not replacing it, so it doesn't count against the nativeness. :)

1

u/xandoid Oct 22 '17

You're absolutely right. That is exactly what my definition means.

1

u/doom_Oo7 Oct 22 '17

but then it doesn't makes sense since it means some OSes can't even "have" native apps, while native applications don't even need operating systems to run (for instance something you'd write for an arduino).

1

u/xandoid Oct 22 '17 edited Oct 22 '17

but then it doesn't makes sense since it means some OSes can't even "have" native apps

Why? That just doesn't follow from anything I said. I think you misunderstand my definition.

What I'm saying is that "native" is only defined relative to a platform. A platform is defined as a set of APIs. Each API serves a specific purpose, i.e. it helps developers achieve a specific goal.

A native app that wants to achieve some of these same goals will strongly prefer the relevant platform APIs in order to do so. If an app ignores important platform APIs and does the same things differently (usually in a way that is transferrable to other platforms) then it is not a native app.

But of course it's not black and white. There are all sorts of hybrid approaches that are hard to classify as native or not native.

→ More replies (0)

1

u/xandoid Oct 22 '17 edited Oct 22 '17

That is a complete non sequitur. I said "replace", not add something the OS doesn't provide.

1

u/NostalgicCloud Oct 21 '17

Except its not replacing the GUI. It provides it's own widgets that reply on the native api's