[Tutor] OT, Tcl & Python
alan.gauld at freenet.co.uk
Sat Jul 16 21:34:19 CEST 2005
> I was wondering if someone knowledgeable of both Tcl and Python
> suggest whether it would be a good or a bad idea to write a
> application, with the motive to rewrite the application in Tcl/Tk
Oooh that's a tough one, it would depend on the program.
Python is a very different language to Tcl and you would need
to write the code in a Tcl style - don't use an OOP style for
the GUI for example. In fact I'd avoid OOP all together since
Tcl OOP is significantly different to Python OOP and not even
part of standard Tcl.
Its much harder to translate a Python script to Tcl than to
translate Python to C++ or Delphi or even Perl because they
have different underlying philosophies. You could just translate
line by line but the end program wouldn't look like anything
a Tcl programmer would recognise!
> My reason for considering this route is that I have never written
> a single line of Tcl code nor coded a Tk application in the past.
You might like to take a quick run through the basics of my old
Python tutor which used Tcl as a comparison to Python. Its far
from comprehensive but would give a fairly good Python view
> motivation is the greater ease of deployment across systems that Tcl
> to offer, with Starkits and Starpacks
Tcl has several nice features there, but if you just deploy the
scripts its not much different to Python. And since I hate bloatware
I nearly always deploy the scripts and interpreter separately.
> also appears useful to learn, for writing scripts in tclsh, etc.
Tcl is a fun language with a wholeheap of interesting concepts new to
Python programmers. So its definitely worth looking at - and its
nearly always more compact than Python too. Its main limitations
are lack of suitability for large projects and performance. The
latter is relative and if you really need fast code use C!
> typical GUI app is approximately 5 MB in python,
> distributed as a collection of files in a folder,
> whereas a Tcl Starpack is a compact 1 MB
Thats because the Tk GUI is a fairly big DLL including the TCl
interpreter as well as Python! You are effectively distributing
Tcl and Python together....
Author of the Learn to Program web tutor
More information about the Tutor