|[Applications in Tcl and Tcl/Tk%|%previous : Applications in Tcl and Tk]|[Tcl Quoting%|%next : Tcl Quoting]| [http://www.equi4.com/pub/om/pub/tclerswiki.png] [Tcl] and its extensions, [Tk] and [Expect], are powerful tools that allow you greater control over your systems, and easier control of interactions between systems. This the primary starting point for [beginner%|%those looking to learn] Tcl. Is there a topic you feel should be discussed but which often isn't? Add it to one of the categories below! [RS]: A hint not only for beginners: due to its interactive nature, Tcl itself is a very good teacher. Start up an interactive tclsh (i.e. not specifying a script file). Type commands in, see how it reacts. Make intentional errors (you can hardly break anything). Read the error messages, they're very often very helpful. [LV]: I would, however, suggest that they could locate and use [tkcon], if tclsh's minimalistic interface is difficult to use. Also, if you are using ''vanilla'' [tclsh], read up on the [history] command. ** See Also ** [Dodekalogue]: The rules of Tcl [A User's Guide to Tcl/Tk]: [Documentation]: [Tcl Developer Guide]: [Beginning Tk]: Learn to wield the most productive [GUI] toolkit ever [Learn to Program]: The general art of programming introduced from a Tcl perspective [Tcl Commands]: manpage extracts for selected commands - and extra notes that are not in the manual [Advanced Tcl]: topics which usually come up after someone has a grasp on the basics of Tcl and Tk [http://www.purl.org/NET/Tcl-FAQ/%|%comp.lang.tcl FAQ]: contains a list of tutorials ** Preliminaries ** [Getting Started]: [Starter Tcl]: [Show me an example]: a step-by-step walthrough of a first Tcl program [IDE]: [Tcl Editors]: [Is there anything I should know before I start coding]?: ** Where to Ask for Help ** It's always a good idea to search this wiki and the Internet for answers first. If good information is not to be found, the following resources provide information on where and how to ask for help. [comp.lang.tcl]: one of the best places to ask for help. Make sure to read the introduction and posting style guide first. [Tcl Questions and Answers]: [Ask, and it shall be given.]: ** [John Ousterhout]'s Materials ** [John Ousterhout], the creator of Tcl, produced various tutorials, guides, and references, and also the classic book on Tcl. [http://wfr.tcl.tk/fichiers/images/dummymed.jpg] [BOOK Tcl and the Tk Toolkit]: [An Overview of Tcl and Tk]: [An Introduction to Tcl Scripting]: based on John's powerpoint tutorials [Writing Tcl-Based Applications in C]: based on John's powerpoint tutorials [Building User Interfaces with Tcl and Tk]: based on John's powerpoint tutorials [ftp://www.tcl.tk/pub/tcl/doc/tut.tar.Z%|%postscript versions of John's powerpoint tutorials]: [http://www.tcl.tk/doc/scripting.html%|%Scripting: Higher Level Programming for the 21st Century]: IEEE Computer Magazine, 1998-03. The article that layed out [Ousterhout's Dichotomy] ** Books ** [Book Practical Programming in Tcl and Tk%|%Practical Programming in Tcl and Tk]: (in print) [Book Effective Tcl - Writing Better Programs in Tcl and Tk%|%Effective Tcl - Writing Better Programs in Tcl and Tk]: [Book Tcl and the Tk Toolkit%|%Tcl and the Tk Toolkit]: [Book Tcl/Tk How To Program . A Book In Arabic.%|%Tcl/Tk How To Program . A Book In Arabic]: ** Tutorials ** [Online Tcl and Tk Tutorials]: [Tcl Tutorial Discussions%|%discussion page%|%]: ** Beginner Introductions ** [tcltutorial]: a community tutorial [An Introduction to Tcl Scripting]: [What is Tcl]: [Tcl Intro]: [Tcl for beginners]: [Show me an example]: [Talk to me, Tcl]: how to learn using an [Interactive Tcl%|%interactive Tcl] [Unix Shells]: an introduction to Tcl syntax by comparision with Unix shell syntax ** Technical Introductions ** [An Overview of Tcl and Tk]: [An Introduction to Tcl Scripting]: [Intermediate Tcl]: resources at the intermediate level [Advanced Tcl]: resources at the advanced level ** Curricula ** [Tcl for Kids]: [Tcl Learning Exercises]: A list of exercises, in order of difficulty ** Exercises ** [What's My Line?]: a game-like exercise where the goal is to guess the output of the Tcl script [BOOK Programming Language Examples Alike Cookbook%|%Programming Language Examples Alike Cookbook]: Reimplements in other languages, including Tcl, examples from the O'Reilly Perl Cookbook ** Learning Programs ** [TclRobots]: a programming game in which one writes Tcl programs to control a robot which must survive a battle with other robots [Tcl Tutor]: a free, downloadable, multi-platform tutorial for Tcl [Tcltalk]: an interactive learning tool and development environment for Tcl/Tk ** Key Concepts ** The following list might be better suited for some other page, but until a better home is found, it lives here. This is a list of are concepts that have proven vital for a good working understanding of Tcl, and should help to get one's bearings if new to the language: '''The [Dodekalogue] is a fine thing''': A little time invested in digesting the dodekalogue has an enormous payoff. '''[everything is a string%|%Every value is a string] (EIAS)''': Every value in Tcl is a string, and each [command] decides on its own how to interpret the values it receives as arguments. Because every value is a string, Tcl and its extensions often expose external resources and data structures as [handle%|%handles], i.e., a string naming the resource. `[open]`, for example, returns a string that can be used as the handle for an open file. '''Double quotes are not a string contructor''': Every value already is a string. Double quotes, braces, and the backslash character merely escape the special meaning of various characters in Tcl syntax, indicating that whitespace, `$`, or `[`, `"`, `{`, or `\` charactes are a part of the value rather than a special instruction to Tcl. '''Braces are not a [list] constructor''': Rather, a value is a list if it conforms to the prescribed format of a list, which uses braces and the backslash character as needed to distinguish between items in the list and the whitespace delimiting those items. One of the biggest misconceptions among Tcl script authors is that one can cobble together a list by adding values to a string and separating them with whitespace. The technique appears at first to work for a lot of values, but eventually some value that needs proper quoting turns up. Avoid problems by using `[list]` to create a properly-formatted list, and use commmands like `[lappend]` and `[lset]` to manipulate those lists. '''[Brace your expr-essions%|%Brace your expressions]''': If `[expr]` receives one literal string as an argument, its performance is often much better. Also, since `[expr]` does its own variable and command substituion, bracing the arguments to `[expr]` protects against the perils of [double substitution]. '''Prefer `[{*}]` over `[eval]`''': `{*}` is worth understanding from the get-go. '''[Dodekalogue%|%Command substitution] is actually [script substitution]''': An entire script, not just a single command, can go between the brackets. The value of the substitution is the value of the final command in the script. '''An [array] is a collection of variables, while a [dict] is a [list] mapping keys to values''': Both are fit for various purposes in a script, with some overlap. `[dict]` is not intended to replace `[array]`, but rather as another useful feature in its own right. '''Values are [copy-on-write]''': New Tcl programmers are tempted to do gymnastics in their scripts to avoid what they perceive as additional [memory management%|%memory] costs of passing values around. In fact, Tcl doesn't actually copy the value until modification of the value makes it necessary. the [unshared value idiom] can be used to avoid the making of a copy when a value is modified. '''a command that modifies a value takes as an argument the name of the variable holding the value''': This is an example of using a string as a [handle], and is the natural way to design a function whose purpose is to modify some value named by the caller. In contrast, commands that simply use the value without modifying it take as an argument the actual value rather than th name of variable holding the value. This pattern is evident throughout the [Tcl commands%|%built-in] commands. '''Commands often implement [domain-specific language%|%domain-specific languages]''': `[expr]` and `[regexp]` are examples of this. Tcl was designed as a language for creating domain-specific languages, and this idea permeates Tcl scripts and extensions. Many DSL's share the syntax of Tcl. '''[event-oriented programming%|%The event loop] that is built into Tcl is quite handy''': It's a more advanced topic, and usually requires a program to be structured quite differently, but a built-in event loop is one of those things that differentiates Tcl from other scripting languages. It is a good idea to learn to take full advantage of the event loop before turning to threads. Those using [Tk] will find it necessary to get familiar with the event loop in short order. ** Documentation ** ** C API ** [Writing Tcl-Based Applications in C]: ** Instructional Pages, Beginner ** This is a selection of pages deemd to be particularly intructive for learning Tcl idioms and usage. The [Tk] page has a similar section specifically for Tk usage [Arrays / hash maps]: [Tcl Quoting]: [Slurping Up Text in TCL]: [Tcl Gems]: [Braintwisters]: [Bag of Algorithms]: useful code examples [Sample Math Programs]: really simple examples of using programming to solve math problems [The infinity trick]: working with "infinity" in expressions [Tcl examples]: more Tcl examples [Regular expressions]: [Uwe Klein]: a bunch of fairly simple Tcl and Tk examples [Additional math functions]: [Sample math programs]: very simple examples '''if''' you have some math background [How to make a Tcl application]: [What kinds of variables can Tcl scripts use]?: [What kinds of variable names can be used in Tcl]?: [Tcl variable scope - how does Tcl control when a variable is seen?]: [What kinds of data can Tcl scripts use]?: [Is there anything I should know before I start coding]?: [Is white space significant in Tcl]?: [Why can I not place unmatched braces in Tcl comments]?: [How can I do math in Tcl]?: [How am I supposed to handle errors in Tcl]?: [debugging%|%What debugging tools are available to a Tcl programmer%|%]?: [How do I read and write files in Tcl]?: [How can I get input from a user and then safely make use of it?]: [How would I program 'ring around a rosie' - looping constructs]?: [How would I reuse my own Tcl code]?: [What do I need to do to reuse someone else's Tcl code]?: [Concepts of Architectural Design for Tcl Applications]: [I cannot get Tcl (or an extension) to compile]: [Setting /bin/sh environment variables in the script]: [http://tcl.sourceforge.net/engManual.pdf%|%Tcl/Tk Engineering Manual]: by John Ousterhout, engineering style guidelines for coding Tcl code ** Instructional Pages, Intermediate ** [Keith Vetter]: A large number of very interesting but small programs [Syntax parsing in Tcl]: [A simple database]: [Complex data structures]: ** The Art ** [Best Practices]: [Tcl Style Guide]: [Tcl style discussion]: [Guidelines for writing big Tcl applications]: [A critical mindset about policy]: A discussion about what belongs in the scripting language, and what belongs in the lower-level implementation ** Resources ** [Contents]: contents of this wiki [Demo]: Pointers to fun and educational tcl demos. [http://phaseit.net/claird/comp.lang.tcl/fmm.html%|%Frequently-Made Mistakes in Tcl%|%]: by [CL] [Tcl Editors]: how to edit the text of a program [Tcl Tutor]: [Tcl Help]: [gotcha]: a variety of illustrative code snippets [Informal Tcl Book Reviews]: [TCL programs for beginners 1-10]: [Tcl cheat sheet]: [Glossary of terms]: [Acronym collection]: [Tcl-URL!]: [Practice Scripts]: A list of scripts people have written to learn Tcl [Richard Suchenwirth]: a rich variety of Tcl examples dealing with Unicode, dates, graphics, and more [Donal Fellows]: [Arts and Crafts of Tcl-Tk programming]: [Dirty Dozen]: a selection of web resources related to Tcl [Example scripts everybody should have]: [Tcl Articles]: a list of articles about Tcl [Teaching Tcl]: a discussion about teaching Tcl (not really for those learning Tcl) [Common questions about Tcl]: [http://glx.me/docs/3d-egg/Simple-Tcl-Code/%|%Simple Tcl Code << 3D Egg - glx docs]: short and simple learning examples of oo, socket, and coroutine [Expect Exceeds Expectations, Cameron Laird, 2002]: Argues that [Expect] is the one language you most need to learn ** Training ** [http://www.it-schulungen.com/seminare/open-source/tcl-und-tk/index.html%|%IT-Schulungen.com%|%] (German): ** Misc ** [license]: ** Historical ** [http://www.slac.stanford.edu/~raines/tkref.html%|%Tcl/Tk Quick Reference Guide for 8.0%|%]: [http://www.bodenstab.org/%|%Tcl/Tk Quick Reference Guide, updated fo 8.4, by Bob Bodenstab%|%]: ** What Links Here ** <> <> TOC | Tutorial | Arts and Crafts of Tcl-Tk Programming