Modern for Cloud Developers

Martijn Verburg – @karianna

Principal SWE Group Manager (Java) - @javaatmicrosoft

Agenda 1. META DATA 2. Modern Java 3. Smaller and Lighter Java for the Cloud 4. Microservices – Your Choices in Java 5. ’s Investment in Java 6. Run your Java workload on Azure today!* META DATA Acknowledging the new normal

• Thanks for being here with us today! • This is new for all of us

• The talk is deliberately text heavy • Absorb the material post presentation • I’ll try to avoid reading to the slides but instead provide context for each one • We’ll be doing lots of Q&A! Modern Java “Java is dead” Tech Media 2015-2020 Quiz Time!

• How old are these top 3 languages?

30 years old 24 years old 24 years old Tiobe Language Rank – Java still in the Top Programming Languages Ranks – RedMonk Q3 2020 Java Continues to Evolve Modern Java

Java is now at version 15 with loads of new Java is now released every 6 months developer productivity enhancements.

Java is modular since Java 9 and you can build Java apps can be packaged tightly custom binaries with jlink and jpackage.

It understands the CPU and limits that Java is fully container aware the container is giving it.

JVM can manage TBs of data with ZGC and Shenandoah GC + other improvements several GC options means you can run 512GB+ heaps efficiently. Where Is Modern Java Used?

Java usage continues to grow Way beyond the traditional 3 tier web app

Apache (Spark, Kafka, Nifi, Accumulo), Java dominates Big Data space Hazelcast et al

Amazon, Google, Microsoft (yes, you’d be It is heavily used in the tech giants surprised!), Netflix et al

Spring Boot dominates, with Java OSS libraries Microservices are incredibly popular providing access to… anything! Modern Java Ecosystem

Java continues to be free with OpenJDK is 100% GPLv2+CE no restrictions

With four major implementations: OpenJDK More competition and innovation HotSpot, GraalVM, Azul Zing and OpenJ9

IntelliJ, Eclipse, + support on Perfect for full stack developers. VS Code is here and improving!

Educators rejoice! Java has a REPL and you can JShell and Single Source File run a Single Java Program without compiling. Developer Productivity – Local-Var Type Inference (10) var greeting = "Hello World!";

/* * Awesome! Java is now less verbose and still * retains its type safety! */ Developer Productivity – Text Blocks (13/14)

String html = """

Hello, world

""";

/* This was long overdue :-) */ Developer Productivity – Switch Expressions (12/13/14)

Day day = getDay(); int numLetters = switch (day) { case MONDAY, FRIDAY, SUNDAY -> 6; case TUESDAY -> 7; default -> { String s = day.toString(); int result = s.length(); yield result; } };

/* * This is awesome because you can have real logic inside a * case statement, and you can switch on complicated data structures. */ Developer Productivity – Records (14) record Point(int x, int y) { }

/* * This is awesome because it will give us tightly * packed data structures without the dreaded Java * object overhead. Java just got lighter again! */ Helpful NullPointerExceptions (14) a.b..i = 99;

--- Exception in thread "main" java.lang.NullPointerException: Cannot read field "c" because "a.b" is null

/* This was long overdue :-) */ Smarter Interfaces (8)

Default methods Private methods default String changeCase() { return isCamelCase(getValue()) ? getValue().toUpperCase() : getValue().toLowerCase() } private boolean isCamelCase(String value) { return ...; }

/* This is awesome because it better supports inheritance by composition */ Windows Arm Port / Mac OS X Arm Port (16/?)

Q: You say what now?

Yes Microsoft has ported Java to Windows Arm

Oh and they’re doing it for Mac OS X as well (Apple Silicon) J

Q: But why?

Arm is going to be a thing in the cloud, and we want to support developer desktops

Q: Where can I try this so I can code on my Pro X? https://github.com/microsoft/openjdk-aarch64 Smaller and Lighter Java for the Cloud Smaller Java

ž Java is now fully modularized ž Customizable runtimes!

ž Bundle Java with your app as a single executable ž You can even build native installers! ž jlink + jpackage

ž Java is fully container

aware as of Java 8u191 @delabassee Lighter Java

ž Java now de-duplicates Strings (when using G1) ž Your XML and JSON apps are instantly lighter

ž Your apps can start with blazing speed ž Class Data Sharing and Application Data Sharing ž Java Ahead-Of-Time (AOT) static compiler (jaotc) ž 20% startup improvement on Java 13, compared to Java 8

ž Asynchronous, Reactive, Non-Blocking, Streaming, ž Built into Java or use one of many battle tested libraries such as Netty or Reactor. Performant Java

ž Java continues to give you performance gains out of the box

ž Java is container aware ž Interprets CPU allocation correctly

ž Java has low pause and no-op GCs ž Low to zero pause GCs, perfect for Microservices and Serverless

ž Projects Panama, Valhalla and Loom, Leyden – Java 15+ ž Lightweight Threads, Faster Native Interop and more efficient Data Types ž Project Leyden to bring some Graal like capabilities into OpenJDK (startup) Microservices – Choices with Java Spring Boot

