7 ms·
Why do people like Tcl? I've never tried diving in to using the language, but I have debugged MacPorts now and then, which is all Tcl, and I've seen that Tcl UI
by jitl 10y ago
Why do people like Tcl? I've never tried diving in to using the language, but I have debugged MacPorts now and then, which is all Tcl, and I've seen that Tcl UI library used in other scripting languages.
What's the draw, other than having some existing code written in the language? Gems like the `upvar` command? (http://wiki.tcl.tk/1508 http://wiki.tcl.tk/1508)
Is there something special about Tcl that makes it a joy to use?
- lmm 10y agoIt's an elegant, lightweight language, with a design thoroughly optimized for interactive use. http://yosefk.com/blog/i-cant-believe-im-praising-tcl.html http://yosefk.com/blog/i-cant-believe-im-praising-tcl.html .
- jitl 10y agoThanks, this blog post was exactly the sort of discussion I was looking for! The TL;DR: - easy to write interactively because there's no fiddling with the parens, quoting, or commas you find in JS, Ruby, or Python - uses [ and ] for subexpressions instead of ( and ), which makes typing easier - "command" oriented, instead of "expression" oriented - saner than shell while having many of the same advantages
- denisw 10y ago> - uses [ and ] for subexpressions instead of ( and ), which makes typing easier I would like to point out that in several non-US keyboard layouts, [ and ] are harder to type, not easier. For instance, on German keyboards, they are mapped to Right-Alt (AltGr) + 8/9, which is quite annoying to type compared to normal parentheses (which are mapped to Shift+8/9, with Shift being better placed and available on both the left and right side of the keyboard).
- yoodenvranx 10y agoAs a German I haven't use a German keyboard layout in years because the US layout easier in most cases (for examole all those curly braces in TeX).
- qznc 10y agoAll my colleagues would agree and did the same. I don't. I want äöü quickly available for chatting and other "quick" writing, while coding typing is usually not the bottleneck.
- hawski 10y agoIs there a German keyboard layout such as?: AltGr + a -> ä AltGr + o -> ö AltGr + u -> ü I'm Polish and I'm very glad that our most common layout is like that for ąćęłńóśźż (with AltGr + x for ź). Currently I'm in Germany and I wonder if there is similar layout for German umlauts.
- yoodenvranx 10y agoThere seems to be a layout called "US international" which might help: https://en.m.wikipedia.org/wiki/File:KB_US-International.svg https://en.m.wikipedia.org/wiki/File:KB_US-International.svg
- mstade 10y agoAs a Swede, I can echo this. I'm so used to the US layout by now that I have to do a double take whenever I switch to the SE layout, or type on someone else's keyboard. I used to get laptops and keyboards with the US layout on them, but stopped since the resale value in Sweden drops sharply because of it. Thankfully, I've touch typed since forever so I rarely look at the keyboard anyway. (Unless, of course, I have to type with the Swedish layout.)
- CyberDildonics 10y agoPragmatically it is actually a giant pain to use. Its bizarre text substitution semantics are hugely unintuitive compared to modern languages.
- auxym 10y agoI would also add that the "Everything is a String" paradigm makes it simple to reason about somewhat complex concepts. You don't have to try to teach beginners about objects and pointers. Just plain old text strings. Everything else is under the hood. I miss some features of more modern languages though. TclOO (object-oriented extension) is minimally useful but lacks GC, so you have to keep track of all objects to manually destroy them when you are done. I miss easily passing around functions (procs), and saner local namespacing for functions (ie like in python). Exception handling is also a bit of a pain. A lot of these things are addressed in Jim Tcl, but it hasn't seen much adoption. http://jim.tcl.tk/index.html/doc/www/www/index.html http://jim.tcl.tk/index.html/doc/www/www/index.html
- tyingq 10y agoA fair amount of the popularity was being the first scripting language with a reasonably complete, cross platform, UI widget toolkit. It was also very easy to embed inside a C application for a user facing scripting capability.
- jancsika 10y ago> A fair amount of the popularity was being the first scripting language with a reasonably complete, cross platform, UI widget toolkit. That wasn't my experience. At least in tcl/tk 8.5 things like zooming in/out of a tk canvas or updating a progress bar were a real pain. For example, tk canvas has this nice, seemingly simple subcommand called "scale" that looks like it does exactly what it's called with a tag and two double-precision floats. Apply it and all the relevant tk items are scaled accordingly. It even has a predefined tag called "all" that applies to all current tk canvas items. Trivial. Awesome. Except text items don't get scaled. And font sizes are limited to integer pixel/point sizes. So zooming is actually non-trivial. Not awesome. There are a sufficient number of such idiosyncracies that if you want to make a clear, usable interface you end up battling the toolkit. Also, on the tcl language level I felt the "everything is a string" feature gets in the way. I'd much rather have implicit expressions and explicit string declarations.
- tyingq 10y agoAll fair, but you have to take the time period in context. There wasn't the plethora of choice we have today.
- jancsika 10y agoIt's the "reasonably complete" phrase that I'm responding to. For example: Qt was released around the same time. Do you know if the first version included QGraphicsView? Because it has features we still associate with a modern 2d graphics API-- affine transforms, opacity, grouping of primitives, arbitrarily complex paths, and decent performance even with event handlers and many items being animated on the canvas.
- forinti 10y agoThere's a situation that springs up sometimes that is perfect for Tcl/Tk: when you need to write a small app with a GUI and you would like it to be multiplatform. Say you want to write an app to rename files in batch, or a wrapper for Ghostscript that automates certain tasks. With Tcl/Tk you can immediately run it on most Linux distros and with Freewrap you get a Windows executable that's a few MB+your source (it's a lot better than having your users install Java).
- mappu 10y agoMy usual solution for this is C++/Qt. Runs well on Linux, and on Windows you can statically link Qt into the single .exe if your small app is FOSS (at least LGPL-compatible), otherwise you should ship a few extra .dll files. Compared to Tcl/tk you get (A) catch errors at compile time, and (B) Qt apps usually look better than Tk apps. With mxe+qmake it's one command to cross-compile from Linux to a Windows binary.
- eggy 10y agoI am now looking at the Red programming language [1] for exactly this, but it does not have the libraries of C++ or Tcl. Still it is under 1 meg complete with libraries and it is homoiconic, cross-platform, and has a REPL and a systems language Red/System for going low level. The GUI and UI DSL and drawing DSL work on Windows and Mac for now, with Linux close behind. [1] http://www.red-lang.org/p/about.html
- systems 10y agowell, for me, when i used to like Tcl, it was * the everything is a string, mantra * meta-programming possibilities * tcl wiki ( http://wiki.tcl.tk/ ) the tcl wiki is the reason i fell in love with wikis, my first wiki experience, and in my opinion when it was very active, it was home of a really nice community I think if someone can rewrite tcl or a tcl like language, as the top level language, using a more modern low level language, like Rust or Go ... it will be a very nice combo, I think Tcl can serve as a really nice declarative language If you look at Sqlite, it really is the perfect example of an offspring of the tcl community, a declarative solution for a complex problem , written in C ... a perfect tcl I stopped following Tcl a long time ago, so I have no clue where it is at now ... but i hope it is still being used, for the super nice community .. it had/has
- ecky-l 10y ago"I think if someone can rewrite tcl or a tcl like language, as the top level language, using a more modern low level language, like Rust or Go ... it will be a very nice combo, I think Tcl can serve as a really nice declarative language" Why would someone rewrite Tcl in another language? That is just an immense amount of work and would (re)introduce bugs that have been found and fixed in Tcl over the last 3 decades. Just the fact that Tcl is old doesn't mean that it is dead. It is actively developed and used, although mostly hidden (its not that kind of hype around as with Python or Ruby). That Tcl is old does in fact imply that the code base is mature and reliable, its well documented and doesn't come with surprises. Which in turn means that your code is almost never broken with a new Tcl version. In fact, scripts and extensions written for 8.4, 15 yrs ago, are mostly still functional in 8.6 without modifications. Yet Tcl does come with pleasant surprises that don't break old programs, as can be seen with the new features in 8.6 (TclOO, coroutines, tailcall, try/trap ...)
- systems 10y agowell .. i am a big believer in the two layer separation we program at two layers, high level, and low level features needed or preferred in low level programming, may not be required in high level programming and vice versa there are several ways to work like this, and many people do for example, many developers use lua or python with c/c++ the effort needed to make the two language interact vary another approach is to use one language with optional features, like optional typing or optional garbage collection, a language i believe is adopting this approach is red have a programming framework, where two languages optimized for the two different layer use each others entities (names, objects, values, interfaces) seamlessly is in my opinion a super good approach for most programming tcl + c .. are not exactly that and i believe a more modern combo will be better
- jankedeen 10y agoBy the time you outgrow TCL you are a really good programmer. You choose and advocate appropriately.
- ecky-l 10y agoI think you are a really good programmer by the time you use Tcl again: as a complementary language for test automation, or to integrate it in your software as DSL... First you use it because it is simple to learn. Then you outgrow it and blame its weaknesses. Then you remember its strengths from a different perspective and pick it up again :)