r/java • • Apr 20 '21

Java is criminally underhyped

https://jackson.sh/posts/2021-04-java-underrated/
291 Upvotes

295 comments sorted by

View all comments

Show parent comments

2

u/maxandersen Apr 21 '21

if you are fine using maven/gradle and whatever keep using it - jbang can still be used to run that output without user having to install and setup java.

if you are fine with the ceremony of dealing with multiple artifacts and multi nested directories just to write a utility keep doing that - jbang lets you just have one file (like bash, python,etc.) and use that directly - no separate build/compile step.

if you love to deal with maven/gradle requirements to do a few things in a project then do that - jbang lets you just write a .java file and run it any kind of project and be used as a debuggable and portable set of utilities not tied to specific build system.

Coincidentally I'm talking about this exact topic in a few hours if anyone interested: https://www.meetup.com/BarcelonaJUG/events/277506478/

1

u/deadron Apr 21 '21

If you annotate a file with JBang specific comments is it still really a Java file? At that point it seems more like a JBang script instead.

Having to install JBang instead of a JDK isn't really a benefit because it is not actually simplifying the fact that you need to install something to run your code.

It sounds like it operates as an alternate build system focused on execution instead of packaging that annotates within existing files instead of within an external file. So it actually reduces your portability and ties you to jBang being the only way to execute your project?

2

u/maxandersen Apr 21 '21

it is 100% pure java. thats why it works.

just because you add a pom.xml or a build.gradle file does that make the .java files non-java?

you can install and run jbang in a single curl command - the rest will be dealt with automatically on any java capable OS. Its just easier. but sure, if you do it all manually you can do that. just tedious.

if maven and gradle does not reduce your portability neither does jbang. And you can mix jbang into your gradle/maven projects so I'm arguing its even more portable.

also jbang can export to a .jar like maven/gradle does at that point its no different.

its just much much simpler to get started with and you can easily move from jbang to gradle/maven once the complexity they require becomes relevant for you.

1

u/deadron Apr 21 '21

So its a build system that is making decisions, like declaring dependencies inside project java files, that gradle, maven(even ant) wisely decided were better in external files...

It sounds like the argument is jbang is a build tool that is easier to get started with than maven/gradle. You should focus on that. It seems like a stretch though considering how easy templates make things these days. Build tools are complicated because builds are complicated. A simple maven build file with no custom build options is mostly just a dependency section inside a template.

→ More replies (5)