Salta al contenuto principale


#BabelOfCode 2024
Week 5
Language: TCL

Confidence level: Medium high

PREV WEEK: mastodon.social/@mcc/113906616…
NEXT WEEK: mastodon.social/@mcc/114308850…
RULES: mastodon.social/@mcc/113676228…

TCL is an odd language. I think anyone who's tried developing a programming language has probably at some point thought "what if I just didn't bother with types and did all operations as string transformations?". I think TCL is just that language.

Officially, TCL is supposed to be capitalized "Tcl". I will not be complying.


#BabelOfCode 2024
Week 4
Language: FORTRAN

Confidence level: High

PREV WEEK: mastodon.social/@mcc/113867584…
NEXT WEEK: mastodon.social/@mcc/113975448…
RULES: mastodon.social/@mcc/113676228…

I was very excited about doing TCL this week, but I told myself the first time I get a two-dimensional array problem I'd go FORTRAN, so I guess this week is FORTRAN.

A friend of mine who did AOC2024 in December noted the early challenges this year were *very* easy. Today's definitely is. I wonder if part 2 will have any depth.


Questa voce è stata modificata (6 mesi fa)

Oblomov reshared this.

in reply to mcc

I have near zero experience with TCL. In the late 90s when I started using Linux it was already considered old; I had one program that used it, a Tk-based AOL Instant Messenger client that was, admittedly, the nicest piece of Linux GUI software I had.

TCL is almost gone today EXCEPT in the Verilog community, which uses it religiously because it's a single language they can use both for build scripts (because it's designed as a scripting language) and as a template language (it can do that too).

Oblomov reshared this.

in reply to mcc

I think that I needed something about Tcl/Tk in graduate school. I think someone told me that it was like Smalltalk. I don't know if looking for Smalltalk resources will help you sort it out.
in reply to Sepideh

@sepdroid Not doing tk. Coming to Smalltalk/Self at some point on this project's list however.
in reply to mcc

The fact I'm picking the languages in this project slightly independently of the problems may be leading to poor pairings (I don't know what problems are coming up, so it's hard to make a schedule that maps well). I think what I most wanted to try with TCL was complex string manipulation. But AOC2024 day 5 appears to be asking me to implement… some sort of sorting algorithm? An auto-sorting data structure? This may turn out to be hell in the exact way trying to do file input in FORTRAN was hell.

Oblomov reshared this.

in reply to mcc

Oh… … I don't like this. I really don't like this.

(The thing I don't like is that {}, which you might want to use instead of quotes due to the balancing feature, also disable interpolation. There aren't a lot of language design concepts I got out of Perl that I still think are good ideas, but the one I still strongly believe is that every language needs easy-to-use balanced quote delineators. `qq` is the best thing in Perl.)

in reply to mcc

I think that means you can use double quoted strings instead of curly brace blocks for if-statements and loops, but you have to escape their contents 🙃
in reply to mcc

I have a programming language I was implementing for a while in the 00s named Emily. There were three versions of it, two of which got released, and all three passed through a phase in their development where they were basically "curried LISP without parentheses".

