rabbit-slide-tommy-crystal 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e29cc0a646712c0cb1d118c771e0c4e4a9339566
4
+ data.tar.gz: 15483c6aba85d008c6a70962a9c1136e20f2b99f
5
+ SHA512:
6
+ metadata.gz: 0d4992b09091678847730e23114d9ffa4893490d61c5c9f71a2454af9ebfa7673a86a3b49152e660e15139f9ca8c93a6e44557128821d07e03e5dd476e78263a
7
+ data.tar.gz: 7bb4ea65795bc19210affc8781d87d975f28f29b58e2ad7c68fb48cb4ee0ad1a59707570c3a78e6b451917cd7fe65c8165e673f4465e6c126d942f903c6d1576
data/.rabbit ADDED
@@ -0,0 +1 @@
1
+ crystal.md
@@ -0,0 +1,24 @@
1
+ # Crystal
2
+
3
+ Crystal について
4
+
5
+ ## 作者向け
6
+
7
+ ### 表示
8
+
9
+ rake
10
+
11
+ ### 公開
12
+
13
+ rake publish
14
+
15
+ ## 閲覧者向け
16
+
17
+ ### インストール
18
+
19
+ gem install rabbit-slide-tommy-crystal
20
+
21
+ ### 表示
22
+
23
+ rabbit rabbit-slide-tommy-crystal.gem
24
+
@@ -0,0 +1,17 @@
1
+ require "rabbit/task/slide"
2
+
3
+ # Edit ./config.yaml to customize meta data
4
+
5
+ spec = nil
6
+ Rabbit::Task::Slide.new do |task|
7
+ spec = task.spec
8
+ # spec.files += Dir.glob("doc/**/*.*")
9
+ # spec.files -= Dir.glob("private/**/*.*")
10
+ # spec.add_runtime_dependency("YOUR THEME")
11
+ end
12
+
13
+ desc "Tag #{spec.version}"
14
+ task :tag do
15
+ sh("git", "tag", "-a", spec.version.to_s, "-m", "Publish #{spec.version}")
16
+ sh("git", "push", "--tags")
17
+ end
@@ -0,0 +1,19 @@
1
+ ---
2
+ id: crystal
3
+ base_name: crystal
4
+ tags: []
5
+ presentation_date:
6
+ version: 1.0.0
7
+ licenses: []
8
+ slideshare_id: crystal-51973486
9
+ speaker_deck_id:
10
+ ustream_id:
11
+ vimeo_id:
12
+ youtube_id:
13
+ author:
14
+ markup_language: :markdown
15
+ name: "とみたまさひろ"
16
+ email: tommy@tmtm.org
17
+ rubygems_user: tommy
18
+ slideshare_user: tmtm
19
+ speaker_deck_user:
@@ -0,0 +1,337 @@
1
+ # Crystal
2
+
3
+ author
4
+ : とみたまさひろ
5
+
6
+ theme
7
+ : clear-blue+
8
+
9
+ date
10
+ : 2015-08-23
11
+
12
+ # Crystal
13
+
14
+ ![http://crystal-lang.org/](crystal.png){:relative_height="100"}
15
+
16
+ # Ruby風の言語
17
+
18
+ # Ruby風?
19
+
20
+ | Crystal | Ruby |
21
+ |----------------|----------------|
22
+ | 静的 | 動的 |
23
+ | 型あり | 型なし |
24
+ | コンパイル言語 | スクリプト言語 |
25
+
26
+ # Crystal プログラム
27
+
28
+ ふつーに Ruby
29
+
30
+ ```ruby
31
+ class Hoge
32
+ def foo
33
+ p "abc"
34
+ end
35
+ end
36
+ Hoge.new.foo #=> "abc"
37
+ ```
38
+
39
+ # 実行
40
+
41
+ ```
42
+ % ruby hoge.rb
43
+ "abc"
44
+ % crystal hoge.rb
45
+ "abc"
46
+ ```
47
+
48
+ # ベンチマーク
49
+
50
+ ```ruby
51
+ # フィボナッチ数列のN番目の値
52
+ def fib(n)
53
+ if n < 2
54
+ n
55
+ else
56
+ fib(n-1) + fib(n-2)
57
+ end
58
+ end
59
+ p fib(35)
60
+ ```
61
+
62
+ # 速い!
63
+
64
+ ```
65
+ % time ruby fib.rb
66
+ 9227465
67
+ real 0m2.275s
68
+ user 0m2.268s
69
+ sys 0m0.004s
70
+
71
+ % time crystal fib.rb
72
+ 9227465
73
+ real 0m0.299s
74
+ user 0m0.236s
75
+ sys 0m0.056s
76
+ ```
77
+
78
+ # コンパイルして実行ファイルを生成
79
+
80
+ ```
81
+ % crystal build fib.rb --release
82
+ % ./fib
83
+ 9227465
84
+ ```
85
+
86
+ # さらに速い!
87
+
88
+ ```
89
+ % time crystal fib.rb
90
+ 9227465
91
+ real 0m0.299s
92
+ user 0m0.236s
93
+ sys 0m0.056s
94
+
95
+ % time ./fib
96
+ 9227465
97
+ real 0m0.090s
98
+ user 0m0.088s
99
+ sys 0m0.000s
100
+ ```
101
+
102
+ # RubyスクリプトをCrystalで実行するだけで速くなる!?
103
+
104
+ # そんなうまい話はない
105
+
106
+ # Crystal ≠ Ruby
107
+
108
+ # 文字と文字列
109
+
110
+ * `"A"` - 文字列
111
+ * `'A'` - 文字
112
+
113
+ ```ruby
114
+ "A"+"B" #=> "AB"
115
+ 'A'+'B' #=> undefined method '+' for Char
116
+ ```
117
+
118
+ # 多倍長整数がない
119
+
120
+ 整数演算の謎に見える挙動
121
+
122
+ ```ruby
123
+ 0x7FFFFFFF.class #=> Int32
124
+ 0x80000000.class #=> Int64
125
+ 0x7FFFFFFF+1 #=> -2147483648
126
+ 0x7FFFFFFFi64+1 #=> 2147483648
127
+ 256*256*256 #=> 16777216
128
+ 256**3 #=> 1.67772e+07
129
+ 256*256*256*256 #=> 0
130
+ 256**4 #=> 4.29497e+09
131
+ ```
132
+
133
+ # Crystal は Crystal として使おう
134
+
135
+ # 拡張子は .rb じゃなくて .cr
136
+
137
+ # Crystalの特徴(Rubyと比較して)
138
+
139
+ # 型
140
+
141
+ ```ruby
142
+ a = [1, 2, 3] #=> Array(Int32)
143
+ a.push 4 #=> OK
144
+ a.push "a"
145
+ #=> no overload matches 'Array(Int32)#push'
146
+ # with types String (コンパイル時エラー)
147
+
148
+ a = [] #=> Syntax error
149
+ a = [] of Int32 #=> OK
150
+ ```
151
+
152
+ # メソッド
153
+
154
+ ```ruby
155
+ def hoge(a, b)
156
+ a + b
157
+ end
158
+
159
+ hoge("abc", "xyz") #=> "abcxyz"
160
+ hoge(1, 2) #=> 3
161
+ hoge("abc", 2) #=> コンパイル時エラー
162
+ ```
163
+
164
+ # コンパイル時エラー
165
+
166
+ ```
167
+ % crystal build hoge.cr
168
+ Error in ./hoge.cr:7: instantiating 'hoge(String, Int32)'
169
+
170
+ hoge("abc", 2)
171
+ ^~~~
172
+
173
+ in ./hoge.cr:2: no overload matches 'String#+' with types Int32
174
+ Overloads are:
175
+ - String#+(other : self)
176
+ - String#+(char : Char)
177
+
178
+ a + b
179
+ ^
180
+ ```
181
+
182
+ # オーバーロード
183
+
184
+ ```ruby
185
+ def hoge(a, b)
186
+ a + b
187
+ end
188
+
189
+ def hoge(a : String, b : Int)
190
+ a * b
191
+ end
192
+
193
+ hoge("abc", "xyz") #=> "abcxyz"
194
+ hoge(1, 2) #=> 3
195
+ hoge("abc", 2) #=> "abcabc"
196
+ ```
197
+
198
+ # 変数に型はない
199
+
200
+ ```ruby
201
+ var = 123
202
+ var = 'a'
203
+ ```
204
+
205
+ # 複数の型の可能性
206
+
207
+ ```ruby
208
+ var = rand < 0.5 ? 123 : "abc"
209
+ var.size # Int にないのでエラー
210
+ var + 1 # String にないのでエラー
211
+ ```
212
+
213
+ # ちゃんと型チェックすればエラーにならない
214
+
215
+ ```ruby
216
+ var = rand < 0.5 ? 123 : "abc"
217
+ if var.is_a? Int
218
+ var + 1
219
+ else
220
+ var.size
221
+ end
222
+ ```
223
+
224
+ # 静的
225
+
226
+ # 静的
227
+
228
+ * eval がない
229
+ * クラス定義/メソッド定義は後勝ち
230
+
231
+ # メソッド定義は後勝ち
232
+
233
+ ```ruby
234
+ if rand < 0.5
235
+ def hoge # ← rand の値に関係なく無視される
236
+ 123 #
237
+ end #
238
+ else
239
+ def hoge # ← 常にこっちが有効
240
+ "abc" #
241
+ end #
242
+ end
243
+ ```
244
+
245
+ # 直感に反したり
246
+
247
+ ```ruby
248
+ def hoge
249
+ 123
250
+ end
251
+ if false
252
+ def hoge
253
+ "abc"
254
+ end
255
+ end
256
+ hoge #=> "abc"
257
+ ```
258
+
259
+ # その他
260
+
261
+ # 名前付き引数
262
+
263
+ Rubyより自然かも
264
+
265
+ ```ruby
266
+ def hoge(n=123, s="abc")
267
+ p [n, s]
268
+ end
269
+ hoge #=> [123, "abc"]
270
+ hoge(789) #=> [789, "abc"]
271
+ hoge(s: "xyz") #=> [123, "xyz"]
272
+ ```
273
+
274
+ # マクロ
275
+
276
+ ```ruby
277
+ macro define_method(name, content)
278
+ def {{name}}
279
+ {{content}}
280
+ end
281
+ end
282
+
283
+ define_method foo, 123
284
+ foo #=> 123
285
+ ```
286
+
287
+ # プロジェクト雛形作成(Rails風?)
288
+
289
+ ```
290
+ % crystal init app my_project
291
+ create my_project/.gitignore
292
+ create my_project/LICENSE
293
+ create my_project/README.md
294
+ create my_project/.travis.yml
295
+ create my_project/Projectfile
296
+ create my_project/src/my_project.cr
297
+ create my_project/src/my_project/version.cr
298
+ create my_project/spec/spec_helper.cr
299
+ create my_project/spec/my_project_spec.cr
300
+ Initialized empty Git repository in /tmp/my_project/.git/
301
+ ```
302
+
303
+ # ライブラリ依存関係解決(Bundler風)
304
+
305
+ ```
306
+ my_project% cat Projectfile
307
+ deps do
308
+ github "manastech/crystal-mysql"
309
+ end
310
+
311
+ my_project% crystal deps install
312
+ Cloning into '.deps/manastech-crystal-mysql'...
313
+ remote: Counting objects: 55, done.
314
+ remote: Total 55 (delta 0), reused 0 (delta 0), pack-reused 55
315
+ Receiving objects: 100% (55/55), 7.03 KiB | 0 bytes/s, done.
316
+ Resolving deltas: 100% (19/19), done.
317
+ Checking connectivity... done.
318
+ ```
319
+
320
+ # ドキュメント作成(YARD風)
321
+
322
+ ```
323
+ my_project% crystal doc
324
+ my_project% ls doc
325
+ Myproject.html css index.html js list.html main.html
326
+ ```
327
+
328
+ # テスト(RSpec風)
329
+
330
+ ```
331
+ my_project% crystal spec
332
+ .
333
+
334
+ Finished in 0.38 milliseconds
335
+ 1 examples, 0 failures, 0 errors, 0 pending
336
+ ```
337
+
Binary file
Binary file
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rabbit-slide-tommy-crystal
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - "とみたまさひろ"
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rabbit
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 2.0.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 2.0.2
27
+ description: Crystal について
28
+ email:
29
+ - tommy@tmtm.org
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".rabbit"
35
+ - README.md
36
+ - Rakefile
37
+ - config.yaml
38
+ - crystal.md
39
+ - crystal.png
40
+ - pdf/crystal-crystal.pdf
41
+ homepage: http://slide.rabbit-shocker.org/authors/tommy/crystal/
42
+ licenses: []
43
+ metadata: {}
44
+ post_install_message:
45
+ rdoc_options: []
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ requirements: []
59
+ rubyforge_project:
60
+ rubygems_version: 2.4.5.1
61
+ signing_key:
62
+ specification_version: 4
63
+ summary: Crystal
64
+ test_files: []