by IshKebab · 3y ago · 0 comments
Performance isn't such a big deal - even though he says it isn't as fast as a really slow language like Python, the scripts tend to be very short.
The issue is "everything is a string". Anyone who has written any significant Bash or CMake will be familiar with how shitty that is. TCL is actually a bit nicer than CMake or Bash, but it still suffers from the fundamental problems of stringly based languages.
Quoting is insane and hard to get right. Type errors are very common. I would say TCL has had a negative effect overall at least on the EDA industry. Maybe if it didn't exist we could have had a slightly nicer embedded language like Lua. Or even just a C API.
This really makes me wonder if you’ve used Tcl. Quoting in Tcl is so much simpler than in e.g. bash or cmake. It’s all about know when a string will be evaluated or not.
> Type errors are very common.
In my experience, no more so than in any other dynamic language, e.g. Python or Lua.
Again in my experience, if one wants a scripting language — i.e., one used to orchestrate a number of commands — then Tcl is exactly what the doctor ordered.
"Writing with a screwdriver is so much simpler than e.g. a potato or a sock."
What I will say is it's absurdly easy to write a Tcl extension - I wanted to talk to a soft CPU using a Xilinx Platform Cable USB (which isn't supported by OpenOCD). I ended up creating a simple Tcl extension around xc3sprog and it worked a treat - I'm pretty sure the engineering effort to do the same for a different scripting language would have been much greater.
On the contrary, compared to e.g. bash, unless you're doing something super unusual or wrong, you rarely have to think about quoting in Tcl. Use "" when you want substitution, {} when you don't, {*} when you need to pass a list as multiple words, construct lists and dicts using their appropriate constructors and never by hand — and you're safe. Unlike bash, quoting in Tcl is dead simple, predictable and never surprising.
That being said, those are very much edge cases.
More damning, from my POV, is that you can't get ref counting of things like C objects or file handles, since they're just string handles. But there are a lot of uses that don't need that
I agree that its syntax is pretty weird when compared to any other language. And a lot of stuff works differently than you’d expect if you’re coming from Python.
For me, there’s always a mental context switch that needs to happen before I can get in the flow with TCL. Once I’m there though, it’s a very fast/powerful language to implement stuff with.