Every time I get exposed to Tcl, I become more convinced that "curried LISP without parentheses" as the whole concept for a minimal-size-interpreter language is actually a super good idea. (TCL isn't this.)

youtube.com/watch?v=gMZsc3cvwK…

in reply to mcc

My only structural objection to TCL is the comments being a first-class language thing instead of being removed before parsing. Abhorrent deviation from normal languages and makes working with TCL such a pain in the ass.
in reply to Michael Kohne

@mhkohne Would you describe this as a pain when writing TCL or only when implementing TCL?
in reply to mcc

sorry, writing. I can't imagine it'd be worse than any other multi-word primitive on the parsing side.
in reply to mcc

*makes a noise as if she were being strangled by her own throat*

Oblomov reshared this.

in reply to mcc

.......I'm sorry is this intended to be ritual magic?
in reply to Fi 🏳️‍⚧️

@munin It appears the correct usage of "expr" in tcl is

[expr {expression goes here}]

It also appears that [expr expression goes here] is allowed, but this is a coincidence/accident, and there are at least two reasons to never do it, one of which is a security flaw

in reply to mcc

@munin check out the switch statement for another case where there's a right way to do things and a potentially unsafe way to do things
in reply to mcc

I only saw this toot in the series and immediately guessed the cursed language
in reply to mcc

there are security reasons to always use braces with expr
in reply to mcc

mastodon.social/@mcc/113975863…

mastodon.sdf.org/@sgeo/1139758…

Currently terrified by the possibility that at some point I will wind up writing a TCL linter


@munin It appears the correct usage of "expr" in tcl is

[expr {expression goes here}]

It also appears that [expr expression goes here] is allowed, but this is a coincidence/accident, and there are at least two reasons to never do it, one of which is a security flaw


in reply to mcc

The official TCL tutorial actually contains a section named "More Quoting Hell"

Oblomov reshared this.

in reply to mcc

Okay. I actually was able to get through the TCL docs very quick. I would have got through it even quicker if I occasionally hadn't had to stop and do something else for a while because something pissed me off.

I am tempted to call this an "elegant" spec. I think I would actively like this language if the syntax were restricted somewhat for safety (e.g. if {} were *required* for things such as expr, if, for instead of "you can leave them out but then it probably does something horribly wrong").

in reply to mcc

Here are my TCL questions:

- I see that there are "integer", "wide integer", "float", "list" and string types in TCL. Is there a builtin that can discern which type a variable has and/or discern which type[s] a variable can be coerced to?

- Is there a string concatenation operator? (besides "$a$b").

- What is the difference between an array¹ and a dict? The tutorial makes it clear both exist and explain the difference very poorly.

¹ This refers to an associative array not a list

in reply to mcc

Answers to the above questions per #tcl on libera:

- Type compatibility in tcl can be tested with [string is …]. "Actual" (interpreter level) type is apparently not exposed. tcl-lang.org/man/tcl8.6/TclCmd…

- Strings can be concatenated with [string cat …].

- Arrays are "weird"; they live in a single scope and can't be exported or passed to a function except by breaking things with "upvar". Additionally, dicts are ordered. "arrays" feel like an old version of "dicts" and I think I intend to avoid them

#TCL
in reply to mcc

My TCL notes file:

{} => ""
[] => ``
set x y => x = y
[expr {…}] => "act like a programming language"
[subst {…}] => {act like ""}
$ and [] work within "" but not {}
eq ne in ni
einter => coerce
proc parameter named "args" is variadic if last
first $ in $$a does nothing
format => sprintf
lsearch and regexp are different
for {} {} {} => for(;;)
[subst $$a] => dereference $a
[string is …] => typecheck
strings are not strings

Before running:
sudo apt install rlwrap
alias tclrl='rlwrap tclsh'

Questa voce è stata modificata (8 mesi fa)

Oblomov reshared this.

in reply to mcc

Have you seen command prefixes? They're the most modern way to have something similar to a lambda. (tcllib has a lambda command that makes command prefixes).
in reply to mcc

If you have a part of a command, like "string compare foo" in a variable a, you can invoke it as {*}$a bar

And can construct it via [list string compare foo]

wiki.tcl-lang.org/page/command… goes into depth about them.

in reply to mcc

I have just written my first TCL program in an hour or two after waking up. I regret to report I found it a very enjoyable experience. "boogerman" from the FPGA discord wins once again. Unlike the very start-and-stop experiences I had with FORTRAN and Forth (due to bad ergonomics and docs), ASM (due to its basic nature) and BASIC (due to both) I found I just *wrote code*; the way to proceed was always obvious. And my final code was terse, despite a complex algorithm including a BFS graph search.
in reply to mcc

isnt that the old tcl bit? that tcl is like a hot cow through lard if you want to write a complex parser but impossible to do string manipulation in?
Questa voce è stata modificata (8 mesi fa)
in reply to mcc

I miss my TCL days. It was the language of choice for extending the functionality of 'eggdrop’, a popular (in its niche, and late-90s) IRC bot.

As a language for extending other softwares, I feel that TCL was succeeded by Lua, a language created here in Brazil. Do you intend to test it too?

in reply to TÔ DE MUDANÇA

@augustocc The rules of the challenge are to only use languages I haven't used before, and I have written a *lot* of Lua, lol (I released like… five to fifteen games using it in the early 2010s, and then spent five years writing it professionally 2018-2023?). I use it less and less due to the lack of a viable typechecker (there's two typecheckers, neither of which *exactly* fit my needs) but I think Lua might literally be my favorite programming language, possibly even above the one I designed.
in reply to mcc