ž A dominant player for now, ideal for simple web services! ž Has connectors to all the various data stores you might want! ž But don’t leave the railroad too much or you’ll find trouble J ž https://www.baeldung.com/spring-boot-docker-images Spring Boot Deployment in Docker Microprofile – (microprofile.io)

ž Using Java EE today? Then this is a comfortable transition ž Lots of runtimes (Payara, Thorntail, Wildfly, Open Liberty, Helidon….) ž Docker Images for each of these, just. Search on DockerHub ž Uses familiar Java EE programming model ž Follows the 12-Factor App philosophy (quarkus.io)

ž Supports Microprofile ž Uses GraalVM – native image for faster start times and smaller ž Suitable for Serverless as well ž Very cloud and container friendly (small footprint) ž WARN: Once you go native image you can’t go back easily Micronaut

ž Polyglot Framework – Good for if you like Groovy or Kotlin! ž Uses GraalVM – native image for faster start times and smaller ž Suitable for Serverless as well ž Good at getting into cloud environments quickly (Azure, AWS, GCP) ž WARN: Once you go native image you can’t go back easily MicroServices + 12-Factor – Non-Functional Reqs.

ž A word of caution! You need to assess each framework carefully

ž Can you apply https://12factor.net/ with this framework?

ž Remember to check: ž Service Discovery, Distributed Tracing, Health Checks, Circuit Breakers, Docker Support ž Ease of deployment, independent data sources, co-ordination

ž You may decide to defer some of this to cloud services and/or k8s Cloud Choices

ž All three major cloud providers support Java well.

ž Which cloud will let you run Java the way you want?

ž Forced to use proprietary services or can you use open standards?

ž Which one do I recommend? Well I do work there J

ž https://azure.microsoft.com/en-gb/develop/java/ Microsoft’s Investment in Java LinkedIn ž Over 1500+ Java microservices in production. ž Over 60+ Java open source projects on GitHub. ž Creators of Apache Kafka and other Apache projects. Azure ž Services dependent on Java include primarily Azure HDInsight, Azure Databricks, and Azure Spring Cloud. SQL Server Microsoft ž Java now embedded out of the box (Azul Zulu). ž PolyBase data visualization and Big Data Clusters interop with Spark, Uses Java Hadoop. ž Java apps and JDBC connectors. Heavily ž Most of its back-end implemented in Java. Mojang’s Minecraft ž Hundreds of servers built in Java, client Java Edition still very popular! Android ž 1,000+ of MS developers who build native or apps for Android still need Java on their dev environments and CI/CD pipelines. ž New phone based on Android OS. Microsoft Gives Back Latest Java Investments

• jClarity Acquisition – August 2019 • Insights tooling for improving performance of Java workloads on Azure • VM Engineering contributions to OpenJDK • Continued AdoptOpenJDK leadership and sponsorship • Java Ecosystem leadership via standards bodies & user groups

• Azure Spring Cloud • GA now! • Managed Service to run Cloud Native microservices written in Java with Spring Boot framework • Built on top of Azure Kubernetes Service • Integrated monitoring, distributed tracing, service binding Microsoft Tools for Java Developers

• Actions • OSS JDBC Driver • Packages • Big Data Connector • Security Advisories • Embedded Java • Code Navigation • Codespaces

• Java Extension Pack • Good for when your app • Java & JDK Installers is setup to run on ! • Cloud Native Extensions • Ubuntu / Debian Visual Studio • Codespaces • SUSE / Kali Code Windows Subsystem for Linux Run your Java workload on Azure today! Support Your Architecture

Monolith Containerized Monolith Monolith + new Parts of monolith Microservices or microservices extracted serverless application Migrate or build Java apps on Azure

Azure Kubernetes Service

AZURE SPRING IaaS Container PaaS CLOUD INFRASTRUCTURE-AS-A- CONTAINER PaaS SERVICE PLATFORM-AS-A-SERVICE PLATFORM-AS-A-SERVICE Azure Services for Java

App Service Functions Spring Cloud Kubernetes Compute Cosmos DB

Azure Monitor Azure DevOps

Blob Storage Key Vault Active Directory Service Bus Event Hub Event Grid Azure Spring Cloud – GA Now!

Jointly developed, Managed service operated, and supported

Out-of-the-box Zero code changes monitoring and tracing And More!

ž Tooling and SDK ž Azure SDKs, Maven & Gradle Plugins, Maven Archetypes

ž CI/CD Platforms ž BYO Jenkins, Azure DevOps, GitHub

ž Log Streaming ž Azure Monitor, Logz.io, Elastic Search

ž Event Streaming and Messaging ž Azure Event Hubs (Kafka API support) ž Azure Service Bus (JMS Support in Preview) Conclusion Modern Java for Cloud Developers on Azure

1. Java’s core has been modernized

2. Java excels in the cloud

3. You have lots of choice in the Microservice ecosystem

4. Pick your cloud carefully

5. Microsoft is investing heavily in Java

6. You can bring any Java workload to Azure J! THANK YOU + Q&A

Twitter: @javaatmicrosoft

Java Blog: https://devblogs.microsoft.com/java/