Here is an example of a domain specific library/language I have created
to start and manage a distributed (Java-based) agent society for a DARPA
program I work on.  The whole point is to load a configuration of an
Agent society from a database (in this case in MySQL).  It then builds a
"society" composed of Hosts, Nodes and Software Agents that run across
JVMs in a (40 machine) network.

I will (through comments) walk through this code.  
____________________

require 'cougaar/controller'

# Cougaar is the agent technology (www.cougaar.org)
# This loads all the domain specific classes/modules

include Cougaar

# Pick a (predefined) experiment and get the Society definitions

csmart = CSmartDatabase.connect("u101", "db")
society = csmart.build_society("Experiment 1") 
csmart.close

# we now have a "Society" composed of Hosts, Nodes and Agents
# where Hosts=computers
#       Nodes=JVM process
#       Agents=software agent

# Get the controller and run the Society

controller = society.controller

# This controller has lots of domain specific event management

# methods.

controller.connect_to_jabber("acme", "alpha")

# We use Jabber to control all the distributed ruby servers that

# are used to start/event/control/stop the (java-based) society.

controller.enable_cougaar_events

# CougaarEvents are feedback (XML) events from the Agents sent

# back to us via Jabber.

controller.on_oplan_ready do |controller|
  puts "Sending OPlan"
  controller.publish_oplan
end

controller.on_gls_ready do |controller|
  puts "Sending GLS Root"
  controller.send_gls_root
end

# These events (oplan and gls) are domain specific.  The 
# solution is a distributed logistics application where
# oplan is Operations Plan and gls is the Logistical 
# root task.  Notice the use of Ruby blocks to act as
# "listeners"

trap("INT") { controller.stop_society }

# Trap ^C to send an instant message to stop society and
# clean up all the java processes.

controller.start_society

_____________________

That's it.  It has lots of additional domain capabilities like stressing
the CPUs that these agents run on, performing actions at timed
intervals, etc.  Ruby controls the whole shooting match via Jabber.
What this provided to the DARPA program we are using this on is the
ability to have folks that understand this domain to write scripts (once
they are trained on the dialect).  As they get more comfortable, they
learn more Ruby code to enable looping experiments, capturing data, etc.

Regards,

Rich

> -----Original Message-----
> From: dave / thomases.com [mailto:dave / thomases.com] On Behalf Of Dave
> Thomas
> Sent: Thursday, August 22, 2002 2:07 PM
> To: ruby-talk ML
> Subject: Re: SV: A Repeat: New Language After Ruby?
> 
> Thomas S√łndergaard <tsondergaard / speakanet.com> writes:
> 
> > As I do so often, I now feel tempted to quote the pragmatic
> > programmers. From the paper "Never Build an Application"
> > (http://www.pragmaticprogrammer.com/ppllc/papers/1998_03.html) I've
> > selected two interesting quotes:
> >
> > 1) "Library design is language design"
> >
> > 2) "Design a domain specific 'language' that can be used to talk
> >    about applications in this domain"
> >
> > These two statements can be simplified to "Design a domain specific
> > 'library' that can be used to talk about applications in this
> > domain"? Have you changed your mind? If so why? I still believe
> > these two quotes to be entirely valid.
> 
> No, I don't think I've changed my mind. The difference between the
> above and the Java case is that domain-specific libraries are intended
> for one task: you write them to provide the infrastructure in order to
> write your application. The Java community seems to have a different
> approach: the books and the examples of code available to developers
> promote "general purpose" coding -- add stuff because someone at some
> point just might want it. This is the attitude that leads the the kind
> of bloat we see in Java applications.
> 
> Cheers
> 
> 
> Dave