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
Recent Updates (近況報告)
Search
yhara
September 21, 2014
Programming
0
590
Recent Updates (近況報告)
2014/09/21 RubyHiroba2014
yhara
September 21, 2014
Tweet
Share
More Decks by yhara
See All by yhara
静的型付けプログラミング言語Shiika
yhara
0
18k
それは残像だ
yhara
4
4.2k
スモートーク
yhara
0
2.8k
Ovto: Frontend web framework for Rubyists
yhara
0
7.1k
Ruby, Opal and WebAssembly
yhara
2
2.4k
Competitive Programming in Ruby (101)
yhara
0
680
Rubyで競技プログラミング(入門編)
yhara
0
1.8k
良いデバッグログはプロジェクトの資産である
yhara
54
18k
Let's make a functional language!
yhara
0
6.3k
Other Decks in Programming
See All in Programming
watsonx.ai Dojo #4 生成AIを使ったアプリ開発、応用編
oniak3ibm
PRO
1
150
3rd party scriptでもReactを使いたい! Preact + Reactのハイブリッド開発
righttouch
PRO
1
610
アジャイルを支えるテストアーキテクチャ設計/Test Architecting for Agile
goyoki
9
3.3k
2024/11/8 関西Kaggler会 2024 #3 / Kaggle Kernel で Gemma 2 × vLLM を動かす。
kohecchi
5
940
flutterkaigi_2024.pdf
kyoheig3
0
150
AWS Lambdaから始まった Serverlessの「熱」とキャリアパス / It started with AWS Lambda Serverless “fever” and career path
seike460
PRO
1
260
Duckdb-Wasmでローカルダッシュボードを作ってみた
nkforwork
0
130
「今のプロジェクトいろいろ大変なんですよ、app/services とかもあって……」/After Kaigi on Rails 2024 LT Night
junk0612
5
2.2k
PHP でアセンブリ言語のように書く技術
memory1994
PRO
1
170
Make Impossible States Impossibleを 意識してReactのPropsを設計しよう
ikumatadokoro
0
240
ヤプリ新卒SREの オンボーディング
masaki12
0
130
Laravel や Symfony で手っ取り早く OpenAPI のドキュメントを作成する
azuki
2
120
Featured
See All Featured
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
44
2.2k
Thoughts on Productivity
jonyablonski
67
4.3k
Practical Orchestrator
shlominoach
186
10k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
109
49k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.2k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
380
Building an army of robots
kneath
302
43k
Rails Girls Zürich Keynote
gr2m
94
13k
The Language of Interfaces
destraynor
154
24k
Teambox: Starting and Learning
jrom
133
8.8k
Adopting Sorbet at Scale
ufuk
73
9.1k
Transcript
ۙگใࠂ (Latest News) ɹ Yutaka HARA ωοτϫʔΫ Ԡ༻௨৴ݚڀॴ 2014/09/21 RubyHiroba2014
Attendees from Matsue office — @nacl — @yukihiro_matz — @shugomaeda
— @takaokouji — @nobyuki — @nari3 — @yhara (me)
http://www.netlab.jp/recruit
My current project — github:yhara/boom — Toy language with type
inference — Will resume it as soon as I quit Ingress
Recent interests 1. "Ruby and Patten Match" 2. "Ideal way
to map a hash" 3. "Opal the Ruby to JS compiler"
1. Ruby and Patten Match
Ruby HAS pattern match (via gem) — pattern-match gem (@k_tsj)
— patm gem (@todesking, limited but faster) — egison gem (@__Egi, RubyKaigi Day 1)
ɹ Pattern Match is like Regexp for Objects
Match regexp against string ʮIf the string is like thisʯ
str = "add 1 2" if str =~ /add (\d+) (\d+)/ puts "Add #{$1} and #{$2}" end
Match pattern against array ʮIf the array is like thisʯ
require 'pattern-match' ary = [:add, 1, 2] match(ary){ with(_[:add, x, y]){ puts "Add #{x} and #{y}" } }
Match pattern against your class class Book # has :title,
:price ... def self.deconstruct(val) accept_self_instance_only(val) return [val.title, val.price] end end book = Book.new("Programming Ruby", 3400) match(book){ with(Book.(/Ruby/, 0..5000)) { p book } }
Try it now. $ gem install pattern-match require 'pattern-match' match(1){
with(x){ p x } } github:k-tsj/pattern-match
2. Ideal way to map a hash
My proposals accepted — #1961 __dir__ — #4890 Enumerable#lazy —
#6670 String#lines should return array and one more challenge:
Current hash.map — How to convert {:a => 1, :b
=> 2} into {"a" => 1, "b" => 2} h = {:a => 1, :b => 2} pairs = h.map{|k, v| [k.to_s, v] } #=> [["a", 1], ["b", 2]]
Hash#[] h = {a: 1, b: 2} pairs = h.map{|k,
v| [k.to_s, v] } #=> [["a", 1], ["b", 2]] Hash[pairs] #=> {"a" => 1, "b" => 2}
Enumerable#to_h (Ruby >= 2.1) h = {a: 1, b: 2}
pairs = h.map{|k, v| [k.to_s, v] } #=> [["a", 1], ["b", 2]] pairs.to_h #=> {"a" => 1, "b" => 2}
Ideal way h = {a: 1, b: 2} h.xxxxxx{|k, v|
[k.to_s, v] } #=> {"a" => 1, "b" => 2} xxxxxx == hash_map, map_hash, hash_by, morph, apply, map_kv, ...???
Join bugs.ruby-lang.org — Feature #10208: Passing block to Enumerable#to_h —
Feature #6669: A method like Hash#map but returns hash We need a good name :-( Any ideas?
3. Opal the Ruby to JS compiler
http://opalrb.org/
http://opalrb.org/ — Compiler from Ruby to JavaScript — Some difference,
but mostly Ruby — String is immutable, etc.
Why Opal matters #1 JavaScript x HTML5 JavaScript x WebSocket
JavaScript x WebRTC JavaScript x Mobile ...
Why Opal matters #1 Ruby(Opal) x HTML5 Ruby(Opal) x WebSocket
Ruby(Opal) x WebRTC Ruby(Opal) x Mobile ...
Why Opal matters #2 — Two languages [Client] [Server] JavaScript
---> Rails(Ruby) <---
Why Opal matters #2 — One language! [Client] [Server] Opal(Ruby)
---> Rails(Ruby) <---
One language for C/S — No context switch — Share
logic among C/S (validation, etc.) — Pre-render view on the server side cf. Rendr, Meteor (Node.js)
Related products Check it out! — For #1: github:yeahrb/yeah "Practical
Ruby video game framework" — For #2: github:voltrb/volt "A ruby web framework where your ruby runs on both server and client"
None
Yeahrb Demo $ gem i yeah $ yeah new hello
$ cd hello $ yeah serve $ open http://localhost:1234 $ vi code/game.rb
Yeahrb Demo code/game.rb: class Hello1 < Game def setup end
def update(elapsed) display.fill_color = C[255,255,255] display.fill_rectangle(V[0,0], display.size) end end
Yeahrb Demo Feels like so Ruby that you never want
to go back to JavaScript :-)
ۙگใࠂ: I'm enjoying programming.