Live data from Hacker News

An Opinionated Guide to Modern Java, Part 2

blog.paralleluniverse.co

121–130 of 138 posts

Re: An Opinionated Guide to Modern Java, Part 2

#121

Earlier quoted context omitted.

Dropwizard is a framework that delegates to Jetty the responsibility of serving requests by default, but you can host a Dropwizard app on whatever server you like. In Java terminology, "application server" has actually started to mean servers capable of the full Java EE stack, which really means EJB and JMS. Jetty is not capable of those. Tomcat from what I know is not capable of those either. Both are targeting firs…

Thinking Java EE is primarily about EJB and JMS is pretty old school. These days CDI is the centrepiece of Java EE, along with services like Interceptors and Bean Validation. JPA, JSF and JAX-RS also play pretty important roles, which are all things you don't find by default in Tomcat. Actually, nearly every time I see people using Tomcat they add many of the things mentioned above. You might as well start with TomEE…

CDI, Interceptors, Bean Validation, JPA, JSF - all of them suck.

JAX-RS is the only thing OK-ish in the list you mentioned, unfortunately its design that ignored asynchronicity has been shortsighted (heard that it got fixed in 2.0, but apparently they also added junk).

Re: An Opinionated Guide to Modern Java, Part 2

#123

Earlier quoted context omitted.

I skimmed through Part 3 and it's basically saying that app servers are hard to deploy, maintain and dev against and you should be using Spring Boot or Dropwizard instead to create applications with the services you require.

Where did you find part 3?

Ah my apologies, it's not actually part 3 it's the link he referenced when he talked about part 3: http://www.slideshare.net/ewolff/java-application-servers-ar...

Re: An Opinionated Guide to Modern Java, Part 2

#124
post #120

Earlier quoted context omitted.

Why does standalone Tomcat need any more integration with the system than an app with embedded Tomcat? They are both Java applications. Tool support is not server specific. In both cases you set the appropriate VM arguments. What XML file would you have to edit? Yes, hot code replacement is faster (although it comes with other tradeoffs). Why can't you do that with standalone Tomcat? What is unreliable about reloadin…

> Why does standalone Tomcat need any more integration with the system than an app with embedded Tomcat? They are both Java applications. With an embedded Jetty my app can just be a jar or set of jars. Tomcat has a directory structure and ships as a binary rather than a jar so I'd need to unpack it and worry about it being linked correctly for the target system. > Tool support is not server specific. In both cases yo…

Tomcat is just a Java application. Its install is just a bunch of jar files with some shell scripts to simplify running them. If you look at an install you see that it is just running the Java class ' org.apache.catalina.startup.Bootstrap'. I'm not sure what linking you are worrying about.

For setting JVM arguments, I think you are thinking of 'setenv.sh' or 'setenv.bat'. These are shell scripts where you can set environment variables used when running Tomcat. This includes the standard 'JAVA_OPTS' to set VM arguments.

Re: An Opinionated Guide to Modern Java, Part 2

#125
post #80
post #16

> While I personally prefer Gradle’s nice DSL and the ability to use imperative code for non-common build operations, I can understand the preference for the fully declarative Maven, even if it requires lots of plugins. The modern Java developer, then, might prefer Maven to Gradle. I find Maven's abstractions surprisingly hard to understand. It is a major part of my annoyance with Java as a dev setup. I miss Make/Ant…

What abstractions? You have a project which has a name and some other metadata and it has a bunch of dependencies. If your build does something weird then it also has plugins, but you should try to avoid those as much as possible. I guess profiles could be confusing, but again, try to avoid them. Maven is the simplest build tool I've used, in any language.

Maven has a lot of jargon. I also found it confusing when I started. POMS, artifacts, plugins, reactors etc ... heck I still find Maven confusing and unintuitive sometimes. Their docs are awful: typical failure mode for software that's in love with the idea of plugins.

Re: An Opinionated Guide to Modern Java, Part 2

#126
post #80

Earlier quoted context omitted.

What abstractions? You have a project which has a name and some other metadata and it has a bunch of dependencies. If your build does something weird then it also has plugins, but you should try to avoid those as much as possible. I guess profiles could be confusing, but again, try to avoid them. Maven is the simplest build tool I've used, in any language.

Maven has a lot of jargon. I also found it confusing when I started. POMS, artifacts, plugins, reactors etc ... heck I still find Maven confusing and unintuitive sometimes. Their docs are awful: typical failure mode for software that's in love with the idea of plugins.

