The Wayback Machine - https://web.archive.org/web/20041010155751/http://www.fpx.de:80/Combat/

(The Combat Logo)

CORBA scripting with Tcl

Combat/C++ Version 0.7.2

Combat/Tcl Version 0.7.4

Table of Contents


Introduction


Combat is an extension to the popular Tcl scripting language that allows accessing and providing CORBA objects at the script level, i.e. with Combat, your Tcl scripts can access CORBA services or become a CORBA server themselves.

Tcl is an open source scripting language that is well-known for its productivity and extensibility. Scripting languages in general allow for rapid application development and incremental prototyping. Especially popular with Tcl is the graphical toolkit Tk, which allows implementing attractive user interfaces with a minimum of code and effort.

CORBA (Common Object Request Broker Architecture) is a Middleware for distributed systems. Designed by the Object Management Group, CORBA is not a product but a standard that describes how client and servers can interoperate in a heterogeneous environment, independent of hardware, operating system, programming language and vendor. The basic idea is to have an Object Request Broker (ORB) that directs requests (i.e. an object method invocation) over the network to their targets.

Enter Combat, which unites both worlds by providing a generic Tcl language mapping. Somewhat simplified, such a language mapping consists of mainly two things, (a) a representation of CORBA's data types in the target language, and (b) commands to pass requests from the language to the ORB and back. Combat achieves this by translating CORBA data types to Tcl's types (strings, list, etc.), and by using "command objects" that appear as a Tcl command but transparently pass their parameters via the ORB to the remote server. If you've already done CORBA programming in C++ or Java, you will know this notion as "stub objects".

There are two versions of Combat available. Combat/C++, does not itself include an ORB, but is a glue package that builds upon an existing ORB C++ ORB such as Mico or ORBacus. Therefore, Combat/C++ inherits your ORBs properties such as configuration options and protocol support.

The other version, Combat/Tcl, includes an ORB written in pure Tcl. By not depending on any compiled code, this version works on all platforms where Tcl is available, and can also be used where compiled code is not acceptable, such as in the Tcl browser plugin. Naturally, packaging and deployment is much easier than with compiled code.

See below for more technical information.

Combat is the new name of the project formerly known as TclMico. Early versions of the C++ version worked with the Open Source ORB Mico only. The name became inappropriate after TclMico was ported to work with other ORBs as well, and was thus changed to Combat, which means something like CORBA Object Management By Application of Tcl. Did you notice that many project names are forced to make the acronym sound interesting?


Why use Combat?


Combat allows you to develop CORBA clients and servers with the ease and speed Tcl is known for. On the client side, one possibility is to use Tcl scripts as a powerful testing facility for your CORBA servers. But then, you're only limited by your imagination. Short scripts that automate simple tasks are just as possible as large Tk-based GUIs. With Tcl as a glue language, you can also use Combat in parallel with other Tcl extensions like database access (pgtcl, oratcl), or even combine it with your own custom extensions. With any portability issues hidden by Tcl and the ORB, your CORBA applications will run on all platforms.

(Interface Repository Browser)
A CORBA Interface Repository Browser written with Combat.
Runs without code changes on Unix and Windows.

Server-side CORBA scripting, which employs the object-oriented powers of [incr Tcl] also has its merits, as it can be done with much less code than a comparative C++ or Java server, without the need to recompile your code whenever some interface has changed.


Example


The Account scenario is a popular example in the CORBA world. Assume that the Bank is an object that allows you to open an account. An account is another object with methods to deposit, to withdraw, and to check your balance.

In CORBA, you would first have to declare the interfaces for both the Bank and the Account object in the Interface Description Language (IDL), which is similar to a Class declaration in C++, and which, in this example, would look like

  interface Account {
    void deposit (unsigned long amount);
    void withdraw (unsigned long amount);
    long balance ();
  };

  interface Bank {
    Account create ();
  };
The contents of this IDL file is the "contract" between the client and the server. Now, assuming that you've implemented and started a Bank server, and written its address into the file Bank.ior in the local directory, a sample session in Tcl could look like this:
  set Bank [corba::string_to_object file://[pwd]/Bank.ior]
  set Account [$Bank create]
  $Account deposit 700
  $Account withdraw 450
  puts "Current balance is [$Account balance]."
  Current balance is 250.
Note the use of the "command objects" (coined handle), Bank and Account.


Documentation



Download Combat/C++


Source Distribution

Combat/C++ is distributed in source code. You need a C++ compiler and a supported ORB (see below) to build Combat from source.

Binary Distribution

A binary distribution of Combat/C++ is available for the Win32 environment, i.e. Windows 95, 98, NT or 2000.


Download Combat/Tcl


The Tcl version of Combat includes an ORB written in pure Tcl, so no external ORB is needed. No compilation is necessary. Therefore, Combat/Tcl can run wherever Tcl is available, which is a much broader range of platforms than those supported by any ORB. Also, the footprint is minimal. Standalone servers and clients can have a size of less than 1 Megabyte (with Tcl and all but the C library statically linked) - see below for a proof of that statement. And these are clients and servers that can actually do something, because as you add more features, scripts only grow very little.

(Banking Demo)
Graphical Banking Application (Client) using Combat.
A mere 300 lines of code (7 kB).

The feature list of Combat/Tcl is pretty inclusive:

The price to pay is that the communications and marshalling code is somewhat slower than in Combat/C++. As a simple benchmark, binding a reference in the naming service (round-trip time) takes Combat/C++ about 5ms, while Combat/Tcl takes 20ms (on the author's machine).

That is to say that Combat/Tcl is by all means fast enough for most jobs, because invocations tend to be small. For shoveling larger amounts of data, Combat/C++ may be more appropriate.

On the other hand, working with Combat/Tcl is sometimes more painless. There are no packages to compile (other than Tcl) or to maintain, no operating system or compiler compatibility issues, and packaging and deployment is much easier: there are no shared library dependencies, and tools exist to pack all of your code into a single executable.

To run Combat/Tcl, you need at least Tcl 8.1 and either [incr Tcl] 3.0.1 or Tcl++ (a Tcl-only drop-in replacement for [incr Tcl]).

Demonstration

To get an impression of the features and small footprint of Combat/Tcl, you can download this demonstration, which implements the popular Account example (see IDL and screenshot above). The server is 2k small (130 lines of code), the client, including the GUI, a mere 7k (300 lines of code).

You can download the source, or ready-to-run standalone programs for Windows.


Other Downloads



External Links


Combat/C++ requires a CORBA 2.3-compliant ORB with a C++ mapping. Examples of suitable ORBs are:

Other links:


Reports of Projects using Combat


Unfortunately, there is little feedback on the usage of Open Source tools. Most feedback happens in case of problems, so getting little feedback indicates either little usage of the software, or that it does work flawlessly enough. With Combat, there is reason to suspect the latter. From my contacts, I know that Combat is in active use at companies such as JPL, NASA or Alcatel. Sometimes I also look for references to Combat (or its earlier incarnation TclMico) using search engines, getting surprisingly many hits. Here are some examples:

Please send an email if you or your company would like to be listed here.


Licensing and Support


Combat/C++ is distributed under the terms of the GNU Library General Public License (LGPL). Read the file LICENSE that comes with the Combat distribution.

Combat/Tcl is distributed under the terms of the BSD license (the same license that Tcl comes with).

Both versions of Combat are distributed without any support or warranty for its fitness. However, support for Combat is available - please contact the author for more information.


Powered by Tcl Uses Combat Powered by [incr Tcl]


(FPX Logo)

Frank Pilhofer, combat@fpx.de