oh, I am so sorry, I didn't connect the dots and hadn't realized that I was addressing the creator of Emily. Keep on rocking!
in reply to mcc

I don't think, at the moment, I'd *pick* TCL over another comparable (lua, typescript, python) language. The excessive "cleverness" of the spec leads to frustration and checking the documentation every time I write a function call: When is {} required or optional? When using a function like lindex or lappend, when is including $ mandatory and when is it banned? Again, if I could get "the typescript of TCL", or even the "use strict" of TCL, I'd maybe actually choose TCL on purpose for some things
in reply to mcc

This isn't so bad though? Like at least I *can* check each call against the docs, because the docs are very good. And maybe I can even make my "use strict tcl" by forking molt docs.rs/molt/latest/molt/

Anyway, my "final" program:

github.com/mcclure/aoc2024/blo…

…not final. Because the code doesn't *work*, but I think that's due to an unclear problem statement (the code gives correct results on the given sample input and a sample input I wrote, but fails on the "real" input. AOC is like this sometimes.)

in reply to mcc

Incidentally, re mastodon.social/@mcc/113975786… , I spent all night thinking about the question "what if Emily, but more like TCL?" and I think I've come up with a *brutally* simple yet actually usable language design which would be unusually easy to design a JIT compiler for (the thing that killed Emily 2 was me not being able to make the interpreter->compiler jump). I actually really want to drop everything and implement this as a JIT learning exercise but unfortunately there is too much everything


I have a programming language I was implementing for a while in the 00s named Emily. There were three versions of it, two of which got released, and all three passed through a phase in their development where they were basically "curried LISP without parentheses".

Every time I get exposed to Tcl, I become more convinced that "curried LISP without parentheses" as the whole concept for a minimal-size-interpreter language is actually a super good idea. (TCL isn't this.)

youtube.com/watch?v=gMZsc3cvwK…


in reply to mcc

Realizing that I must have been misreading the ambiguous and convoluted-ly worded instructions for AOC 2024 day 5, I tried implementing two alternate versions of my program with alternate interpretations of the prompt text. Neither produced better results than my original. Actually, both did worse. I'm gonna try going back to my original version and making it stricter.
in reply to mcc

I just caught “AOC 2024” and was simultaneously intrigued and disappointed.

As you were 🫡

in reply to mcc

Update: Out of 5 different possible interpretations of the problem-statement-as-written I can imagine, it turned out AOC wanted me to do the least interesting one. I now have part one done. I am more impressed with the language this week than I am with the challenge

Oblomov reshared this.

in reply to mcc

I saw this toot in isolation and it took me a while to figure out what AOC meant in this context
in reply to mcc

Couldn't sleep so I got up and tried part 2. It took like… minutes. Thank goodness for Perl/Python style sort comparison functions. Now seriously wondering how many of the things I like from Perl/Python are actually just adopted from TCL.

github.com/mcclure/aoc2024/blo…

True final code's a mess, due to both scars of me making random changes trying to figure out what the problem spec wanted and commented-out debug prints. I think TCL code could be quite clean if you went about it properly.

Glrbfghf

Questa voce è stata modificata (8 mesi fa)
in reply to mcc

hard to say since Perl is just slightly older than tcl, and both language creators were very good about stealing good ideas from everywhere
in reply to mcc

the cleanliness even as sort of a quick script is impressive. It makes me wonder if there’s some specific reason tcl didn’t get picked up over lua for all the places we see lua. (I think I’d rather write tcl) Maybe binding it to other langs is hard?
in reply to Justin 😸

@onyxraven I think if I had to make a specific case for Lua over Tcl, it is much easier to write incorrect code in Tcl and when you do it's harder to debug it. There are fewer guardrails.

This said, I don't think the "lua displaces tcl" was as direct as all that. I feel it went like "TCL is popular for scripting and embedding" -> "perl and python eat tcl's space, but perl can't be embedded, and embedding python is obnoxious" -> "Lua arises and becomes popular for embedding, but not scripting".

in reply to mcc

@onyxraven Incidentally it's very frustrating to me that JavaScript is not easier to embed in an application. People will write a whole app in Electron but putting a little JS interpreter in their non-JS app is so much rarer.
in reply to mcc

@onyxraven if Tcl had ended up being the scripting language of the web (which was close to happening, and it was the first web scripting language in Mosaic), we would have had both 😀
in reply to mcc

What I'm still trying to figure out: I've heard of people using TCL as a template language. I have been looking for a turing-complete template language to generate ASM and possibly Verilog. I'm unclear how exactly you do this with TCL. I guess do you just… do you just have a thin trampoline script that loads your template file and runs [subst] on it? Is this something people actually do?

Oblomov reshared this.

in reply to mcc

Never tried it with TCL, but did write a Z80 assembler in Common Lisp and the user-most part of that was basically just macros (if memory serves me right).
in reply to mcc

it's been a long time... but IIRC in Tcl 'everything is a string', and you can evaluate Tcl code inside a string (what's known as 'f-strings' today in other languages):

