the crystal language *recently* update
TRANSCRIPT
The Crystal language *recently* updates@karupanerura Ruby Kaigi 2016 LT
How about me
• @karupanerura (Twitter/Github/etc..)
• Perl/Python/Go/Crystal/Swift/ES2016/etc..
• Maintener of mRuby.pm (mruby Perl binding)
• Director of Japan Perl Association
• Of cause, I like Perl and Ruby also :)
Well..
This talk’s topic is the Crystal language
Do you know about the Crystal language?
The Crystal language is …
• Ruby like syntax and APIs
• static typing & union type & type inference
• nil safe
• self hosting compiler (using llvm)
• SEE ALSO: https://crystal-lang.org/
It works
# A very basic HTTP server require "http/server"
server = HTTP::Server.new(8080) do |context| context.response.content_type = "text/plain" context.response.print "Hello world" end
puts "Listening on http://0.0.0.0:8080" server.listen
# Copied from: https://crystal-lang.org/
It works
# A very basic HTTP server require "http/server"
server = HTTP::Server.new(8080) do |context| context.response.content_type = "text/plain" context.response.print "Hello world" end
puts "Listening on http://0.0.0.0:8080" server.listen
# Copied from: https://crystal-lang.org/
Load module (at compile time)
It works
# A very basic HTTP server require "http/server"
server = HTTP::Server.new(8080) do |context| context.response.content_type = "text/plain" context.response.print "Hello world" end
puts "Listening on http://0.0.0.0:8080" server.listen
# Copied from: https://crystal-lang.org/
type inference as HTTP::Server
It works
# A very basic HTTP server require "http/server"
server = HTTP::Server.new(8080) do |context| context.response.content_type = "text/plain" context.response.print "Hello world" end
puts "Listening on http://0.0.0.0:8080" server.listen
# Copied from: https://crystal-lang.org/
type inference as HTTP::Server::Context
It works
# A very basic HTTP server require "http/server"
server = HTTP::Server.new(8080) do |context| context.response.content_type = "text/plain" context.response.print "Hello world" end
puts "Listening on http://0.0.0.0:8080" server.listen
# Copied from: https://crystal-lang.org/
yield code block
type inference in arguments
# https://github.com/crystal-lang/crystal/blob/master/src/io.cr#L262 module IO def <<(obj) : self obj.to_s self self end end
type inference in arguments
# https://github.com/crystal-lang/crystal/blob/master/src/io.cr#L262 module IO def <<(obj) : self obj.to_s self self end end
type inference as Class having #to_s (using union type: String|Integer|etc..)
language updates
YOU SHOULD READ IT
https://github.com/crystal-lang/crystal/blob/master/
CHANGELOG.md
It’s kidding :p but, you can do that :)
Release dates
• 0.19.0 (2016-09-02)
• 0.18.0 (2016-06-14)
• 0.17.0 (2016-05-17)
• 0.16.0 (2016-05-05)
• 0.15.0 (2016-03-31)
• 0.14.0 (2016-03-21)
• 0.13.0 (2016-03-07)
• 0.12.0 (2016-02-16)
• 0.11.0 (2016-01-23)
• 0.10.0 (2015-12-23)
• 0.9.0 (2015-10-16)
• 0.8.0 (2015-09-19)
Release times
• 0.19.0 (2016-09-02)
• 0.18.0 (2016-06-14)
• 0.17.0 (2016-05-17)
• 0.16.0 (2016-05-05)
• 0.15.0 (2016-03-31)
• 0.14.0 (2016-03-21)
• 0.13.0 (2016-03-07)
• 0.12.0 (2016-02-16)
• 0.11.0 (2016-01-23)
• 0.10.0 (2015-12-23)
• 0.9.0 (2015-10-16)
• 0.8.0 (2015-09-19)
12 minor version up releases in a year
Summary of changes in a year
• 12 minor version up releases
• 72 breaking changes
• 200+ methods/macros are added
• Some methods/macros are removed/renamed
• Many bug fixes and some micro-optimizations
(My) Featured new features
`crystal play` sub-command
`crystal tool format` sub-command
✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨
$global variable is removed
👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍
Int#to_s(Int)
255.to_s(2) # => "11111111" 255.to_s(8) # => "377" 255.to_s(10) # => "255" 255.to_s(16) # => "ff"
Updated syntax (before)
class Foo getter foo :: Int32 getter bar :: String
def initialize(@foo, @bar) end end pp Foo.new(1, "matz")
Updated syntax (after)
class Foo getter foo : Int32 getter bar : String
def initialize(@foo, @bar) end end pp Foo.new(1, "matz")
and more…
Conclusion
Conclusion
• Crystal is still improved
• updating the syntaxes/APIs
• self hosting compiler is stable (I think)
• Join to Crystal JP (Crystal UG in Japan)
• http://crystal.connpass.org/
Let’s enjoy Crystal!
Thank you
🍺🍣🍶