diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f4df0be --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.pdf +*.html diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..c7965b0 --- /dev/null +++ b/build.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +marp slides.md -o slides.html +marp slides.md -o slides.pdf \ No newline at end of file diff --git a/slides.html b/slides.html deleted file mode 100644 index 7bf12bd..0000000 --- a/slides.html +++ /dev/null @@ -1,268 +0,0 @@ -Una mirada funciona a Java 21
-

Una mirada 👀 funcional a Java 2️⃣1️⃣

- -

Antonio Muñoz

-
#Commitconf 2024
-
-
-

¿Quien soy?

-
    -
  • Programo en Java desde Java 1.1.
  • -
  • Actualmente trabajo en https://clarity.ai como backender.
  • -
  • Mi primera charla en una conferencia.
  • -
  • -
-
#Commitconf 2024
-
-
-

Agenda 📆

-
    -
  • El largo camino a Java 21.
  • -
  • Tipos de datos algebraicos.
  • -
  • Ejemplos.
  • -
  • Futuro.
  • -
-
#Commitconf 2024
-
-
-

Java Release Cadence ☕

-
    -
  • Dos release al año.
  • -
  • Preview features.
  • -
  • They have a plan.
  • -
-
#Commitconf 2024
-
-
-

Switch expressions

-
    -
  • Incluido en Java 14.
  • -
  • Una nueva vida para switch.
  • -
  • Una gran mejora en general para el lenguage.
  • -
-
var value = switch (input) {
-    case "a" -> 1;
-    case "b" -> 2;
-    default -> 0;
-};
-
-
#Commitconf 2024
-
-
-

Records

-
    -
  • Incluido en Java 16.
  • -
  • Muy esperado por la comunidad.
  • -
  • Inmutables.
  • -
-
public record Movie(String title, int year, int duration) {
-
-}
-
-
#Commitconf 2024
-
-
-

Sealed classes and interfaces

-
    -
  • Incluido en Java 17.
  • -
  • Jerarquías de clases cerradas.
  • -
-
public sealed interface Shape {
-
-    record Square(int side) implements Shape {}
-    record Rectangle(int weight, int height) implements Shape {}
-    record Circle(int radious) implements Shape {}
-
-}
-
-
#Commitconf 2024
-
-
-

Pattern matching for switch

-
    -
  • Incluido en Java 21.
  • -
  • Exhaustiveness.
  • -
-
var result = switch (obj) {
-    case Integer i -> String.format("int %d", i);
-    case Long l    -> String.format("long %d", l);
-    case Double d  -> String.format("double %f", d);
-    case String s  -> String.format("String %s", s);
-    default        -> obj.toString();
-};
-
-
#Commitconf 2024
-
-
-

Record patterns

-
    -
  • Incluido en Java 21.
  • -
  • Deconstructores, nos permite acceder a los componentes de los objectos.
  • -
-
var area = switch (shape) {
-    case Square(var side) -> side * side;
-    case Rectangle(var weight, var height) -> weight * height;
-    case Circle(var radious) -> Math.PI * radious^2;
-}
-
-
#Commitconf 2024
-
-
-

Tipos de datos algebraicos

-
    -
  • AKA ADTs (algebraic data types)
  • -
  • Viene de las matemáticas.
  • -
  • Productos y sumas de tipos.
  • -
  • Recursivo.
  • -
-
#Commitconf 2024
-
-
-

Tipos de datos algebraicos (II)

-
    -
  • Podemos representarlos en Java.
  • -
  • Un record es un producto de tipos.
  • -
  • Un sealed interface es una suma de tipos.
  • -
-
public sealed interface Tree {
-
-    record Node(String value, Tree left, Tree right) implements Tree { }
-    record Leaf(String value) implements Tree {}
-
-} 
-
-
#Commitconf 2024
-
-
-

Tipos de datos algebraicos (III)

-
    -
  • Podemos representar Optional con ADTs
  • -
-
public sealed interface Optional<T> {
-
-    record Empty<T>() implements Optional<T> { }
-    record Present<T>(T value) implements Optional<T> {}
-
-} 
-
-
#Commitconf 2024
-
-
-

Ejemplo

-
    -
  • ¿Pero eso para qué me sirve?
  • -
  • Manejo de errores.
  • -
-
#Commitconf 2024
-
-
-

Próximamente ⌚

-
#Commitconf 2024
-
-
-

Unnamed variables and patterns

-
    -
  • Incluido en Java 22.
  • -
  • Mejora para el pattern matching.
  • -
  • Eliminar verbosidad.
  • -
-
var result = switch (obj) {
-    case Integer _ -> "int";
-    case Long _    -> "long";
-    case Double _  -> "double";
-    case String _  -> "string";
-    default        -> "other";
-};
-
-
#Commitconf 2024
-
-
-

Primitive types in patterns

-
    -
  • Preview en Java 23 (sep 2024).
  • -
-
var result = switch (obj) {
-    case int i -> String.format("int %d", i);
-    case long l    -> String.format("long %d", l);
-    case double d  -> String.format("double %f", d);
-    case String s  -> String.format("String %s", s);
-    default        -> obj.toString();
-};
-
-
#Commitconf 2024
-
-
-

Bola de cristal 🔮

-
#Commitconf 2024
-
-
-

Derived Record Creation

-
    -
  • Draft.
  • -
  • AKA withers.
  • -
-
Point newPoint = oldPoint with { 
-    x *= 2; 
-    y *= 2; 
-};
-
-
#Commitconf 2024
-
-
-

Member patterns

-
    -
  • Early work.
  • -
  • AKA deconstructors.
  • -
  • Mejora para pattern matching.
  • -
  • Cualquier clase.
  • -
-
#Commitconf 2024
-
-
-

¿Qué falta todavía?

-
    -
  • Tail recursion.
  • -
  • Soporte de tipos de datos primitivos en genericos.
  • -
-
#Commitconf 2024
-
-
-

¿Preguntas?

-
#Commitconf 2024
-
-
-

¡Gracias!

- - -
#Commitconf 2024
-
-
-

JEPs

- -
#Commitconf 2024
-
-
\ No newline at end of file diff --git a/slides.pdf b/slides.pdf deleted file mode 100644 index 6ee73b0..0000000 --- a/slides.pdf +++ /dev/null Binary files differ