
Implement Tcl in Tcl (2007) - blacksqr
http://wiki.tcl.tk/12646
======
antirez
Clicked on the link to check what it was about, and discovered the
implementation was mine. Did not remember at all this stuff.

~~~
zeveb
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.

~~~
antirez
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.

------
coliveira
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).

~~~
fusiongyro
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.

------
fithisux
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.

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

[https://pypy.org/](https://pypy.org/)

------
mmahemoff
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)](https://en.wikipedia.org/wiki/Bootstrapping_\(compilers\))

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

------
stevefan1999
A Tcl in Tcl. A Tcl-ception.

Is this is also a kind of compiler bootstrapping?

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

~~~
theoh
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.

~~~
isostatic
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?

~~~
blacksqr
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.

~~~
isostatic
Bah, now I have to hate it

------
auntienomen
Why stop there? Implement Tcl in Tcl in Tcl.

~~~
unkown-unknowns
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, ...

~~~
colejohnson66
Interpreters all the way down? ;)

