Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Project Amberで変わる Javaのプログラミングスタイル

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
Avatar for Yuichi.Sakuraba Yuichi.Sakuraba
November 18, 2023
1.3k

Project Amberで変わる Javaのプログラミングスタイル

2023.11.18 JavaDo
Java 21 リリース記念イベント@札幌 発表資料

Avatar for Yuichi.Sakuraba

Yuichi.Sakuraba

November 18, 2023
Tweet

Transcript

  1. OpenJDK JDK Project https://openjdk.org/projects/jdk/ のサブプロジェクト JDK Project: OpenJDK 他のサブプロジェクトをまとめて を開発

    JDK JDK 22 2024-03-19 JDK 21 2023-09-19 半年ごとのリリース Java 21から 2 年周期 LTS Oracle は などのディストリビュータによる Note: OpenJDK LTS LTS には と非 の区別はない
  2. JEP: JDK Enhancement Proposal の機能を規定 JDK 新機能だけでなく、実装改善、機能の削除も含む Preview Standard 正式な機能

    の種類 JEP Incubator Experimental プレビュー機能 実験的な機能 新しいモジュール ex. Records ex. HTTP Client ex. ZGC Note: Preview, Experimental, Incubator は最低 2 回
  3. JEP: JDK Enhancement Proposal の機能を規定 JDK 新機能だけでなく、実装改善、機能の削除も含む Preview Standard 正式な機能

    の種類 JEP Incubator Experimental プレビュー機能 実験的な機能 新しいモジュール ex. Records ex. HTTP Client ex. ZGC Note: Preview, Experimental, Incubator は最低 2 回
  4. JEP: JDK Enhancement Proposal Java 21 430: String Templates (Preview)

    431: Sequenced Collections 439: Generational ZGC 440: Record Patterns 441: Pattern Matching for switch 442: Foreign Function & Memory API (Third Preview) 443: Unnamed Patterns and Variables (Preview) 444: Virtual Threads 445: Unnamed Classes and Instance Main Methods (Preview) 446: Scoped Values (Preview) 448: Vector API (Sixth Incubator) 449: Deprecate the Windows 32-bit x86 Port for Removal 451: Prepare to Disallow the Dynamic Loading of Agents 452: Key Encapsulation Mechanism API 453: Structured Concurrency (Preview)
  5. Project Amber 言語仕様の改良と拡張を行うプロジェクト 286: Local-Variable Type Inference (var) (10) 323:

    Local-Variable Syntax for Lambda Parameters (11) 361: Switch Expressions (14) 378: Text Blocks (15) 394: Pattern Matching for instanceof (16) 395: Records (16) 409: Sealed Classes (17) 440: Record Patterns (21) 441: Pattern Matching for switch (21) 仕様策定完了
  6. Project Amber 言語仕様の改良と拡張を行うプロジェクト 仕様策定中 447: Statements before super() 455: Primitive

    types in Patterns, instanceof, and switch 456: Unnamed Variables & Patterns 459: String Templates 463: Implicitly Declared Classes and Instance Main Methods
  7. Project Amber 型 395: Records 409: Sealed Classes 447: Statements

    before super() (Preview) 361: Switch Expressions 394: Pattern Matching for instanceof 440: Record Patterns 441: Pattern Matching for switch 455: Primitive types in Patterns, instanceof, and switch (Preview) 456: Unnamed Variables & Patterns パターンマッチング 286: Local-Variable Type Inference (var) 323: Local-Variable Syntax for Lambda Parameters 378: Text Blocks 459: String Templates (2nd Preview) 463: Flexible Main Methods and Anonymous Main Classes (2nd Preview) その他
  8. Project Amber 型 395: Records 409: Sealed Classes 447: Statements

    before super() (Preview) 361: Switch Expressions 394: Pattern Matching for instanceof 440: Record Patterns 441: Pattern Matching for switch 455: Primitive types in Patterns, instanceof, and switch (Preview) 456: Unnamed Variables & Patterns パターンマッチング 286: Local-Variable Type Inference (var) 323: Local-Variable Syntax for Lambda Parameters 378: Text Blocks 459: String Templates (2nd Preview) 463: Flexible Main Methods and Anonymous Main Classes (2nd Preview) その他
  9. Data Oriented Programming データを(イミュータブルな)データとして表す 代数的データ型を用いたデータモデリング ビジネスロジックをデータと切り離す データ ビジネスロジック リソース 値オブジェクト

    イベント ... ステートレスな処理 型として表現する モジュールとして表現する ( 型として扱う必要はない ) イミュータブルであることが重要
  10. Data Oriented Programming Boundary Controller Entity Boundary 他システム ブラウザ 他システム

    インタフェース クラスベースの モデリング ドメインモデル ビジネスロジック DOP
  11. 直和型における処理の振り分け 例 商品の購入価格 価格 = 商品単価 × 割引率 × 個数

    誰が買うかで異なる 非会員/会員 キャンペーン 特売などで変動 個数が多いと 割引 Template Patternで書きますか?
  12. JEP 459: String Templates (2nd Preview) 文字列に 変数 / 式

    を埋め込み 文字列補間を行う言語仕様 “Hello, ” + name + “!”; STR.”Hello, \{name}!” 容易なカスタム化 ログメッセージなどを文字列から生成 JSON, SQL,
  13. Conclusion Java 21 LTS Virtual Threads などが導入 データ指向プログラミングに向けた機能 Project Amber

    Java 21 String Templateが では Preview データを型で表す ビジネスロジックと切り離して考える データ指向プログラミング
  14. 参考文献 InfoQ: Data Oriented Programming in Java https://www.infoq.com/articles/data-oriented-programming-java/ JavaOne 2022:

    Data Oriented Programming in Java https://youtu.be/UQAw3pvZPCY?si=5SiP6O0o8i6EWsyi https://slides.com/kawasima/truth-of-data-oriented-programming データ指向プログラミングの真実をお話しします