Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Crystal - Lightning Talk - MWRC 2016

Crystal - Lightning Talk - MWRC 2016

friendly, static, modern, compiled
http://crystal-lang.org/

aemadrid

March 22, 2016
Tweet

More Decks by aemadrid

Other Decks in Programming

Transcript

  1. FRIENDLY SYNTAX def fibonacci(n) return n if n <= 1

    fibonacci(n - 1) + fibonacci(n - 2) end number = (ARGV[0]? || "40").to_i puts "Calculating fibonacci for: #{number}" puts fibonacci(number) RUBY MOSTLY Mountain West Ruby Conf 2016 Adrian Madrid
  2. STATIC TYPE CHECKING ➤ All the benefits of static typing

    ➤ While figuring it all out on its own, mostly DOH CHECKING def foo(arg) arg + 1 end a = rand(2) == 0 ? 1 : nil foo(1) Mountain West Ruby Conf 2016 Adrian Madrid
  3. MODERN STANDARD LIBRARY ➤ Spec (like RSpec) ➤ CSV, JSON,

    XML, YAML, Markdown ➤ HTTP Client & Server (WebSocket too) ➤ OAuth & OAuth2 ➤ SecureRandom, Levenstein, HTML Builder, etc. NEW STUFF Mountain West Ruby Conf 2016 Adrian Madrid
  4. COMPILES INTO FAST NATIVE CODE MICRO SECOND FAST require “http/server”;

    require "http/server/handler" host = "0.0.0.0" port = 8080 handlers = [ HTTP::ErrorHandler.new, HTTP::LogHandler.new, HTTP::StaticFileHandler.new(“.") ] server = HTTP::Server.new(host,port, handlers) 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 $ crystal build —release http_server.rb $ ./http_server Listening on http://0.0.0.0:8080 GET / - 200 (725µs) GET / - 200 (82µs) GET / - 200 (57µs) Mountain West Ruby Conf 2016 Adrian Madrid
  5. MACROS PRE-COMPILE METAPROGRAMMING macro define_method(name, content) def {{name}} {{content}} end

    end # This generates: # def foo # 1 # end define_method foo, 1 foo #=> 1 Mountain West Ruby Conf 2016 Adrian Madrid
  6. SELF HOSTED ➤ Compiled and linked ➤ You can cross-compile

    too 98.2% IN CRYSTAL Mountain West Ruby Conf 2016 Adrian Madrid
  7. LINKS ➤ Language - http://crystal-lang.org/ ➤ API - http://crystal-lang.org/api/ ➤

    Code - https://github.com/manastech/crystal ➤ Docs - http://crystal-lang.org/docs/ ➤ Libraries - http://awesome-crystal.com/ GO CHECK IT OUT Mountain West Ruby Conf 2016 Adrian Madrid