The author should rather be honest and say "I like TCL just because", instead of coming up with contrived examples to state alternatives are bad.
E.G, in the Counter snippet, why make some complicated code when Python is designed to make it simple?
import sys, collections
for p in sys.argv[1:]:
try:
with open(p) as f:
for k, v in collections.Counter(f).items():
if v > 1:
print(v, "\t", k, end="")
except Exception as e:
print("dup error: ", e)
I don't buy the argument of simplicity here. Also, if you are going to just do "get", you don't need requests, the stdlib is fine.
And I don't get the speed argument either, given his script uses most_common(), that basically sorts the entire dict, which none of the other codes do. Yes Python is likely slower, but let's not push it.
Also the Go code is more complicated, but you can cross compile it and ship it as is. And it's fast.
I get it, TCL is cute, but making up arguments is not selling it.
Yeah—as a TCL fan, I agree. Comparing implementations of common coding tasks with other languages doesn’t highlight TCL’s strengths or, really, its purpose.
Personally, TCL fits a niche like QBASIC did. QBASIC was the shortest path from brain -> code drawing on a monitor. Literally 1 line to draw a shape, no initialization and not even an entry point function.
TCL similarly lets you just get on with what you’re doing when you need glue code, GUI’s, and DSL’s. It is easily (even trivially) able to do things that are just a pain in other languages, especially all at once:
- interop with native code (no limits on who calls who or in what order)
- define GUI’s that behave well without it being a huge pain to make anything non-trivial (lookin at you, UE5)
- create novel control flow that feels built-in
- implement an interactive GUI debugger with breakpoints & variable watch in ~200 LOC (saw this once, it’s amazing what you get “for free”)
- save or load a running program’s entire state, including code defined at runtime
- detour any function, allowing you to optimize or patch on the fly
- run from tiny, standalone executables so your users don’t have to install a ton of crap just to run your widget
There’s more but you get the idea. It’s been around for decades for a reason :)
The author, while having a passing familiarity with it obviously, is clearly not a Python expert, so take all the Python stuff with a major grain of salt. Like they claim not to know how to get granular exceptions out of the requests modules:
>The requests here is a third-party package that required installation and a virtual environment to use. I don't know how to catch more granular exceptions in this example.
E.G, in the Counter snippet, why make some complicated code when Python is designed to make it simple?
I don't buy the argument of simplicity here. Also, if you are going to just do "get", you don't need requests, the stdlib is fine.And I don't get the speed argument either, given his script uses most_common(), that basically sorts the entire dict, which none of the other codes do. Yes Python is likely slower, but let's not push it.
Also the Go code is more complicated, but you can cross compile it and ship it as is. And it's fast.
I get it, TCL is cute, but making up arguments is not selling it.