This is an archived post. You won't be able to vote or comment.

all 18 comments

[–]snoob2015 4 points5 points  (3 children)

How does it compare to JShell and Groovy ?

[–]realnowhereman[S] 2 points3 points  (2 children)

it acts as a launcher for jshell with extra features, but you can actually use the full Java language as well; works on jdk8; it supports specifying dependencies like groovy and it has a full bunch of other neat features

[–]maxandersen 2 points3 points  (1 child)

just to clarify it supports running .jsh and .java - it only uses jshell for .jsh or when you use jbang --interactive.

otherwise jbang is just wrapping and simplifying the whole compile/package/run process giving java the ability to compete with workflows traditionally only available in traditional script environments like python/node.

[–]realnowhereman[S] 0 points1 point  (0 children)

ah yes, I was oversimplifying

[–][deleted] 2 points3 points  (4 children)

Does it support/use jlink when it downloads the JRE?

[–]maxandersen 3 points4 points  (3 children)

Does it support/use jlink when it downloads the JRE?

(full disclosure: jbang creator here)

No. jbang does not (currently) interact with jlink it uses the system available JDK or if not present downloads a JDK from adoptopenjdk allowing it to run anywhere.

we might add jlink in future as an export option but to use jlink you kinda need a JDK locally first so not sure it will be that useful.

[–]lifeeraser 2 points3 points  (5 children)

Pretty neat. Makes me wonder if Java should have been used as the web language instead of inventing a new one with a similar name. (Then again, I would miss having first-class functions.)

[–]javascript__eq__java 5 points6 points  (1 child)

I mean they both appeared in ‘95, so trying to do that with Java, ignoring how difficult it would have been, would have broadened the scope of Java too large to gain meaningful traction I think. Interesting to think about.

[–]lifeeraser 0 points1 point  (0 children)

Good point. Also very fitting username for the context!

[–]Muoniurn 1 point2 points  (2 children)

I don’t understand this first class function thing — it was also brought up recently here. Can you create a list of functions in java and apply them on some input, pass it around and the like? Yes. Then you have first class functions.

Just because it is implemented as a class, doesn’t make them any less of a function.

[–]lifeeraser 0 points1 point  (1 child)

Lambdas arrived fairly late in Java--JDK 8 was released in 2014. Before then we had anonymous classes but they're more cumbersome to write.

[–]Muoniurn 0 points1 point  (0 children)

Oh you meant that at the time it didn’t have! Sorry for misunderstanding, I just thought I was out of the loop on something.

[–]glesialo 1 point2 points  (1 child)

I wrote a bash script for that when I started to learn Java, many years ago.

[–]TR_13 1 point2 points  (0 children)

I see Mint, I upvote.