Live data from Hacker News

An Opinionated Guide to Modern Java, Part 2

blog.paralleluniverse.co

31–40 of 138 posts

Re: An Opinionated Guide to Modern Java, Part 2

#31
post #9
post #5

As someone not very familiar with Java can someone expand on what he means by this: "Every library is usually packaged into its own JAR, and merging all dependencies into a single JAR, might cause collisions, especially with packaged resources (non-class files)."

A common example is with logging config files (e.g., logback.xml). Some libraries ship with their own (or a library's dependency). It's not uncommon in a large project to wind up with several logback.xml files littered around from libraries that included their own. These are called "resources" because they aren't code but they are included with the compiled distributable and are placed on the classpath. Of course, yo…

Speaking of Java logging, that's one area that drives me batty. The lack of a good standard Java logging library caused a multitude of logging libraries to be written. Different libraries then of course use different logging libraries, so each logging library generally has a way to wrap all the others, and they all work in different ways. Getting consistent and controllable logging (e.g. ability to turn on or off logging for a given thing) can sometimes be almost impossible to understand.

Re: An Opinionated Guide to Modern Java, Part 2

#32
post #15

Nice article - Many of the suggestions (single-jar deployment, metrics, slf4j logging, etc) are all wrapped up for you in Dropwizard http://dropwizard.io , which we use and love.

Do you just use it for producing a REST API or do you use it to render HTML, handle session management etc.?

I happen to use Dropwizard as well and purely for REST APIs that serve as internal micro services.

Re: An Opinionated Guide to Modern Java, Part 2

#33

"Java application servers are dead" and since there's no alternative to Java application servers here's a solution I cooked up myself. Like I mentioned last time I appreciate an overview of modern Java practices but boy howdy I can't discern if this is clever trolling or a cheap way to make me read Part 3.

> "Java application servers are dead" and since there's no alternative to Java application servers here's a solution I cooked up myself. The alternative are servlet containers, like Jetty or Tomcat. Jetty for example is very popular and really good and can be easily embedded inside an app for single JAR deployments, which is an awesome way to deploy an app btw.

Fair enough, it's a matter of terminology then, I guess?

Generally I think of Tomcat as being as much of an application server as something like JBoss is.

Granted, JBoss/Wildfly has a lot more enterprise-y features, but they both 'serve' web 'applications.'

Re: An Opinionated Guide to Modern Java, Part 2

#34
post #19

Earlier quoted context omitted.

Why is the Java community so enamored with creating Java-only solutions when general-purpose solutions work just as well (and often better)? There's no need to bundle everything up into an executable jar or war. It's much easier to write a Chef recipe to copy all the right files to the right places. And it's even easier to create a Docker container with the exploded war in its correct place. Both of those solutions d…

Java - "run anywhere" (supposedly) Docker - "The Linux Container Engine" Think you've got your answer there.

> Java - "run anywhere" (supposedly)

Sure, it's a nice benefit, but is it actually used? In 2014, how many of us are doing backend/service development in java and not deploying to Linux machines? There are certainly still backend/service java shops out there that aren't deploying to linux machines, but I wager that most are.

Regardless of those numbers though, why do the linux shops actually care about being able to deploy to non-linux machines if they never do in practice? Python can run just about anywhere these days, but python shops that deploy exclusively on Linux don't care about maintaining deployment compatibility with systems that they don't actually use.

Re: An Opinionated Guide to Modern Java, Part 2

#35
As a Java developer, I thought this article had some interesting information about logging and monitoring. However, the deployment section had my scratching my head a little.

I've never totally understood why people want to make fat jars. It seems like a process full of headaches since you can't have jars in jars. Wouldn't it be much easier to create a regular zip file with a small script to set the classpath and and run the project?

I'm not sure I understand the motivation for embedded instead of standalone servlet container. The article linked to some slides but they mostly seemed be demonstrating that you can function using an embedded container rather than providing clear benefits. Maybe it would have made more sense with the associated talk.

Can anyone provide more insight to these?

Re: An Opinionated Guide to Modern Java, Part 2

#36
post #14

I'm a fan of simplifying the server side, one I'd recommend for the latter part of the slideshow he referenced: http://www.sparkjava.com/

...or just use JAX-RS, which is simple, standardised, and has good implementations (such as RESTEasy and Jersey).

I suppose but SparkJava has as its core philosophy, build as a runnable jar from the start which is in line with what the article was discussing in its referential prohibition of conventional app server approaches.

edit: Further to the point of getting Java server technology to a simpler to understand, design, debug and maintain place, SparkJava makes it insanely easy to do REST services eliminating both Annotations and heavy configuration. I've also speed tested my side projects on SparkJava and they are unreal fast.

Re: An Opinionated Guide to Modern Java, Part 2

#38

As a Java developer, I thought this article had some interesting information about logging and monitoring. However, the deployment section had my scratching my head a little. I've never totally understood why people want to make fat jars. It seems like a process full of headaches since you can't have jars in jars. Wouldn't it be much easier to create a regular zip file with a small script to set the classpath and and…

Author here. A capsule is not necessarily a fat jar. It can point to Maven dependencies that are downloaded on the first launch, and can later be shared by other capsules. A zip with startup scripts is OK, but it requires installation.

As to full blown app servers vs embedded servers, I think it's the other way around. It's the big app servers that require justification, as they are a lot more cumbersome to set up and deploy.

Re: An Opinionated Guide to Modern Java, Part 2

#39
post #15

Nice article - Many of the suggestions (single-jar deployment, metrics, slf4j logging, etc) are all wrapped up for you in Dropwizard http://dropwizard.io , which we use and love.

We'll discuss Dropwizard in part 3, but the single-jar deployment is not really solved by Dropwizard. To launch the server you still need to configure the JVM at the command line.

Re: An Opinionated Guide to Modern Java, Part 2

#40

I'm glad someone took the time to write this, it's actually a very nice resource to get new coworkers up to speed. Shouldn't be tought as dogma of course (e.g. Gradle vs. Maven). Also, thanks for mentioning Packr even though noone has used it in production yet. It's only a week old. Assuming OP is the original author: are you by any chance following JGO? I see Quasar is actually using Matthias Mann's green thread lib…

Yep. JGO. And Quasar now uses a heavily modified fork of Matthias Mann's code.
Post reply on HN