the crystal language *recently* update

32
The Crystal language *recently* updates @karupanerura Ruby Kaigi 2016 LT

Upload: karupanerura-xmp

Post on 19-Mar-2017

281 views

Category:

Engineering


0 download

TRANSCRIPT

Page 1: The Crystal language *recently* update

The Crystal language *recently* updates@karupanerura Ruby Kaigi 2016 LT

Page 2: The Crystal language *recently* update

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 :)

Page 3: The Crystal language *recently* update
Page 4: The Crystal language *recently* update

Well..

Page 5: The Crystal language *recently* update

This talk’s topic is the Crystal language

Page 6: The Crystal language *recently* update

Do you know about the Crystal language?

Page 7: The Crystal language *recently* update

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/

Page 8: The Crystal language *recently* update

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/

Page 9: The Crystal language *recently* update

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)

Page 10: The Crystal language *recently* update

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

Page 11: The Crystal language *recently* update

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

Page 12: The Crystal language *recently* update

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

Page 13: The Crystal language *recently* update

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

Page 14: The Crystal language *recently* update

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..)

Page 15: The Crystal language *recently* update

language updates

Page 16: The Crystal language *recently* update

YOU SHOULD READ IT

https://github.com/crystal-lang/crystal/blob/master/

CHANGELOG.md

Page 17: The Crystal language *recently* update

It’s kidding :p but, you can do that :)

Page 18: The Crystal language *recently* update

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)

Page 19: The Crystal language *recently* update

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

Page 20: The Crystal language *recently* update

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

Page 21: The Crystal language *recently* update

(My) Featured new features

Page 22: The Crystal language *recently* update

`crystal play` sub-command

Page 23: The Crystal language *recently* update

`crystal tool format` sub-command

✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨

Page 24: The Crystal language *recently* update

$global variable is removed

👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍

Page 25: The Crystal language *recently* update

Int#to_s(Int)

255.to_s(2) # => "11111111" 255.to_s(8) # => "377" 255.to_s(10) # => "255" 255.to_s(16) # => "ff"

Page 26: The Crystal language *recently* update

Updated syntax (before)

class Foo getter foo :: Int32 getter bar :: String

def initialize(@foo, @bar) end end pp Foo.new(1, "matz")

Page 27: The Crystal language *recently* update

Updated syntax (after)

class Foo getter foo : Int32 getter bar : String

def initialize(@foo, @bar) end end pp Foo.new(1, "matz")

Page 28: The Crystal language *recently* update

and more…

Page 29: The Crystal language *recently* update

Conclusion

Page 30: The Crystal language *recently* update

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/

Page 31: The Crystal language *recently* update

Let’s enjoy Crystal!

Page 32: The Crystal language *recently* update

Thank you

🍺🍣🍶