3 ms·
Just out of curiosity: If you decide to use Java (or any other languages that run on JVM), are their 3rd party libraries as "nice" (read: as many) as npm?
by ohstopitu 10y ago
Just out of curiosity: If you decide to use Java (or any other languages that run on JVM), are their 3rd party libraries as "nice" (read: as many) as npm?
- javajosh 10y agoJava has an incredible range of libraries, often of very high quality. You have to manually install the dependency piece in the form of Maven (http://maven.apache.org/ http://maven.apache.org/), or if you're doing Clojure, Leiningen (https://leiningen.org/ https://leiningen.org/). The total number of artifacts in the main archive, Maven Central (http://search.maven.org/#stats http://search.maven.org/#stats) is ~1.8M.
- hkjgkjy 10y agoFormer node dev, currently Clojure here. Npm has more abundance of good packages. They are typically better documented and easier to get started with, sadly :(. JVM has some really great stuff - things which are lightyears ahead of what is there in NPM. Much of which started as university projects, as Java is popular at schools. I wish JVM developers took a hint from others and started making very easy and fun documentation, but have no high hopes.
- mike_hearn 10y agoCan you give some examples? I've usually found docs to be pretty good in the Java library space. One of the nice surprises about it.
- hkjgkjy 10y agoHi Mike! Big fan of your work! Have been for years, so it's a pleasure seeing you have replied to my comment. My latest example of this is the Apache Commons-Net Java package [0]. I wanted to make a toy Telnet server as an example for a friend asking how to do so. I gave trying to install the library a good 20 minutes in my evening at home. Couldn't find a simple Maven "this is how you install" and no "easy 1-2-3 get started with this library" text either. After looking around for a while, I decided to check how to do it in Node. It's super easy, you just do require('net').createServer((socket) => socket.write('Hello from a toy telnet server!')).listen(8080) And that is all! Got my task done in 5 minutes, and my friend learned something easy. My takeaway is that for software to be successful, being technically sound is only the first half of the marathon. You also need to make it accessible. [0] https://commons.apache.org/proper/commons-net/ https://commons.apache.org/proper/commons-net/
- mike_hearn 10y agoA telnet server is just a socket connected to a pty, no? I'm not sure there's much to it, which is why it's so easy in node. I guess in java you'd do the same program something like this: ServerSocket server = new ServerSocket(8080); while (true) { try (Socket sock = server.accept()) { sock.getOutputStream().write("Hello world!".getBytes()); } } It's a bit more verbose, but hey, that's Java. I think maybe the issue there is you got distracted by the idea that you needed a library. Commons-Net doesn't actually provide a telnet server because it doesn't need to. That said, I agree that Commons-Net doesn't have great docs. I think it's fallen out of use over time. These days if you wanted a powerful non-blocking socket library you'd use Netty or VertX. The docs for Netty are much better: http://netty.io/wiki/index.html http://netty.io/wiki/index.html
- hkjgkjy 10y agoCheers for the example. The Commons-Net library was where I ended up after some searching - so my experience is of someone who wants to get from 0 to 100 asap. Cheers and have a good day!
- lmm 10y agoYes. Maven has been doing package management right for years (and avoids the wasteful repetition that node does, that can often hide silent incompatibilities until runtime).
- Macha 10y agoIf you're building jars with a classpath on the filesystem, maybe. If you're building wars, fat-jars or anything else that gets you to that "single jar deployment" which is often mentioned as a pro, you're definitely not immune to duplication. Especially when you get to libraries that have changed their package name over the year like say jackson.
- lmm 10y ago> If you're building wars, fat-jars or anything else that gets you to that "single jar deployment" which is often mentioned as a pro, you're definitely not immune to duplication. True, though at least it's once per transitive dependency per deployable application rather than once per path to transitive dependency per project. > Especially when you get to libraries that have changed their package name over the year like say jackson. Yeah, you do have to deal with those, though it's a relatively small number IME. It would be nice if maven had some integrated support for saying that library x and y are actually what was previously combined library z or similar, though I'm not aware of any package manager that does that yet.