Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Gleamという選択肢
Search
Comamoca
June 14, 2025
Programming
6
840
Gleamという選択肢
関数型まつり2日目「Gleamという選択肢」のスライドです。
Comamoca
June 14, 2025
Tweet
Share
Other Decks in Programming
See All in Programming
SQLアンチパターン第2版 データベースプログラミングで陥りがちな失敗とその対策 / Intro to SQL Antipatterns 2nd
twada
PRO
36
11k
JetBrainsのAI機能の紹介 #jjug
yusuke
0
170
LLMは麻雀を知らなすぎるから俺が教育してやる
po3rin
3
1.8k
Amazon Q CLI開発で学んだAIコーディングツールの使い方
licux
3
160
DynamoDBは怖くない!〜テーブル設計の勘所とテスト戦略〜
hyamazaki
0
160
#QiitaBash TDDで(自分の)開発がどう変わったか
ryosukedtomita
1
340
それ CLI フレームワークがなくてもできるよ / Building CLI Tools Without Frameworks
orgachem
PRO
17
3.6k
[Codecon - 2025] Como não odiar seus testes
camilacampos
0
100
Claude Code派?Gemini CLI派? みんなで比較LT会!_20250716
junholee
1
790
オンコール⼊⾨〜ページャーが鳴る前に、あなたが備えられること〜 / Before The Pager Rings
yktakaha4
2
1.2k
商品比較サービス「マイベスト」における パーソナライズレコメンドの第一歩
ucchiii43
0
240
顧客の画像データをテラバイト単位で配信する 画像サーバを WebP にした際に起こった課題と その対応策 ~継続的な取り組みを添えて~
takutakahashi
4
1.4k
Featured
See All Featured
A Modern Web Designer's Workflow
chriscoyier
695
190k
Build The Right Thing And Hit Your Dates
maggiecrowley
37
2.8k
Making Projects Easy
brettharned
117
6.3k
Raft: Consensus for Rubyists
vanstee
140
7k
The Art of Programming - Codeland 2020
erikaheidi
54
13k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.4k
Git: the NoSQL Database
bkeepers
PRO
431
65k
Balancing Empowerment & Direction
lara
1
520
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
126
53k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
A Tale of Four Properties
chriscoyier
160
23k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.8k
Transcript
Gleam という選択肢 6/15 関数型まつり 2 日目 こまもか
自己紹介 こまもか Twitter: @Comamoca_ \ Twitter から来ました! /
None
None
None
None
注意点 • 基本的に Gleam v1.11.0 を前提にしています。 • 表示の都合上 import などを省略している箇所があります。
Gleam とは Louis Pilfold 氏が開発している、静的型付けの関数型言語 シンプルな構文と Erlang VM に基づいた並列性が特徴 GitHub
19.4K ⭐
シンプル…Go と何が違うの?
Gleam とは https://crowdhailer.me/2024-10-04/6-years-with-gleam/
Gleam is Go ideas but from the perspective of a
FP nerd instead of a C nerd — Louis Pilfold
意訳するなら Gleam は Go の設計思想を取り入れているけど、C オタクの 視点じゃなくて FP オタクの視点で解釈した言語だ。 —
Louis Pilfold
Gleam の特徴 • シンプルな構文 • 関数型言語由来の関数が多いためコードがスッキリする • エラーメッセージが親切 • Erlang
VM / JS Runtime で動く
Erlnag VM について https://gleam.run/getting-started/installing/
エラーメッセージの例 error: Unknown variable ┌─ /src/main.gleam:3:8 │ 3 │ echo
prson │ ^^^^^ Did you mean person? The name prson is not in scope here. warning: Unused variable ┌─ /src/main.gleam:2:7 │ 2 │ let person = "Jhon" │ ^^^^^^ This variable is never used Hint: You can ignore it with an underscore: _person.
LSP • 型アノテーションの追加 • import 文の自動追加 • case における不足してるパターンの追加 •
パイプ形式への自動変換
None
構文 • if とか for がない • コールバックの構文糖(use 構文) •
ブロック構文 • パターンマッチ • パイプライン演算子
use 構文 これ一つで • 例外処理 • 非同期処理 • early return
• middleware などが表現できる
None
例えば 1 let val = True 2 case True {
3 True -> "これは True" 4 False -> "これは False" 5 }
例えば 1 import gleam/list 2 3 pub fn main() {
4 list.range(0, 10) 5 |> list.map(fn (n) { n * 2 }) 6 |> list.filter(fn (n) {n % 3 == 0}) 7 |> echo 8 }
None
開発環境 https://gleam.run/getting-started/installing/
インストール • brew • AUR • apt • scoop •
Nix
拡張機能 • VSCode • Vim • Emacs • Zed
Gleam のエコシステム
Web サーバー • gleam/http • mist • wisp
ルーティング 1 import gleam/string_tree 2 import hello_world/app/web 3 import wisp.{type
Request, type Response} 4 5 pub fn handle_request(req: Request) -> Response { 6 // ["tasks", "2"] 7 case wisp.path_segments(req) { 8 [] -> index(req) 9 ["hello"] -> greet(req) 10 ["tasks", id] -> show_task(req, id) 11 _ -> wisp.not_found() 12 } 13 }
ミドルウェア 1 pub fn greet_middleware(req: Request, handler: fn (Request) ->
Response) -> Response { 2 io.println("Hello!") 3 } 4 5 pub fn handle_request(req: Request) -> Response { 6 use req <- greet_middleware(req) 7 8 case wisp.path_segments(req) { 9 [] -> index(req) 10 _ -> wisp.not_found() 11 } 12 }
Lustre • TEA ベースの Web フレームワーク • 表示単位が純粋関数なためどこでもレンダリングできる • CSR,
SSR, SSG が可能 • 開発が Lustre dev tools で完結する • GitHub 1.6K ⭐
None
実例
Gleam Packages
Gloogle
kirakira
これからの展望 • 更なる開発支援機能の追加 • コード生成技術の発達 • フルスタックフレームワークの発達 • 新たなコンパイルターゲットの登場
寄付について 現在 Louis Pilfold 氏はフルタイムで Gleam を開発しているので すが、残念ながら財政状況は良くないらしいです… GitHub Sponsors
経由で寄付を行えるので、Gleam を気に入った らぜひ寄付をお願いします。
ちなみに、寄付を行なうとブログの一番下に名前が載ります。