• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Javascript for Rubyists
 

Javascript for Rubyists

on

  • 7,200 views

We’ve all used JavaScript. At least, we’ve all used jQuery to manipulate some part of the DOM. Maybe we think we understand the syntax enough, so we ‘improvise’ when we’re forced to write ...

We’ve all used JavaScript. At least, we’ve all used jQuery to manipulate some part of the DOM. Maybe we think we understand the syntax enough, so we ‘improvise’ when we’re forced to write some. Maybe we’ve tried it a few years ago and ran screaming from this seemingly broken language.

In 2011, JavaScript has a lot to offer once you get past its ‘java-ish’ syntax. The ‘little language that could’ has a rapidly growing, vibrant online community and opens the door to a diverse world of MVC browser based apps, high-speed 2D and 3D graphics and real-time server development. Spending a little time to learn JavaScript will allow you to easily increase the capabilities of your applications in a safe, error free and most of all fun way.

At this workshop, I re-introduced JavaScript and then moved on to building a real-time geospatial app with some interesting libraries; Backbone.js and Node.js.

The code for this tutorial is available here: https://github.com/tokumine/conferenciarails-js-workshop along with a handout to go with the slides here: https://docs.google.com/document/pub?id=16GAjYlGOhyD-mwtIZSRb75WywwUUCWyCxzBb_QLjsg4

JavaScript is a Lisp at heart. You may be surprised to find parts of Ruby that you love have been hiding out in JavaScript all along, waiting for you to find them.

Statistics

Views

Total Views
7,200
Views on SlideShare
3,774
Embed Views
3,426

Actions

Likes
4
Downloads
21
Comments
0

9 Embeds 3,426

http://tokumine.wordpress.com 2021
http://www.tokumine.com 1385
http://localhost:4000 11
http://webcache.googleusercontent.com 2
http://translate.googleusercontent.com 2
http://www.365dailyjournal.com 2
http://www.hanrss.com 1
http://localhost 1
http://s2.wp.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • explained in more detail in the handout\n
  • If there were to be a language entirely based on the idea of monkeypatching, this could be it.\n
  • \n
  • functions are like Ruby Lambdas\n
  • or like OpenStruct in Ruby 1.9.x\n
  • \n
  • \n
  • \n
  • \n

Javascript for Rubyists Javascript for Rubyists Presentation Transcript

  • JavaScript for Rubyists
  • jQuerybut I already do JS?
  • “JavaScript is the only language that people think they can program without actually learning it.” - D.Crockford
  • refresherbackbone and node need it
  • basic grammar
  • familiar object model Ruby JS object object
  • familiar object model Ruby JS object object JS primitive
  • JS datatypesprimitives objects• Boolean • Object• Number (fp) • Array (object)• String (16-bit)• nil/undefined/NaN
  • Core syntaxRuby JavaScript• no semicolons • optional semicolons*• # + =begin/=end • // + /* */• implicit return • return required• do/end or {} • {}
  • the bad stuffhey! It was made in 10 days
  • beware!• Global variables •+• Scope • NaN• Semicolon insertion • Phony arrays• Reserved words • Falsy values• typeof • ==• parseInt • eval
  • the good stuff it’s actually very lispy
  • functions are objects Ruby JavaScript1 def my_function arg1 1 function myFunction(arg1){2 something arg1 2 something(arg1);3 end 3 }4 4 5 var myFunction = function(arg1){ 6 something(arg1); 7 } 8
  • functions are objects Ruby JavaScript1 def my_function arg1 1 function myFunction(arg1){2 something arg1 2 something(arg1);3 end 3 }4 45 my_function = lambda do |arg1| 5 var myFunction = function(arg1){6 something arg1 6 something(arg1);7 end 7 }8 8
  • object literalsRuby JavaScript1 # hashie gem + objects 1 // new object with var2 require (‘hashie’) 2 var obj = {name: ‘simon’};34 a = {:name => ‘simon’}5 obj = Hashie::Mash.new a6 obj.name #=> simon
  • dynamic objects Ruby JavaScript 1 # hashie gem + objects 1 // new object with var 2 require (‘hashie’) 2 var obj = {name: ‘simon’}; 3 3 4 a = {:name => ‘simon’} 4 // new object with function 5 obj = Hashie::Mash.new a 5 obj.hello_world = function(){ 6 obj.name #=> simon 6 return “Hola Mundo”; 7 7 } 8 def obj.hello_world 9 puts "Hola Mundo"10 end
  • want to try?http://jsconsole.com
  • resources• http://www.youtube.com/watch?v=hQVTIJBZook• http://oreilly.com/catalog/9780596517748• http://javascript.crockford.com/survey.html
  • thanks! @tokumin