n things 

in 

x minutes


Flogging the horse until dead

Hi

I'm Toby

@tobyhede




#cloudharder


JavaScript

wat

like php, but for web browsers

the language you have





Lua

I couldn't think of a joke



Lua is a powerful, fast, lightweight, embeddable scripting language.


Lua combines simple procedural syntax with powerful data description constructs based on associative arrays and extensible semantics. Lua is dynamically typed, runs by interpreting bytecode for a register-based virtual machine, and has automatic memory management with incremental garbage collection, making it ideal for configuration, scripting, and rapid prototyping.


She's fast enough for you, old man.


Redis

I don't often use stored procedures, 
but when I do ...

  local result = c.conn.Do("ZREVRANGE", %s, 0, 10, "WITHSCORES");
  redis.call('ZREMRANGEBYRANK','%s',0, 9);
  return result;
  



OpenResty

Nginx webapp with embedded Lua scripting and bundled modules.


#worker_processes  1;
pid        /tmp/nginx.pid;
error_log stderr error;

events {
    worker_connections  16384;
}

http {
    resolver 127.0.0.1;
    access_log off;
    lua_package_path 'CWD/openresty/?.lua;;';
    init_by_lua 'encode = require("cjson").encode mysql = require("resty.mysql")';
    server {
        listen       8080;
        location /plaintext {
            default_type "text/plain";
            content_by_lua 'ngx.print("Hello, world!")';
        }

        location /json {
            default_type "application/json";
            content_by_lua 'ngx.print(encode({message = "Hello, World!"}))';
        }
        location / {
            content_by_lua 'require("app")(ngx)';
        }
    }
}
  


local mysql = mysql

local encode = encode
local random = math.random

local mysqlconn = {
    host = "DBHOSTNAME",
	port = 3306,
	database = "hello_world",
	user = "user",
	password = "pwd"
}
return function(ngx)
	local db = mysql:new()
	assert(db:connect(mysqlconn))
	ngx.print(encode(db:query('SELECT * FROM World WHERE id = '..random(1,10000))[1]))
	db:set_keepalive(0, 256)
end



Scala

All the benefits of Enterprise Java with all the benefits of condescending functional hipsters


Java

Now with added function



    
    Observable.toObservable("one", "two", "three"
      .take(2)
      .subscribe((arg) -> {
          System.out.println(arg);
      });
      


Go

You so hot right now

In 2013




  • familiar, bracey syntax
  • static types
  • memory management (gc)
  • super-fast compilation
  • functional-ish
  • concurrency as an actual, like, thing
  • performance as an actual, like, thing
  • packagable - distribute executable

    

    type Channel struct {
		Key			string
		Messages	[]Message
		Msg			map[string]string
		conn		redis.Conn
	}

	type Message struct {
		Timestamp	string	`json:"timestamp"`
		Message		string	`json:"message"`
	}

	func (c *Channel) Get() {
		messages, err := redis.Strings(c.conn.Do("ZREVRANGE", c.Key, 0, 10, "WITHSCORES"))

		log.Print(len(messages)/2)
		m := make([]Message, 0, len(messages)/2)

		for index,element := range messages {
			if index % 2 == 1 {
				msg := &Message{Timestamp: element, Message: messages[index-1]}
				m = append(m, *msg)
			}
		}

		c.Messages = m

		if err != nil {
			log.Fatal(err)
			ERROR.Fatal(err)
		}
	}

	func (c Channel) GetMessages() []Message {
		return c.Messages
	}
    



Revel

Like Rails, but for Go.
Without ActiveRecord.
No-one likes it



Martini

Like Sinatra, but for Go.
Seems legit.
Still no ActiveRecord.





    package main

	import "github.com/codegangsta/martini"

	func main() {
	  m := martini.Classic()
	  m.Get("/", func() string {
	    return "Hello world!"
	  })
	  m.Run()
	}
      


Elixir

holy fucking shit



Oh Erlang


    

  -define(CHILD(I, Type), {I, {I, start_link, []}, permanent, 5000, Type, [I]}).
  -define(CHILD(I, Type, Params), {I, {I, start_link, Params}, permanent, 5000, Type, [I]}).

  start_link() ->
      io:format("hammer_sup:start_link~n"),
      supervisor:start_link({local, ?MODULE}, ?MODULE, []).

  start_child() ->
    io:format("hammer_sup:start_child~n").
    % supervisor:start_child(?MODULE, ?CHILD(hammer_plan_sup, supervisor)).

  init(_Args) ->
      io:format("hammer_sup:init~n"),
      { ok, {
          {plan, Plan},
          {session, Requests}
        }
      } = hammer_config:load(),

      Children = [
        ?CHILD(hammer_planner, worker, [Plan])
      ],

      RestartStrategy = {one_for_one, 0, 1},
      {ok, {RestartStrategy, Children}}.




  • functional
  • meta-programming
  • macros
  • pattern-matching
  • immutabililility 
  • concurrency as an actual, like, thing
  • kick-ass virtual machine


Not variables, actually
    
  > [a, a] = [1, 2]
  ** (MatchError) no match of right hand side value: [1, 2]

  > [a, b, 3] = [1, 2, 3]
  > a
    1



Concurrency
    

  current_pid = self

  spawn fn ->
    current_pid <- { :hello, self }
  end

  receive do
    { :hello, pid } ->
      IO.puts "Hello from #{inspect(pid)}"
  end
  




OTP




Useful Links


Rust

Like Go, but before it was cool



  • functional
  • static types
  • no shared state
  • pattern matching
  • concurrency as an actual, like, thing
  • bleeding edge


Random

Thoughts

Peak Rails

It's teh Culture

n things in x minutes

By tobyhede

n things in x minutes

  • 2,703