frameworks

45
The Right Tool For the Job

Upload: ryan-levick

Post on 22-May-2015

473 views

Category:

Technology


1 download

TRANSCRIPT

The Right Tool For the Job

Who am I?

@itchyankles

I need to build a server!

What do I do?!

So many choices

ASP.Net MVC

Rails CakeSinatra

Play Liberator Grails

Meteor

Code Ignitor

DjangoCompojure

Spring

Scalatra

What Makes Them Different?

• Language

• Performance

• General Developer Speed

• Library Support

• Abstraction

Quick HTTP Break

What is HTTP?

Protocol An established set of guidelines for

communication

Some Languages Have Nice Built in Web Server Support

var http = require("http"); http.createServer(function(request,response){ response.write("Hello World"); response.end(); }).listen(8080);

package main !import ( "fmt" "net/http" ) !func handler(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, "Hello, world!") } !func main() { http.HandleFunc("/", handler) http.ListenAndServe(":8080", nil) }

Ruby also has a built in server library….

… but no one uses it.

Rack wraps HTTP in a very thin Ruby layer

Rackapp = lambda do |env| body = "Hello, World!" [ 200, { "Content-Type" => "text/plain", "Content-Length" => body.length.to_s }, [body] ] end !run app

Weird, no?

Let’s Make this Prettier

require 'sinatra' !

get '/' do "Hello World!" end

Sinatra

And The Next Step?

Well there are other alternatives, but let’s hold

off on those…

Let’s Compare, Shall We?

Why Would We Ever Use Rack?

With Great Power Comes…

With Great Power Comes…

So why does Sinatra give us?

DSL (Domain Specific

Language)

View Helpers!

A bit of convenience

So why does Rails give us?

ActiveRecord ActiveSupport

ActionView

Good News

Rails and Sinatra are Popular!

Questions?!