onecompiler.com/tcl/438sr4qpa

...maybe today not so impressive anymore since a lot of languages got those f-strings too.

in reply to mcc

If you're looking for Verilog, perhaps SpinalHDL is close to what you're looking for?
spinalhdl.github.io/SpinalDoc-…
I know about it from following VexRiscV
github.com/SpinalHDL/VexRiscv
in reply to Network == Abstraction Layer

@overunderlay An alternate HDL is an entirely different thing to be looking for than a template language for a specific HDL.
in reply to mcc

# Here is the script I came up with for
# "interpret a file like a TCL template".

if { $argc != 2 } {
puts stderr "Need in-file and out-file args."
exit 1
}

proc x {} {
return ""
}

set input [open [lindex $argv 0] r]
set output [open [lindex $argv 1] w]
puts $output [subst [read $input]]

in reply to mcc

Yes. We had a "plugin" feature that was basically storing Tcl in the db. You could do anything the "outer" program could do, including delete itself from the db. Perfect for malware!

But on the cybersecurity form we said it was "plugins".

in reply to mcc

I have personally used [subst] in exactly that way: as a templating language for stuff. It's very effective for some basic things. Also really easy to build around it and do even more powerful things due to how #Tcl allows you to build your own language constructs.

So like in addition to [foreach] I could do a [webForeach] (for wont of a better name) that returns whatever string is in it, concatenated for each iteration, but runs [subst] on it for each round.

#TCL
in reply to mcc

i remember this problem! (I did a few AOC problems this year until I got distracted and lost interest). I was so excited that I get to implement my own sparse-matrix multiplication. And then they didn't even want me to use it. So frustrating
in reply to lambdageek

@lambdageek Yeah, I think you made the same mistake I did! I find something very satisfying about doing graph operations with perl dictionaries representing an edge list, and I was happy TCL let me do that… until I realized the graph operations weren't actually wanted…
in reply to mcc

@lambdageek anyway the early puzzles seem REAL easy this year so I hope it picks up. Last time I did this they got pretty complex by the end…
in reply to mcc

@lambdageek gonna be annoying if I try to use this to learn Idris or something and the challenge is something like "write a sort"
in reply to mcc

oh no!

FWIW, I seem to recall merge-sort isn't too too terrible in a dependently typed language - you convert the input into a big dependently typed tree where the dependent indices are the upper and lower bounds for the contents of that subtree and then flatten it. Something like that...

Edit: I think this is either missing a complicated bit, or it's actually describing insertion sort. Looking at other developments online, there's more to it

Questa voce è stata modificata (8 mesi fa)
in reply to lambdageek

@lambdageek i'm reasonably certain i've implemented merge sort with no mutable data structures… i do not specifically know what additional complications dependent typing would add but my intuition is that since each time you recurse you're dealing with "smaller" items that the dependent typing requirements would be happy
in reply to mcc

i think $ is mandatory iff the variable binding is modified
in reply to ✧✦Catherine✦✧

@whitequark In fact, it is the other way around 🙁 If you say

procname $a

You are passing in the value, and if you say

procname a

You are passing in the string "a", and procname will use upvar to scoop the variable $a out of your scope and modify it. The docs make this consistently clear by naming parameters either "stringvalue" or "stringvariable", but I had to figure out that pattern on my own.

in reply to mcc

totally agree it's too clever, which also makes it so fun to use! @omar wrote a bit about why he chose it for folk.computer's datalog-style language

github.com/FolkComputer/folk/b…

in reply to mcc

