Purpose: contrary to the title, the aim of this page is to present some opinions on why adding Tcl (and possibly also Tk) to a C/C++ is a bad idea (IMO -jcw). ---- The following questions tend to be asked regularly on the comp.lang.tcl newsgroup: * ''I have a large C program, how do I make it scriptable with Tcl?'' * ''I have a large C program, how do I add a Tk GUI to it?'' Unfortunately, they reflect a deep misunderstanding of what scripting is about. Suppose one were to ask: I've built this great wooden desk, how do I make it adjustable? or: I have a great room. How do I add a nice outside view to it? The trouble, of course, is that the order of questioning is reversed. The same goes for scripting, the point of which is that a program has structure at various levels, and consist of different types of coding. With scripting, the insight is that at the higher levels, performance is far less relevant than structural flexibility and the ability to evolve applications as development progresses. On deeper levels, the opposite is true: algorithms are pretty well fleshed out, and one needs all the speed one can get. Hence the concept of having a main application as a scripting environment, with specialized parts inside coded as extensions, usually in C or C++. '''Build in Tcl/Python/whatever. Fill in the inner pieces in C/C++.''' When faced with the task of adding Tcl/Tk to a C/C++ program, the best advice one can give is: throw out your "main()", quickly define all the rest as one or more extensions, and get going again quickly with tclsh or wish or tclkit. If nothing else, the hours spent making this transformation will be the start of the most productive phase of your development work. Really. If you disagree, the next best advice I think I can give is: stay away from Tcl and Python and Perl, and have a look at scripting tools such as Lua, which still take the perspective that scripting can be slapped on to existing code. That may well be true, but the fact is that for languages such as Tcl and Python, most people have long given up on the perspective that scripting is something you slap on as an afterthought. The reality is that scripting is not an add-on, but that C/C++ is. You can agree with it or fight it. ''Your choice...''