Beyond Ruby (RubyConf Argentina 2011)

1,948 views

Published on

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?

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,948
On SlideShare
0
From Embeds
0
Number of Embeds
201
Actions
Shares
0
Downloads
5
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Beyond Ruby (RubyConf Argentina 2011)

  1. 1. Beyond Ruby Konstantin Haase
  2. 2. La verdadera pregunta es ...
  3. 3. ¿Quién es el mejor fútbolista?
  4. 4. Ampliar tus horizonte. No deje Ruby ... ... evolucionar!
  5. 5. ¡Explora!
  6. 6. Por cierto ...
  7. 7. Vamos a empezar!
  8. 8. Goal: Tell you something new! no erlang, no go, no clojure no node.js
  9. 9. Full Object Orientation
  10. 10. Doesnt Ruby have that already?
  11. 11. OOP != OOP
  12. 12. "Objects are data and functionality." Your high-school teacher
  13. 13. "Actually I made up the term object-oriented,and I can tell you I did not have C++ in mind." Alan Kay
  14. 14. "OOP to me means only messaging,local retention and protection and hidingof state-process, and extreme late-binding of all things." Alan Kay
  15. 15. "OOP to me means only messaging,local retention and protection and hidingof state-process, and extreme late-binding of all things." Alan Kay
  16. 16. if respuesta == 42 "¡correcto!"else "equivocado"end
  17. 17. respuesta = 42 ifTrue: [ ¡correcto! ] ifFalse: [ equivocado ]
  18. 18. def true.if_true yieldenddef false.if_trueend
  19. 19. TrueClass.define_method(:if_true) { yield }FalseClass.define_method(:if_true) { }
  20. 20. class Falso def if_true; endend
  21. 21. x = Delegator.new({})x.is_a? Hash # => truecase xwhen Hash ...else failend
  22. 22. Dont treat your objects like data structures!
  23. 23. my_instance.properties[:foo][1,4] == "blah"my_instance.foo? "blah"
  24. 24. "OOP to me means only messaging,local retention and protection and hidingof state-process, and extreme late-binding of all things." Alan Kay
  25. 25. "OOP to me means only messaging,local retention and protection and hidingof state-process, and extreme late-binding of all things." Alan Kay
  26. 26. "A conforming processor may omit an invocation of a method of a built-in class or module for optimization purpose, and do the same calculation as the method instead. In this case, even if a program redefines themethod, the behavior of the program might notchange because the redefined method might not actually be invoked." Ruby Standard (JIS X 3017)
  27. 27. Every built-in Ruby method could actually be a keyword.
  28. 28. Is Smalltalk Object Oriented?
  29. 29. variable/constant access is no method send self/super is no method send
  30. 30. Also...no implementation treats ifTrue sends to a boolean as method send constants are not late bound
  31. 31. Newspeakthere are only method sends there is no global state
  32. 32. But I want lexical scope!
  33. 33. Foo = 42class Bar def foo(x) Foo + x endend
  34. 34. Outer = 23module Wrapper Inner = 42 class Nested def result Outer + Inner end endend
  35. 35. Solution: clever, bidirectional dispatch
  36. 36. Homoiconic
  37. 37. "In computer programming, homoiconicity is a property of some programming languages, in which the primary representation of programs is also a data structure in aprimitive type of the language itself, from the Greek wordshomo meaning the same and icon meaning representation. This makes metaprogramming easier than in a language without this property." Wikipedia
  38. 38. "In computer programming, homoiconicity is a property of some programming languages, in which the primary representation of programs is also a data structure in aprimitive type of the language itself, from the Greek wordshomo meaning the same and icon meaning representation. This makes metaprogramming easier than in a language without this property." Wikipedia
  39. 39. "In computer programming, homoiconicity is a property of some programming languages, in which the primary representation of programs is also a data structure in aprimitive type of the language itself, from the Greek wordshomo meaning the same and icon meaning representation. This makes metaprogramming easier than in a language without this property." Wikipedia
  40. 40. "In computer programming, homoiconicity is a property of some programming languages, in which the primary representation of programs is also a data structure in aprimitive type of the language itself, from the Greek wordshomo meaning the same and icon meaning representation. This makes metaprogramming easier than in a language without this property." Wikipedia
  41. 41. Homoiconic Languages Lisp, Logix, Prolog, Snobol, Io, Ioke, Lego
  42. 42. LISP
  43. 43. (1 2 3)
  44. 44. (+ 1 2) ; 3
  45. 45. (setf b 23)
  46. 46. (car (1 2)) ; 1(cdr (1 2)) ; (2)(car (cdr (1 2))) ; 2
  47. 47. (setf a (setf b 23))(eval a)
  48. 48. (setf a (setf b 23))(setf (car (cdr (cdr a))) 42)(eval a)
  49. 49. Hows that useful? Macros and Partial Evaluation Language extensions from within
  50. 50. DeclarativeProgramming SQL, XSLT, SPARQL, Pig
  51. 51. Did the last slide just say SQL and XSLT? Seriously?
  52. 52. declarative programming can be fun Prolog, Erlang
  53. 53. Prolog
  54. 54. ruby_core(tenderlove).?- ruby_core(tenderlove).Yes?- ruby_core(X).X = tenderlove
  55. 55. ruby_core(tenderlove).rails_core(tenderlove).ubercore(X) :- ruby_core(X), rails_core(X).?- ubercore(X).X = tenderlove
  56. 56. Prolog is Lisp, kindacar([H|_], H).cdr([_|T], T).?- car([1, 2, 3], X).X = 1?- cdr([1, 2, 3], X).X = [2, 3]
  57. 57. Sort a listsorted([]).sorted([_]).sorted([X,Y|T]) :- X =< Y, sorted([Y|T]).sort(X,Y) :- perm(X,Y), sorted(Y).
  58. 58. Thanks!github.com / rkh / presentations

×