Exactly. With Make, I can delve down into the bash code easily and figure out what is happening. With Maven, there is enough overhead that I have to resort to cargo-cult googling.

Re: An Opinionated Guide to Modern Java, Part 2

#127
post #85
post #16

> While I personally prefer Gradle’s nice DSL and the ability to use imperative code for non-common build operations, I can understand the preference for the fully declarative Maven, even if it requires lots of plugins. The modern Java developer, then, might prefer Maven to Gradle. I find Maven's abstractions surprisingly hard to understand. It is a major part of my annoyance with Java as a dev setup. I miss Make/Ant…

I find all of them hard to work with, because they are all aiming for the modern day "zero configuration" nirvana that Ruby on Rails achieved, and thus enormous amounts of implicit knowledge is required to understand them. Part of the problem is that the initial steps are so easy that you're actually never forced to learn the mechanics of what is happening. Hence you get away with a lot until you need to do something…

> I find all of them hard to work with, because they are all aiming for the modern day "zero configuration" nirvana that Ruby on Rails achieved, and thus enormous amounts of implicit knowledge is required to understand them.

> ... realised there is a theoretical path from ignorance to enlightenment that didn't involve learning Groovy.

Yes! Learning is so non-linear that sure there are in theory fine lines that minimize the amount of new stuff to learn. Yet, it never is that simple. Bad design, indeed.

> What you would probably like is Gant, which is Ant entirely converted to Groovy. It's missing all the higher level project stuff from Maven / Gradle, but it works a treat when you just want the simplest possible thing that could work.

I will check it out; thank you!

Re: An Opinionated Guide to Modern Java, Part 2

#128
post #16

> While I personally prefer Gradle’s nice DSL and the ability to use imperative code for non-common build operations, I can understand the preference for the fully declarative Maven, even if it requires lots of plugins. The modern Java developer, then, might prefer Maven to Gradle. I find Maven's abstractions surprisingly hard to understand. It is a major part of my annoyance with Java as a dev setup. I miss Make/Ant…

I really enjoy Gradle. I have done significant work with Ant, Maven, and a host of tool chains in the C/C++ world. Gradle seems to have the cleanest DSL. Not every single thing under the sun is supported (Maven seems to be the most comprehensive tool I have used), but Gradle is nice to work with.

I've been struggling to find out what's even available in Gradle. How does one debug it, or print available methods, or really anything?

My woes are mostly around Android's gradle integration, which appears poorly documented at best. There are tons of magic commands that appear out of nowhere and with no explanation beyond "use this.". And Gradle's massive guide covers things that barely see the light after being seemingly wrapped in several layers by Android's plugin.

I want to give it a real try, but the Android projects I deal with are reasonably complex, would use code generation (`scopes.PROVIDED.plus += configurations.provided }`? wtf does that even do and how in the world would I have discovered I could use it?), and need multiple products. I would have to know what and why before considering switching over for real, but there seem to be some huge walls preventing me from finding out.

Re: An Opinionated Guide to Modern Java, Part 2

#129
post #104
post #87

Earlier quoted context omitted.

ClassLoader contortions are one of the cleaner ways to handle the problem, but they're not the only way. You could: - Create a fat jar, which necessitates bytecode transformations to prevent namespace collisions if you don't want to be sloppy. JarJar did this kinda of thing many years ago, but it seems hard to trust a process like that. - Create what is essentially a self-extracting archive. This looks like the path…

The next release will include the option to resolve (potentially download) all dependencies without launching the app, if someone finds that useful. If dependencies are resolved, or are embedded, startup time is increased by 100ms or so.

It still feels like a pre-automation mindset...this is a step that should happen during CI, not application startup or even deployment.

The delay is going to be a lot more than 100ms if you use something like this when scaling elastically. In that situation, you need to go from automatically provisioned to running and accepting load in as short a timeframe as possible. Fully-baked machine images or Docker containers work for this use case, your solution doesn't.

Also, making your Maven repository a dependency of your production environment just seems like a bad idea. It creates an additional attack vector from a security standpoint and an additional component that can fail from a reliability standpoint.

Re: An Opinionated Guide to Modern Java, Part 2

#130

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…

Actually, you can have Jars in Jars. Of course, you need to do the lifting yourself. It is actually very nice to have a simple unpack / installation application inside a Jar and to unpack the actual application from this Jar. In this way, the only requirement for unpack / installation is the JVM, which you already require to run the application itself. This is much more elegant than a platform dependent unpack / inst…

Huh, jars within jars... sounds a lot like .war files!
Post reply on HN