@jwcounts (upvar is the tcl equivalent of Lua "getfenv". it can be used to screw arbitrarily with the scopes of functions higher up the stack.)
in reply to mcc

I have been (slowly) working on a spec that would unify dicts and arrays for #Tcl. I think they desperately need that. But arrays are indeed older. They are basically uniquely named variables.
#TCL
Questa voce è stata modificata (8 mesi fa)
in reply to mcc

@nev …okay a lot is up with me but i don't have time to list it all right now lol
@nev
in reply to mcc

it should be cheating to not post to the newsgroup first
in reply to nev

@nev firefox keeps removing all the cool features
@nev
in reply to mcc

…I'm not sure Firefox ever had newsgroup support? Maybe a very long time ago?

Still works fine on Thunderbird

in reply to mcc

Used to code my own eggdrop IRC scripts with Tcl. Fun times. What an oddball.
in reply to mcc

oh no problem, just put the string "use strict" as the first line of code!
(i have no reason to assume this actually does anything)
in reply to mcc

"An Elegant Weapon for a More Civilized Age.”

I wrote a whole id card printing system for a govt in TCL (then printed my own card with it).

Then when the foolishly tight ministerial deadline had passed we re-wrote it in C (or was it java - I forget).

in reply to mcc

btw instead of [expr], I do simple maths with math ops commands (commands like + - etc). Work in a Lisp like way.
in reply to mcc

TCL is awesome like that. Back in the day I installed some fun script on my eggdrop and when I had [afk] in my nick I noticed in the bot logs "afk unknown command".

Changing your nick to have [die] in it had pretty funny results, on far more than just my bot. Apparently it was really easy to mess this up.

Last time I told this story some TCL nerd went "🤓 ackchually `die` isn't a valid TCL command", to which I said "shut the hell up nerd, it's a valid *eggdrop* command."

in reply to mcc

One time I was working with some particularly cursed tooling that had TCL scripts generating TCL scripts and involved a ludicrous number of backslashes
in reply to mcc

If you should run into a friendly yak looking to be shaven, perhaps you could write a Lua-to-Tcl translator? :blobcatinnocent:

Oblomov reshared this.

in reply to mcc

we should make this a thing in C, instead of using `-O6` to optimize the whole thing you could just use `{` and `}` to indicate code that's just cool and normal vs. using `{{{{{{` and `}}}}}}` to indicate a critical piece which should be highly optimized.

reshared this

in reply to nick

@nickzoic I don't know why but code surrounded by an army of curly brackets feels to me like adding the "intensifies" suffix to a it
@nick

Oblomov reshared this.

in reply to BrazMogu (i.e. Bruno Guedes)

@brazmogu __attribute__((spoilers))
for when reading the source will just ruin the surprise.

reshared this

in reply to mcc

if this language were a movie, it would be 10,000% acceptable to walk out of the theater at this point, and everyone would agree that we can all pretend that that movie does not exist, we never saw it, and we were all somewhere else at the time of the alleged screening (which did not happen)
Questa voce è stata modificata (8 mesi fa)
in reply to mcc

Is expr { expr {$1 * 10} } faster than expr {$1 * 10}?
in reply to Bitslingers-R-Us

@AnachronistJohn
Is 1+0+0 faster than 1+0?
Of course not; there are few opcodes on the right expression, so the left is constant-order slower by the number of "+"

Same here, but compounded two similar ways:

First, your left expression has an extra code block, which means storing off exception stack, local variable scratchpad, etc, and then restoring them all when done.

Second, I would expect "expr" itself to be a heavyweight opcode, having to prep for a whole new execution context.

in reply to Dragon-sided D

@AnachronistJohn IIRC TCL is kinda doing the opposite of what you'd expect from the syntax in any other language; the braces are telling it to keep the stuff inside in the *current* execution context

