source code size metric: Python and modern C++

Ian Bicking ianb at colorstudy.com
Thu Dec 5 16:19:49 EST 2002


On Thu, 2002-12-05 at 08:18, Duncan Grisby wrote:
> In article <mailman.1039059246.30953.python-list at python.org>,
> Ian Bicking  <ianb at colorstudy.com> wrote:
> 
> >But the IDL doesn't describe the service either -- because it's so
> >formal, it's not tremendously helpful for documenting the interface in a
> >way that's useful for the programmer.
> 
> I don't understand that statement. How is unambiguously specifying the
> operations available and the types involved not helpful?  I agree that
> it's not _all_ you need, but given that you need to specify types, you
> might as well specify them in a way that's understandable to the
> system, so it can write some checking code for you.

I don't often check types.  Why would I?  What's the advantage of doing:

result = some_remote_call()
if not type(result) is int: raise TypeError
if result < 100:
    do stuff...

?  < will give me an error just fine.  If I get a type I don't expect,
it's an error, that's all.  It doesn't matter that much where the error
occurs -- if it occurs on the server, in the transport, in my type
checking, or my use of the results.  If there's security issues then
almost certainly I need to do more checking than an IDL can do.  And
again if I do such checks, type errors will be likely be raised
implicitly.

An error is an error.  I don't usually try to recover from them, that
just turns into second-guessing.  Getting the wrong type is just one of
many errors, it's not an important enough error to warrant building
complicated systems to avoid.

> >That said, I don't think an XMLRPC example is really fair -- XMLRPC was
> >designed for languages like Python, not languages like C++.  It may very
> >well be superior than CORBA in many domains -- very possibly because
> >it's designed for languages like Python -- but even if it wasn't it
> >would still be easier to use in Python than C++.
> 
> Yes, but systems like CORBA are easier to use from Python than systems
> like XML-RPC are. Non trivial Python XML-RPC programs will in general
> have to do more argument checking than the equivalent Python CORBA
> programs. That's not to say that with CORBA you do no checking at all,
> just that you have to do less.

I just can't believe this is true.  Type checking is at most one line
per argument of a call, and can be wrapped in a function, so that
checking only applies to distinct methods.  CORBA just isn't that easy
to use, even from Python.  And there's really almost no win even for
type checking -- the type information has to be passed somehow.  XML-RPC
passes it dynamically at run time, and statically (and informally) in
the documentation.  CORBA passes it in an IDL.  Handling the IDL isn't
any easier than dealing with the same information in an ad hoc manner as
with XML-RPC.

But again, it's hard to compare -- CORBA has a lot of complexities
besides type checking.  A better comparison would be something otherwise
fairly simple like XML-RPC, but with a formal interface definition.


-- 
Ian Bicking           Colorstudy Web Development
ianb at colorstudy.com   http://www.colorstudy.com
PGP: gpg --keyserver pgp.mit.edu --recv-keys 0x9B9E28B7
4869 N Talman Ave, Chicago, IL 60625 / (773) 275-7241





More information about the Python-list mailing list