Skip to content
HN On Hacker News ↗

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

▲ 112 points 60 comments by aryonoco 6d ago HN discussion ↗

Pangram verdict · v3.3

We believe this text is mainly human-written, with some AI content.

8 %

AI likelihood · overall

Human
92% human-written 8% AI-generated
SEGMENTS · HUMAN 1 of 2
SEGMENTS · AI 0 of 2
WORD COUNT 1,280
PEAK AI % 51% · §2
Analyzed
Aug 31
backend: pangram/v3.3
Segments scanned
2 windows
avg 640 words each
Distribution
92 / 8%
human / AI fraction
Verdict
Human
Pangram v3.3

Article text · 1,280 words · 2 segments analyzed

Human AI-generated
§1 Human · 1%

What if I told you there exists a language, or a whole toolkit that: Can be used to create cross-platform Console and GUI tools or apps Those GUI apps look native on Windows, Linux and macOS Supports safe and efficient threading, non-blocking events and I/O Has a small footprint of about 100MB with most common packages installed Can produce very compact single-file apps for any supported platform Is capable of building robust cross-platform Web Apps Has existed and been in use by some of the largest corporations for over three decades Is free and BSD-licensed, so you can do whatever you want with it, or to it Would you believe me? Foreword Documenting personal experiences on fascinating or useful topics is what I do. Real-time visualization, 3D simulation, data safety, energy efficiency, or even input devices, microcontrollers, and fitness — an endless stream of ideas for new studies and exploration is always on the ToDo list. This particular topic turned up to be quite a bit more involved than I originally planned. But I promise: all information here is what I myself would've loved to have known before I started my Tcl/Tk toolkit learning journey. I'm writing this long after my honeymoon phase with Tcl/Tk ended, and will try to be as objective and honest as possible. Both to you, and to myself. I have nothing to "sell" except my personal experience, hoping to better inform you and simplify the "onboarding" process if you ever decide to give Tcl/Tk a try. Due to its command-centric nature, Tcl is a powerful, yet widely misunderstood language. I want to contribute to the conversation, aiming to clear up this persistent confusion with concise explanations and concrete examples. And a bit of flair, of course, to keep you entertained. Please note: We’re skipping the "Programming 101" talk here with the assumption that you already have a baseline familiarity with general programming logic. If you know your way around an if statement and know what function is, you're probably ready to dive straight into Tcl-specific structures and syntax. Think of this article as both a "Tcl hands-up and a primer", in hopes to make you, too, discover and appreciate this almost 40-year old technology that quietly powers the world. And maybe convince you to try it for yourself, and spread the word. As for the "About the Author" — if you're interested, please visit the "About" page. Ready? Let's go. Table Of Contents Introduction The Why Meet Tcl/Tk "Heroes Don't Wear Capes" The SQLite Connection The Anatomy Of Tcl/Tk Tcl Basics Which One to Use — tclsh Or wish? Homoiconicity and the Extreme Flexibility of Tcl Basic Demo Of Tcl's Homoiconicity A Word for the Experienced Tcl Devs Language With a "Different Philosophy of Power" Tcl/Tk — Alive and Kicking With Tcl 9.0 Tk GUI Toolkit Tk Cross-Platform GUI Showcase Tk — High DPI/4K Ready Tk Basics Tcl/Tk — Data-Oriented and Event-Driven by Design Python, Tkinter and Tk Where to Learn Tk Tcl 9.0 UI Widget Demos Namespaces Namespace Ensembles The "Everything Is a String" Conundrum In Tcl, the Canonical Form of Every Value is a String* The Same String Can Represent Both Data and a Command Native Introspection Pure Binary Data? Not a Problem With Tcl! Shimmering Tracing Shimmering With the "Trace" Command The Power of Tcl Dictionaries Tcl Arrays "Boo! Namespaces Are Better!" Global Arrays and Namespace Upvar Object-Oriented Programming (OOP) With TclOO Why Isn't Tcl More Popular? Practical Tcl/Tk Use Case — Decent Espresso Why Choose Tcl/Tk? Tcl/Tk on Android With Androwish Tcl's Powerful Stackful Coroutines Threading in Tcl Threading Demo High Memory Efficiency Doesn't Imply Maximum Performance Script-Embedded C? Script-Embedded C! The "Thin-Client UI" Use Case Example Standalone Apps. Starkits and Zipkits Tcl 8.6 and Starkits Tcl 9 and ZipFS What About Tclkits? Zipkits and Standalone Apps Web-Based Apps with Tcl Wapp The Fossil Connection Wapp.tcl More Cool Facts About Tcl/Tk "WebAssembly From a Parallel Universe" Radical Language Modifications With DSL Why Is Doing Math in Tcl So Awkward? Tcl 9.0 — Strict, Honest and Reliable Platform-Specific Libraries On Nullable Types Limitations (and "Quirks") The Tcl "Quoting Hell" No Garbage Collection managed_create managed_channel No Centralized Package Manager Do You Need a Package Manager? Mediocre IDE Support Limited Multimedia Capabilities No Matrix Multiplication "Ugh… Tcl Is So Annoying!" "Shooting Yourself in the Other Foot" Learning Resources Where to Get Tcl/Tk Tcl/Tk for Windows Tcl/Tk for Linux Tcl/Tk for macOS Tcl/Tk IDEs Afterword Useful Links Introduction There's plethora of transformative inventions that ended up benefitting humanity as a whole: the Printing Press, Electricity or the Transistor. As for the intellectual commons, there are of course the Linux OS, the World Wide Web protocols, and the concept of Public-Key Cryptography. You know, the stuff we mostly take for granted, or aren't even aware exists. Tcl, or the "Tool Command Language", created and released by John Ousterhout in 1990, deserves a place among the greatest products of the human mind. Especially when combined with its better known graphical user interface Toolkit — Tk. In 1997 Ousterhout was awarded the ACM Software System Award for Tcl/Tk, an award given to institutions or individuals recognized for developing software systems with a lasting influence, reflected in contributions to concepts, in commercial acceptance, or both. A good overall summary of what Tcl is could be found in the project's source code repository: Tcl provides a powerful platform for creating integration applications that tie together diverse applications, protocols, devices, and frameworks. When paired with the Tk toolkit, Tcl provides the fastest and most powerful way to create GUI applications that run on PCs, Unix, and macOS. Tcl can also be used for a variety of web-related tasks and for creating powerful command languages for applications. Tcl is maintained, enhanced, and distributed freely by the Tcl community. Source code development and tracking of bug reports and feature requests take place at core.tcl-lang.org. Tcl/Tk release and mailing list services are hosted by SourceForge with the Tcl Developer Xchange hosted at www.tcl-lang.org. Tcl is a freely available open-source package. You can do virtually anything you like with it, such as modifying it, redistributing it, and selling it either in whole or in part. See the file "license.terms" for complete information. Ok, Ok… But what does this all mean, and why should you care? The Why Some time ago I needed to develop a cross-platform desktop app with a graphical user interface which would run on Windows and Linux (X11/Wayland). Prior to this, I had spent years using AutoHotkey to build small Windows utilities, like the ones mentioned in my post on Alt ♫ Code ♥ Numpad Emulation. AutoHotkey, specifically v2, is actually very capable, and suitable for the development of small GUI tools, not just doing "hotkey-related stuff". With the improved "C-like" syntax it's a pleasure to use for someone with extensive background in JavaScript, PHP, or C#. The only problem? — it's Windows-only. Sure, with the Wine compatibility layer AHK scripts and single-file executables could be run in Linux, but there's no guarantee that all Windows-specific bindings and native library calls that AutoHotkey relies on would work well, or at all. I looked at other options in pursuit of a cross-platform GUI framework and/or runtime: C# with WinForms — I considered the .NET ecosystem first, but WinForms remains fundamentally tied to the Windows API.

§2 Mixed · 51%

Even with modern .NET cross-platform capabilities, achieving a truly native look and feel on Linux or macOS requires migrating to MAUI or Avalonia, both of which carry a giant dependency footprint and are a pain to develop "non-enterprise" software with Headless Local Web Server (The "Electron-like" approach) — I explored building a tool in a modern decoupled architecture.