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

RubyKaigi 2013: Beyond Ruby

RubyKaigi 2013: Beyond Ruby

Ruby is the most flexible language out there, imposing no limitations on the developers, giving all the expressiveness possible. Or so we think. But there are languages pushing dynamic features and expressiveness far beyond what is possible in Ruby. Some are old, like Lisp and Smalltalk, some are just emerging, purely experimental languages, like Ioke or Newspeak. In this talk, we will take a look at some of these languages and what they can do that Ruby can't. What does it mean, to be homoiconic? How does a language without keywords work? Can I dispatch in more than one direction? And what is partial evaluation?

Konstantin Haase

June 01, 2013
Tweet

More Decks by Konstantin Haase

Other Decks in Technology

Transcript

  1. Konstantin Haase
    Beyond Ruby

    View Slide

  2. @konstantinhaase
    github.com/rkh
    Everybody,
    please stand up!
    ΈΜͳ͕ɺ্ཱ͕ͪͬͯ
    ͍ͩ͘͞ʂ

    View Slide

  3. @konstantinhaase
    github.com/rkh
    ͋ͳͨ͸Rubyϓϩάϥ
    ϜΛॻ͍ͨ͜ͱ͕ͳ͍৔
    ߹͸ɺ࠲Δɻ

    View Slide

  4. @konstantinhaase
    github.com/rkh
    ͋ͳͨ͸Smalltalkϓ
    ϩάϥϜΛॻ͍ͨ͜ͱ͕
    ͳ͍৔߹͸ɺ࠲Δɻ

    View Slide

  5. @konstantinhaase
    github.com/rkh
    ͋ͳͨ͸Lispϓϩάϥ
    ϜΛॻ͍ͨ͜ͱ͕ͳ͍৔
    ߹͸ɺ࠲Δɻ

    View Slide

  6. @konstantinhaase
    github.com/rkh
    ͋ͳͨ͸Prologϓϩά
    ϥϜΛॻ͍ͨ͜ͱ͕ͳ͍
    ৔߹͸ɺ࠲Δɻ

    View Slide

  7. @konstantinhaase
    github.com/rkh
    ͋ͳͨ͸VHDLϓϩά
    ϥϜΛॻ͍ͨ͜ͱ͕ͳ͍
    ৔߹͸ɺ࠲Δɻ

    View Slide

  8. @konstantinhaase
    github.com/rkh
    ͋ͳͨ͸Newspeak
    ϓϩάϥϜΛॻ͍ͨ͜ͱ
    ͕ͳ͍৔߹͸ɺ࠲Δɻ

    View Slide

  9. @konstantinhaase
    github.com/rkh
    Konstantin Haase
    Open Source Developer

    View Slide

  10. View Slide

  11. @konstantinhaase
    github.com/rkh

    View Slide

  12. @konstantinhaase
    github.com/rkh
    “Second to K&R, the
    most lagom technical
    book I’ve read.”
    Peter Cooper (Ruby Inside)
    Discount Code: AUTHD
    50% off ebook ($6.50)
    40% off print

    View Slide

  13. @konstantinhaase
    github.com/rkh

    View Slide

  14. @konstantinhaase
    github.com/rkh

    View Slide

  15. @konstantinhaase
    github.com/rkh

    View Slide

  16. @konstantinhaase
    github.com/rkh
    Language

    View Slide

  17. @konstantinhaase
    github.com/rkh

    View Slide

  18. @konstantinhaase
    github.com/rkh

    View Slide

  19. @konstantinhaase
    github.com/rkh

    View Slide

  20. @konstantinhaase
    github.com/rkh
    Ruby

    View Slide

  21. @konstantinhaase
    github.com/rkh
    Questions?
    Shugo
    Maeda

    View Slide

  22. @konstantinhaase
    github.com/rkh
    Yukihiro
    "Mad Matz"
    Matsumoto

    View Slide

  23. @konstantinhaase
    github.com/rkh
    Can you say
    it in Ruby?

    View Slide

  24. @konstantinhaase
    github.com/rkh
    me
    Ruby

    View Slide

  25. @konstantinhaase
    github.com/rkh
    A Programming
    Language is just a
    Tool

    View Slide

  26. @konstantinhaase
    github.com/rkh
    Tell you something
    new

    View Slide

  27. @konstantinhaase
    github.com/rkh

    View Slide

  28. @konstantinhaase
    github.com/rkh
    No Node.js

    View Slide

  29. @konstantinhaase
    github.com/rkh
    No Node.js
    No Erlang

    View Slide

  30. @konstantinhaase
    github.com/rkh
    No Node.js
    No Erlang
    No Go

    View Slide

  31. @konstantinhaase
    github.com/rkh
    Full Object Orientation

    View Slide

  32. @konstantinhaase
    github.com/rkh
    Doesn’t Ruby already
    have that?

    View Slide

  33. @konstantinhaase
    github.com/rkh
    OOP ≠ OOP

    View Slide

  34. @konstantinhaase
    github.com/rkh
    “Objects are data and
    functionality”
    Your High School Teacher

    View Slide

  35. @konstantinhaase
    github.com/rkh

    View Slide

  36. @konstantinhaase
    github.com/rkh
    “I made up the term
    object-oriented, and I can
    tell you, I did not have
    C++ in mind.”
    Alan Kay

    View Slide

  37. @konstantinhaase
    github.com/rkh

    OOP to me means only
    messaging, local retention
    and protection and hiding of
    state-process, and extreme
    late-binding of all things.”
    Alan Kay

    View Slide

  38. @konstantinhaase
    github.com/rkh
    Smalltalk

    View Slide

  39. @konstantinhaase
    github.com/rkh
    if response == 42
    "correct!"
    else
    "wrong"
    end

    View Slide

  40. @konstantinhaase
    github.com/rkh
    response = 42
    ifTrue: [ 'correct!' ]
    ifFalse: [ 'wrong' ]

    View Slide

  41. @konstantinhaase
    github.com/rkh
    def true.if_true
    yield
    end
    def false.if_true
    end

    View Slide

  42. @konstantinhaase
    github.com/rkh
    TrueClass.
    define_method(:if_true){ yield }
    FalseClass.
    define_method(:if_true) { }

    View Slide

  43. @konstantinhaase
    github.com/rkh
    class Falsy
    def if_true; end
    end

    View Slide

  44. @konstantinhaase
    github.com/rkh
    x = Delegator.new({})
    x.is_a? Hash # => true
    case x
    when Hash then ...
    else fail
    end

    View Slide

  45. @konstantinhaase
    github.com/rkh
    Do not treat
    Objects like Data
    Structures!

    View Slide

  46. @konstantinhaase
    github.com/rkh
    my_instance.
    properties[:foo][1,4] == "blah"
    my_instance.foo? "blah"

    View Slide

  47. @konstantinhaase
    github.com/rkh
    Is Smalltalk Object
    Oriented?

    View Slide

  48. @konstantinhaase
    github.com/rkh

    View Slide

  49. @konstantinhaase
    github.com/rkh
    variable/constant access is
    no method send

    View Slide

  50. @konstantinhaase
    github.com/rkh
    variable/constant access is
    no method send
    keywords like self and
    super are no method
    sends

    View Slide

  51. @konstantinhaase
    github.com/rkh

    View Slide

  52. @konstantinhaase
    github.com/rkh
    no implementation treats
    ifTrue: and ifFalse: as
    method sends

    View Slide

  53. @konstantinhaase
    github.com/rkh
    no implementation treats
    ifTrue: and ifFalse: as
    method sends
    constants are not late
    bound

    View Slide

  54. @konstantinhaase
    github.com/rkh
    Newspeak

    View Slide

  55. @konstantinhaase
    github.com/rkh

    View Slide

  56. @konstantinhaase
    github.com/rkh
    there are only method
    sends

    View Slide

  57. @konstantinhaase
    github.com/rkh
    there are only method
    sends
    there is no global state

    View Slide

  58. @konstantinhaase
    github.com/rkh
    But I want
    lexical scope!

    View Slide

  59. @konstantinhaase
    github.com/rkh
    Foo = 42
    class Bar
    def foo(x) Foo + x end
    end

    View Slide

  60. @konstantinhaase
    github.com/rkh
    Outer = 23
    module Wrapper
    Inner = 42
    class Nested
    def result
    Outer + Inner
    end
    end
    end

    View Slide

  61. @konstantinhaase
    github.com/rkh
    Solution: Clever, Bi-
    Directional Dispatch

    View Slide

  62. @konstantinhaase
    github.com/rkh

    View Slide

  63. @konstantinhaase
    github.com/rkh
    Hi usingPlatform: platform =
    (
    platform Transcript
    open show: 'Hello!'.
    )

    View Slide

  64. @konstantinhaase
    github.com/rkh

    View Slide

  65. @konstantinhaase
    github.com/rkh

    View Slide

  66. @konstantinhaase
    github.com/rkh
    Homoiconic Languages

    View Slide

  67. @konstantinhaase
    github.com/rkh
    "In computer programming, homoiconicity is a
    property of some programming languages, in which
    the primary representation
    of programs is also a
    data structure in
    a primitive type of the language itself, from the
    Greek words homo meaning the same and icon
    meaning representation.
    This makes
    metaprogramming
    easier than in a language without this property."
    Wikipedia

    View Slide

  68. @konstantinhaase
    github.com/rkh

    View Slide

  69. @konstantinhaase
    github.com/rkh
    Lisp, Logix, Io

    View Slide

  70. @konstantinhaase
    github.com/rkh
    Lisp, Logix, Io
    Prolog, Snobol, Ioke

    View Slide

  71. @konstantinhaase
    github.com/rkh

    View Slide

  72. @konstantinhaase
    github.com/rkh
    '(1 2 3)

    View Slide

  73. @konstantinhaase
    github.com/rkh
    (+ 1 2) ; 3

    View Slide

  74. @konstantinhaase
    github.com/rkh
    (car '(1 2)) ; 1
    (cdr '(1 2))
    ; '(2)

    View Slide

  75. @konstantinhaase
    github.com/rkh
    (car
    (cdr '(1 2)))
    ; 2

    View Slide

  76. @konstantinhaase
    github.com/rkh
    (setf b 23)
    (+ b 19) ; 42

    View Slide

  77. @konstantinhaase
    github.com/rkh
    (setf a '(setf b 23))
    (eval a)
    (+ b 19) ; 42

    View Slide

  78. @konstantinhaase
    github.com/rkh
    (setf a
    '(setf b 23))
    (setf
    (car
    (cdr (cdr a)))
    42)
    (eval a) ; 42

    View Slide

  79. @konstantinhaase
    github.com/rkh

    View Slide

  80. @konstantinhaase
    github.com/rkh
    How’s that useful?

    View Slide

  81. @konstantinhaase
    github.com/rkh

    View Slide

  82. @konstantinhaase
    github.com/rkh
    Macros and Partial
    Evaluation

    View Slide

  83. @konstantinhaase
    github.com/rkh
    Macros and Partial
    Evaluation
    Language Extensions from
    within

    View Slide

  84. @konstantinhaase
    github.com/rkh
    Declarative
    Programming

    View Slide

  85. @konstantinhaase
    github.com/rkh

    View Slide

  86. @konstantinhaase
    github.com/rkh
    SQL, XSLT, SPARQL, Pig

    View Slide

  87. @konstantinhaase
    github.com/rkh
    SQL, XSLT, SPARQL, Pig
    Prolog, Erlang

    View Slide

  88. @konstantinhaase
    github.com/rkh

    View Slide

  89. @konstantinhaase
    github.com/rkh

    View Slide

  90. @konstantinhaase
    github.com/rkh

    View Slide

  91. @konstantinhaase
    github.com/rkh

    View Slide

  92. @konstantinhaase
    github.com/rkh
    ruby_core(tenderlove).
    ?- ruby_core(tenderlove).
    Yes
    ?- ruby_core(X).
    X = tenderlove

    View Slide

  93. @konstantinhaase
    github.com/rkh
    ruby_core(tenderlove).
    rails_core(tenderlove).
    ubercore(X) :-
    ruby_core(X), rails_core(X).
    ?- ubercore(X).
    X = tenderlove

    View Slide

  94. @konstantinhaase
    github.com/rkh
    car([H|_], H).
    cdr([_|T], T).
    ?- car([1, 2, 3], X).
    X = 1
    ?- cdr([1, 2, 3], X).
    X = [2, 3]

    View Slide

  95. @konstantinhaase
    github.com/rkh
    sorted([]).
    sorted([_]).
    sorted([X,Y|T]) :-
    X =< Y, sorted([Y|T]).
    sort(X,Y) :-
    perm(X,Y), sorted(Y).

    View Slide

  96. @konstantinhaase
    github.com/rkh
    ?- sort([1, 3, 2], X).
    X = [1, 2, 3]
    ?- sort(X, [1, 2, 3]).
    X = [1, 2, 3]
    Continue? [Y/n]

    View Slide

  97. @konstantinhaase
    github.com/rkh
    Hardware
    Programming

    View Slide

  98. @konstantinhaase
    github.com/rkh
    VHDL
    Very-high-speed integrated circuits Hardware
    Description Language

    View Slide

  99. @konstantinhaase
    github.com/rkh
    FOO <= '1';
    BAR <= '0';
    BAZ <= FOO and BAR;

    View Slide

  100. @konstantinhaase
    github.com/rkh
    FOO <= '1';
    BAR <= '0';
    BAZ <= FOO and BAR;

    View Slide

  101. @konstantinhaase
    github.com/rkh

    View Slide

  102. @konstantinhaase
    github.com/rkh
    http://www.ht-lab.com/

    View Slide

  103. @konstantinhaase
    github.com/rkh
    github.com/a-team/Pong

    View Slide

  104. @konstantinhaase
    github.com/rkh
    ਧ͖ඈ͹͞ؾ

    View Slide

  105. @konstantinhaase
    github.com/rkh
    Thank you!
    ͋Γ͕ͱ͏ʂ

    View Slide