16. 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."
17. OPAL IS THE RUBY WAY
(from
)
http://www.get-covers.com/do-more-of-what-makes-you-
happy/
18. 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)
20. 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
21. #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
22. RUBY LANGUAGE FEATURES IN OPAL
classes
modules & mixins
singleton methods
method_missing
arity checks
lambda
blocks
yield
CONSTANTS
global variables
24. DON'T UNDERESTIMATE THE POWER OF A
BETTER LANGUAGE
opal-irb, opal-inspector, easy to write
leads us to Greenspun's 10th rule
25. 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.
26. #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
49. 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();
});
52. 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
53. 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
57. #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
58. #5 EASY INTEGRATION WITH RUBY
opal-rails
opal-sprockets (already shown in modules)
it's Ruby
62. 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
64. QUICK LOOK AT CODE
only 440 lines for opal-inspector current state
very short, small classes
didn't need a framework
65. #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…