Upload
adler-hsieh
View
312
Download
8
Embed Size (px)
Citation preview
AdlerHsieh2016/12/02
FastasC,SlickasRuby
About
• AdlerHsieh• So=wareEngineer• ContributorofCrystalLanguage
Blog:moGon-express.comadlerhsieh
Whatisthislanguage?
What’sthedifference?
Features
• Rubysyntax• CompiledwithLLVM• StaGsGcallytype-checked• Cbindings• Macrosystem
Features
• Rubysyntax• CompiledwithLLVM• StaGsGcallytype-checked• Cbindings• Macrosystem
• Unixsystemonly
Whydoweneedanewprogramminglanguage?
Crystal
• WeloveRuby'sefficiencyforwriGngcode.• WeloveC'sefficiencyforrunningcode.• Wedon'twanttowriteCcodetomakethecoderunfaster.
calculator.rb
Performance?
Compile!
28Gmesfaster!
Somelibraries…
Kemal
source
Macros
InRuby…
InRuby…
"foo".send(:upcase)# => "FOO"
InRuby…
"foo".send(:upcase)# => "FOO"
code = "a = 10 ; a += 10"eval(code)# => 20
InCrystal…
"foo".send(:upcase)# => "FOO"
code = "a = 10 ; a += 10"eval(code)# => 20
Macros
“MacrosaremethodsthatreceiveASTnodesatcompile-Gmeandproducecodethatispastedintoaprogram”
Macros
“MacrosaremethodsthatreceiveASTnodesatcompile-Gmeandproducecodethatispastedintoaprogram”
1. Runmacros2. Runcode
QuickExample
foo = 20
macro plus(number) foo += {{number}}end plus(20)puts foo
QuickExample
foo = 20
macro plus(number) foo += {{number}}end plus(20)puts foo
1.Runmacros
QuickExample
foo = 20
macro plus(number) foo += {{number}}end plus(20) foo += 20puts foo
1.Runmacros
QuickExample
foo = 20
macro plus(number) foo += {{number}}end plus(20) foo += 20puts foo
2.Runcode
QuickExample
foo = 20
macro plus(number) foo += {{number}}end plus(20) foo += 20puts foo # => 40
2.Runcode
Andalotofsyntaxsugar!!!
QuickExample class Foo getter :bar # => attr_reader setter :baz # => attr_writer property :qux # => attr_accessor
def initialize(@bar : Int32) @bar += 10 endend
foo = Foo.new(20)foo.bar # => 30
CBinding!
QuickExample
@[Link("pcre")]lib LibPCRE # …end
Jointhecommunity!!!
CurrentStatus
• Startin2012• v0.20.0• SGllneedmaturelibraries
TheOfficialWebsite
Thelibraries
ThankYou!
Blog:moGon-express.comGitHub:adlerhsiehTwider:@adler_hsieh