3 ms·
Having not used Tcl since the 90s, I recently wrote some small graphical scripts in Tcl, basically tailing a text file, parsing the data, and producing a live a
by rwmj 6y ago
Having not used Tcl since the 90s, I recently wrote some small graphical scripts in Tcl, basically tailing a text file, parsing the data, and producing a live animation[1]. The project was successful, but also reminded me about what I disliked about the language in 1994: As long as what you are doing is supported by the core language, it's "fine", but if you need to use an external library or need to do something beyond what the core does, it becomes quite tedious or even impossible. Also structured data is really badly handled. The article mentions defining your own operators and control flow, but is that something you ever really need? (Yes, occasionally, but not very often)
I believe now as then that the great contribution of Tcl was Tk (the graphical toolkit), which is fantastic and has bindings in other languages. I really wish GIMP had used Tk and improved it rather than inventing Gtk which is inferior in most ways.
Maybe this is all because I'm doing it wrong, writing scripts, and I should stick to its original purpose as an extension language, but it's easy enough to add C extensions to Lua or Python, and at some point you may end up writing a significant sized extension and the language will matter.
[1] http://git.annexia.org/?p=libguestfs-talks.git;a=tree;f=2019-fosdem/nbdview http://git.annexia.org/?p=libguestfs-talks.git;a=tree;f=2019...
- cafard 6y agoIt has been a long time since I fooled with Tcl, but in my recollection writing a function to call an external library wasn't that bad.
- rwmj 6y agoWhere Tcl is nice is embedding the Tcl interpreter in a C main program. Lua also does this well. This is the oft-overlooked embedding case which can be difficult in other languages (compared to the normal case where you start out in language X and need to call into a C function to do something low level). For example in Python the embedding case is tricky and lightly documented, and with only a semi-stable API which has changed under us a few times. In nbdkit we do a lot of language embedding (https://github.com/libguestfs/nbdkit/tree/master/plugins https://github.com/libguestfs/nbdkit/tree/master/plugins) including Tcl, Lua, Python and many others.
- cmacleod4 6y agoThere is quite a wide range of extensions available, if you need to access an external library it's pretty straightforward to wrap it with Swig (https://wiki.tcl-lang.org/page/Swig https://wiki.tcl-lang.org/page/Swig), and creating new commands in C is also fairly easy, so I'm doubtful that there is much that's really impossible in Tcl :-)
- deleted 6y ago[deleted]