What am I upto?
Ruby is fun and practical
Compiled languages are efficient
Type checking is useful
class Hello
def initialize(name : String)
@name = name
end
def speak!
puts "Hello #{@name}!"
end
end
obj = Hello.new("World")
obj.speak!That's pretty much Ruby!
▶ crystal build hello_world.cr && ./hello_world
Hello World!
Became self hosted in Nov 2013
puts "Hello" + 1In ruby, this is a runtime error
In crystal, this is caught at compile
▶ ruby sample.cr
sample.cr:1: in `+': no implicit conversion of Integer into String (TypeError)
▶ crystal build sample.cr
Error in sample.cr:1: in `+': no overload matches 'String#+' with type Int32
def fib(n)
return n if n <= 1
fib(n-1) + fib(n-2)
end
puts fib(36)▶ time ruby fib.cr
14930352
ruby fib.cr 2.27s user 0.56s system 96% cpu 2.931 total
▶ crystal build fib.cr --release && time ./fib
14930352
./fib 0.08s user 0.00s system 91% cpu 0.085 total
That's 0.08s vs 2.27s on a micro-benchmark!
require "kemal"
get "/" do
"Hello World"
end
Kemal.runrequire "sinatra"
get "/" do
"Hello World"
end
*From the kemal website: Kemal is 100+x better on micro-benchmarks!
Good for micro-services, cli
Possibly a good way to speed up your ruby gems!
sidekiq, kemal, amber, lucky is a solid stack
This should be really good for game engines.
*Though it's pre-1.0 so buyer beware!
Better windows support - Shipping output to windows could become simple!
True parallelism - It's planned but wip...
Incremental compile - This will be hard...
Some large web code bases and experience with them.
Let's do some crystal!