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

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.

3

u/pron98 Oct 22 '17 edited Oct 22 '17

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

OK. The software I use most on a daily basis is an OS, a browser, editors with plugins (some entirely written in JS), and an IDE, all heavily rely on runtime interpretation/compilation, and that's before we even get to my phone, where all apps are written mostly in Java (and compiled on installation to save energy).

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.

First, I did not claim that Java is as fast as C, I just said the processor ends up running a stream of native instructions, just as it does when running a program written in C. Second, the reason Java is slower in some cases has absolutely nothing to do with the JIT (which only contributes to warmup time). It mostly has to do with memory layout, and to a lesser extent with GC. What you mention regarding Javascript is similar. None of this has anything to do with being native or not. I'm sure you'd agree that Java is faster than other languages that don't compile at runtime, but may also rely on a GC etc. It is possible to compile even Javascript AOT, yet the resulting "native" code would be much slower than the JITted one, because JITs produce better code in general, and much better code when the language is as dynamic as JS.

1

u/doom_Oo7 Oct 22 '17

OK. The software I use most on a daily basis is an OS, a browser, an editor with plugins, and an IDE, all heavily rely on runtime interpretation/compilation.

So, some questions:

  • what kind of run-time interpretation / compilation does the linux kernel ? apart from BPF, which is unused if you don't use it yourself AFAIK.

  • do you really think browsers are a good example ? these fuckers are slow as mollasses (on modern scriptful websites). I only use them because I have no choice but fuck, isn't browsing the modern web painful.

  • well, I use an IDE too, which happens to be written in c++. Whenever I have to go look on coworker's computers who use intellij or atom I get quite nervous from the whole general slowness feeling... any operation like opening a menu, typing code, just feels laggy.

What then ? LibreOffice ? Native. Krita ? Native. File manager (dolphin) ? Native. Terminal ? native. Compiler ? native.

3

u/pron98 Oct 22 '17 edited Oct 22 '17

what kind of run-time interpretation / compilation does the linux kernel ?

I don't use just the kernel when I use the OS. It runs and interprets hundreds of scripts.

do you really think browsers are a good example ? these fuckers are slow as mollasses

So what? There are native applications that are even slower.

any operation like opening a menu, typing code, just feels laggy.

I can't tell the difference. VS code and NetBeans feel the same to me as any "native" IDE. They're certainly more responsive than MS word.

LibreOffice ? Native.

Extensions are often written in Java/Python.

Krita ? Native. File manager (dolphin) ? Native. Terminal ? native. Compiler ? native.

Good for you. My compiler is written in Java (one of them, at least), my document editor (Typora) is in JS (I admit that it's slow, but not because of JS), Slack is also JS.

I don't think anyone can deny that a huge portion of prevalent software relies to some degree or another on runtime interpretation/code generation, and if it's slower compared to alternatives, that's hardly because it runs a compiler when it loads, but because of other, quite unrelated reasons.

-2

u/doom_Oo7 Oct 22 '17

I don't use just the kernel when I use the OS. It runs and interprets hundreds of scripts.

... really, which ones ? I just don't know. My kernel boots, starts up systemd, which starts X11 and other services like systemd-networkd, systemd-resolved, etc, and runs the following script:

xrandr --output DVI-D-1 --mode 1920x1080 --rate 120
hdspmixer& 
setxkbmap -model pc105 -layout fr -variant oss_latin9
nvidia-settings --load-config-only
exec i3

and then I'm good to go.