Hacker News new | past | comments | ask | show | jobs | submit login
Implement Tcl in Tcl (2007) (tcl.tk)
76 points by blacksqr on Sept 18, 2017 | hide | past | favorite | 24 comments



Clicked on the link to check what it was about, and discovered the implementation was mine. Did not remember at all this stuff.


I have vaguely similar experiences when hitting up a google search result on Stack Overflow only to discover the answer/solution I'm looking at is one I wrote years ago.


I can relate to this. I once started searching for an I2C driver for a Kinetis microcontroller, only to have Spotlight find one sitting on my hard drive. I had written one and forgot all about it.

This is when I decided to post any reasonably-complete code on GitHub: so that I can easily find it later on.


Out of curiosity, how come Redis uses Lua instead of TCL?

They're both neat, small, fast little languages, and they're both based around a powerful primitive used everywhere (tables in Lua, strings in TCL). I think TCL is a bit more elegant, while Lua is a bit more familiar.


To maximize familiarity indeed. Lua is more algol like. Moreover while the Tcl implementation is small is nowhere near the ANSI C target of Lua that compiles even into a toaster.


For anyone who learned Prolog, implementing Prolog in Prolog is a classic exercise in the language which can be one in a dozen lines. The goal is to be able to modify the language to handle additional syntax that is problem-specific (think about a macro system that can implement in its own syntax).


Even aside from changing the syntax, you often have to do this to modify the resolution strategy, such as using breadth-first instead of depth-first search, or add probabilistic or fuzzy logic. A lot of papers on Prolog from the 80s start with "what would it be like to use logic-X from Prolog?" You can do a lot of interesting deep cuts like this without a huge amount of work. Prolog even has a built-in context-free parser that works the same way: definite clause grammars.


Personally, I would like to see a lisp replicating tcl functionality, in other words an alternative surface syntax that could reuse existing pure tcl libraries or at least be able to transpile them to this lisp.


If anyone is interested in this and haven't heard about it already there's also Python implemented in Python:

https://pypy.org/


Wikipedia has a long list of languages which have been bootstrapped, including BASIC, C, Python, Perl, Java, Rust. https://en.wikipedia.org/wiki/Bootstrapping_(compilers)


Perl 6 (Rakudo, the main implementation) is implemented in its subset - NQP (Not Quite Perl).


A Tcl in Tcl. A Tcl-ception.

Is this is also a kind of compiler bootstrapping?


Interpreter bootstrapping, but probably with no clear motive. This appears to be just for fun, since it would be such a slow beast.


The word is "metacircular". It's easy in some languages, difficult in others.

I never learned Tcl properly but found the rules for quoting and evaluation of program strings to be a confusing aspect. That was 20 years ago, and I thought the language was effectively dead ten years ago.


Really ? I've found it to be the simplest language ever. It is just defined with 12 rules and that's all. I miss that lovely animal.


Indeed, but this is the third time I've seen a Tcl reference in as many days. Is someone trying to make it come back?


Tcl never went away. It's everywhere. It's like Clara Oswald, the impossible girl, always behind the scenes giving crucial aid without drawing attention.


Bah, now I have to hate it


I've seen it pop up a fair amount recently as well and a new book is out that looked quite extensive (Ashok might be the author).


It is very much alive and kicking in the EDA industry, all the tools use it as their command language.


Why stop there? Implement Tcl in Tcl in Tcl.


If you've implemented it in itself once then you've also implemented it in itself an infinite amount of times I think.

You run your interpreter in the official interpreter, then you run your interpreter in that, in that, in that, in that, ...


Interpreters all the way down? ;)


"Yo dawg, I heard you like Tcl..."




Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: