D. A. Clarke
831 459 2630
(you will have difficulty reaching me by phone; recommend you use email)
I don't give out my home phone number.
Misc applications programming, sysadmin, network engineer, scientific applications, database applications, realtime control, test suites. 20 years in various software positions at Lick Observatory (Univ. of CA).Tcl programmer since fairly early days of the language; not a founding community member but one of the older turks. Have written mid-to-large projects in Tcl/Tk since 1990 or so, mostly database apps and realtime machine control apps. Presented papers/posters at each of the last few Tcl conferences; co-chair of Tcl/2K Usenix conference in Austin TX. Author of 1 chapter in O'Reilly book 'Tcl/Tk Tools'. My chapter was on TclX and should constitute the "published writing sample" on similar topic required by the proposal guideline. An unpublished writing sample on Tcl and database applications has already been submitted to Gretchen.
See my home page for information about Tcl projects, published papers, etc.
I. Book Contents
What I would try to do with a book of this kind is show the reader that Tcl/Tk is a *friendly* language, as friendly as BASIC but much more powerful; that even a person without a computer science degree or a formal software engineering background can write useful and even fairly sophisticated applications using tcl/tk, and that applications can be tested and deployed very quickly using this language. In particular, that a rather important kind of application, i.e. data mining/management/visualization apps, can be quickly and easily built and tested using tcl/tk.
While trying to write about programming for the ordinary person, I'd still want to stress bread-n-butter "good coding" practises, because these are as much for the programmer's own good as for compliance with some abstract standard or management-enforced style guide.
I'd like to stress the practical aspect, as in Brent's excellent book, but use the pedagogical model of building an entire functioning app rather than presenting many unrelated code fragments as examples.
The first chapter of this book is for the absolute beginner, the person who has never written a line of code. It will explain, at a non-expert level, the meaning of basic programming language concepts like 'variable,' 'subroutine,' 'scope,' 'interpreter,' 'compiler,' 'boolean expression,' 'array,' 'sort,' 'argument,' 'GUI,' and so forth.
Many readers, however, will have written some code at some time in some language, whether it was a shell script, a complicated Excel macro, or a massive FORTRAN card deck back in the Middle Ages. These readers can skip the first chapter and get right to work. For the rest of the book, a basic understanding of the concepts and terms in the first chapter will be assumed.
For all readers, I assume that you know how to load software from a CDROM or from a web site onto your target machine, and that you know what an operating system is. You should have a text editor with which you can create plain text files, and you should understand what a command line is and how to type commands on a command line.
I assume that you have not programmed in Tcl/Tk before, or that you never got past "hello world" when you tried it. I assume that you want to know not only the bare syntax of a new language, but what particular strengths the language has and what approaches to a problem are best suited to it. I assume that you have never designed a GUI before, or that you have designed one only with point-drag-n-click tools, without understanding the underlying code. I assume that you want to know more about GUI design and the philosophy behind successful GUIs. I assume that you may never have written a complete small application before (i.e. more than 1000 lines of code) and that you may not be familiar with code management tools, good documentation practise, or the maintenance of moderate to large bodies of source.
Sorry, I am hopeless at estimating page counts. If you guesstimate 20-30 pages per chapter, there seem to be about 14 chapters in this rough outline, and that would come out to 300-350 pages more or less, exclusive of indices, appendices, etc.
The idea is to guide the reader through the creation of a series of simple, basic applications. No application will be ambitious in scale, but each one will teach a few basic concepts and be either useful in itself, or easily adaptable for the reader's use. Basic concepts of automation and event processing, as well as data retrieval and massaging, will be covered.
what is tcl/tk? who is the author and what is this book? what will it cover? what will it not cover? how will it be structured? how to read the typographical conventions why is tcl/tk easy to use?
how to start the interp wish vs wishx refer non programmers to Appendix A? your first tcl/tk program (hello world): button .b -text "Hello World" -command "puts stderr {That was easy}" pack .b (don't worry about understanding these 2 lines of code, all will be explained in a moment) basic syntactic conventions of tcl evaluation quoting, magic chars basic data types mention this will be discussed more later simple math puts, gets (command line i/o) getting to an OS command "outside" system, exec (Windows equiv???) sample script demonstrating the basics get the process table via ps auxww. *hmm, no Windoze equiv?* *how about a directory scrape then?*
an overview of specific tcl programming commands flow control (if, while, loop) debugging (stderr out, errorInfo) error handling (catch) tcl help facility tclX commands why it's quick to develop in tcl/tk using basic shell/command line tools ability to check out commands interactively collapse the edit/compile/test cycle sample mini-app using these commands, developed quickly :-) test commands interactively edit script from tcl command line this could be a copy of will's nice ps getter.
(more about data types) lists keyed lists (tclx) math functions string functions procedures the source command here we could model attribs of processes (or of files) using lists... procedurize mini-app, i.e. start breaking code into procedures (function/subroutine chunks) we are going to lose this mini-app at some point, probably at the end of the next chapter, and pick up a different one which uses files.
slightly more advanced functions string modification/manipulation list modification/manipulation recursive evaluation (eval) the dreaded regexp command canned procedures (provided on cdrom) incorporate a couple of these features into mini-app and call it done, time to move on to something different.
file i/o open for op, error handle handy read_file for_file functions in tclx writing to files mini app using input from files: a set of numbers? how about the web stats file from an Apache server? a strength of interpreting languages: code is data mini app that reads a file and writes a report or other output based on data from the file + user input maybe have it write HTML source :-) we need a good file... web stats log is not a bad idea, it keeps us in online-data-land, mentally...
putting a GUI on it (at last!) very basic GUI lego blocks entry box push button menu label turn script from ch 5 into simpleminded GUI app pack, grid (simple and basic, no tricky stuff) binding of variables to graphical items, which leads us to basic variable scoping, management of variables (refer to namespace as an advanced command for larger apps, not for this book) simple app that shows stats for any page or group of pages, based on file?
Here we have a hard time being generic. I would always use Sybase as my example, but stick strictly to ANSI SQL-92 syntax so the user could use the same commands with any compliant RDBMS... some weasel language will be required here, considerable introduction. outline the basic SQL commands: connect, submit SQL query, retrieve row examples of a simple query from a simple table examples of (a) importing TSV data into a table, but with a little editing on the fly (say, adjusting the pkey field for sequence and uniqueness), (b) exporting the data back out (as HTML, or as tsv, or both).
more about GUIs (down to business) superficial GUI design principles (more later) more lego blocks to play with: checkbutton radiobutton listbox textbox scrollbars grid appearance controls debugging tool: tkinspect more on packing, esp. padding facelift for the sample app: add listbox/menu for user to pick item from database, show how GUI items can reconfigure themselves on the fly as different data sets are retrieved
we take a break from new app code and make a digression into... introspection, a strength of tcl/tk how does "smartness" in the app save time and effort for the programmer/user? work around version incompats widgets state and attribs how can you 'explore' tk widgets using introspection this is how tkinspect works! avoid hard coding and use introspection wherever possible examples of smart little introspective tricks (the chameleon trick from dashboard comes to mind, have to think of some more)
Let's scrape a remote Web page! pick a target web page (the bus schedule app is quite reasonable, it's the right size, and the metro pages may still look the same by the time the book hits print). scrape it, and do something with the data... in fact, show the rest of the bus app, including the cgi-bin that permits users to look up the current sched. A dead simple little cgi app that shows how you can use tcl on both ends, server-side apps and client-side scrapers.
recap progress so far and refine principles: event handling, response to user events data storage, mapping data to screen widgets modelling real world function in code reality-to-data data-to-GUI event-to-action action-to-visual-feedback show alternate ways of achieving same result introduce trace command can we somehow make a RT GUI that also talks to remote HTTP and scrapes? what remote HTTP changes often enough to warrant RT surveillance? obviously, UGH, stock quotes... or weather... yeah, I could make a combined weather UI for my local area, scraping 6 different weather pages, and offering various user features. aha, yes, we could actually log the weather to a file or database, keeping history. then we'd have numbers to go back and get later for plotting. [I wonder if this ch should be combined with ch 8, or is that too much for one chapter?]
now the apps we're making are getting bigger, so let's mention... managing code code legibility code re-use versioning (cvs refs) documentation the tone here needs to be modest, not hectoring, and not stifling (as in ISO9000) -- just plain common sense and "applied laziness".
back to work on an app! now, when this was a jukebox, we had a good reason to make an event queue, fork processes, etc. I cannot at this moment think of any reason to do this kind of sequence stuff for data management apps. this is now an ORPHAN chapter, with no immediate relevance to the new book topic. it might have to go. more event handling, response to asynchronous external events process fork + process synchronize (linux only) vs tk send command, apps communicating with one another remember ch 5? data is code, too :-) what is a queue? how to manage a queue synchronization and asynch commands after (timer) tkwait show use of introspection
more discussion of GUI design; ref Tufte look and feel consistency use of X resources (no idea what Windoze equiv is) online help, "warm and fuzzy" features that make an app more attractive and easier to use maintainability, abstraction mention megawidgets but these are outside scope of book but shouldn't we design from the top down, as opposed to building up from the bottom as we have so far? most effective to do both at once! tcl ideal for this. error logging, other logging issues revise previous simple GUI based on these rules
overview of VU widgets and BLT (what about Bwidgets?) Pie chart, Bar chart, Strip Chart, Dial gauge, Plot. The basic tools of data visualization. Mine some of the weather data back out of the database and plot it? why not? we could end with a semi-finished app that talks to a database, talks to a remote HTTP server, and plots data on the screen in various forms. is weather data really the best we can do? well I guess we could scrape pricewatch for product pricing... ick. with weather, trends are more interesting. and the weather data are relatively easy to scrape...
Tcl/Tk Famous Newbie Errors, Gotchas performance considerations any nifty tricks suitable for beginners but not already demonstrated fun tcl tricks to try
Tcl/Tk resources in print and online, where to go for more advanced topics, where to go to see more interesting and diverse tcl/tk apps, list of the most popular tcl/tk extensions and what they do. what's an extension why are extensions good where can you get them how do you use them web and print bibliography incl screen shots of tcl apps by author?
for non-programmers only; you can skip this text if you have written code before definition of most fundamental concepts and terms variable, evaluation expression (incl boolean) flow control (while, loop, if, else) scope procedure/subroutine array, list i/o GUI, interactive, noninteractive, synchronous, asynch ascii/binary interpreter, compiler argument
I want to include some kind of disclaimer like
This is a book for beginners; hence a number of interesting Tcl/Tk topics are outside its scope. This is not a book about object-oriented programming technique. There are other books about OO programming in Tcl/Tk. This is not a book about benchmarking or benchmark design. Tcl internals will not be mentioned except in brief, oblique references. This book will not teach you how to write a Tcl extension, but it will discuss the utility of Tcl extensions and how to make use of them, and we will use a couple of the most popular ones. This is not a book about CGI programming, although some HTTP client code will be used.
Other concerns (some have already been discussed in email but I wish to keep them fresh)