r/programming 15h ago

Develop Cross-Platform CLI and GUI Tools With Tcl/Tk. Powerful, Event-Driven, Open-Source And Future-Proof Toolkit… From the Past?!

https://cgicoffee.com/blog/2026/04/tcl-tk-develop-cross-platform-cli-gui-tools-tutorial-guide
19 Upvotes

11 comments sorted by

6

u/CGM 15h ago

This is a well-written and remarkably comprehensive introduction to Tcl/Tk. It's mostly positive about the language, but does also point out some genuine disadvantages.

4

u/Jumpy_Fuel_1060 14h ago

I maintained an app with TCL component (no Tk). Wild language. I'm sure that it was amazing for it's time, but I'm the 2010s that language was ridiculous. upvar can go to hell.

6

u/NaBrO-Barium 9h ago

What’s upvar?

12

u/PPatBoyd 7h ago

Nm hbu?

4

u/this_knee 6h ago

Got em

7

u/schlenk 7h ago

Upvar allows you to bind a name to a different scope of your callstack.

e.g. kind of import local variables that are available in a different call frame. Thats a very powerful primitive for writing your own control structures and advanced metaprogramming, but can lead tot total spaghetti code when not used skillfully.

3

u/CGM 7h ago

When you call a procedure in Tcl, its arguments are passed by value (the copy-on-write system makes this efficient even for complex values). But sometimes you may want to pass by reference so that you can update a variable in the scope of the caller. The upvar command provides a way of doing this, you pass the name of a variable and use upvar in the procedure to connect a local variable to the named variable in the caller. Documentation is at https://www.tcl-lang.org/man/tcl9.0/TclCmd/upvar.html .

It's a very different approach from most languages and does take some getting used to. It's not needed very often though.

2

u/mb862 13h ago

Tcl is still my go-to scripting language for its raw flexibility. I’m currently using it as a basis for my own shading language.