Hacker News new | past | comments | ask | show | jobs | submit login
Tcled: Pure Tcl Console Text Editor (2019) (github.com/slebetman)
103 points by blacksqr on Aug 9, 2022 | hide | past | favorite | 29 comments



Ousterhout just spoke about software design. He's been at this game for a while (TCL was 34 years ago, feel old?) and has some well rooted ideas.

https://www.se-radio.net/2022/07/episode-520-john-ousterhout...


His "A Philosophy of Software Design" book is one of my favorite software books of the last few years.


Given that my first job was being part of a portuguese startup that created an AOLServer clone for our middleware, yep.


One of the things the Sprite people gave out to motivate using Tcl ca 1994 was mxedit: http://www.texteditors.org/cgi-bin/wiki.pl?Mxedit

It wasn't pure Tcl, but it had more than 1 "cursor", which I haven't seen elsewhere.


I regret that I didn't run into Tcl and Tk back when it really made sense to put in the effort to learn them. Such a capable little language.


It is worth learning considering a few things. The ruleset is freakishly simple and the docs are good. The speed at which you can prototype a gui is somewhat unparalleled. The ability to glue or automate different bits of software is often better than bash. It is called the tool command language after all, though they'll never get me to stop saying tickle.


> The speed at which you can prototype a gui is somewhat unparalleled.

Yeah, but it's some kind of Alternate Web Ghost Story prototype where an uncanny valley ends up terrorizing the developer.

Imagine: you hear faint sounds outside your tent in the middle of the night. You get out to see an vector infographic rustling through your backpack.

And as you slowly approach, it gets bigger. And bigger.

Except for the text, which remains the same size no matter how close you get!

"AAaaaah!"

When the forest rangers arrive the next morning, you and your entire party are nowhere to be found. All that remains is a tiny library a mere few megs in size.

A bush behind your tents hides an old, rusty sign with text too small for the rangers to read:

"Caution: tk canvas scale subcommand does not rescale text or images-- it only adjusts their x/y coordinates."

Edit: clarification


Lol! And when you're running your very own GUI app in the cutest little window. But, just to see what happens, you decide to reach for the resize handle...


Now I'm never going to fall asleep.


It’s worth learning in its own right… high time someone reposted “TCL the Misunderstood”…


Yes! http://antirez.com/articoli/tclmisunderstood.html

(I know you meant post at the top level, but I don't do that and don't have time to look up the rules for doing that.)


That's always a great read. The last time I stumbled across it I decided to write my own "TCL", and I had a few weeks of fun doing that, in golang:

https://github.com/skx/critical/

It's a little addictive writing toy-interpreters for various (older and simpler) languages.


“I can’t believe I’m praising Tcl”[1] (last posted here[2] in 2020) also makes some good points that are not in other writeups, specifially regarding interactive use.

I think Tcl(’s standard library) is still too wordy to make a comfortable interactive shell, but it’s still leagues above everything else I’ve seen; in particular, I can’t help but think Shivers’s dismissal of interactive use in his description of Scsh is something of a cop-out—there are (now, maybe not then) plenty of nice languages to hack a prototype or a quick script in, but somehow Bourne shell + Unix utilities is still the best we can do that won’t make my fingers ache? Tcl demonstrates very well that inside sh there’s a Lisp trying to get out (and Plan 9’s rc does the same but worse), but somehow that line of thought seems to not have been continued further.

(Just in case, I see both Elvish and PowerShell as being more in the Scsh direction than the Tcl direction, that is making a “proper” language at the expense of interactive use and my fingers; Elvish appears to at least have a properness-Bourneness knob but that’s hardly a solution. Anyhow, I don’t think either contributes much to our knowledge of the virtually untouched interactive-use landscape, as opposed to the relatively well-explored scripting-language landscape.)

[1] http://yosefk.com/blog/i-cant-believe-im-praising-tcl.html

[2] https://news.ycombinator.com/item?id=24386867


I’m rereading this now and I realize I was probably thinking about Oil, not Elvish, or rather that my brain mixed some of the Elvish materials I read into the Oil author’s (extensive and illuminating) blog posts and on top of that called the resulting chimera by its smaller part. I’m sorry.


An excellent read. Googling I think it was posted only 3 months ago, so best to wait a bit...

https://www.google.com/url?sa=t&source=web&rct=j&url=https:/...


Yes, very much so - I tend to temper my language more than I'd like. Tcl is the fucking bomb.


