my-preamble
OPAL - CHAPTER 4: A
NEW HOPE
FORREST CHANG
FKCHANG2000@YAHOO.COM
WHO CODES RUBY?
WHO WORKS WITH THE WEB?
WHO LIKES JAVASCRIPT
WHO LIKES RUBY BETTER?
from
http://dark--romance.deviantart.com/art/Screamy-and-
Bee-love-Ruby-146852940
YOU ARE MY AUDIENCE
THE PITCH
OPAL WILL MAKE YOU HAPPY
STEP BACK
(from:
)
http://www.celiajohnsononline.com/knee-exercises-
osteoarthritis-joint-pain/
WHAT IS OPAL?
Ruby to JS Source to Source, similar to Coffescript
Runtime (supports method missing, operator overloading,
...
TOTALLY AWESOME
AS CODE
class Opal < Ruby
include Browser::Access
include Javascript::Interaction
runs_in :browser
runs_in :node
end
WHAT'S CURRENTLY UNDER
GITHUB.COM/OPAL
PAGE 2
THE RUBY WAY
Matz wrote in an introductory article to Ruby
"For me the purpose of life is partly to have joy. Programmers
...
OPAL IS THE RUBY WAY
(from
)
http://www.get-covers.com/do-more-of-what-makes-you-
happy/
OPAL IS JDD FOR ME
Joy Driven Development
no need for it, but I can't stop coding
Forrest just loves to write opal (Test I...
WHAT IF YOU CODE RUBY IN THE BROWSER?
TOP 7 REASONS WHY OPAL WILL MAKE YOU
HAPPY
1. It is a viable Ruby
2. Greenspun's 10th Rule, Opal Edition
3. Solves things ...
#1 VIABLE - NOT A TOY
In production - 5 + apps, 2 more coming soon
Real Ruby1.9.3 - compliant (mostly)
passes 1377 rubyspe...
RUBY LANGUAGE FEATURES IN OPAL
classes
modules & mixins
singleton methods
method_missing
arity checks
lambda
blocks
yield
...
MORE FEATURES
class variables
instance variable
Enumerable
BasicObject
Kernel
NilClass
Range
Hash
String Interpolation
Her...
DON'T UNDERESTIMATE THE POWER OF A
BETTER LANGUAGE
opal-irb, opal-inspector, easy to write
leads us to Greenspun's 10th ru...
GREENSPUN'S 10TH RULE
Any sufficiently complicated C or Fortran program contains
an ad hoc, informally-specified, bug-ridd...
#2 GREENSPUN'S 10TH RULE, OPAL EDITION
Any sufficiently complicated Javascript program contains an
ad hoc, informally-spec...
JAVASCRIPT EFFORTS THAT IMITATE RUBY OR
RAILS
PROTOTYPE
UNDERSCORE
HTTP://RUBYJS.ORG
STRUKT
STRINGJS
HTTP://JSCLASS.JCOGLAN.COM
HTTP://CODE.GOOGLE.COM/P/JOOSE-JS/
HTTP://BLOG.JAVASCRIPTMVC.COM/?P=61
HTTPS://GITHUB.COM/TOBEYTAILOR/DEF.JS
HTTP://YEHUDAKATZ.COM/2012/01/10/JAVASC
NEEDS-BLOCKS/
HTTP://WWW.CODEPROJECT.COM/ARTICLES/314
IN-HUMAX-V0-3-EXTENDING-YOUR-JAVASCRIP
HTTP://WWW.SCATTERPOLL.COM/#TITLE-
SLIDE
ACTIVEJS
REDSCRIPT
FORML
OTHER ATTEMPTS TO DO RUBY ON JS
(from:
)
https://github.com/jashkenas/coffee-script/wiki/List-of-
languages-that-compile-t...
WHY NOT THE REAL THING?
OPAL IS RUBY
#3 SOLVING THINGS THE RUBY WAY
packaging/modules
javascript integration
testing
PACKAGING AND MODULE
JAVASCRIPT MODULES
long article
AMD
CommonJS
Harmony
http://addyosmani.com/writing-modular-js/
MODULES
Do This
define(
module_id /*optional*/,
[dependencies] /*optional*/,
definition function /*function for instantiat...
RUBY
require
uses gems
require 'file_or_gem_you_want'
OPAL
require
uses gems
opal-sprockets handles requires
also include templates
require 'file_gem_template_you_want'
FOR NON RAILS STANDALONE - RAKEFILE
require 'bundler/setup'
# require 'opal/rake_task'
require 'opal'
require 'opal-sprock...
FOR NON RAILS STANDALONE APP-JQCONSOLE.RB
require 'opal'
require 'opal-jquery'
require 'opal-parser'
require 'opal_irb_jqc...
JAVASCRIPT INTEGRATION
x strings (backticks %x)
method missing
window = `window`
window.location
TESTING
opal-spec
rake/phantomjs
in browser
OPAL-SPEC
#4 THE TOOLS YOU KNOW AND LOVE
language - Ruby
editor - emacs, vim, sublime, Rubymine, etc.
Rake
rspec (sorry DHH)
guard
<...
#5 EASY INTEGRATION WITH RUBY
opal-rails
opal-sprockets (already shown in modules)
it's Ruby
OPAL RAILS
https://github.com/opal/opal-rails
#6 NEW IN BROWSER TOOLS
opal-irb
opal-inspector
OPAL-IRB
irb for opal
history
readline controls
multiline edit (over all of history)
send a link - live gist
OPAL-INSPECTOR
inspired by amber.js in browser Smalltalk like code browser
change the paradigm of development
develop in b...
DEMOS
opal-irb
opal-inspector
Source Maps (head has broken it somewhat though)
QUICK LOOK AT CODE
only 440 lines for opal-inspector current state
very short, small classes
didn't need a framework
#7 A NEW FUTURE (HOPE)
in browser dev, goodness from Smalltalk, Ruby and Lisp
Machines
meteor.js like same code on both si...
THERE CAN ONLY BE ONE
May that language be Ruby/Opal
CALL TO ARMS
things are good
they can be better
need your help
HELP
try it out
talk, google group, irc
document
contribute, it's just Ruby
have fun
KISS JAVASCRIPT GOODBYE
Created by fkchang.
Opal chapter 4_a_new_hope
Upcoming SlideShare
Loading in …5
×

Opal chapter 4_a_new_hope

3,230
-1

Published on

Opal presentation given at OC Ruby 7/25/2013

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
3,230
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Opal chapter 4_a_new_hope

  1. 1. my-preamble OPAL - CHAPTER 4: A NEW HOPE FORREST CHANG FKCHANG2000@YAHOO.COM
  2. 2. WHO CODES RUBY?
  3. 3. WHO WORKS WITH THE WEB?
  4. 4. WHO LIKES JAVASCRIPT
  5. 5. WHO LIKES RUBY BETTER? from http://dark--romance.deviantart.com/art/Screamy-and- Bee-love-Ruby-146852940
  6. 6. YOU ARE MY AUDIENCE
  7. 7. THE PITCH
  8. 8. OPAL WILL MAKE YOU HAPPY
  9. 9. STEP BACK (from: ) http://www.celiajohnsononline.com/knee-exercises- osteoarthritis-joint-pain/
  10. 10. WHAT IS OPAL? Ruby to JS Source to Source, similar to Coffescript Runtime (supports method missing, operator overloading, etc)
  11. 11. TOTALLY AWESOME
  12. 12. AS CODE class Opal < Ruby include Browser::Access include Javascript::Interaction runs_in :browser runs_in :node end
  13. 13. WHAT'S CURRENTLY UNDER GITHUB.COM/OPAL
  14. 14. PAGE 2
  15. 15. THE RUBY WAY Matz wrote in an introductory article to Ruby "For me the purpose of life is partly to have joy. Programmers often feel joy when they can concentrate on the creative side of programming, So Ruby is designed to make programmers happy."
  16. 16. OPAL IS THE RUBY WAY (from ) http://www.get-covers.com/do-more-of-what-makes-you- happy/
  17. 17. OPAL IS JDD FOR ME Joy Driven Development no need for it, but I can't stop coding Forrest just loves to write opal (Test Infected parody)
  18. 18. WHAT IF YOU CODE RUBY IN THE BROWSER?
  19. 19. TOP 7 REASONS WHY OPAL WILL MAKE YOU HAPPY 1. It is a viable Ruby 2. Greenspun's 10th Rule, Opal Edition 3. Solves things the Ruby way 4. Tools you already know and love 5. Easy integration with Ruby 6. Better tools (In Browser) 7. A new future
  20. 20. #1 VIABLE - NOT A TOY In production - 5 + apps, 2 more coming soon Real Ruby1.9.3 - compliant (mostly) passes 1377 rubyspec examples runs asciidoc gem unmodified runs mspec gem unmodified can compile itself Capable of compiling complex code Is written in Ruby, easy to contribute
  21. 21. RUBY LANGUAGE FEATURES IN OPAL classes modules & mixins singleton methods method_missing arity checks lambda blocks yield CONSTANTS global variables
  22. 22. MORE FEATURES class variables instance variable Enumerable BasicObject Kernel NilClass Range Hash String Interpolation Heredocs %w splits
  23. 23. DON'T UNDERESTIMATE THE POWER OF A BETTER LANGUAGE opal-irb, opal-inspector, easy to write leads us to Greenspun's 10th rule
  24. 24. GREENSPUN'S 10TH RULE Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp.
  25. 25. #2 GREENSPUN'S 10TH RULE, OPAL EDITION Any sufficiently complicated Javascript program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Ruby
  26. 26. JAVASCRIPT EFFORTS THAT IMITATE RUBY OR RAILS
  27. 27. PROTOTYPE
  28. 28. UNDERSCORE
  29. 29. HTTP://RUBYJS.ORG
  30. 30. STRUKT
  31. 31. STRINGJS
  32. 32. HTTP://JSCLASS.JCOGLAN.COM
  33. 33. HTTP://CODE.GOOGLE.COM/P/JOOSE-JS/
  34. 34. HTTP://BLOG.JAVASCRIPTMVC.COM/?P=61
  35. 35. HTTPS://GITHUB.COM/TOBEYTAILOR/DEF.JS
  36. 36. HTTP://YEHUDAKATZ.COM/2012/01/10/JAVASC NEEDS-BLOCKS/
  37. 37. HTTP://WWW.CODEPROJECT.COM/ARTICLES/314 IN-HUMAX-V0-3-EXTENDING-YOUR-JAVASCRIP
  38. 38. HTTP://WWW.SCATTERPOLL.COM/#TITLE- SLIDE
  39. 39. ACTIVEJS
  40. 40. REDSCRIPT
  41. 41. FORML
  42. 42. OTHER ATTEMPTS TO DO RUBY ON JS (from: ) https://github.com/jashkenas/coffee-script/wiki/List-of- languages-that-compile-to-JS
  43. 43. WHY NOT THE REAL THING?
  44. 44. OPAL IS RUBY
  45. 45. #3 SOLVING THINGS THE RUBY WAY packaging/modules javascript integration testing
  46. 46. PACKAGING AND MODULE
  47. 47. JAVASCRIPT MODULES long article AMD CommonJS Harmony http://addyosmani.com/writing-modular-js/
  48. 48. MODULES Do This define( module_id /*optional*/, [dependencies] /*optional*/, definition function /*function for instantiating the module or objec t*/ ); // Consider 'foo' and 'bar' are two external modules // In this example, the 'exports' from the two modules loaded are passed as // function arguments to the callback (foo and bar) // so that they can similarly be accessed And This require(['foo', 'bar'], function ( foo, bar ) { // rest of your code here foo.doSomething(); });
  49. 49. RUBY require uses gems require 'file_or_gem_you_want'
  50. 50. OPAL require uses gems opal-sprockets handles requires also include templates require 'file_gem_template_you_want'
  51. 51. FOR NON RAILS STANDALONE - RAKEFILE require 'bundler/setup' # require 'opal/rake_task' require 'opal' require 'opal-sprockets' desc "build jqconsole based irb" task :build_jqconsole do File.open("js/app-jqconsole.js", "w+") do |out| env = Opal::Environment.new env.append_path "examples" env.append_path "opal" out << env["app-jqconsole"].to_s end # system "terminal-notifier -title 'opal-irb build' -message 'js file built'" system "open -a 'Google Chrome' index-jq.html" end
  52. 52. FOR NON RAILS STANDALONE APP-JQCONSOLE.RB require 'opal' require 'opal-jquery' require 'opal-parser' require 'opal_irb_jqconsole' Document.ready? do OpalIrbJqconsole.create("#console") end
  53. 53. JAVASCRIPT INTEGRATION x strings (backticks %x) method missing window = `window` window.location
  54. 54. TESTING opal-spec rake/phantomjs in browser
  55. 55. OPAL-SPEC
  56. 56. #4 THE TOOLS YOU KNOW AND LOVE language - Ruby editor - emacs, vim, sublime, Rubymine, etc. Rake rspec (sorry DHH) guard <fill in the ruby tool> - remember it's just Ruby
  57. 57. #5 EASY INTEGRATION WITH RUBY opal-rails opal-sprockets (already shown in modules) it's Ruby
  58. 58. OPAL RAILS https://github.com/opal/opal-rails
  59. 59. #6 NEW IN BROWSER TOOLS opal-irb opal-inspector
  60. 60. OPAL-IRB irb for opal history readline controls multiline edit (over all of history) send a link - live gist
  61. 61. OPAL-INSPECTOR inspired by amber.js in browser Smalltalk like code browser change the paradigm of development develop in browser w/better tools persistent live Opal objects is similar to Smalltalk image
  62. 62. DEMOS opal-irb opal-inspector Source Maps (head has broken it somewhat though)
  63. 63. QUICK LOOK AT CODE only 440 lines for opal-inspector current state very short, small classes didn't need a framework
  64. 64. #7 A NEW FUTURE (HOPE) in browser dev, goodness from Smalltalk, Ruby and Lisp Machines meteor.js like same code on both sides blurring front and back 1 language…
  65. 65. THERE CAN ONLY BE ONE May that language be Ruby/Opal
  66. 66. CALL TO ARMS things are good they can be better need your help
  67. 67. HELP try it out talk, google group, irc document contribute, it's just Ruby have fun
  68. 68. KISS JAVASCRIPT GOODBYE
  69. 69. Created by fkchang.
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×