1 - Introduction
Scripting can only get you so far. Often the last 5-10% of an application needs to be compiled, for a number of reasons, including
Fortunately, it is relatively easy to add C extensions to Tcl, either by building custom interpreters or dynamically loadable extensions. But it is still a complex issue - not only does one have to deal with tools such as autoconf, make, etc. - but it also means having a development environment configured with Tcl/Tk header files and "stub libraries". The conceptual difference between "writing a bit of C code" and having an extension which is actually callable from a Tcl script can be daunting. Worse, the Tcl build environment is somewhat foreign to those building on a Windows platform (TEA is not everyone’s cup of tea). Yes, "real programmers" will point out that this is what it takes to do "true" programming. But for many who are used to the productivity of Tcl it can easily become a frustrating and time-wasting exercise.
This paper describes Critcl - which stands for "Compiled Runtime In Tcl" - a tool designed to address these issues. Critcl allows C code to be embedded in Tcl scripts, (transparently) compiled and called like any Tcl procedure.
Critcl also takes care of many of the details of building compiled extensions, hiding issues such as including Tcl headers, stubs support and creating Tcl commands for C functions - even setting up fully TIP 55 compliant packages in a directory, with a cross-platform pkgIndex.tcl ready to go.