> The speed at which you can prototype a gui is somewhat unparalleled.

While Tcl/Tk is good, it isn't better than VB, Delphi, C++ Builder, Qt Design Studio, Windows Forms on that regard.


As others already said, it's still a nice language to learn for several reasons. For one, doing even very minor stuff in the Lua-Tcl-Scheme triad gets you a good overview of the trade-offs of scripting languages, the importance of syntax etc.

But in a more practical sense, I see Tcl/Tk closer to awk these times. You won't deliver products in it, but it can come in very helpful in your own tooling or ad-hoc scripting. There's a surprising amount of uses for GUIs that are basically just a few buttons.

One very fruitful use I can remember is a factory setup, where people controlled parts of the machinery via Windows remote login. Now, if someone was already doing this and another person logged in, you basically stole their session.

So in came a very simple "busy" desktop app that just checked the status and showed an appropriately colored button. Clicking on it started the session app, I think there was even some "Please get off soon" messaging later.

There's a lot of utility in that, and Tcl makes it easy to build and deploy. Especially compared to some kind of webapp thingamajig. You probably won't sell this as a product, but that's what scripting is about.

Note that Tcl's other killer app was "expect", which enabled you to script interactive terminal sessions, e.g. getting information or executing commands via ssh. That tied in well with a GUI to display said information or trigger the commands.

Whether Tcl as a language is worth it over just using e.g. Tkinter is another matter these days.

The GUI parts of the default git (git-gui/gitk) install are written in Tcl/Tk, by the way. This means that it's likely to be installed on a developer system. Even the Windows GIT package includes it, which adds to the ease of deployment/development.


The best time was “back when it made sense”. The second best time is now.

Fantastically capable language.


I honestly think that it still makes sense. It’s a nicer language than most of the popular ones out there right now: more-easily embeddable than JavaScript, better designed than Lua. In a lot of way it would have been great had it replaced shell, although that would be a bit of a stretch.

Give it a shot!


Hmm, Ctrl-A for start of line, but Ctrl-C for copy? That's a somewhat idiosyncratic mix of CUA and Emacs.


It started out as a single script editor in under 1k lines of code written by someone else. I needed a syntax highlighting editor (so that I can see comments colored correctly in config files - useful if you use comments to turn configs on and off) so I took that script and added features. I kept the old key bindings to support old users of the original script (at its height I had like several dozen known users of the editor - people who wanted a better editor on routers and TiVo) but added key bindings to make it work more like Windows Notepad or Word/WordPerfect or SimpleText on the Mac etc, basically the "normal" GUI text editor keybinding, because I've gotten used to it. Even the Home key behavior I took from what I've come to expect on Mac code editors like BBEdit or CodeWarrior. So the ^C, ^V etc. are my additions to the script. The rest I inherited from the original script.


Is there a reason the scripts are just called `a`,`c`,`g`,`r`,`s`, and `u`?


Some communities actually promote that style. Particularly the terse array languages like APL or K/Q. Each file might only be half a page of code (you can do a lot with a single line of APL) so long and detailed names might not be necessary. You can look at all of Aaron Hsu's talks to get a better idea of this (particularly everything about his co-dfns compiler). He wrote thousands of pages of code to finally get to the final compiler that is a single page of code (fits on a t-shirt).


It makes no sense to me. Even in math notation where one-letter names and terse notation are the norm, you rely heavily on familiarity and convention to understand the notation.

Reading a computer program written in such terse style is like reading a textbook in a completely unfamiliar field, without a symbol glossary or explanatory text. The cognitive burden can be extreme.

I do agree that there is some value in higher information density and the ability to quickly "pattern match" on sections of code (eg. regex), but only up to a point.


Looking at the scripts, they're mostly wrappers intended to be called on the file or a selection, so closer to a macro, shortcut, vim mapping etc. instead of a general purpose executable name. So closer to "C-x C-k" than "M-x save-buffers-kill-terminal".

(Most of them seem to have parameters, so it wouldn't make sense to golf this even further and have a exec command that just accepts one letter)


It's because they're easy for me to remember and easy for me to type. No other reason. a=awk, c=git commit, g=go, r=replace, s=sed and u=undo (obviously z would work just as well for undo). The core idea was commands in the editor is just any executable in your system instead of a custom scripting language - kind of like CGI. You are free to implement commands in bash, tcl, javascript etc.


Thanks for the answer.


job security /s




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: