3 ms·
I'm using Lanterna, a Java library for creating text-based terminal GUIs (https://github.com/mabe02/lanterna https://github.com/mabe02/lanterna), and the startu
by atomashpolskiy 9y ago
I'm using Lanterna, a Java library for creating text-based terminal GUIs (https://github.com/mabe02/lanterna https://github.com/mabe02/lanterna), and the startup is 1-2 seconds. Can't recommend it enough
- weberc2 9y agoGood to know, but 1-2 seconds is still very slow compared to a native app. I have an 8MB Go CLI application that can startup and print its help in .05 seconds, and even that is probably slow compared to a C or Rust equivalent.
- deepsun 9y agoWell, printing stuff is easy. Just tried: $ time java HelloWorld Hello, World real 0m0.088s user 0m0.088s sys 0m0.016s
- pebers 9y agoThat's presumably not loading any libraries at all though - the time to being interactive (or just doing something useful) will get worse as more bytecode has to be decompressed and loaded.
- pjmlp 9y ago> That's presumably not loading any libraries at all though Sure it is loading libraries, everything that System.out.println() depends on.
- pjmlp 9y agoAny savy Java developer knows how to AOT compile to native code, if that really matters. There are plenty of JDKs that support it, and even Oracle is finally adding support for it with Java 9, initially only for Linux x64. By Java 10 timeframe no one that only knows about OpenJDK and not the several other JDKs can state that Java starts slow vs C, because both will be AOT compiled to native code, loading native .so files.
- atomashpolskiy 9y agoGood point, but I wonder what size will the final binaries have, given that bytecode inflates significantly when translated to the machine code (there was a good discussion on HN recently about app sizes)
- readittwice 9y agoFrom what I've seen Java/JVM AOT won't produce binary executables but shared libraries that will be loaded on startup by the JVM. When I first read about Java AOT-compilation I expected it to produce real executables that's why I think this is important to mention. But please correct me if I am wrong. So if this is true even with AOT compilation you still need the JVM as dependency (although I think you can get a minimal JVM in under 10MB). It also seems that the AOT compiled code needs to be recompiled on Java updates. Although I quite like Java and the JVM, I still wouldn't choose Java for writing simple command line tools. Nevertheless it is quite useful for improving startup for tools like Gradle or server applications. But sure, I also don't expect Java startup performance to be a problem in the mid- to long-run.
- pjmlp 9y agoCorrect, but that is no different than having to ship glibc.so or MSVCRT.dll alongside your application, specially if you want to be certain which version gets used. This is only relevant to Oracle's implementation though. Other JDKs do support static linking, as long as you restrain yourself from features that could require dynamic compilation. There was a talk at JVM Languages Summit about the current state of AOT compilation regarding Java 10. https://www.youtube.com/watch?v=n5DCg6M2MDM&index=11&list=PLX8CzqL3ArzXJ2EGftrmz4SzS6NRr6p2n https://www.youtube.com/watch?v=n5DCg6M2MDM&index=11&list=PL...
- Manozco 9y agoopening and quiting vim for a file of 2500 lines of C++ (so with all the plugins and stuff) takes 0.030seconds. I don't see how you can be satisfied with 2 seconds startup for a terminal application
- atomashpolskiy 9y agoI completely agree that for a interactive tool like text editor startup time is crucial. But in my case being a bit on the slow side is probably fine, because the UI is for informational purposes only, and VLC takes around 5-10 seconds anyways to startup and begin playing the file, that is being downloaded.
- hdhzy 9y agoWell the torrent download will take a lot more than 2 seconds so that time is totally amortized. Besides this comparison looks like a total bikeshedding unless you plan on downloading torrents with vim. By the way the project looks fantastic. I'll be giving it a try. The alternative for just command line torrent on a *nix is aria2 [0]. Works exactly as advertised. [0]: https://sourceforge.net/projects/aria2/ https://sourceforge.net/projects/aria2/
- rijoja 9y agoWell there is a truth to that. However this might be something symptomatic. As power consumption is getting more and more interesting nowadays, having a minimal impact on system resources overall might still be a sensible goal.