6 ms·
I'm curious, it looks like the screenshot shows the author is using a Mac. But Mac OS hasn't shipped with Java in several years. So why Java? Is it simply famil
by styfle 9y ago
I'm curious, it looks like the screenshot shows the author is using a Mac. But Mac OS hasn't shipped with Java in several years. So why Java? Is it simply familiarity, or are there other reasons?
- pvg 9y agoMost OS's don't ship with a C compiler, go, python 3, rust, arc, etc, what does that have to do with anything?
- soperj 9y agoTechnically _most_ ship with a C compiler and a python compiler since pretty well every linux distribution & bsd distribution has those. But that really doesn't have anything to do with which language you should use.
- pvg 9y agoTechnically, that's not true.
- weberc2 9y agoYou're conflating developer tools with a language runtime. Every popular OS ships with everything necessary to run a C, Go, or Rust binary. Python 3 and Java both require a separate runtime to be installed, but I will say that every Java CLI I've used has had terrible startup performance.
- atomashpolskiy 9y agoI'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)
- deepsun 9y agoSome apps just include JRE into the app package (+100MB), and just use it if it's not provided by OS. But then you need to provide different app packages for different OSes.
- weberc2 9y agoC, Go, and Rust would require different app packages for different OSes--that's not a problem. The problem is bundling a 100MB runtime for a CLI.
- Zekio 9y agopeople bundle a browser for a tiny icon in your taskbar so 100MB for a runtime in a CLI isn't gonna prevent people from using it
- pjmlp 9y agoJava 9 has a linker, you have remove everything that is not needed and have a application specific runtime. On top of that, if lucky enough to be on an Linux x64 system, you can AOT compile to native code.
- pvg 9y agoI'm not conflating them and it's still a silly way to frame the question. If you want to ask someone why they wrote something in language X, just ask them that.
- weberc2 9y agoYou're being pedantic; natural language is contextual for better or worse. Anyway, asking "Why did you use Java", is likely to be interpreted as a slight against the language and thus be downvoted (indeed, his politely phrased question was even downvoted when I saw it!).
- atomashpolskiy 9y agoA mix of both, actually. I've been using uTorrent for years until 2016, when I've decided to switch to some new OS X release. After installing the system update, the old, ad-free version of uTorrent has stopped working. The new version seemed a bloated mess to me, so I've tried a few other clients, but was left unsatisfied. Finally, in despair I've decided to write my own client with simplistic command-line UI, with emphasis on streaming movies. The sheer amount of new information in BEPs was enough for me to decide to take the easiest route and use the language, that I'm most familiar with.
- styfle 9y agoThanks for the reply (it seems my question caused an uproar here, oops). I definitely like the idea. My question was more aimed to understand if Java has some desirable features for writing a torrent client maybe as part of the SDK or other 3rd party libs. I didn't even look at your source code yet :P Java stood out to me because I don't think I've seen other CLIs written in Java.
- atomashpolskiy 9y agoTurns out that the gif was kind of misleading, it's just a demo application for the library. I'm trying to use as little 3rd party dependencies as possible (core only uses slf4j and Guice)
- jrs95 9y agoThis is a library for development. If you wanted to ship a client based on this, you could do that and package it with the Java runtime.