Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ANN: Online Tcl interpreter (emtcl)

194 views
Skip to first unread message

Aidan Hobson Sayers

unread,
Aug 29, 2014, 12:33:50 AM8/29/14
to
In short: online repl at http://aidanhs.github.io/emtcl/

As a diversion from my current project, I wondered if there's an in browser repl for Tcl. I discovered [1], but it's done server side.
[2] and [3] have a number of projects which seem incomplete or abandoned, or require manual work to keep up with Tcl advances (e.g. which of those supports TclOO?).

[4], [5] and [6] (the latter in particular) mention emscripten. I've played with emscripten in the past and the Tcl source is relatively small and simply structured, so I had a go and you can see the result at the link above.

Nice things:
1. Little manual maintenance - updating means checking out a new tag and recompiling.
2. Only two small hacks were needed [7], and those are because I was focused results rather than correctness.
3. Because this is the library rather than tclsh, all the C calls are available if you take the time to expose them (I only needed 3 to make the demo).

Warnings:
1. Because this was a quick effort, some null byte handling isn't quite right.
2. Some commands definitely won't work (e.g. socket) due to browser js limitations, but some commands (e.g. clock) unexpectedly don't work. I've not checked why.
3. It's 3.1M. Pretty small (smaller than many .gifs), but not ideal.

Aidan

[1] http://www.compileonline.com/execute_tcl_online.php
[2] http://wiki.tcl.tk/17972
[3] http://wiki.tcl.tk/36481
[4] https://groups.google.com/d/msg/comp.lang.tcl/OQETwhvaYlE/Kko8i0cj6ccJ
[5] https://groups.google.com/d/msg/comp.lang.tcl/emvcD2-EYqk/iyEnOequ-qIJ
[6] http://wiki.tcl.tk/38911
[7] https://github.com/aidanhs/emtcl/blob/master/hacks.patch

crt...@gmail.com

unread,
Aug 29, 2014, 1:19:05 AM8/29/14
to
Maybe we can have an online TclTutor. :-)

Christian Gollwitzer

unread,
Aug 29, 2014, 3:46:53 AM8/29/14
to
Am 29.08.14 06:33, schrieb Aidan Hobson Sayers:
> In short: online repl at http://aidanhs.github.io/emtcl/
> [...]
> [4], [5] and [6] (the latter in particular) mention emscripten. I've
> played with emscripten in the past and the Tcl source is relatively
> small and simply structured, so I had a go and you can see the result
> at the link above.

Wow, nice one! Finally we are on par with python and ruby, to provide an
interactive "Try Tcl" environment. As crtmike said, it would be nice to
couple this with a renewed TclTutor, showing off all the nice goodies we
have in today's Tcl. (OO, lambda, coroutine, ...) Some syntax
highlighting input widget in JS would be needed, otherwise it shouldn't
be hard to do.

Christian

stefan

unread,
Aug 29, 2014, 4:08:51 AM8/29/14
to
> Some syntax highlighting input widget in JS would be needed

A former master student of mine contributed a decent tcl mode to ACE as part of his thesis project:

https://github.com/ajaxorg/ace/blob/master/lib/ace/mode/tcl.js

Check out the tcl mode at:
http://ace.c9.io/build/kitchen-sink.html

Cheers,
Stefan

palmtcl

unread,
Aug 31, 2014, 9:47:26 AM8/31/14
to
Very nice! Really fills a gap in Tcl's web presence. Hope you keep refining it.

Alexandre Ferrieux

unread,
Aug 31, 2014, 2:22:29 PM8/31/14
to
Quote: Aidan Hobson Sayers wrote on Fri, 29 August 2014 06:33
----------------------------------------------------
> In short: online repl at http://aidanhs.github.io/emtcl/

Very cool ! Especially given the size of the tgz :)

> 1. Because this was a quick effort, some null byte handling isn't quite right.

OK, when you have time, please document the failing cases (eg in the github tracker).

> 2. Some commands definitely won't work (e.g. socket) due to browser js limitations, but some commands (e.g. clock) unexpectedly don't work. I've not checked why.

Presumably because [clock] is defined in a big Tcl script loaded at init time by tclsh, but not by the lib ;-)
I'd guess that devising some kind of [source] (not from the local filsystem; rather, over the network, or with an embedded string) would solve the problem.

> 3. It's 3.1M. Pretty small (smaller than many .gifs), but not ideal.

Heh. Already awesome anyway.

-Alex
0 new messages