Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

The Crystal language *recently* update

427 views

Published on

Ruby Kaigi LT 2016

Published in: Engineering
  • Be the first to comment

  • Be the first to like this

The Crystal language *recently* update

  1. 1. The Crystal language *recently* updates @karupanerura Ruby Kaigi 2016 LT
  2. 2. 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 :)
  3. 3. Well..
  4. 4. This talk’s topic is the Crystal language
  5. 5. Do you know about the Crystal language?
  6. 6. 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/
  7. 7. 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/
  8. 8. 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)
  9. 9. 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
  10. 10. 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
  11. 11. 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
  12. 12. 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
  13. 13. 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..)
  14. 14. language updates
  15. 15. YOU SHOULD READ IT https://github.com/crystal- lang/crystal/blob/master/ CHANGELOG.md
  16. 16. It’s kidding :p but, you can do that :)
  17. 17. 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)
  18. 18. 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
  19. 19. 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
  20. 20. (My) Featured new features
  21. 21. `crystal play` sub-command
  22. 22. `crystal tool format` sub-command ✨✨✨✨✨✨✨✨✨ ✨✨✨✨✨✨✨✨✨ ✨✨✨✨✨✨✨✨✨ ✨✨✨✨✨✨✨✨✨ ✨✨✨✨✨✨✨✨✨
  23. 23. $global variable is removed 👍👍👍👍👍👍👍👍👍👍 👍👍👍👍👍👍👍👍👍👍 👍👍👍👍👍👍👍👍👍👍 👍👍👍👍👍👍👍👍👍👍 👍👍👍👍👍👍👍👍👍👍 👍👍👍👍👍👍👍👍👍👍
  24. 24. Int#to_s(Int) 255.to_s(2) # => "11111111" 255.to_s(8) # => "377" 255.to_s(10) # => "255" 255.to_s(16) # => "ff"
  25. 25. Updated syntax (before) class Foo getter foo :: Int32 getter bar :: String def initialize(@foo, @bar) end end pp Foo.new(1, "matz")
  26. 26. Updated syntax (after) class Foo getter foo : Int32 getter bar : String def initialize(@foo, @bar) end end pp Foo.new(1, "matz")
  27. 27. and more…
  28. 28. Conclusion
  29. 29. 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/
  30. 30. Let’s enjoy Crystal!
  31. 31. Thank you 🍺🍣🍶

×