(but I could be wrong; haven't used TCL in a loooong time)

in reply to Dragon-sided D

@AnachronistJohn Hold up, finally reading the thread more carefully:
> {} ... disable interpolation

But wait if interpolation is disabled, I expect "$i" to be a literal string, not a variable with some numeric value.

Right?

So
{$i * 10}

Should either error out, or evaluate to 0 assuming Perl-like treatment of nonnumeric strings as 0 value

in reply to mcc

@AnachronistJohn FML
So yeah, eval is itself even more expensive than I assumed

TCL was useful only as a way to deliver Tcl/Tk

Now... I mean, we have Befunge

in reply to dixego

@dixego if you think deeply about how the engine works you will realize how this makes sense but also you will become very unhappy
in reply to mcc

Fascinating ideas. I love this kind of thing. Thanks for sharing.
in reply to Chris Ammerman

@cammerman It was actually quite usable as a programming language, although I'm not happy that you had to carefully keep track of when to use () and when to use {}

(TCL also has this problem a little.)

in reply to mcc

I think it would be really interesting to try to write something in Emily. Or to try to learn an Emily codebase.

I think it would be tough for me coming from a C-family language background, we love our commas and curly brackets. Losing them feels almost like losing an eye.

in reply to mcc

isnt this basically haskell lite? hm i wonder what that is, maybe like nix? it has currying unless im misremembering. not a bad little language.
in reply to Ellyse

@ellyxir it is trying to be dynamically typed ML, and ML is haskell lite.

(the name is a reference to ML. ML-y.)

in reply to mcc

OHHHHhh ok, i need to check out ML one day. but APL first. i think. but scary.
in reply to Ellyse

@ellyxir the version of ML people mostly use these days is called OCaml.
in reply to mcc

ahhh yes, it seems like a very pragmatic language thats actually has a good ecosystem and library support. will get to it eventually.
in reply to Ellyse

@ellyxir If you look at it, my advice is:

Short term advice: opam is very nice and I recommend using it early

Longer term advice:

- You can ignore the OOP extensions, I never used them
- Do not use ocamlp4. If you are tempted to ocamlp4, use ppx.
- Do not be afraid of ref

in reply to mcc

You can [eval { ... }] to get the interpolation back...

But yeah, it's terrible compared to today's languages. And don't get me started on the lack of libraries.

You can see why it would be great as a better shellscript, tho.

in reply to mcc

there’s a very important reason for that. Remember, everything is a string. Code is too. Passing a code body to e.g. [proc] is just that. You are not passing a block, but a string wrapped in {} so as to avoid evaluating variables and everything else inside the body parameter. You could pass it in “ but you would have to escape lots of stuff.

#Tcl takes a while to fully understand, but it is very consistent which allows a lot of very nice things.

#TCL
Questa voce è stata modificata (8 mesi fa)
in reply to mcc

«this year I'm going to do AOC by choosing the worst fit language for each of the tasks»

Joking aside, I wonder what are the chances that picking languages at random* one ends up with the worst possible pairings?

*Or at least independently from the task

in reply to mcc

It feels like there are "ideal" versions of babel of code where languages are matched either ideally or optimally badly to their problems. I imagine one would feel incredible—until you tried to use a language for anything else—while the other would feel awful the entire time but make it surprisingly pleasant if you ever used one of those languages again.

I would've guessed more random pairings would be the best way to avoid that disenchantment but it sounds like that just hits both extremes. v_v

in reply to [_]

@_ Yeah, it might be a team doing an AOC and then publishing a "curated" list of languages for that AOC would be interesting.
@[_]
in reply to mcc

Meanwhile, in the Wild World of HPC: github.com/envmodules/modules

(Just had this 'splained at FOSDEM, use it daily at the $DAYJOB.)

Oblomov reshared this.

in reply to mcc

Interestingly, it survived well into the 2000s on macOS in the form of MacPorts, which was one of the more popular macOS distributions of free software until it was supplanted by Homebrew: guide.macports.org/#developmen…

You keep on finding Tcl in these weird little niches, like MacPorts and the Verilog community.

Interestingly, @cliffle has recently mentioned that he has two different embedded Tcl-like languages that he maintains, written in Rust: github.com/cbiffle/wartcl and github.com/cbiffle/remolt

It seems like one of these little languages that's never really prominent, but will never really go away either.

in reply to Brian Campbell

@unlambda @cliffle tcl is actually one of the interpreters that Apple couldn’t get away with removing from the core install of recent versions of macOS, since the Unix conformance test suites depend on expect

Oblomov reshared this.

in reply to Joe Groff

Sensitive content

in reply to Mark Bessey

@mbessey @joe @unlambda @cliffle maybe if you design a language around the principle it should be easy to put inside of other things then that language will wind up frequently put inside of other things
in reply to mcc

Agree, Tcl has become a niche language.

It's quite small and easily linked into C projects if you want to add configuration and scripting. I suspect that Lua has overtaken it in that area, too.

There's one closely related language which I constantly come back to: Expect en.m.wikipedia.org/wiki/Expect

I've found nothing better for automating interactive programs.

Oblomov reshared this.

in reply to mcc

i have used TCL in exactly one place and it was configuration scripts at a particle accelerator
in reply to mcc

Tk was surprisingly good for UIs, including cross platform applications that actually manage to look native everywhere except Unix where they look kind of ugly.
in reply to mcc

one more weird use case for expect(1) is automating the UEFI TUI and UEFI Shell over a serial console.
in reply to mcc

One of the other niches where TCL persists is in spacecraft testing, particularly in Europe, where it is the scripting language for a popular test automation software suite.

I found TCL hideous to begin with (and still do for anything intensely numerical), but found more things to like about it as time went on. I particularly like that its homoiconic nature supports writing seamless script language extensions - something I miss when working in Python and similar languages.

in reply to mcc

I don't think I ever used Tcl directly, but I have to admit a fondness for Tk, as a simple GUI library you could use from pretty much any language on pretty much any platform without having to learn some new paradigm
in reply to mcc

It is a close cousin to shell script except command lines call functions instead of programs.

I don't know if they ever fixed this but at the time I used it, "what if it was all strings?" specifically meant C strings and as a result you couldn't handle binary data with zero bytes because they would be treated as string terminators.

Unknown parent

Unknown parent

mastodon - Collegamento all'originale
mcc
@dysfun No it's because it is an ML-y language
Unknown parent

mastodon - Collegamento all'originale
mcc
@stuartyeates *checking* oh, Lua has this too actually
in reply to mcc

You see, in the '60s, a breakthrough was done in linguistics, Noam Chomsky & his pals developed generative grammar theory, and it turned out so useful that Niklaus Wirth and his pals made it into a whole theory of how to make nice programming languages.

Unfortunately, the way it's commonly taught "looks like maths". There's a type of people who hate this look, and there have been several waves since late '1960s to build programming languages while avoiding the fun theory. Making everything into a string is typically a common starting point, even though it only really works well in the context of shell scripts, preprocessors, and, arguably, m4. In REXX's world, it's probably defensible, because REXX is primarily a shell scripting language (for some weird kinds of shells, out of the IBM's world). In SAS macro language's world, it's somewhat defensible, on the basis that it's "supposed to be" a preprocessor. I wouldn't dare to argue for it in any of the contexts that Tcl is used, though.

A sad irony is, while a lot of people imagine Tcl to have come out before solid competitors to it were available, this is also not the case. Tcl is way younger than, for example, AWK. (And AWK was carefully hand-designed using Wirthian theory, until somebody at Bell Labs shaved enough yaks to make yacc.) If not for the early flames of copyright wars, Tcl would probably have died within a few years the way most bad ideas are supposed to.

in reply to mcc

Back in the early days at TiVo we used a lot of Tcl. I finally printed out the one page in the documentation that describes the string substitution rules and taped it to the wall.

The thing that hurt my head the most, coming from a Lisp background, is that a list containing one thing and the one thing have exactly the same representation.

in reply to mcc

The thing people missed about Tcl was that it was meant to be a language you built into things, a foundation for creating DSLs.

It did happen, there is a number of routers&switches which you configure in Tcl, and it pops up in odd-ball industrial and medical equipment configurations as well.

Lua came five years after Tcl, aiming for the same niche.

The world would have been a much better place if Intel had used Tcl or Lua instead of inventing the kludge ACPI.

Questa voce è stata modificata (8 mesi fa)
Unknown parent

mastodon - Collegamento all'originale
mcc
@Scmbradley I will not be complying
Unknown parent

mastodon - Collegamento all'originale
mcc
@Scmbradley Yes, I find occasionally AOC problems are like this. I half suspect the AOC author does this on purpose, because sometimes parsing unclear requirements is a part of software engineering. I'm gonna have to reread the (very convoluted!) problem statement like 3 times carefully to find the detail I missed (I already found one ambiguous sentence and tried inverting my interpretation of the ambiguous sentence, this it made things worse) (don't tell me what i missed btw)
Unknown parent

in reply to mcc

Sensitive content