Where Tcl and Tk Went Wrong
I've been pondering this subject for a while, and I think I'm finally ready to write about it.
Tcl was, for many years, my go-to language of choice. It's still near and dear to me in many ways, and I even worked on a portion of a book about it ( http://journal.dedasys.com/2009/09/15/tcl-and-the-tk-toolkit-2nd-edition ).
However, examining what "went wrong" is quite interesting, if one attempts, as much as possible, a dispassionate, analytical approach that aims to gain knowledge, rather than assign blame or paper over real defects with a rose-colored vision of things. It has made me consider, and learn, about a variety of aspects of the software industry, such as economics and marketing, that I had not previously been interested in. Indeed, my thesis is that Tcl and Tk's problems primarily stem from economic and marketing (human) factors, rather than any serious defects with the technology itself.
Before we go further, I want to say that Tcl is not "dying". It is still a very widely used language, with a lot of code in production, and, importantly, a healthy, diverse, and highly talented core team that is dedicated to maintaining and improving the code. That said, since its "heyday" in the late 90ies, it has not ... "thrived", I guess we can say. I would also like to state that "hindsight is 20-20" - it's easy to criticize after the fact, and not nearly so easy to do the right thing in the right moment. This was one reason why I was reticent to write this article. Let me repeat that I am writing it not out of malice or frustration (I went through a "frustrated" phase, but that's in the past), but because at this point I think it's a genuinely interesting "case history" of a the rise and gentle decline of a widely used software system, and that there is a lot to be learned.
At the height of its popularity, Tcl was up there with Perl, which was the scripting language in those days. Perl, Tcl, and Python were often mentioned together. Ruby existed, but was virtually unknown outside of Japan. PHP was on the rise, but still hadn't really come into its own. Lua hadn't really carved out a niche for itself yet, either. Tcl is no longer one of the popular languages, these days, so to say it hasn't had problems is to bury one's head in the sand: it has fallen in terms of popularity.
To examine what went wrong, we should probably start off with what went right:
- Tk. This was probably the biggest draw. Easy, cross platform GUI's were, and are, a huge reason for the interest in Tcl. Tk is actually a separate bit of code, but since many of the widgets are scripted in Tcl, the two are joined at the hip. Still, though, Tk is compelling enough that it's utilized as the default GUI library for half a dozen other languages.
- A simple, powerful language. Tcl is easy to understand and get started with. It borrows from many languages, but is not an esoteric creation from the CS department that is inaccessible to average programmers.
- Easily embeddable/extendable. Remember that Tcl was created in the late 80ies, when computers were orders of magnitude less powerful than today. This meant that fewer tasks could be accomplished via scripting languages, but a scripting language that let you write routines in C, or, conversely, let the main C program execute bits of script code from time to time was a very sensible idea. Tcl still has one of the best, and most extensive C API's in the game.
- An event loop. Lately, systems like Python's "twisted", and node.js have made event-driven programming popular again, but Tcl has had it for years.
- BSD license. This meant that you could integrate Tcl in your proprietary code without worrying about the GPL or any other legal issues.
These features led to Tcl being widely used, from Cisco routers to advanced television graphics generation programs to the AOLserver web server, which was busy serving out large quantities of dynamic web pages when many of us were still fiddling around with comparatively slow and clunky CGI programs in Perl. Note also that there have been a lot of cool things to have gone into Tcl in the mean time. It has a lot of impressive features; many more than most people realize, and has had a lot of them for a while. Check out http://www.tcl.tk to learn more about the "good stuff". But that's not the point of this article...
There was a healthy, active community of developers producing lots of interesting add-ons for the language, and working on the language itself. This culminated in its adoption by Sun Microsystems, which hired the language's creator, Dr. John Ousterhout, and a team of people, who added a lot of great features to the language. Quoting from Ousterhout's history of Tcl page:
The additional resources provided by Sun allowed us to make major improvements to Tcl and Tk. Scott Stanton and Ray Johnson ported Tcl and Tk to Windows and the Macintosh, so that Tcl became an outstanding cross-platform development environment; Windows quickly came to be the most common platform. Jacob Levy and Scott Stanton overhauled the I/O system and added socket support, so that Tcl could easily be used for a variety of network applications. Brian Lewis built a bytecode compiler for Tcl scripts, which provided speedups of as much as a factor of 10x. Jacob Levy implemented Safe-Tcl, a powerful security model that allows untrusted scripts to be evaluated safely. Jacob Levy and Laurent Demailly built a Tcl plugin, so that Tcl scripts can be evaluated in a Web browser, and we created Jacl and TclBlend, which allow Tcl and Java to work closely together. We added many other smaller improvements, such as dynamic loading, namespaces, time and date support, binary I/O, additional file manipulation commands, and an improved font mechanism.
Unfortunately, after several years, Sun decided that they wanted to promote one and only one language. And that language was Java. So Ousterhout and many people from his team decamped to a startup that Ousterhout founded, called Scriptics, where the Tcl and Tk innovations continued:
In 1998, Scriptics made several patch releases for Tcl 8.0 to fix bugs and add small new features, such as a better support for the [incr Tcl] extension. In April 1999, Scriptics made its first major open source release, Tcl/Tk 8.1. This release added Unicode support (for internationalization), thread safety (for multi-threaded server applications), and an all-new regular expression package by Henry Spencer that included many new features as well as Unicode support.
However, as many a company based around open source was to find later, it's a tough space to be in. Scriptics changed its name to Ajuba, and was eventually sold (at a healthy profit, apparently, making it a relative dot com success story, all in all) to Interwoven, for the "B2B" technology that Ajuba had developed. Interwoven was not interested in Tcl, particularly, so, to create a system for the ongoing development and governance of the language, the "Tcl Core Team" was created.
This was something of a blow to Tcl, but certainly not fatal: Perl, Python, Ruby, PHP, Lua have all had some paid corporate support, but it has by no means been constant, or included large teams.
At the same time in the late 90ies, open source was really starting to take off in general. Programmers were making all kinds of progress, and had begun to make Linux into what is today the world's most widely used server platform, and laying the groundwork for the KDE and Gnome desktops. While these may still not be widely used, they are for the most part very polished systems, and leaps and bounds better than what passed for the 'Unix desktop' experience in the 90ies.
One of the key bits of work that was added to Tk was to make it look pretty good on Microsoft Windows systems. This was in an time when the "enterprisey" folks were turning away from Unix in the form of AIX, Solaris, HPUX, et al. and taking up NT as the platform of choice, so it was in some ways sensible to make Tk work well there, and in any case as a cross platform GUI toolkit, it ought to work well there in any case.
And, on the Unix side, Tk emulated the expensive, professional Motif look and feel that serious Unix programmers used. What could go wrong?
As Gnome and KDE continued to mature, though, what would become one of Tk's major (in my opinion) marketing blunders took root. I have it on good authority, from someone who was there in the office, that the Scriptics guys working on Tcl and Tk viewed Gnome and KDE (and the Gtk and Qt toolkits) as not really worth their while. To be fair, since Tk has always been under a liberal BSD style license, the Qt toolkit has always been "off limits". Still, though, the attitude was that Tk was a standalone system, and since it ran on pretty much any Unix system, it didn't need to bother with Gnome or KDE. Gradually, though, as more and more people used Gnome and KDE exclusively on Linux, the Tk look and feel began to look more and more antiquated, a relic from the 1990ies when Motif (which has since pretty much disappeared) was king. Tk applications started to really stand out by not looking at all like the rest of the operating system. And, while Linux may not be responsible for a vast portion of the world's desktops, it is widely used by developers, who were turned off by the increasingly creaky look of the Tk applications they saw.
Tk is and was actually a fairly flexible system, and it would have been possible to tweak the look and feel to make it look a bit better on Linux, without even doing any major work. Maybe not perfect, but certainly better looking. Nothing happened, though.
Another problem was that Tk and Tcl made it so easy to create GUIs that anyone could, and did, despite, in many cases, a complete lack of design skills. You can't particularly blame the tools for how they're used, but there was certainly a cultural problem: if you read most of the early Tcl and Tk books, and even many of the modern ones, there are hundreds of pages dedicated to exactly how to use Tk, but few to none explaining even basic user interface concepts, or even admonitions to the user to seek out that knowledge prior to attempting a serious GUI program.
The end result is that a lot of Tk programs, besides just looking "old fashioned" had fairly poor user interfaces because they were made by programmers who did not have a UI/design culture.
Contrast that with Gnome and KDE, which have made a point of focusing on how to make a good GUI for their systems, complete with guidelines about how applications should behave. It may have taken them some time to get things right, but they have done a lot to try and instill a culture of creating high quality, well-integrated GUI's that are consistent with the system where they run.
Lately, there has been a lot of work to update the Tk look and feel, and it has finally started to bear fruit. However, in terms of marketing, the damage has already been done: the image of "old, crufty Tk" has been firmly planted in countless developers' minds, and no amount of facts are going to displace it in the near future.
Another problem Tcl faced, as it grew, was the tug-of-war between those wishing to see it small, light, and easy to distribute embedded within some other program, and those wishing it to become a "full-fledged" programming language, with lots of tools for solving every day programs. Unfortunately, that tug of war seems to have left it somewhere in the middle. Lua is probably more popular these days as an embedded language, because it is very small, and very fast, and doesn't have as much "baggage" as Tcl. Meaning, of course, that it doesn't do as much as Tcl either, but for a system where one merely wishes to embed a scripting language, without much 'extra stuff', Tcl's extra functionality is perhaps a burden rather than a bonus. On the other hand, while Perl was happily chugging along with their CPAN system for distributing code, giving users easy access to a huge array of add-on functionality, and Python was building up a "batteries included" distribution, that included a lot of very useful software straight out of the box. Tcl, on the other hand, chose to keep the core distribution smallish, and only lately has got some semblance of a packaging and distribution system, that is, however, run by ActiveState, and is (at least according to a cursory glance at the Tcl'ers wiki), not even fully open source. The lack of a good distribution mechanism, and, in the meantime, eschewing a larger, batteries-included main distribution left Tcl users with a language that, out of the box, did significantly less than the competition. Technically, a Python style "big" distribution would not have been all that difficult, so once again, I think this is a marketing problem: a failure of the Tcl Core Team to observe the "market", assess what users needed, and act on it in a timely manner.
Somewhat related to the large Tcl vs small Tcl issue was one particular extension, or extensions to the language that was noticeably absent: a system for writing "object oriented" code. Tcl, at heart, will never be an OO language through and through, like Ruby or Smalltalk, but that doesn't mean that an OO system for it is not a useful way of organizing larger Tcl systems. Indeed, Tcl's syntax is flexible enough that it's possible to write an OO system in Tcl itself, or, optimizing for speed, utilizing the extensive C API in order to create new commands. Over the years, a number of such systems have arisen, the most well-known being "Incr Tcl" (a play on the incr command, which is akin to += 1 in languages like C). However, none of these extensions was ever included with the standard Tcl distribution or somehow "blessed" as the official OO system for Tcl. This meant that a newcomer to Tcl wishing to organize their code according to OO principles had to pick a system to use from several competing options. And of course, newcomers are the least able to judge a complex feature like that in a language, making it a doubly stressful choice. Furthermore, even experienced Tcl programmers who wanted to share their code could not utilize an OO system if they wanted their code to work with just standard Tcl. Also, if their code had a dependancy on some OO system, it would require the user to download not only the extension in question, but the OO system it was built on, which, naturally, might conflict with whatever OO system the user had already selected! As of Tcl 8.6, thanks to the work of Donal Fellows, Tcl is finally integrating the building blocks of an OO system in the core itself, but this effort is probably something like 10 years too late.
Some other more or less minor things that have taken too long to get integrated in the Tcl or Tk distributions include the PNG format (still not there in a production release of Tcl), a readline-based command line (Tkcon is nice, but not a replacement for simply being able to type "tclsh" and get a nice, functional shell like Python, Ruby and most other languages have. This could easily lead to a bad first experience for someone trying out Tcl). Tcl also took too long to integrate a first-class hash type (accessed with the 'dict' command), which only appeared in 8.5. Its "arrays" aren't bad, but don't quite have the full power of a hash table as dict implements them. Once again, the code to do these things was/is out there, it has just been a matter of integrating it into Tcl and Tk, which has been a slow process.
One actual technical problem that Tcl faces is the concept that all values must be representable as a string. This is more or less ok for things like lists, hash tables or numbers, but is problematic when the user wishes to represent a value that simply isn't a string. A basic example is a file handle, which at the C API level is a FILE*. How does Tcl get around this? It keeps an internal hash table with a Tcl-script accessible string, such as "file5" that points to a FILE * value that is used internally by file commands. This works pretty well, but there is a big "but": since you can compose a string like "file5" at any time, that must be able to access the actual file pointer, you can't do any sort of "garbage collection" to determine when to clean things up automatically. Other languages have explicit references to resources, so the program "knows" when a resource is no longer referenced by the rest of the program, and can clean it up. Therefore, the programmer must explicity free any resources referenced this way. This explanation is simplifying things somewhat, but it is something I view as a technical problem with Tcl.
If you've been following along, you've noticed a lot of "these days" and "recently". That's because Tcl is still very actively developed, with a lot of new ideas going into it. However, if you look at the release dates, it seems that after Ajuba was sold off, and Ousterhout pretty much abandoned an active role in the language for good, placing it in the hands of the Tcl Core Team, there was a lull in the momentum, with Tcl 8.5 taking 5 years to be released.
This is actually, in my opinion, an interesting phenomenon in languages: you risk hitting some kind of local maximum when your language is popular enough to have a lot of users who will be angry if things are changed or accidentally broken in the course of big upheavals. So you have to slow down, go carefully, and not rock the boat too much. On the other hand, there is an opportunity cost in that newer languages with less to lose can race ahead of you, adding all kinds of cool and handy new things, or simply fix and remove "broken" features. Erlang is another system that has, in my opinion, suffered from this problem to some degree, but this article is long enough already! Once again, though, not really a technical issue, but a problem with how the code was managed (and not an easy one to solve, at that).
A Tcl failure that I was personally involved with was the web infrastructure. What went on to become Apache Rivet was one of the first open source Apache/Tcl projects, and was actually quite a nice system: it was significantly faster than PHP, and of course made use of Tcl, which at the time had a large library of existing code, and could be easily repurposed for projects outside the web (or the other way around: non-web code could be brought in to a web-based project). One thing I ought to have done differently with the Apache Rivet project was listen to the wise advice of Damon Courtney, my "partner in crime" on the project, who wanted to see Apache Rivet have a fairly "fat" distribution with lots of useful goodies. Rails and Django, these days, have shown that that's a sensible approach, rather than relying on lots of little extensions that the user has to go around and collect. The code was out there, I should have helped make Rivet do more "out of the box".
A problem that is and it isn't: the syntax. Tcl's syntax is amazingly flexible. Since everything is a command, you can write new commands in Tcl itself - and that goes for control structures, too! For instance, Tcl has a "while" command, but no "do ... while". It's very easy to implement that in Tcl itself. You simply can't do that in most "everyday" languages. However, this comes at something of a "cost". The syntax, for your average programmer who doesn't want to go too far out of their comfort zone, is perhaps a little bit further afield from the C family of languages than they would prefer. Still though, a "human" problem, rather than a technical one. Perhaps, sadly, the message is that you'd better not "scare" people when introducing a new language, by showing people something that doesn't look at least a little bit familiar.
Conclusions? First and foremost, that, gradually, Tcl and Tk continue to be improved. However, if one visits developer forums, there are also a lot of negatives associated with the Tcl and Tk "brands", and I am not sure if it will be possible to rectify that. So what can we learn from the rise and subsequent "stagnation" of Tcl?
- Success in the first place came from doing one particular thing very well, and making it a lot easier than other existing systems at the time. That's a good strategy.
- Not staying up to date can be deadly. Of course it can be tricky to know what's a genuine trend, and what's just a fad, in this industry, and picking the right things to stay up to date with can be tricky. That said, there are a number of areas where Tcl and Tk failed to follow what became very clear directions until way too late.
- Do your best not to get trapped between existing users who don't want to rock the boat, and don't lose your agility and ability to iterate with the system you're developing. Long delays between releases can be deadly.
- Don't lose touch with your "roots". In this case, the open source community that is a "breeding ground" for new developers and projects. Tcl and Tk became passe` in that environment, which has led to its lack of adoption for new projects not only in the world of open source, but in businesses as well.
- Don't isolate yourself: Tcl and Tk stopped appearing at a lot of the open source conferences and events and in magazines/books/articles online, either because with no figurehead/leader to invite there was less interest in speakers and authors, or because the rest of the Tcl Core Team wasn't particularly engaged, or for whatever other reason. This created something of a negative feedback loop where Tcl and Tk were things associated with the past, rather than something currently talked about and discussed.
Trackbacks
Use the following link to trackback from your own site:
http://journal.dedasys.com/trackbacks?article_id=2180
-
This post was mentioned on Reddit by davidw: After seeing the recent thread about Tcl and Tk, I decided it was finally time to write up some of what I saw go wrong with Tcl and Tk.
-
Ενδιαφέρουσα ανάλυση της ανόδου και πτώσης μιας γλώσσας: http://journal.dedasys.com/2010/03/30/where-tcl-and-tk-went-wrong
about {{count}} hours later:
David,
Good article. I think it summarizes Tcl/Tk very well, and I agree with you observations. I think Tcl/Tk still have a future, but have a steep hill to climb.
Cheers
about {{count}} hours later:
Interesting read, David. Nice to see an even-keeled view from somebody in a position to know. I think the biggest obstacle Tcl faces is psychological, in the sense of having "the world" realize it's a viable choice when deciding on a dynamic language. I too believe Tcl has a future, and look forward to seeing it (re)acquire it's deserved credit.
about {{count}} hours later:
expect!
about {{count}} hours later:
I will probably start a project with Oracle Business Intelligence and was surprised to find out that Tcl is the language used for scripting the OWB. My first thought was why not javascript, python, Lua? I guess marketing issues exist indeed.Either way I will have to learn some Tcl...Who knows, I may even like it.
about {{count}} hours later:
I ran a company based around using TCL for web production in the late '90s through mid-2000's.
I agree that the popularity factor mattered, and Tcl certainly was not as cool as Ruby, say, but having paid many many developers to learn Tcl over the years, I think that the language itself was part of the problem.
Tcl is procedural, but reads almost like Lisp sometimes: maintainability is a huge problem for a significant body of code. As you mention in your essay, you could bolt on an OO-alike setup in Tcl, but nothing we used was a first class object/class system, frustrating the object-oriented programmers we hired.
"everything is a string" meant you were constantly building type-checking tools, and probably constructing your own mix of strong and weak typing setups for your large application.
My experience was that programmers hated learning Tcl, found the language a bad mix of high and low-level (meaning, not low-level enough to do some things well, but not high-level enough to have any magic), and didn't have great job prospects at the end of the day when they'd moved on.
I did love some things about Tcl, it really was highly flexible, (writing a program that modified your own procs to auto-type-check and throw polite errors was reasonably easy, for instance), but in the end, I don't miss Tcl at all, and since I left that company, I have never once wished I could do a project in Tcl.
I think what could possibly rescue Tcl would be a sort of Rails-level leap in "magic" for some specific applications -- that would be enough to grab programmers to the system, where they could then be pleasantly surprised at how extensible the Tcl system is.
This would require some people who don't need a future in programming to do though, or who are willing to risk their careers, because the number of Tcl jobs being posted out there seems to be asymptotically approaching a smallish constant.
about {{count}} hours later:
"An event loop. Lately, systems like Python's "twisted", and node.js have made event-driven programming popular again, but Tcl has had it for years."
well, sure they all have an event loop. But without any support for epoll, kqueue, etc., you are comparing apples to oranges.
about {{count}} hours later:
Peter,
no "magic"? I've always thought generating and even redefining proc's on the fly was pretty cool. Also tracing variables can be nice.
about {{count}} hours later:
As a programmer, I think TCL's metaphor of "everything is a string" is what kills it.
Firstly, that classes it with the "academic" point-proving languages in that it flatly ignores pragmatism for purity.
Second, as fundamental datatypes go, a string is a dirty mess. It has none of the structure preserving or type-controllable nature of a tree. You can slice, dice, splice and interlace it, and very few of the resulting strings represent /anything/. The atoms of a string, characters, are meaningless in isolation. No structure is visible above the atoms without parsing. Most strings don't parse, and parse-able strings are uniquely fragile.
IMO basing the language around it was a fatal flaw.
about {{count}} hours later:
Wow, fantastic article. GNU Guile maintainer speaking; our histories are intertwined, different yet alike.
(I guess I should mention something about the "Tcl wars"; I wrote about it in Guile's manual, here: http://www.gnu.org/software/guile/docs/master/guile.html/History.html. Personally I think Richard's strong reaction was produced by Sun's marketing department and his personal history, more than by technical issues. I won't disclaim the technical side, but all choices involve technical, aesthetic, and social choices, and it's great that we have such diversity.)
The notes about "old, crufty Tk" are spot-on. I did a soft spot for GNU things, but I got involved with GNOME because of the focus on design, around the time of 2.0. And yet it was clear looking at things underneath that much of GTK+ 2.x's widgets were based on Tk concepts, and I still have people asking me what to use instead of the Tk canvas. (I don't have an answer. Clutter, maybe. But the Tk canvas is a fine piece of work.)
The small-vs-large language thing is also interesting. I'm missing references, but I'm sure some early Guile maintainer disclaimed belief in small languages: in the end, programming languages are for doing things, and pretty soon (if not now?) even Common Lisp will be small. The intermediate position is no good either; one must have a small core, yes, but a large language.
(This is also a self-serving position to adopt, given that Guile has also been undercut by smaller Schemes -- TinyScheme, Chibi.)
Anyway, thanks for the observations. Happy hacking!
Andy
about {{count}} hours later:
Thanks for sharing your reflections. This clears up a lot of confusion I've had regarding Tcl/Tk. Programming languages and software need context & history in order for developers to feel invested. People such as Eric Raymond and Russ Walter, despite their eccentricity, have handed down valuable knowledge from the 1st & 2nd generation of (post epoch) programmers. I read Walter's book recently & can now almost appreciate BASIC. I have been reading the 2nd edition Tcl/Tk book also & it is excellent. I will probably use the C API to optimize a bottleneck too.
Motif may have been popular at an enterprise level but people were desperate to get away from it. Tk seems almost unfinished even in it's latest versions. TkchooseDirectory is a bad hack of TkopenFile. Under Mac OS X there's a "New Directory" button (inherited from Aqua I guess) that has no connection to the underlying Tk widget. When even the basic widgets don't make sense it's impossible to design an intuitive app. Tix, BWWidgets, etc. are all very rudimentary and inconsistent.
Ousterhout leaving shows the importance of a BDFL. Can one imagine Guido, Matz, or Larry Wall leaving their languages? No, even though Perl has become something of a Monty Python joke itself with the dead Parrot that is Perl 6.
Tivo shows that Tcl works well in the new embedded world although there the BSD license may contribute to the isolated Tivo-ization that the GPL tries to protect against. Tivo seems to have moved on to Flash of all things perhaps as a way to move from Tcl to Javascript.
This post has helped me understand that my problems with a Tcl/Tk project are part of a larger issue. Ironically that does make it easier to continue on.
Thanks again!
about {{count}} hours later:
Having learned and used Tcl/Tk in the last 2-3 years and having developed multiple simple GUI applications in it, I think Tcl/Tk is fantastic and is an excellent language for quick prototyping of a GUI app.
I have wondered many times about the general lack of interest in the language and your article gives great insight into this.
From my limited usage and thinking on this, I think the main reason for the decline is "losing steam" -- it's a combination of not having a BFDL/CorporateSponsor/KillerApp at the right time and as a result not keeping up with the times. If the push to use Tcl for web-development had progressed effectively, I think Tcl would still be one of the more popular languages. Many times I have reconsidered rewriting PHP web-apps in Tcl, but the general lack of visibility of such usage has put me off.
about {{count}} hours later:
Back in the 90s, I was very impressed with Tk. And I did like some things about Tcl.
But the "everything was a string" feature was a huge turnoff, because it meant that you had to be very, very careful with "arrays" of strings. And most Tcl programmers weren't, at least back then—almost any file-processing Tcl script would choke and die on a files with spaces in their names.
Tcl, in my mind, was an interesting case of just how far you could push a fundamentally broken abstraction. And thanks to Ousterhout's amazing design talents, the answer was: very far indeed, but perhaps not far enough.
about {{count}} hours later:
Tcl is still alive
about {{count}} hours later:
Tcl being a string processing language is what killed it for me. Not enough safety lacking types, too much flexibility, and not enough efficiency. Needed separate namespaces so you could create modules with private functions and data (or did it have that and I just don't remember it?)
Needed / needs a Gtk version of Tk. Motif is an early 90's look and feel, sorry.
Best thing ever written in tcl: expect
Best thing ever written in tk: Scotty
about {{count}} hours later:
I've come to Tcl/Tk in the past five years, after its heyday, and I still prefer this combination to just about anything else: I do all my commercial application development with them (well, I also do work with Python). I think whatever Tcl's shortcomings are, they are more than made up for by its strengths.
about {{count}} hours later:
Eh, left the wrong URL. :-(
about {{count}} hours later:
Brilliant article!
Last year I had a discussion with a colleague about programming languages and we wondered why things have become kind of quiet regarding Tcl. Thanks to this article the reasons have now become very clear to me.
I would be interested to read more about the state of Erlang that is briefly alluded to in this text. It appears to have drawn a lot of attention lately, with CouchDB using it etc., despite being anything but new.
about {{count}} hours later:
I don't know that the syntax is merely a human problem. You could never write e.g. an automated refactoring tool for TCL, for example, because there is no parse phase distinct from execution.
about {{count}} hours later:
missed something: performance.
this is a real killer.
that, and like you said, no real oo.
too bad, there was so much to like...
about {{count}} hours later:
Perhaps another issue is that people who do write on Tcl don't mention a lot of the more recent developments (and by recent, I mean the last 8 years). Stuff like Starkits, TclOO, coroutines, closures, Tile (themed Tk), the Wiki as a resource, etc.
about {{count}} hours later:
I'm convinced the computer world has an Oedipus complex about Tcl. The revilement historically heaped upon it has been inversely proportional to the role it played in bringing the current open source/internet world into being.
Some people remember that Tcl was used in the first serious database-backed web server running the busiest web site in the world. Nobody seems to remember that Cygnus Systems relied heavily on Tcl for tools and testing as they laid the groundwork for GNU software, including taking gcc from a toy to the foundation of the free software world.
Oh, and Cisco. Tcl also helps run the internet.
People also tend to forget that one of Tcl's biggest fields of application is chip design.
In other words, when it absolutely. positively has to work, Tcl has been the tool traditionally turned to. Yet somehow it's still not good enough.
Tcl isn't a hero. It's a silent guardian, a watchful protector. A dark knight.
about {{count}} hours later:
I haven't found any debuggers for it; I haven't found the equivalent of "use strict" and "use warnings", and its interpreter seems a heck of a lot less careful about sanity checking at compile time than other interpreted languages.
Lastnight, it took me ages to work out that I had forgotten a $ when referencing a variable, partly because it accepted it fine at compile time, and kept on going after it executed that line. My app was popping up 20 dialogs a second saying "programming error", but I had to very quick to press "see stack trace" before it hit application limit for the number of open window before I could even hope to have an idea of what my syntax error was (it took me a few restart cycles for the app in question).
My own new GUI apps (I've started one app in the past 2 years) get written in Perl/TK, but work has lots of historical cruft in Tcl/TK, as well as most new GUIs.
about {{count}} hours later:
Lots of things to say... let's go down the list:
@Brian : an event loop is an event loop. Epoll driven event loops might be better/faster, but what matters most is how the language is organized around it. For instance, the undisputed king of event driven programming is Erlang. Wedging it is quite difficult because it's got its own built-in scheduler so as to never block the event loop. And these days, yes, they use epoll when available, but I'd take Erlang with a select loop any day over a poor event loop implementation that happens to use epoll.
@JulianMorrison: I get the impression you aren't actually that familiar with Tcl. Tcl is fairly strict about types, including lists and hashes, when it needs to be. Everything isn't really a string; more like everything must be representable as one.
@Andy: Guile is cool, but the BSD license is a must for wide adoption, and a positive feedback loop that includes not just free software fans, but also companies. It's a much bigger feedback loop. Also, back in the day, IIRC, you could only call into Guile, after that Guile took over your program, because it needed to control the C stack in order to handle GC.
@Russ: I never thought you'd complain about too much freedom;-) Tcl has had namespaces for a long time now.
@Lukas: use the search box to search for 'Erlang'. I've written about it some in the past. Nice language, but my gut feeling is that someone (Scala?) is going to come along and steal the good ideas and be much more popular/mainstream.
@Mentalguy: anything with 'eval' in it is potentially problematic that way. But 'eval' and friends are part of they reason why interpreted languages are cool and useful.
@stevel: a lot of that stuff is too little, too late. Too many people are already convinced that Tcl is not what they want; you're not only trying to make a favorable impression on a blank slate, but you're trying to overcome a negative bias as well. A Sisyphean task in some ways...
1 day later:
Some further thoughts...
I think it's fair to say that Tcl and Tk have smaller communities, and somewhat smaller mindshare, than trendier toolkits. David's historical overview of how we got to this point is astute.
The question is, is Tcl/Tk's small mindshare a problem, or simply a fact? I don't see it as a crippling problem, as long as the language and toolkit continue to be developed. It's definitely an inconvenience: in Perl or Python, if you're looking for a library or extension package, it's more likely that someone, somewhere has done it already, because their communities are larger. In Tcl/Tk you often have to do it yourself. But it's not a crippling problem: the core of the language continues to be developed by the TCT.
Also, Tcl/Tk has continued to attract corporate sponsorship even today. Apple has twice sponsored ports of Tk to run on top of its native GUI frameworks: first Carbon in 2001, and then Cocoa in 2009. Even though the core Tk-Mac community is small even by Tcl/Tk standards, Tk itself is so widely used (by Python, Ruby, etc.) that Apple wanted it as a first-class cross-platform GUI library. That support by Apple is the major reason I continue to develop my Mac-only apps in Tk instead of another toolkit.
I'm well aware of Tk's limitations, but none of them are dealbreakers. The toolkit can be extended so easily, and integrates so well with command-line tools, that it is usually easier to continue working with Tk than to port to another framework. I don't program directly in Cocoa (the Mac's native framework) because even its scripting language bindings are thin wrappers over an Objective-C API that is huge and complex. Other toolkits have licensing issues (PyQt), lack 64-bit/Cocoa capability (wxPython), or have poor platform integration even in their native, non-X11 mode (Gtk).
I feel very confident in Tcl/Tk's future, and am not troubled by its small community. It would be nice if it had a larger community, but as long as the language continues to evolve and grow, then I will continue to stick with it.
1 day later:
I'm a new convert to tcl after years of MS Access "development", looking for a platform where I could easily create GUI applications that I can distribute to friends. Using tcl/tk, sqlite, and freewrap, I can simply meet this goal.
Tcl isn't what the cool kids use. Oh well, my users don't care at all. And I can still find enough people who use it to get help.
I think tk should be nicer on Gnome, XFCE, KDE, etc. No reason that it couldn't look up the theme being used and match the colors and fonts. Perhaps mine isn't set up correctly, but antialiased fonts do not look good!
p.s. I don't understand why Object Orientation has to be tacked on to every language around.
1 day later:
Hi David,
Great article. It made an excellent supplement to this week's issue of LWN. You might see if Corbet needs a guest article for next week...
{{count}} days later:
I have a hard time explaining myself why the Tcl language community is still (i.e., after more than a decade) so unaware of the very existence of http://www.aolserver.com/, http://wiki.tcl.tk/2090, and http://openacs.org/ (built on top of the former two). They are evidence that Tcl has certainly not failed in providing web app infrastructures.
However, the remaining observations also apply to these three sub-communities. In particular: "Don't isolate yourself"!