Ingen bruger Java!
Java er langsomt!
Java er omstændeligt!
Java er svært at bruge!
Kender du til Java?
Bruger du Java?
Er Java dødt?
Ingen bruger Java!
Java er langsomt!
Java er omstændeligt!
Java er svært at bruge!
'94-'96 - Datamatiker i Ikast
'98-'00 - Datalog i Aalborg
'00-'04 - Softwareudvikler i Aarhus
'04-'17 - Open Source Udvikler i Neuchatel, Schweiz
'21-'24 - Open Source Udvikler i Pederstrup, Fyn

Hibernate, JBoss AS/WildFly, JBoss Tools, Eclipse, Ceylon, OpenShift, Quarkus, …
OpenJDK, GraalVM, Apache Camel, vert.x, KeyCloak, Microsoft VSCode, JetBrains, Docker, …
JBang, Home Assistant, …
Java, Python
Ingen bruger Java!
Java er langsomt!
Java er omstændeligt!
Java er svært at bruge!
"Every backend at ??? is basically a Java app….2800 Java applications…microservices of a variety of sizes….1500 internal libraries" - February 2024
"Every backend at Netflix is basically a Java app….2800 Java applications…microservices of a variety of sizes….1500 internal libraries" - February 2024

Microsoft, Amazon, Google, Twitter, LinkedIn, NASDAQ, Red Hat & IBM …
Spotify, Slack, Lyft, DoorDash, Instagram, BitPanda, Uber, Airbnb, …real-time financial trading!
Danske Bank, Maersk, Systematic, Netcompany, Trifork, LEGO, Bang & Olufsen, KMD, DSB, Rejseplanen, BankData, JYSK, TDC, Yousee, 3, Maersk, Grundfoss, Orested, Danfoss,Norlys,Skat og andre ministerier, Region Midt/Hoved, Schneider electric, …
Python - DataScience
Go/Rust - System/cloud-native
JavaScript - Frontend
C# - Windows/Backend
Java - Backend/Enterprise
Java er brugt a 30% af alle udviklere
Java er #2 efter Python i PYPL og #4 efter Python/C/C++ i TIOBE
69% af fuldtids udviklere globalt
"Java’s market share was over 31% in 2008 and has decreased to 15.81% in 2023'
Conclusion?

The One Billion Row Challenge

Baseline: 4m 49s
Result: 1.5s
192x faster
Minimer IO
Divde & Conquer
Udnyt CPU arkitektur
Optimeret hukommelse (unsafe())
GraalVM native binary
Build Time vs Run Time
JavaVM vs Native Image
Quarkus, Micronaut, Helidon, Spring Boot, …






Conclusion?

