Choosing Perl/Python for my particular niche

Roy Smith roy at panix.com
Sat Mar 27 08:46:53 EST 2004


Fred Ma <fma at doe.carleton.ca> wrote:
> I was under the impression (rightly or wrongly) that Tcl
> was good at interfacing to, and controlling, CAD tools.

Tcl is an interesting language, and well worth learning, although it 
certainly has its share of quirks.

The product I work on has close to 20,000 lines of Tcl code doing 
network discovery via SNMP.  The low-level SNMP protocol is accessed via 
hooks done in C.  It's not very fast, but it's as fast as it has to be, 
and I shudder to think how many lines of C or C++ the whole system would 
have been.

The real strengths are twofold:

1) It's easy to learn.  Even easier than Python.  We take guys who are 
networking types with no programming experience and get them doing 
useful development in Tcl in just a few days.

2) It's dead simple to embed in a C/C++ application.  This is one place 
where it really outshines Python.  It's literally two lines of C to get 
a Tcl interpreter up and running.  It's equally trivial to extend Tcl by 
providing functions in C.  Compare this to the native Python/C 
interface, boost.python, or swig, and you really appreciate the 
difference!

For most general purpose tasks, I reach for Python first.  But if I 
needed to provide a quick scripting interface to an existing C library, 
or wanted to embed some easy scriptability into a large C/C++ app, Tcl 
is what I would be looking at.



More information about the Python-list mailing list