Critcl – C Runtime in Tcl

19 ofalkaed 5 8/3/2025, 7:58:55 PM andreas-kupries.github.io ↗

Comments (5)

bb01100100 · 31m ago
I was doing some looping recently with tcl and comparing against another implementation (called Jim [1], a very cool project in its own right) and wondered why datetime formatting was so slow when using `clock format`.

The code at [2] provided an alternative approach using C via critcl. It was interesting to see how malleable tcl can be.

[1] https://github.com/msteveb/jimtcl [2] https://wiki.tcl-lang.org/page/speed+up+clock+format+and+clo...

NelsonMinar · 47m ago
Still in active development, or at least maintenance. https://github.com/andreas-kupries/critcl/commits/master/
ofalkaed · 37m ago
I don't think it needs much development at this point, it is stable, all it needs to do is keep up with Tcl/Tk development. I just started playing with it two days ago so I might be missing some of its flaws but so far it seems quite mature.
forinti · 58m ago
I suppose you would use this to do low level stuff because it's much harder to do in TCL, but it just doesn't feel right.

It makes more sense to me to embed Tk into a C program.

ofalkaed · 40m ago
Depends on how much C you need, it might make more sense to write a proper Tcl extension and it might make sense to just embed Tcl/Tk but having this middle ground is nice because swinging to the fences is rarely the best course of action.

Critcl looks to be quite nice in those situations when Tcl/Tk is almost but not quite, you get the speed and ease of Tcl/Tk but a little more as well. The big gotcha looks to be having the foresight of identifying when writing a proper Tcl/Tk extension or switching language is the better plan, but this is almost always the big gotcha.