Adler	Hsieh		2016/12/02	
Fast	as	C,	Slick	as	Ruby
About
•  Adler	Hsieh	
•  So=ware	Engineer	
•  Contributor	of	Crystal	Language	
Blog:	moGon-express.com	
							adlerhsieh
What	is	this	language?
What’s	the	difference?
Features
•  Ruby	syntax	
•  Compiled	with	LLVM	
•  StaGsGcally	type-checked	
•  C	bindings	
•  Macro	system
Features
•  Ruby	syntax	
•  Compiled	with	LLVM	
•  StaGsGcally	type-checked	
•  C	bindings	
•  Macro	system	
•  Unix	system	only
Why	do	we	need		
a	new	programming	language?
Crystal
•  We	love	Ruby's	efficiency	for	wriGng	code.	
•  We	love	C's	efficiency	for	running	code.	
•  We	don't	want	to	write	C	code	to	make	the	
code	run	faster.
calculator.rb
Performance?
Compile!
28	Gmes	faster	!
Some	libraries…
Kemal
source
Macros
In	Ruby…
In	Ruby…
"foo".send(:upcase)
# => "FOO"
In	Ruby…
"foo".send(:upcase)
# => "FOO"
code = "a = 10 ; a += 10"
eval(code)
# => 20
In	Crystal…
"foo".send(:upcase)
# => "FOO"
code = "a = 10 ; a += 10"
eval(code)
# => 20
Macros
“Macros	are	methods	that	receive	AST	nodes	at	
compile-Gme	and	produce	code	that	is	pasted	
into	a	program”
Macros
“Macros	are	methods	that	receive	AST	nodes	at	
compile-Gme	and	produce	code	that	is	pasted	
into	a	program”
1.  Run	macros	
2.  Run	code
Quick	Example
foo = 20
macro plus(number)
foo += {{number}}
end
plus(20)
puts foo
Quick	Example
foo = 20
macro plus(number)
foo += {{number}}
end
plus(20)
puts foo
1.	Run	macros
Quick	Example
foo = 20
macro plus(number)
foo += {{number}}
end
plus(20) foo += 20
puts foo
1.	Run	macros
Quick	Example
foo = 20
macro plus(number)
foo += {{number}}
end
plus(20) foo += 20
puts foo
2.	Run	code
Quick	Example
foo = 20
macro plus(number)
foo += {{number}}
end
plus(20) foo += 20
puts foo # => 40
2.	Run	code
And	a	lot	of	syntax	sugar!!!
Quick	Example
class Foo
getter :bar # => attr_reader
setter :baz # => attr_writer
property :qux # => attr_accessor
def initialize(@bar : Int32)
@bar += 10
end
end
foo = Foo.new(20)
foo.bar # => 30
C	Binding!
Quick	Example
@[Link("pcre")]
lib LibPCRE
# …
end
Join	the	community!!!
Current	Status
•  Start	in	2012	
•  v0.20.0	
•  SGll	need	mature	libraries
The	Official	Website
The	libraries
Thank	You!
Blog:	moGon-express.com	
GitHub:	adlerhsieh	
Twider:	@adler_hsieh

Intro to Crystal Programming Language