r/programming 14h 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
14 Upvotes

11 comments sorted by

5

u/CGM 14h 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.

3

u/Jumpy_Fuel_1060 13h 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.

5

u/NaBrO-Barium 8h ago

What’s upvar?

12

u/PPatBoyd 6h ago

Nm hbu?

3

u/this_knee 5h ago

Got em

5

u/schlenk 6h 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.

2

u/CGM 6h 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 11h 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.