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

Show parent comments

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.

7

u/pron98 Oct 21 '17 edited 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.

Sure, but the line isn't always so clear cut. A browser executes a lot of Javascript code (not just in web pages, but also in extensions); MS office executes VB code; an OS executes a lot of scripts; games' actual content is usually found in script files interpreted at runtime. Most complex software today must interpret/compile some code as it runs, so while you could decide to draw the line somewhere, the distinction is not always very useful.

1

u/doom_Oo7 Oct 21 '17

MS office executes VB code; an OS executes a lot of scripts; games' actual content is usually found in script files interpreted at runtime. Most complex software today must interpret/compile some code as it runs, so while you could decide to draw the line somewhere, the distinction is not very useful.

I'd say that the distinction is : does the software need to interpret code for normal operation ? e.g. you can write plenty of office documents without using VB scripts. Likewise, linux has BPF but you can run entire days without a single interpreted code running. However you can't run unity3D games without C# code running, even though most of the engine is C++, so I'd not call them native.

6

u/pron98 Oct 21 '17

Yeah, but you can't really run Linux normally without (say, init) scripts, and non-Unity games use Lua scripts and others extensively as well. Anyway, I don't doubt that you could find a reasonable point to draw the line. The question is, what difference does it make? Why is the distinction useful?

2

u/doom_Oo7 Oct 21 '17

Yeah, but you can't really run Linux normally without (say, init) scripts,

... uh, what ? of course you can. Plenty of embedded systems run with just the kernel and init=/bin/my_software. Also, systemd doesn't use scripts for instance.

Why is the distinction useful?

It gives a ballpark of what kind of reactivity and throughput you can expect from your system.

6

u/pron98 Oct 21 '17 edited Oct 21 '17

Plenty of embedded systems run with just the kernel and

That's really not the point. Of course there are some instances of software running without scripts. The point is that the most pervasive software is normally a mix of code compiled at build time and code compiled/interpreted at runtime.

It gives a ballpark of what kind of reactivity and throughput you can expect from your system.

Why? Java, for example, compiles to very efficient machine code, and what runs is the same code as a C program. Javascript is similar. The only difference is that the code is generated at runtime rather than at build time.

It's not that a JIT compilation doesn't have a cost. It takes some time to warm up, and takes up RAM and energy, but max-performance is not it. I also agree that your distinction may be meaningful in constrained environments, but not in general.

1

u/doom_Oo7 Oct 22 '17

The point is that the most pervasive software

I disagree. Most software I use on a daily basis really do not do any kind of interpretation for their "normal" runtime operation.

Why? Java, for example, compiles to very efficient machine code, and what runs is the same code as a C program. Javascript is similar. The only difference is that the code is generated at runtime rather than at build time.

is this why database engines ported from java to C++ end up being ten times faster ? Seriously, the whole "java is as fast as C++ because of JIT" was false twenty years ago, and it's still false today. Let's not even talk about javascript where even when JIT'ed you'd still get so much indirection and memory allocations it's not even funny.

→ More replies (0)

1

u/CyclonusRIP Oct 21 '17

OK suppose I write an application in C++. This application defines a data structure and a program that reads that data structure and executes conditionally based on what it reads. Whole thing compiles down to assembly, so I guess it's a native app then?

2

u/schmerm Oct 22 '17

In this case, the interpreter is native and the sequence of instructions defined by the data structure is not.

2

u/doom_Oo7 Oct 22 '17

This application defines a data structure and a program that reads that data structure and executes conditionally based on what it reads. Whole thing compiles down to assembly, so I guess it's a native app then?

that's like saying your Python program is native because the Python interpreter is written in C

→ More replies (0)