• RSS
  • Archive
  • Likes

john manoogian III : jm3

"FLEET HORSE. THE OPEN STEPPE. FALCONS, AT YOUR BREAST"


December 12, 2011 • 20 notes • thechangelog

cool.io - cool event driven programming for Ruby

thechangelog:

It seems like there is a common pattern with many libraries: You have your full stack solution, and then you have your lean and mean one. Ruby on Rails has its counterpart in Sinatra, for example. So what about event-driven programming frameworks, like EventMachine or Node.js?

Enter cool.io:

require 'rubygems'
require 'cool.io'

ADDR = '127.0.0.1'
PORT = 4321

cool.io.server ADDR, PORT do
  on_connect do
    puts "#{remote_addr}:#{remote_port} connected"
  end

  on_close do
    puts "#{remote_addr}:#{remote_port} disconnected"
  end

  on_read do |data|
    write data
  end
end

puts "Echo server listening on #{ADDR}:#{PORT}"
cool.io.run

Pretty cool. Cool.io is trying to make evented programming really easy, which is good, because this style of programming is a bit different than your usual kinds of web programming.

Under the hood, Cool.io is built on top of libev, which hooks it up to various system calls on different operating systems for doing this kind of thing in a blazing fast manner. Then again, my OS developer buddies would kill me for calling a system call ‘performant,’ but that’s a different story… what it boils down to is that Cool.io doesn’t reinvent the wheel: epoll on Linux, kqueue on BSD and OSX…

Personally, I’ve been meaning to write some software in the evented style, but I haven’t had the time to appropriately level up my Javascript skills yet. Cool.io just might be the ticket to building something more than just a toy example or two.

[Github] [README]

  1. jm3 liked this
  2. jm3 reblogged this from thechangelog
  3. reparatiifrigidere liked this
  4. last--minute liked this
  5. elv1s liked this
  6. dentarg liked this
  7. sanemat reblogged this from iorionda
  8. iorionda reblogged this from thechangelog
  9. oivoodoo liked this
  10. polyacr liked this
  11. fareastside liked this
  12. justinherrick liked this
  13. justinherrick reblogged this from thechangelog
  14. thechangelog posted this
Designed by Sleepover