Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Introduction to Scala
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Yukiyan
April 21, 2020
Technology
110
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Introduction to Scala
2020/04/21 社内LT
Scala入門
Yukiyan
April 21, 2020
More Decks by Yukiyan
See All by Yukiyan
Introduction to Scala about type parameter
yukiyan
0
180
digdagで支えるデータパイプライン / Building a data pipeline with digdag
yukiyan
1
5.9k
機械学習基盤を一人で構築するということ / Hitori ml team
yukiyan
3
3.7k
ECSのデプロイツールを試している話
yukiyan
0
2.5k
Replace a batch application to ECS
yukiyan
1
1.6k
Introduction to Docker
yukiyan
0
5.8k
Other Decks in Technology
See All in Technology
Adversary Infrastructure Hunting101
disconinja
0
160
国際カードブランドルール変更に伴うクレジットカード決済取引仕様変更について
k1style
0
250
自宅サーバと脆弱性
masakiokuda
1
120
クラウドサインを止めずに Nuxt へ 次の10年のために先に決めたこと
bengo4com
1
170
Autonomous AI Lakehouse - Live AI Hubから始めるセキュアなAIデータ活用 -
oracle4engineer
PRO
2
160
AIをリアル世界に解き放つ 〜M5Stack×AIであなたのアイディアを手の平に〜
hamadakoji
1
570
シンプルな設定ファイルで実現する AWS IAM Identity Center の ユーザー管理Terraformフレームワークを公開しました / Simplifying AWS IAM Identity Center User Management: An Open-Source Terraform Framework
yamaguchitk333
1
330
DevelopersIO 2026 Tokyo 現時点の衛星通信サービスの現状を整理してみる
maroon1st
0
320
dbt Semantic Layerで進めるenechainのデータ民主化
akizhou
1
280
あなたのDartコードは丸見えかもしれない ~reFlutterで暴くFlutterアプリの中身と多層防御~
zozotech
PRO
0
320
AIエージェント時代、Kaggleにどう取り組むか
takanao
1
300
E2Eってつらくないですか?E2Eの管理コストを下げる手段とその実践
akaboshinit
5
2.4k
Featured
See All Featured
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.9k
Utilizing Notion as your number one productivity tool
mfonobong
4
630
How GitHub (no longer) Works
holman
316
150k
The Curious Case for Waylosing
cassininazir
1
580
Ruling the World: When Life Gets Gamed
codingconduct
0
420
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
4
4.4k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
620
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Designing for Timeless Needs
cassininazir
1
530
Statistics for Hackers
jakevdp
799
230k
Navigating Team Friction
lara
192
16k
Transcript
Scala 入門 ゆきやん
教材
Scala をやる動機 データエンジニアリングをしていると Scala や Java 製のプロダクトを利用することが多い • 大規模分散処理系のプロダクトで採用事例が多い ◦
apache/spark ◦ apache/kafka ◦ apache/flink ◦ apache/beam • データ処理に便利 ◦ NULL 安全なエラーハンドリング (大規模データ処理で数時間待ってヌルポはきつい ) ◦ 型を生かした豊富なコレクションライブラリ ◦ 柔軟な非同期処理 • Java の資産を利用できる ◦ treasure-data/digdag, embulk/embulk のプラグインを Scala で書ける ◦ spotify/scio
• jenv/jenv • scalaenv/scalaenv • Language Server ◦ scalameta/metals ◦
R.I.P ENSIME IDE は必ずしも必要ではない REPL もちゃんとある (sbt console) 環境構築
基本的な文法
面白かった機能 • ケースクラス • トレイト • 高階関数 • implicit parameter
• パターンマッチ • Option, Either, Try • コレクション(for 内包表記)
ケースクラス • Value Object 使うときに役立つ
トレイト • Java のインターフェースみたいなやつ • 複数のトレイトを 1つのクラスやトレイトにミックスインできる • 直接インスタンス化できない
トレイト
高階関数
高階関数
implicit parameter メタ情報のような使うか使わないか分からん情報を、引数でひたすら引き回す手間を省ける (DBコネクションとか) 「引数の省略ができる」というメリットはあるけど、場合によっては可読性が下がるので次スライドの活用法のほ うが多用される
implicit parameter リファクタリング前
implicit parameter まずは trait でリファクタリング 要素の型で自明なのに HogeAddr 書くのが無駄
implicit parameter さらに implicit parameter で リファクタリング
型クラス(≒implicit parameter)は、うまく使うと、後付けのデータ型に対して既存のアルゴリズムを型安全に 適用するのに使うことができます。 この特徴は、特にライブラリ設計のときに重要になってきます。 ライブラリ設計時点で定義されていないデータ型に対していかにしてライブラリのアルゴリズムを適用する か、つまり、拡張性が高いように作るかというのは、なかなか難しい問題です。 簡潔に書けることを重視すると、拡張性が狭まりがちですし、拡張性が高いように作ると、デフォルトの動作で いいところを毎回書かなくてはいけなくて利用者にとって不便です。 型クラスを使ったライブラリを提供することによって、この問題をある程度緩和することができます。 皆さんも、型クラスを使って、既存の問題をより簡潔に、拡張性が高く解決できないか考えてみてください。
型クラスへの誘い · Scala研修テキスト implicit parameter
パターンマッチ
パターンマッチ
パターンマッチ
パターンマッチ
Option, Either, Try
Option, Either, Try
Option, Either, Try
Option, Either, Try
コレクション(for 内包表記) for 内包表記が便利
コレクション(for 内包表記)
• ジェネリクス ◦ class Foo[A] • 変位指定 ◦ class Foo[+A]
◦ class Foo[-A] • 型境界 ◦ class Foo[A <: B] ◦ class Foo[A >: B] • Future ◦ andThen ◦ recover, recoverWith ◦ result, ready ...etc 次回予告