Ruby On Rails as the frontend for polyglot programming

(written by lawrence krubner, however indented passages are often quotes). You can contact lawrence at: lawrence@krubner.com

True:

Rails is a good framework for proof-of-concept and small applications, it promotes conventions over configuration. As the application grows it becomes difficult to maintain. This is primarily because rails promotes coupeled architecture with fat model, skinny controller approach. Developers need to adopt to new patterns and create new conventions to keep projects moving on pace and in shape. PUBSUB can help us resolve some of the problems we face often.

And the subscribers can be written in any language, allowing for easy polyglot programming. Seems to me this is becoming a common use of Rails.

PUBSUB is a simple architecture for a website that needs to do a lot of background work — the frontend can be Rails and the backend can be written in any language. My preference, of course, would be Clojure for 99% of the backend work I do.

In software architecture, publish–subscribe is a messaging pattern where senders of messages, called publishers, do not program the messages to be sent directly to specific receivers, called subscribers. Instead, published messages are characterized into classes, without knowledge of what, if any, subscribers there may be. Similarly, subscribers express interest in one or more classes, and only receive messages that are of interest, without knowledge of what, if any, publishers there are.

A basic publisher is drop-dead simple:

 # app/pub_sub/publisher.rb
 module Publisher
   extend self

   # delegate to ActiveSupport::Notifications.instrument
   def broadcast_event(event_name, payload={})
     if block_given?
       ActiveSupport::Notifications.instrument(event_name, payload) do
          yield
       end
     else
       ActiveSupport::Notifications.instrument(event_name, payload)
     end
   end
 end
Source