**What is C?** C [http://cm.bell-labs.com/cm/cs/cbook/index.html] is a programming language found first [http://cm.bell-labs.com/cm/cs/who/dmr/chist.html] on Unix systems but now found on many platforms. The [Tcl] and [Tk] core is written in C. '''C FAQ''': http://c-faq.com/ The ANSI committee as well as the ISO committee have approved a standard reference for C (as well as I believe a few revisions). See http://www.lysator.liu.se/c/ for pointers to various papers. [http://web.archive.org/web/20050207010641/http://dev.unicals.com/papers/c99-draft.html] (big HTML file) seems to be a newer version of the C99 standard than lysator provides. ---- **Compilers** Support for C is traditionally provided by a compiler. The [FSF]'s [gcc] compiler is a quite popular C compiler found on many platforms and operating systems. Also, most Unix systems have vendor supported compilers. They are often unbundled products these days. Sun is one of the vendors who have this type of product. There is also [tcc], the "Tiny C Compiler". [[In the following list, be certain to indicate whether or not you have built Tcl and Tk with the compiler in question.]] On [Microsoft Windows] there are many options, including * Visual C++ from [Microsoft] (commercial) (but, in summer 2003, tclguy says VC7 is "free from ms - it just has the opts turned off" [http://msdn.microsoft.com/visualc/vctoolkit2003/]), [PT] NB: as of Apr 2004 the command line version ''with optimizations'' is now free (see below). * [C++Builder] from [Borland] (commercial; an older command-line version is still available as a free download), * the [Cygwin] C compiler (free; a version of [gcc]; for some strange reason it cannot be used to compile the [Tcl] source code out-of-the-box - but Cygwin comes with its own version of Tcl at least), * the [Mingw] C compiler [http://www.mingw.org/] (free; another version of [gcc] for Windows with goals slightly different from [Cygwin]), * CodeWarrior [http://www.metrowerks.com/MW/Develop/Desktop/Windows/default.htm] (commercial), * Digital Mars C [http://www.digitalmars.com/] (free), which was once Zortech C and later became Symantec C, * LCC-Win32 [http://www.cs.virginia.edu/%7Elcc-win32/] (free) [[Can that compile Tcl itself?]], * Intel C++ compiler [http://www.intel.com/software/products/compilers/] (commercial) * OpenWatcom C++ compiler [http://www.openwatcom.org/] (free?) [[No idea if it can compile Tcl.]] etc. The number of C compilers available on [MacOS] is more limited. There is * CodeWarrior by Metrowerks [http://www.metrowerks.com] (commercial) for [MacOS Classic] and [MacOS X], * Apple's MPW for [MacOS Classic] (free download), * [gcc] for [MacOS X] (free; download from Apple); either used stand-alone or with Apple's XCode IDE (included in the download). * IBM's XL C/C++ for [MacOS X] [http://www-306.ibm.com/software/awdtools/vacpp/features/xlcpp-mac.html] (commercial), intended to be optimized for recent machines. **Interpreters** Support for C can also take the form of an interpreter. For instance, a recent advertisement for Ch, a product at http://www.softintegration.com/ , is interesting. It is a C/[C++] interpreter that runs cross-platform on a large number of operating systems and hardware. It provides not only standard language features, but also support for 2 and 3 dimensional plotting, shell programming, and numerical programming. It supports 1990 ISO C standard as well as C99 features. In Jan, 2003, the product page for Ch Standard says that the product is free for use on Unix, Linux, and Mac OS X. See also EiC [http://eic.sourceforge.net], another C interpreter. See as well CInt (free) from Masaharu Goto originally apparently maintenance was taken over by the CERN Root team which uses CInt as its scripting language (http://root.cern.ch/root/Cint.html) I do not know if [Tcl] can be interpreted under this interpreter [RFox]. **Linkable Compilers** Support for C can also take the form of a run-time compiler. [tcc] provides a libtcc library, which allows a running program to compile and link C code without touching disk. In milliseconds for a small chunk of code. (x86 only as of Jun 2003) - see also [Odyce]. ---- **Annoying things about C** [AMG]: One annoying thing about C is that, like [Fortran], it uses "'''='''" as its assignment operator. This is very easy to confuse with the comparison operator "'''=='''", resulting in either of the following two coding errors: x == 5; /* Nothing happens, except maybe a warning if -Wall is on. */ if (x = 6) {...} /* Unintended assignment and incorrect logic. */ [Algol] uses "''':='''" as its assignment operator, and [C] is ancestrally derived from [Algol], so I was always mystified about why [C] reverted to [Fortran]'s assignment syntax. But I just now figured it out, I think. A "''':='''" assignment operator looks almost identical to C's "'''!='''" inequality operator, so using "''':='''" instead of "'''='''" for assignment simply trades one potential coding error for another. To fix ''that'' problem, "'''!='''" would have to be replaced with, say, "'''/='''" (borrowed from [Ada]), but that (1) collides with the compound division and assignment operator "'''/='''" and (2) breaks symmetry with the logical negation operator "'''!'''". Or instead use "'''\='''", but that will behave unexpectedly when placed inside double quotes. Or use "'''<>'''" and be like [BASIC] and [SQL]. Shrug! ---- **Questions about C vs Tcl** How does performance in Tcl compare to comperable programs in C? For instance, certainly there are types of programs which can likely be developed more quickly in Tcl than in C. Are there types of things that '''run''' faster in Tcl than C? If not, how much slower than C is Tcl? 10 times slower? 50 times slower? 100 times slower? ---- **Miscellaneous Thoughts** [AMG]: I just thought of a cute alternate name for C: "lightspeed". You know, 'cuz physicists use the constant "c" to represent the speed of light. :^) I leave it up to you to figure out if this name has any deeper meaning. At least it would give C an excuse to have a snazzy, energetic theme song: [http://www.ocremix.org/remix/OCR01160/]. ---- **Related Topics** * [What 'embedding' means] * [How to embed Tcl in C applications] * [Adding Tcl/Tk to a C application] * [Extending Tcl] * [Writing Tcl-Based Applications in C] * [Building a custom tclsh], [Tcl_Init], [Init Scripts in the DLL] * [Tcl interpreter in C# Application] * [Adding Tk to an Existing Xt Program] * [Mixing Tcl/Tk and Xt Event Loops] * [Using Xlib With Tcl/Tk] * [3D Text for Tk in Unix] * [C compiled image processing on an interactive Bwise canvas] * [automatically generating socket based Tcl / C connection code, 1], [automatically generating socket based Tcl / C connection code, 2, using bwise] * [Connecting Tcl/Tk with GNUstep Objective-C programs] * [Building Tcl with the free VC++ toolkit] * [How to invoke a C function from Tcl] * [Tcl and other languages] * [Critcl] * [C code generators] * [C Language] ---- !!!!!! %| [Category Language] |% !!!!!!