TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Tcl the Misunderstood (2006)

182 pointsby goranmoominabout 3 years ago

20 comments

deepsunabout 3 years ago
Watching someone learns basics of programming in Python, I realized that Python is actually not that easy to learn for beginners as I thought:<p>1. Types in Python are implicit. It&#x27;s really hard to explain that they need to always think about what type something is, especially when they haven&#x27;t grasped the concept of types yet.<p>2. Indentation as part of the language. I thought it&#x27;s a great thing for beginners, but it&#x27;s actually confuses beginners that empty space affects your program, e.g. they think that spaces around assignment or arithmetic operators should affect their program too, which is not the case.<p>3. Ranges for iteration -- they just memorize the syntax blindly :(<p>So I started to wonder whether Pascal is better to learn for beginners -- you have to list all the types at the beginning, and no implicit conversions are done.<p>But now I think what about TCL? Maybe it&#x27;d be even easier for total beginners?
评论 #31133536 未加载
评论 #31133720 未加载
评论 #31132759 未加载
评论 #31133509 未加载
评论 #31133486 未加载
评论 #31134144 未加载
评论 #31136518 未加载
theszabout 3 years ago
Tcl forces you to create new data, because you have to think and work harder to introduce effects on variables in upper scope through the use of uplevel and upvar. This reduces side effects significantly and makes data transformation explicit. Which, in turn, reduces cognitive load and increase productivity.<p>Tcl also does not have distinguished NULL value like Python, C, C++, C# and many other languages. You do not have to account for that.<p>The reduction of side effects and no universal no-value value puts Tcl in my hierarchy of programming languages right below Haskell and above pretty much everything else. Tcl is very easy to use when you know how to structure the program.<p>I still use it for various prototyping when I do not want strict type discipline.
评论 #31133148 未加载
jrapdx3about 3 years ago
I think it&#x27;s worth pointing out that in the years since this article was written (2006) quite a few new features have been added to Tcl. A few of the more significant include coroutines, robust object-oriented system, tailcalls, apply (lambdas), namespace ensembles, et.al.<p>Of course some of these features were already present in other languages. However, steady improvements to Tcl have pushed the language well beyond how it was described in the article. Definitely not a &quot;toy&quot; but overall as capable as the other scripting tools out there.
评论 #31133633 未加载
repiretabout 3 years ago
What I like most about TCL is that a TCL REPL feels a lot more like a normal command prompt than Lua or Python or whatever. If I’m going to write a complex program, TCL wouldn’t be my first choice, but if a program I’m using has a command prompt (think autocad or the debug console a lot of games have). Plenty easy for one-off commands, but with a simple and powerful programming language there if you ever need it.<p>Put differently: The command line ergonomics of POSIX shell, with the scripting ergonomics of Lisp
评论 #31133743 未加载
macintuxabout 3 years ago
Some discussions over the last several months, including just yesterday:<p>* The Birth of Tcl: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=31111220" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=31111220</a><p>* TclTutor 3: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=30327945" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=30327945</a><p>* Tcl&#x2F;Tk Spline Editor: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=29772621" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=29772621</a><p>* Tcl library for CSP: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=29421786" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=29421786</a><p>* Why Tcl syntax is so weird: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=29143346" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=29143346</a><p>* Tcl: Lisp for the masses: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=28957701" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=28957701</a>
评论 #31133751 未加载
thanatos519about 3 years ago
My favourite thing about Tcl is (was? This was 25 years ago) that adding commands just requires a couple of Tcl things, then an argc&#x2F;argv, so it was relatively simple to turn an existing C program into a Tcl command:<p><pre><code> int my_command (ClientData clientData, Tcl_Interp *interp, int argc, const char *argv[]) { ... } </code></pre> However, that might have been the only thing I liked about Tcl. For some binary data import tasks I ended up writing a Perl program that translated it into Tcl.
评论 #31133071 未加载
ufoabout 3 years ago
The thing that I most appreciate about Tcl is that it feels like Unix shell &quot;done right&quot;. It is still a bit weird because everything is a string, but it doesn&#x27;t have all those footguns around variable expansion, such as word splitting. It also has decent support for subroutines and local variables, no weirdness with subshells and so on.
评论 #31133253 未加载
spijdarabout 3 years ago
&gt; Every string is internally encoded in utf-8, all the string operations are Unicode-safe<p>This seems <i>very slightly</i> disingenuous, if my memory is correct. I don&#x27;t remember all the details, but I ran into an issue with a Tcl application a while back and Unicode support. Digging into it, I recall that the Tcl interpreter actually represents every character as a predefined number of bytes, set by a preprocessor definition. The default was 2, and cut off any Unicode character that needed more than 2 bytes to encode, unless you were willing to recompile the interpreter to use 4 bytes, at the cost of doubling memory consumption for every string.<p>Very nitpicky, but I think it&#x27;s important to point out it&#x27;s not &quot;quite&quot; utf-8, because Tcl needs each codepoint to be O(1) indexable in an array, something normal utf-8 can&#x27;t do.
评论 #31131854 未加载
IshKebababout 3 years ago
This is nonsense. I have had the misfortune of having to learn TCL (it&#x27;s standard in the EDA world unfortunately) and it is most assuredly a toy language. That doesn&#x27;t mean you can&#x27;t write big complicated programs with it. You can do that with any language. But stuff like this is an outright lie:<p>&gt; There are no types, and you don&#x27;t need to perform conversions, however, you aren&#x27;t likely to introduce bugs because the checks on the format of the strings are very strict.<p>You aren&#x27;t likely to introduce bugs when literally every type is a string. Even lists. Lists are strings. Lists of strings are strings. Maps are strings.<p>It&#x27;s pretty insane, and the interpreter does some horrible magic so that if you never access a list as a string it can store it <i>internally</i> as a real list (to avoid insanely bad performance) but to the programmer it&#x27;s still a string and nothing prevents you from treating it as such.<p>I actually made a semi-funcitonal WASM-to-TCL transpiler to avoid having to write TCL. Worked kind of well! Unfortunately WASM is quite large and I lost interest before completing it.
gilbetronabout 3 years ago
I&#x27;ve managed to work on two TCL codebases in my career, one in 1992ish, and one in 2011ish. I was very surprised to be working on it the second time! I&#x27;ve said it before, but working on TCL is interesting, kinda fun, and ultimately a lesson in frustration once you get to a certain sized codebase. It really hammered home the need for static typing as your repo gets over 50k lines because it is so &quot;type free&quot;. However, it is a cool thought experiment for it&#x27;s premise, which is more-or-less, &quot;what if everything is a string&quot;. It has a lot of benefits, and a lot of nasty side effects. I&#x27;m glad I spent time doing it, and I think the use case for which it was made (&quot;Tool Control&quot; roughly speaking) it has good ideas. TK was fun, as well, I miss it in some ways. But ultimately, TCL is a dead end for a programming language - the negatives accumulate too quickly.
slbttyabout 3 years ago
The author of this article is the creator of Redis.
评论 #31133085 未加载
bitwizeabout 3 years ago
The idea that Tcl was a toy came from the 90s and the Tcl Wars Stallman was involved with. But to Stallman, anything other than Lisp is pretty much a toy. Tcl is indeed a deep, deep rabbithole -- again, deeper than our dimension allows and lined with toothed cilia... but I can totally see where a person might look in Tcl&#x27;s deadlights and want to be there.
评论 #31132140 未加载
pjmlpabout 3 years ago
It might be powerful, and Lisp like, however in any large application eventually the amount of C code in extensions to make it perform, outgrows the TCL code.<p>And then one stars wondering if it isn&#x27;t better to migrate to something else.
xaropeabout 3 years ago
I remember bumping into Tcl as part of Tcl&#x2F;Tk, during my xwindows days. Never realised there was still so much work ongoing for the language!<p>Reminds me of Forth too... do people still make firmware with Forth?
pxeger1about 3 years ago
This article fails to note that Tcl is very closely related to shell script. A lot of the concepts listed already exist in Shell, and nobody complains that Shell is only a toy language.
评论 #31133129 未加载
swahabout 3 years ago
Fond memories of tcl inside ModelSim - it was not the Lua I was enjoying then but, like using emacs, made me love automation and coding a little bit more.
sirfzabout 3 years ago
TCL was my entry into coding back when I was a teenager, haven&#x27;t touched it in over 12 years or so but I&#x27;ll always fondly remember it. The title of this post is very familiar to me, I&#x27;m sure I read it back when it was published but its cool to now know it was written by the creator of redis which I now use extensively
dganabout 3 years ago
Wow, looks like TCL is &quot;the better bash&quot;
评论 #31134539 未加载
uwagarabout 3 years ago
expr is horrible though. but i love tcl.
评论 #31134418 未加载
zulbanabout 3 years ago
Overwhelming number of tcl positive comments here. Must be selection bias. Tcl is ridiculous. I propose that anyone who prefers tcl over other top languages in 2022 simply doesn&#x27;t have productivity or teamwork as their top goal.<p>Do you want your language to help you solve real problems, or do you just enjoy your weird toy from another era? Everything is a string..? Please.