[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

dual-language systems increase modularity



One of the things the recent LL3 workshop made me think about is the
practical utility and usefulness of embedding a scripting language in
an application.  Roberto Ierusalimschy gave a talk about the Lua 5.0
VM[1].  The language was designed to be easily embeddable and is
currently used by major gaming studios to script their games.  It is
also used to control other kinds of application, such as the C--
compiler described by Norman Ramsey[2].  Ramsey says,

    Using an embedded, interpreted language to control a complicated
    application can have significant software-engineering benefits.

What exactly are those benefits?  I think one of the possible answers
to this question was provided by Dan Sugalski's hand waving in his
talk about boundaries[3].

John Ousterhout asserts[4] that

  ...scripting languages are designed for gluing: they _assume_
  [emphasis mine - V.N.] the existence of a set of powerful components
  and are intended primarily for connecting components together.

Sure, if you have a well-designed system with all the right boundaries
in place, it is relatively easy to take a well-designed scripting
language and, by embedding it, make your application more useful and
more easily extensible.

What if your application lacks useful components?  My thought of the
day is, you can go ahead and embed a scripting language anyway.  Even
though it may prove useless initially, you can, by trying to make it
useful, begin to see where the internal boundaries in your system
should be.  By trying to make the system scriptable, you will force
yourself to start partitioning stuff in a cleaner way.

This reminds me of a comment Martin Fowler made in his talk at the
Softpro bookstore in Burlington, MA about a year ago.  To judge how
well-designed a system is, he applies this rule of thumb.  If the
system provides a GUI, how difficult would it be to slap on a CLI on
top of it?  If the answer is, not very hard, congratulations, you have
a fairly well-designed system.

Shriram said at the workshop that his big question was, how do you go
"from scripts to programs"?

My question is, how do you go from programs to scripts?  Is it useful
to explicitly adopt a dual-language architecture as a way to achieve
greater modularity?


References
  1. http://ll3.ai.mit.edu/abstracts.html#lua
  2. http://ll3.ai.mit.edu/abstracts.html#embedding
  3. http://ll3.ai.mit.edu/abstracts.html#boundaries
  4. http://home.pacbell.net/ouster/scripting.html