SV: A Repeat: New Language After Ruby?

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

Below is my personal opinion:

Longtime ago, I saw the 3 volumes of books,
I cannot remember the exact title of the books (maybe in French?),
It kind of volume 2 describe some OO languages,
Volume 3 describes some scripting languages.

In the scripting languages, the book even mentions something for
music scripting languages. That surprise me a lot, I never heard a
computer language for music. (I did see some for graphic image and
animation)

I think when you try learning a new language, it is like Dave said,

Learning a language means coming to understand it: the philosophy,
the idioms, and the “way things are done”.

Some language is designed for some specific domain, not all languages
are
general purpose, even they are general purpose, and other language may
suit
better for some problem domain then those languages.

I think the important is you learn new language that will open
your mind to view/thinking stuff.
It kind of “there are just an other better way to do the job”.

It likes sorting a list, there is just a lot of different algorithms
to sort a list. (Do you think you just need to know one, and that suit
in
all situations? If yes, all you need to know is assembler language :slight_smile:

In case of “cost/reward”, it is difficult to estimate that.
If you base on reward, you should specialist only in the language that
is used
in your current job (or future job). That’s it.
I really not idea about this “cost/reward”, give you a similar case.
We learn
from school physics, chemistry, …etc, may-be now in your current
job, you
just need computer science and some math; can you say learn calculus,
physics,
chemistry …etc are just waste time? (If so, why we still teach our
children that stuff? If the child just want to know computer science)

I remember longtime ago, I tried learn Perl, my co-worker ask me
what’s that ?
After I explain, he just told me that I am waste time. Well, I never
have a job
using only Perl, Perl is just like a tool help me a lot. And it also
gives me
some new view on regular expression (the no-greed invention).

Same thing for Ruby now, I do not have job and it also rare to find a
job that
using Ruby only. I still like to learn it and have fun :slight_smile:
(I will never regret learn Ruby. Am I waste time again? Some of my new
co-worker said so again. I hope not :slight_smile: )