Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Polyglot

 Polyglot

How To Write A Web App in 6 Programming Languages

Sau Sheong Chang

October 10, 2014
Tweet

More Decks by Sau Sheong Chang

Other Decks in Technology

Transcript

  1. Polyglot Or  How  To  Write  A  Web  App  in  6

      Programming  Languages Chang  Sau  Sheong   Oct  2014 1
  2. Acceptor HTTP Responder Responder Responder POST/_/post Responder Responder Responder GET/_/posts

    Acceptor HTTP Acceptor HTTP Broker ZMQ ZMQ Responder Responder Responder GET/_/post/new 9
  3. Simple  responder require 'securerandom' require 'bundler' Bundler.require broker = "tcp://localhost:4321"

    routeid = "GET/_/hello/ruby" identity = SecureRandom.uuid puts "#{routeid} - #{identity} responder ready." ctx = ZMQ::Context.new client = ctx.socket ZMQ::REQ client.identity = identity client.connect broker client.send_string routeid loop do request = String.new client.recv_string request response = [routeid, "200", "{\"Content-Type\": \"text/html\"}", "Hello World"] client.send_strings response end Define  route  ID  and  unique   responder  identity Connect  to  broker Register  responder Receive  request  and  process   it Return  with  response 13