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
型付きWebフレームワークで遊んでみた
Search
kokuyouwind
July 14, 2014
Programming
1.9k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
型付きWebフレームワークで遊んでみた
発表時間5分の社内LT大会で使用した資料です(実名・所属など一部改変)。
OCamlのWebフレームワークOcsigenを使ってみたので、その簡単な紹介となっています。
kokuyouwind
July 14, 2014
More Decks by kokuyouwind
See All by kokuyouwind
疑似コードによるプロンプト記述、どのくらい正確に実行される?
kokuyouwind
0
610
謎解きサイトを Rails SPA で作って RubyKaigi で配布した話
kokuyouwind
0
100
ドメイン指定Cookieとサービス間共有Redisで作る認証基盤サービス
kokuyouwind
0
47
Do LLMs dream of Type Inference?
kokuyouwind
0
50
Let's use LLMs from Ruby 〜 Refine RBS types using LLM 〜
kokuyouwind
0
8.7k
APMをちゃんと使おうとしたら、いつのまにか独自gemを作っていた話
kokuyouwind
0
990
RBS meets LLMs - Type inference using LLM
kokuyouwind
0
1.1k
オンラインボードゲームを作りたい人生だった
kokuyouwind
0
720
1年間本番運用してわかった、スタートアップこそAWS Copilot CLIを使うべきNつの理由
kokuyouwind
2
12k
Other Decks in Programming
See All in Programming
Heart of Swift Concurrency
koher
0
1.1k
Are APIs Still Relevant in the AI Era?
soyuka
0
400
AI が書く Go コードの品質を劇的に向上させる Linter: “declscope”
mpyw
0
470
GitHubハンズオン講座 — 実務レベルのチーム開発のフローを身につけよう
junhat6
0
120
C#の現在地 進化の歴史と、AI時代の.NET Everywhere
neuecc
5
4.8k
Simple Storage Service(S3) is not simple
iwatsukayura
0
120
Agentic Software Factoryに、すごく賢いIF文を。 / super smart IF statement into the Agentic Software Factory.
rkaga
1
460
速習iPhone Duo対応
yuukiw00w
2
930
FreeBSDでZabbixを動かす
kenkino
0
350
市販E-Readerを乗っ取れ 〜Embedded Swiftで電子ペーパーガジェットを制御する〜
trickart
0
230
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
520
技術的負債を組織課題として解く-増えすぎたマイクロサービスとの戦い-
reimaru
1
2.6k
Featured
See All Featured
The SEO Collaboration Effect
kristinabergwall1
1
580
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
470
Designing for Timeless Needs
cassininazir
1
510
The Language of Interfaces
destraynor
162
27k
How to train your dragon (web standard)
notwaldorf
97
6.8k
Speed Design
sergeychernyshev
33
2.1k
Abbi's Birthday
coloredviolet
4
10k
We Are The Robots
honzajavorek
0
380
Google's AI Overviews - The New Search
badams
0
1.6k
Raft: Consensus for Rubyists
vanstee
142
7.7k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
710
Ruling the World: When Life Gets Gamed
codingconduct
0
380
Transcript
型付きWebフレームワークで 遊んでみた @kokuyouwind
$ whoami • Web開発 3年目(PHP Only) • Twitter : @kokuyouwind
• ブログ : blog.kokuyouwind.com • ニコニコミュニティ : co1347624 • ポーカー好き このアイコンの人→
先週のハッカソン
テーマ:出会い
出会い → 協調作業
協調作業 → 一緒にお絵かき
お絵かきアプリだ!
デモ http://draw.kokuyouwind.com/
screenshot
普通じゃね?
面白い所: HTMLもJavaScriptも 書いてない!
Haml? TypeScript?
いえいえ
全てOCamlです!
Code on Github https://github.com/kokuyouwind/ocsigen-tutorial ロジック部分は全てOcamlコード graffiti.eliomは150行弱
謝罪
さっきのデモは チュートリアルの丸写しです 正直すまんかった
Ocsigen http://ocsigen.org/
基本記法 {shared{ type message = string }} {client{ let _
= Eliom_lib.alert "Hello!" }} let main_service = (* ... *) 共通コード クライアントコード サーバーコード
サービス定義 let main_service = Eliom_registration.Html5.register_service ~path:[“hello"] ~get_params:Eliom_parameter.unit (fun () ()
-> Lwt.return (html (head (title (pcdata “hello")) []) (body [h1 [pcdata “hello, world!"]]))) Html型の値を生成
サービス定義 let main_service = Eliom_registration.Html5.register_service ~path:["graff"] ~get_params:Eliom_parameter.unit (fun () ()
-> Lwt.return (html (head (title (pcdata "Page title")) []) (body [ul [pcdata "Graffiti"]]))) ↑コンパイル時に型エラー (ulの子要素がliじゃない)
サーバー変数埋め込み let message = “hello” {client{ let _ = Eliom_lib.alert
“%s” %message }} ↑ %hogeでサーバー側の 変数を参照
サーバー変数埋め込み let message = 0 {client{ let _ = Eliom_lib.alert
“%s” %message }} ↑ Stringじゃないので エラーになる
サーバー変数埋め込み let message = 0 {client{ let _ = Eliom_lib.alert
“%s” (string_of_int %message) }} ↑ これならオーケー
他にも… • Bus, React – イベントをやりとりする – 前者がEvent Driven, 後者がReactive
– 型が合わないとコンパイル時にエラー • Ajaxでのjsonとかの呼び出し – service定義を参照してurlを生成 – 型が合わないとコンパイル時にエラー
まとめ • Ocsigenだと全部Ocamlで書ける • コンパイル時点で型起因のバグは弾く • コードが割と短くなる • 学習コストは結構高い •
名古屋こわい • ことりちゃんかわいい http://tkotori.github.io/
終わり from @mzp
以下予備スライド
Ocsigenプロジェクト • OcsigenServer : Webサーバ • Eliom : Webフレームワーク •
Js_of_ocaml : JSコンパイラ • Lwt : 並列計算ライブラリ • 他色々 – http://ocsigen.org/overview/framework
ページサイズ • HTML : 3.39KB – 通信用の識別子とかが埋め込まれている • JavaScript :
282.39KB – OCamlバイトコード => JavaScriptコード – 直接読むのは多分辛い – 実行はかなり高速らしい • VM実行OCamlよりも速い場合があるとのこと
ことりちゃん? • 高階ことり • モナドの薄い本のイメージキャラクター – @dico_lequeさんの本(予定) – @bleisさんと@mzpさんの差し金 •
ことりちゃん可愛い • http://tkotori.github.io/
参考 • Ocsigenプロジェクトページ – http://ocsigen.org/ • OCamlで構築するモダンWeb – http://proofcafe.org/~keigoi/pplss2012- ocaml.pdf
• OCamlで作ったWebアプリをHerokuで 動かす方法(2) – http://mzp.hatenablog.com/entry/2013/06 /08/003029