source code size metric: Python and modern C++

Duncan Grisby duncan-news at grisby.org
Tue Dec 3 16:45:45 EST 2002


In article <mailman.1038895624.15806.python-list at python.org>,
 Brian Quinlan  <brian at sweetapp.com> wrote:

>Has anyone done any RPC programming in C/C++? I'll use XML-RPC as an
>example. In Python, making an XML-RPC call is as simple as this:

I'll use CORBA as a fairer example for C++...

  Adder_var adder = // get an adder from somewhere...
  int result = adder->add(2, 3);

RPC systems have traditionally had interface definition languages,
meaning a compiler writes the type safe proxy code for you. The code
to acquire the object could be something like

  CORBA::Object_var obj = orb->string_to_object("corbaloc::myhost/adder");
  Adder_var adder = Adder::_narrow(obj);

The _narrow() call causes the system to go and check that the object
really does support the interface we expect, rather than just being
some other object that happens to have an add method.

Static typing at the RPC level means that we don't have to worry about
using C++ or Python to tell the system what the types are. More
significantly for Python, we don't have to check that the add method
really does return an integer (like we do with Python XML-RPC), since
the RPC runtime does it for us. This kind of thing is significantly
more important in a distributed environment that within a single
program, where Python's dynamic typing is great.

Cheers,

Duncan.

-- 
 -- Duncan Grisby         --
  -- duncan at grisby.org     --
   -- http://www.grisby.org --



More information about the Python-list mailing list