Live data from Hacker News

Tcl 9.0

tcl-lang.org

31–40 of 247 posts

Re: Tcl 9.0

#31

I know of Tcl but I don’t know anything about its structure. The number one thing I ask of a language is consistency: the minimal amount of magic and most of the language implemented in itself. Ruby almost got there and then, for me, slipped up on class . How does Tcl fare under these criteria?

The Tcl language is made up of commands; a command has a name and takes an argument list, with which it can do literally anything. The standard commands are written in C; Tcl `procs` are commands that are written in Tcl. The control structures, like `if` and `foreach` and `while` is just a Tcl command. The `proc` command that defines a proc is just a Tcl command.

I think of it as Lisp for C programmers.

So: is the language implemented mostly in itself? No, it's mostly implemented in C. Is there a minimal amount of magic? No; the amount of magic you can do is effectively unlimited.

Re: Tcl 9.0

#32
post #12
post #8

The only time I’ve dealt with Tcl in recent memory was for some MacPorts portfile stuff. Anybody using it for something else and can speak to why you’d use it today? Genuinely curious; I don’t hate the language but can never bring myself to enjoy it either.

Tk based GUIs work across pretty much all desktop platforms and are much less resource intensive than electron and friends.

Absolutely. It's even been remarkable stable--programs written 20 or 30 years ago work without any kind of modification.

Re: Tcl 9.0

#33

Earlier quoted context omitted.

In the long run, special cases like that often turn out to be more trouble than they are worth. If an ordinary file happened to start with '~' it would not be handled correctly. So you either accept or ignore that potential problem, or you have to write extra code to work around it. It's safer to not have such special cases at all.

Should be starts with ~/

No, ~abc will be interpreted as the home directory of user abc in Tcl 8.*

Re: Tcl 9.0

#34
post #8

The only time I’ve dealt with Tcl in recent memory was for some MacPorts portfile stuff. Anybody using it for something else and can speak to why you’d use it today? Genuinely curious; I don’t hate the language but can never bring myself to enjoy it either.

I used it a few weeks ago to fetch and display access timing histograms in an FPGA project.

Re: Tcl 9.0

#35
post #8

The only time I’ve dealt with Tcl in recent memory was for some MacPorts portfile stuff. Anybody using it for something else and can speak to why you’d use it today? Genuinely curious; I don’t hate the language but can never bring myself to enjoy it either.

I think of Tcl as Lisp for C programmers; by which I mean, Tcl give you the metaprogramming capabilities you get with Lisp in a language that looks more like C, plays well with C, is much more straightforward than your typical shell language, and has a cross-platform GUI. A skilled Tcl programmer can do magic. I spent ten years, from 2005 to 2015, programming almost entirely in Tcl/Tk and I loved it. Since then I mos…

I should add...Tk is the easiest GUI toolkit I've ever used (and I've used a bunch of them). It's got all the basic stuff you need, either built-in or readily available. But it comes from the classic desktop GUI world, you have to work at it to make it look nice, and it's a pain to do webpage-like layouts with it.

I wouldn't do an end-user GUI in Tk at this point; but for in-house tools that need a GUI and don't need to be on the web it's hard to beat.

Re: Tcl 9.0

#36
post #8

The only time I’ve dealt with Tcl in recent memory was for some MacPorts portfile stuff. Anybody using it for something else and can speak to why you’d use it today? Genuinely curious; I don’t hate the language but can never bring myself to enjoy it either.

I should also note that Richard Hipp, the creator of SQLite, says that SQLite is coded in Tcl. The database engine itself is coded in C, of course; but the vastly larger test suite is mostly coded in Tcl; and it's the test suite that makes SQLite the reliable engine that it is. The test suite persists; the engine's been re-written in whole and in part.

Re: Tcl 9.0

#37

I know of Tcl but I don’t know anything about its structure. The number one thing I ask of a language is consistency: the minimal amount of magic and most of the language implemented in itself. Ruby almost got there and then, for me, slipped up on class . How does Tcl fare under these criteria?

Tcl is incredibly consistent, because it's homoiconic.

Re: Tcl 9.0

#38

I know of Tcl but I don’t know anything about its structure. The number one thing I ask of a language is consistency: the minimal amount of magic and most of the language implemented in itself. Ruby almost got there and then, for me, slipped up on class . How does Tcl fare under these criteria?

The Tcl language is made up of commands ; a command has a name and takes an argument list, with which it can do literally anything. The standard commands are written in C; Tcl `procs` are commands that are written in Tcl. The control structures, like `if` and `foreach` and `while` is just a Tcl command. The `proc` command that defines a proc is just a Tcl command. I think of it as Lisp for C programmers. So: is the l…

> Is there a minimal amount of magic? No; the amount of magic you can do is effectively unlimited.

I might be mistaken, but I think the OP was asking if there is surprising magic (I.e. special cases/considerations) built into the language, in which case I’d say, “No, Tcl is not “magical”, but surprisingly simple and regular.” That said, indeed it’s powerful in its application of its primitives, but you do still need to mind some things (don’t pretend* you can quote better than the quoting engine, don’t pretend* you can do lists better than the list processor, …). Not magical though - very understandable.

*rules are meant to be broken, blah, blah, but the “gotchas” are new practitioners falling into this, or advanced cases, falling into this…

Re: Tcl 9.0

#39

I know of Tcl but I don’t know anything about its structure. The number one thing I ask of a language is consistency: the minimal amount of magic and most of the language implemented in itself. Ruby almost got there and then, for me, slipped up on class . How does Tcl fare under these criteria?

The Tcl language is made up of commands ; a command has a name and takes an argument list, with which it can do literally anything. The standard commands are written in C; Tcl `procs` are commands that are written in Tcl. The control structures, like `if` and `foreach` and `while` is just a Tcl command. The `proc` command that defines a proc is just a Tcl command. I think of it as Lisp for C programmers. So: is the l…

It's also absurdly easy to integrate into C or C++ projects, or to write an extension in C or C++ which can be loaded to implement new commands.

Re: Tcl 9.0

#40
post #8

The only time I’ve dealt with Tcl in recent memory was for some MacPorts portfile stuff. Anybody using it for something else and can speak to why you’d use it today? Genuinely curious; I don’t hate the language but can never bring myself to enjoy it either.

I often use the tool that is closest to another tool I am using. The closeness may be due to a common heritage, both technical and cultural. A common thread between the two is often high quality, maturity, cross-fertilization, long-term commitment, etc.

Now when it comes to Tcl, I use it for the above reasons because it is so convenient for writing scripts to use SQLite. In other words, it is my go-to wrapper for many SQLite applications. This is mainly related to (rapid) prototyping use cases.

From https://sqlite.org/tclsqlite.html :

> The SQLite library is designed to be very easy to use from a Tcl or Tcl/Tk script. SQLite began as a Tcl extension and the primary test suite for SQLite is written in TCL. SQLite can be used with any programming language, but its connections to TCL run deep.

Post reply on HN