Decided to finally *learn* Javascript

Mahzkrieg

New member
Nov 13, 2007
585
31
0
Austin, Texas
1. The constant barrage of awesome JS projects has been making it very hard for me to validate why I'm still bad with JS.

  • Example: the Meteor framework
  • And, of course, frameworks like Backbone.js and Ember.js
2. With the explosion of server-side JS, that gives you the same language on the server and the client.

3. I'm tired of JS being nothing but a hack that I inject only when I need it, mostly because I don't know it.

  • Does my Ruby screen scraper encounter Javascript? Damn. Or I can just use Phantom.js from the beginning.
  • Rails app needs some interactivity? Gotta begrudgingly context-shift to JS.
4. While Ruby goes better with my Starbucks latte, I think I'll get more cool points from the emerging Javascript bandwagon with a Node.js sticker on my Macbook Air.

Some resources I'm using to learn JS:

The syntax always bothered me. I couldn't grok it within 30 seconds, so I avoided it. Forever. var lol = (function (param, function () {}) {})(); But the Try CoffeeScript CS -> JS converter helps ease the transition from Ruby-mindedness to JS.


AhIIS.png


Wait... wat? Guess it's back to the books!

TL;DR

De38s.jpg
 


backbone is awesome, I love it. It has a fairly steep learning curve though. I recommend watching the peepcode screencasts for it. They are cheap or can be acquired easily with some fancy googling.

What are you looking to build with JS? I plan on doing the next iteration of serpIQ on Backbone so it will be more like a tool or desktop app than a traditional "click...page load...back...refresh" etc. Will be a big project but I think will be a nice step forward for us.

Hit me up on skype I can share some backbone resources I have found over time
 
Pro tip: write your js like normal code until you get it working and can understand it, then use a minifying script to make it look like:
var lol = (function (param, function () {}) {})();
 
backbone is awesome, I love it. It has a fairly steep learning curve though. I recommend watching the peepcode screencasts for it. They are cheap or can be acquired easily with some fancy googling.

What are you looking to build with JS? I plan on doing the next iteration of serpIQ on Backbone so it will be more like a tool or desktop app than a traditional "click...page load...back...refresh" etc. Will be a big project but I think will be a nice step forward for us.

Hit me up on skype I can share some backbone resources I have found over time

This is mostly just motivated by the sheer utility of JS. I'm pretty confident in my ability to make really any prototypical app with Rails. But being a monoglot is painful, especially when I'm trying to call myself a web developer without knowing Javascript.

As you said, JS is a centerpiece of UX in a world leaving the monolithic http request/response cycle behind. The new Basecamp.com rewrite feels like it's milked the last few drops of what passing around html can give us with its abundance of fragment cache(fragment cache(fragment cache)) Inception and use of pjax.

And now that your simple Sinatra app can be rewritten as a vanilla html page that uses pushState to change the url to "domain.com/page1" when $("#page1").show() is triggered, server round-trips feel especially silly.

It all started when I was building a push notification system for a Rails forum app. Trying to stay with Ruby, I was playing with async servers like Cramp and Goliath. But I stumbled across Socket.io for Node.js which exposed me to Batman.js and Express.js.

When you compare Express

Code:
app = express.createServer;

app.get '/', (req, res) ->
  res.send 'Hello World'
To Sinatra

Code:
require 'sinatra'  

get '/hi' do   
  "Hello World!" 
end
I started wondering whether all the Ruby<->JS context-switching was worth it. And I'm not talking about syntax, but the switching between Haml templates, Handlebar templates, JS representations of Ruby domain logic, and bubbling JS through Ruby while the JS files stay off in a pocket `assets/` directory.

...Also, I've been looking a for a Rails job (just graduated) but every job board is pretty much a barrage of front-end dev positions.

Finally, I don't mean to sound like I'm discounting Rails. Only that superficially embedding JS as a second-class component (especially one that you don't really grasp) leaves much to be desired. Nothing is more pleasant than Rails for architecting a back-end and exposing endpoints for Javascript.

If you look at the roadmap, Rails 4 will have `config.middleware.api_only`.
 
After getting comfortable enough with Javascript, I finally switched to Coffeescript which was so pleasant to type after paying my pure-JS dues that this whole venture into JS might be more permanent than I intended.

Code:
class User
  initialize (@name) ->

Posts = ->
  @respondsWith = ['html', 'json', 'xml', 'js', 'txt']

  @index = (req, resp, params) ->
    @respond {params}
Compiles to:

Code:
(function() {
  var Posts, User;

  User = (function() {
    function User() {}
    initialize(function(name) {
      this.name = name;
    });

    return User;
  })();

  Posts = function() {
    this.respondsWith = ['html', 'json', 'xml', 'js', 'txt'];

    this.index = function(req, resp, params) {
      return this.respond({
        params: params
      });
    };
}).call(this);

Feels good. :338:

At the moment, I'm porting a hobby Rails app over to Geddy, a Railsy MVC framework for Node to learn how to latch on to Node's `module.exports` system.

I've also started playing with Derby (similar to Meteor). While Derby is much more than what I initially started using it for, I stumbled upon it trying to find the fastest and easiest way to make a static content JS site that effortlessly rendered the same template server- and client-side and catered to search engine crawlers.

Backbone.js has been pleasant. Code School's course and the Peepcode series seem to be the fastest way to get caught up to speed.