public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World");
}
}void main() {
System.out.println("Hello, World");
}void main() {
println("Hello, World");
}
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class ReadFile {
public static void main(String[] args) {
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader("example.txt"));
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import static java.lang.System.out;
public class ReadFile {
public static void main(String[] args) {
try (BufferedReader reader = new BufferedReader(
new FileReader("example.txt"))) {
String line;
while ((line = reader.readLine()) != null) {
out.println(line);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}import java.io.IOException;
import static java.nio.file.Files.lines;
import java.nio.file.Paths;
import java.util.stream.Stream;
import static java.lang.System.out;
public class ReadFile {
public static void main(String[] args) {
try (Stream<String> stream = lines(Paths.get("example.txt"))) {
stream.forEach(out::println);
} catch (IOException e) {
e.printStackTrace();
}
}
}import java.io.IOException;
import static java.nio.file.Files.lines;
import java.nio.file.Paths;
import java.util.stream.Stream;
import static java.lang.System.out;
public class ReadFile {
public static void main(String[] args) {
try (var stream = lines(Paths.get("example.txt"))) {
stream.forEach(out::println);
} catch (IOException e) {
e.printStackTrace();
}
}
}import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import static java.nio.file.Files.readString;
import static java.lang.System.out;
public class ReadFile {
public static void main(String[] args) {
try {
var content = readString(Path.of("example.txt"));
out.println(content);
} catch (IOException e) {
e.printStackTrace();
}
}
}import java.io.IOException;
import static java.nio.file.Path.of;
import static java.nio.file.Files.readString;
import static java.lang.System.out;
void main() {
try {
out.println(readString(of("example.txt")));
} catch (IOException e) {
e.printStackTrace();
}
}import static java.nio.file.Path.of;
import static java.nio.file.Files.readString;
void main() {
try {
println(readString(of("example.txt")));
} catch (IOException e) {
e.printStackTrace();
}
}import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class ReadFile {
public static void main(String[] args) {
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader("example.txt"));
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}String navn = "John";
int alder = 55;
String indhold = "Hej " + navn + ",\n\n" +
"Du er " + alder + " år gammel.\n\n" +
"De bedste hilsner,\n" +
"Max";String navn = "John";
int alder = 55;
String indhold = STR."""
Hej \{navn},
Du er \{alder} år gammel.
De bedste hilsner,
Max
""";class Employee {
private String firstName;
private String lastName;
private int Id;
public Employee(String firstName, String lastName,
int Id)
{
this.firstName = firstName;
this.lastName = lastName;
this.Id = Id;
}
public void setFirstName(String firstName)
{
this.firstName = firstName;
}
public String getFirstName() { return firstName; }
public void setLastName(String lasstName)
{
this.lastName = lastName;
}
public String getLastName() { return lastName; }
public void setId(int Id) { this.Id = Id; }
public int getId() { return Id; }
public String toString()
{
return "Employee [firstName=" + firstName
+ ", lastName=" + lastName + ", Id=" + Id + "]";
}
@Override public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + Id;
result = prime * result
+ ((firstName == null)
? 0
: firstName.hashCode());
result
= prime * result
+ ((lastName == null) ? 0
: lastName.hashCode());
return result;
}
@Override public boolean equals(Object obj)
{
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Employee other = (Employee)obj;
if (Id != other.Id)
return false;
if (firstName == null) {
if (other.firstName != null)
return false;
}
else if (!firstName.equals(other.firstName))
return false;
if (lastName == null) {
if (other.lastName != null)
return false;
}
else if (!lastName.equals(other.lastName))
return false;
return true;
}
}public record Employee(int id,
String firstName,
String lastName) {}30 års "bagage" som verdens mest populære sprog
Skoler/Universiteter opdaterer ikke hvad der virker
Conclusion?

javac, java, jar, war, ear, …
Maven/Gradle ?
JavaEE/Jakarta & Spring Boot ?
IntelliJ/Eclipse/VSCode ?
curl -Ls https://sh.jbang.dev | bash -s - app setupDownloads and configure JBang
If no Java found, downloads Java 11
$ jbang -c 'println("Hello World")'
Hello World$ jbang -c 'println("Hello " + args[0])' Universe
Hello Universe-c evaluates code via JShell
Handles user arguments
No files to create
No public static class main
$ jbang -i
| Welcome to JShell -- Version 11.0.15
| For an introduction type: /help intro
jshell> println("Hello!")
Hello$ jbang --java 17 -i
WARNING: Using incubator modules: jdk.incubator.vector, jdk.incubator.foreign
| Welcome to JShell -- Version 17
| For an introduction type: /help intro
jshell>$ jbang init hello.java
[jbang] File initialized. You can now run it with
'jbang hello.java' or edit it using
'jbang edit --open=[editor] hello.java' where [editor]
is your editor or IDE, e.g. 'eclipse'
$ jbang hello.java
[jbang] Building jar...
Hello World
$ ./hello.Java
Hello World$ jbang init -t cli app.java
[jbang] File initialized. You can now run it with
'jbang app.java' or edit it using
'jbang edit --open=[editor] app.java' where [editor]
is your editor or IDE, e.g. 'eclipse' ///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS info.picocli:picocli:4.5.0
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Parameters;
import java.util.concurrent.Callable;
@Command(name = "app", mixinStandardHelpOptions = true, version = "app 0.1",
description = "app made with jbang")
class app implements Callable<Integer> {
@Parameters(index = "0", description = "The greeting to print", defaultValue = "World!")
private String greeting;
public static void main(String... args) {
int exitCode = new CommandLine(new app()).execute(args);
System.exit(exitCode);
}
@Override
public Integer call() throws Exception { // your business logic goes here...
System.out.println("Hello " + greeting);
return 0;
}
}$ ./app.java
[jbang] Resolving dependencies...
[jbang] info.picocli:picocli:jar:4.5.0
Done
[jbang] Dependencies resolved
[jbang] Building jar...
Hello World$ ./app.java --help
Usage: app [-hV] <greeting>
app made with jbang
<greeting> The greeting to print
-h, --help Show this help message and exit.
-V, --version Print version information and exit.jbang edit app.java
[jbang] You requested to open default editor but no default
editor configured.
jbang can download and configure a visual studio code (VSCodium)
with Java support to use
Do you want to
(1) Download and run VSCodium
(2) Use 'code'
(3) Use 'eclipse'
(4) Use 'idea'
(0) CancelIntelliJ

Eclipse and Visual Studio Code too!
$ jbang --debug app.java
Listening for transport dt_socket at address: 4004We started creating, then edited, ran and debugged Java
Without java or javac
Witout mvn or gradle
No vscode, eclipse, intellij Install
Just jbang

$ cat 5letterwords.txt | jbang -c \
'lines().filter(s->s.contains("dog")).forEach(p->println(p))'$ jbang init -t qrest myservice.java
$ ./myservice.java
./myservice.java
[jbang] Resolving dependencies...
[jbang] Artifacts used for dependency management:
io.quarkus:quarkus-bom:pom:3.8.1
[jbang] io.quarkus:quarkus-resteasy-reactive
Done
[jbang] Dependencies resolved
[jbang] Building jar...
[jbang] Post build with io.quarkus.launcher.JBangIntegration
May 04, 2022 9:30:43 PM org.jboss.threads.Version <clinit>
INFO: JBoss Threads version 3.2.0.Final
May 04, 2022 9:30:44 PM io.quarkus.deployment.QuarkusAugmentor run
INFO: Quarkus augmentation completed in 999ms
__ ____ __ _____ ___ __ ____ ______
--/ __ \/ / / / _ | / _ \/ //_/ / / / __/
-/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2022-05-04 21:30:45,453 INFO [io.quarkus] (main) Quarkus 2.8.0.Final on JVM started in 0.839s. Listening on: http://0.0.0.0:8080
2022-05-04 21:30:45,488 INFO [io.quarkus] (main) Profile prod activated.
2022-05-04 21:30:45,488 INFO [io.quarkus] (main) Installed features: [cdi, resteasy]///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS io.quarkus:quarkus-bom:${quarkus.version:3.8.0}@pom
//DEPS io.quarkus:quarkus-resteasy
//JAVAC_OPTIONS -parameters
//FILES resources/index.html=index.html
//SOURCES **.java
import io.quarkus.runtime.Quarkus;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
@Path("/hello")
@ApplicationScoped
public class myservice {
@GET
public String sayHello() {
return "Hello from Quarkus with jbang.dev";
}
}$ jbang -c "Hello"
$ jbang app.java
$ jbang demo.jsh
$ jbang app.jar
$ jbang org.jreleaser:jreleaser:1.0.0
$ jbang https://github.com/jbangdev/jbang/../examples/inetTest.java
$ jbang https://jbang.dev//DEPS com.github.javafaker:javafaker:1.0.2
import com.github.javafaker.Faker;
Faker faker = new Faker();$ jbang -s faker@jbangdev -c \
'Stream.generate(faker.name()::fullName).filter(s->s.contains("Angie")).forEach(s -> println("Awesome " + s))'$ jbang app install -n myapp https://.../a.jar
$ jbang app install quarkus@quarkusio
$ quarkus
quarkus
Quarkus CLI version 2.8.2.Final
Create Quarkus projects with Maven, Gradle, or JBang.
Manage extensions and source registries.
Create: quarkus create
Iterate: quarkus dev
Build and test: quarkus build
Find more information at https://quarkus.io
If you have questions, check https://github.com/quarkusio/quarkus/discussions
Usage: quarkus [-ehv] [--verbose] [-D=<String=String>]... [COMMAND]
Options:JBang is the best way to Get started with Java
JBang let you write anything; from one-liners…
…to full-fledged Java microservices
JBang lets you run and install Java apps
JBang has an appstore
Quarkus demo
Conclusion?

Basic: Lav dit eget JBang/Java script
Prøv JBang (https://jbang.dev/download)
jbang init -t cli hello.java
jbang init -t qrest rest.java
Less Basic: Quarkus (næste slide)
Less Basic: Start et Quarkus projekt (https://quarkus.io/get-started/)
Java forbliver relevant, effektiv, moderne og brugervenlig
Det er helt i orden at udforske andet, men…
Undervurder ikke Java’s potentiale ;)