-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.html
243 lines (227 loc) · 9.43 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
---
title: Crystal
nav_title: Home
nav_order: 1
description: 飛快如 C,靈巧似 Ruby
custom_body_classes:
- main
---
<div class="banner center bountysource no-select">
<div class="flag">
<a href="https://www.bountysource.com/teams/crystal-lang/fundraisers/702-crystal-language" target="_blank">
群眾募資中 —— 在
<img src="{{ 'bountysource.png' | asset_path }}" class="bountysource-logo">
上一同協助 Crystal 進入 Production 階段
</a>
</div>
</div>
<div class="container">
<div class="row">
<div class="col s12">
<h2>語法</h2>
<p>語法源自於 Ruby,這使得我們能夠更自然的閱讀及撰寫 Crystal,且對於有經驗的 Ruby 開發者們在學習曲線上更有助益。</p>
<div class='code_section'>
{% include sample_server.md %}
</div>
<p class="read-more"><a href="http://tw.crystal-lang.org/docs/overview/">> 現在就跟著入門文件學習如何撰寫 Crystal</a></p>
</div>
</div>
<div class="row">
<div class="col s12">
<h2>編譯式</h2>
<p>Crystal 是一個需要經過編譯的語言,這讓它可以以低成本的記憶體來執行飛快的程式。 並以 LLVM 為基石可以使 Crystal 在建置過程中進行最佳化。</p>
<h3>網頁伺服器吞吐量比較<hr class="squares"/></h3>
<p id="benchmark"></p>
<p class="read-more">資料來源: <a href="https://github.com/costajob/app-servers#results" target="_blank">costajobs/app-servers</a><br />
<a href="http://tw.crystal-lang.org/docs/using_the_compiler/">> 學習如何使用 Crystal 編譯器</a></p>
</div>
</div>
<div class="row">
<div class="col s12">
<h2>型別系統</h2>
<p>Crystal 使用了靜態型別檢查,所有的型別錯誤都會在編譯時期被捕捉,而不是在執行時期才進行檢查。 另外,為了保持語言的純淨度,Crystal 還內建了型別推導的能力,在大部分的情況下,我們不需要自行宣告型別類型。</p>
<div class="code_section">
{% include sample_type_system.md %}
</div>
<p class="read-more"><a href="http://tw.crystal-lang.org/docs/syntax_and_semantics/types_and_methods.html">> 閱讀更多關於 Crystal 型別系統的資訊</a></p>
</div>
</div>
<div class="row">
<div class="col s12">
<h2>空參照自動檢查</h2>
<p>在 Crystal 裡的所有型別都是非空的,所有允許空值的變數都被宣告成預期型別與空值型別的集合型別。 因此,編譯器會在編譯時期自動地檢查空參照來避免著名的「<a href="https://www.infoq.com/presentations/Null-References-The-Billion-Dollar-Mistake-Tony-Hoare" target="_blank">The Billion Dollar Mistake 問題</a>」。</p>
<div class="code_section">
{% include sample_null.md %}
</div>
<p>執行結果如下:</p>
<div class="code_section">
<figure class="highlight console">
{% include sample_null_refs.html %}
</figure>
</div>
</div>
</div>
<div class="row">
<div class="col s12">
<h2>巨集</h2>
<p>針對 Metaprogramming,Crystal 亦內建了強大的巨集機制來實現模板機制以及在編譯時期檢閱 AST 與型別的功能,甚至於能夠在巨集中執行獨立的外部程式。</p>
<div class="code_section">
{% include sample_macros.md %}
</div>
<p class="read-more"><a href="http://tw.crystal-lang.org/docs/syntax_and_semantics/macros.html">> 瞭解更多關於巨集的說明</a></p>
</div>
</div>
<div class="row">
<div class="col s12">
<h2>併發模型</h2>
<p>Crystal 使用了一種稱為 Fiber 的綠色執行緒來實作併發模型。 如同 Go 或 Clojure,Fiber 能夠透過使用 Channel 來互相溝通而避免使用 SHM 與鎖。</p>
<div class="code_section">
{% include sample_concurrency.md %}
</div>
<p class="read-more"><a href="http://tw.crystal-lang.org/docs/guides/concurrency.html">> 更多有關 Crystal 中併發模型的說明</a></p>
</div>
</div>
<div class="row">
<div class="col s12">
<h2>C 函式庫綁紮</h2>
<p>Crystal 亦提供了簡單的語法來呼叫原生函式庫,如此一來我們便能減少在 Crystal 上重新實作的必要性。</p>
<div class="code_section">
{% include sample_bindings.md %}
</div>
<p class="read-more"><a href="http://tw.crystal-lang.org/docs/syntax_and_semantics/c_bindings/">> 瞭解如何與 C 函式庫互動</a></p>
</div>
</div>
<div class="row">
<div class="col s12">
<h2>相依性</h2>
<p>我們稱 Crystal 函式庫為 Shards,不同於常見的套件管理機制,Shards 避免了中心化管理而是透過 Git 來派送。 透過內建的指令我們可以輕易地透過編輯 YAML 格式的設定檔來描述套件之間的相依並從各自的倉庫抓取套件。</p>
<div class="code_section">
{% include sample_dependencies.md %}
</div>
<p class="read-more"><a href="https://github.com/crystal-lang/shards">> 參閱 Shards 的 GitHub 頁面以瞭解更多</a></p>
</div>
</div>
<!--
<div class="row center">
<div class="col s12">
<div class="flag">
<h3>Crystal top sponsors</h3>
<a href="/sponsors">Meet all</a>
</div>
</div>
</div>
<div class="row">
<div class="col s12">
<div class='sponsors-list'>
<a href='https://manas.tech/' target='_blank' class="sponsor">
{% img manas-orange.svg %}
<span class="small">Manas Technology Solutions</span>
</a>
<a href='https://openredis.com' target='_blank' class="sponsor">
{% img home/openredis.svg %}
<span class="small">openredis</span>
</a>
<a href='https://fly.io' target='_blank' class="sponsor">
{% img sponsors/fly_io_.png %}
<span class="small">Fly.io</span>
</a>
</div>
</div>
</div>
<hr class="fullwidth">
-->
<div class="row center">
<div class="col s12">
<div class="flag">
<h3>以下資訊若未即時更新請至</h3>
<a href="https://crystal-lang.org">原文網站</a>
</div>
</div>
</div>
<div class="row">
<div class="col s12">
<h2>Articles from our blog</h2>
{% assign articles = site.posts | where: "release_notes",nil %}
{% for post in articles limit: 3 %}
{% include blog_row.html post=post %}
{% endfor %}
<p><a href="/blog">More articles</a></p>
</div>
</div>
<div class="row">
<div class="col s12">
<h2>Release Notes</h2>
<table class="bordered no-underline">
<tbody>
{% assign releases = site.posts | where: "release_notes",true %}
{% for post in releases limit: 10 %}
<tr>
<td></td>
<td><a href="{{ post.url }}">
{{ post.title }}
</a></td>
<td>{{ post.date | date_to_string }}</td>
{% endfor %}
</tbody>
</table>
<p><a href="/blog#release_notes">More release notes</a></p>
</div>
</div>
<div class="row center">
<div class="col s12">
<div class="flag">
<h3>社群資源</h3>
<a href="/community">更多……</a>
</div>
</div>
</div>
<div class="row">
<div class="col s12">
<div class='row community-list center'>
<div class="col s12 m12 l6">
<a href='https://github.com/crystal-tw/crystal-tw.github.io' target='_blank' class="item">
<span class="small">正體中文(臺灣)翻譯計劃</span>
<i class="extra-icons github"></i>
<span class="with_icon">crystal-tw/crystal-tw.github.io</span>
</a>
</div>
<div class="col s12 m12 l6">
<a href='https://gitter.im/crystal-tw/crystal-tw.github.io' target='_blank' class="item">
<span class="small">Crystal-TW 聊天室</span>
<i class="extra-icons gitter"></i>
<span class="with_icon">crystal-tw/crystal-tw.github.io</span>
</a>
</div>
<div class="col s12 m12 l3">
<a href='https://github.com/crystal-lang/crystal/' target='_blank' class="item">
<span class="small">程式碼倉庫</span>
<i class="extra-icons github"></i>
<span class="with_icon">crystal-lang/crystal</span>
</a>
</div>
<div class="col s12 m12 l3">
<a href='https://groups.google.com/forum/#!forum/crystal-lang' target='_blank' class="item">
<span class="small">討論區 [英]</span>
<i class="extra-icons google"></i>
<span class="with_icon">crystal-lang</span>
</a>
</div>
<div class="col s12 m12 l3">
<a href='https://gitter.im/crystal-lang/crystal' target='_blank' class="item">
<span class="small">聊天室 [英]</span>
<i class="extra-icons gitter"></i>
<span class="with_icon">crystal-lang/crystal</span>
</a>
</div>
<div class="col s12 m12 l3">
<a href='https://twitter.com/CrystalLanguage' target='_blank' class="item">
<span class="small">官方動態更新 [英]</span>
<i class="extra-icons twitter"></i>
<span class="with_icon">@CrystalLanguage</span>
</a>
</div>
</div>
</div>
</div>
</div>
<script src="https://d3js.org/d3.v3.min.js"></script>