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

ANN: Online Tcl Interpreter (emtcl) update - JimTcl and the DOM

230 views
Skip to first unread message

Aidan Hobson Sayers

unread,
Nov 22, 2014, 10:38:03 PM11/22/14
to
http://aidanhs.github.io/emtcl/

I've updated emtcl with
1. A JimTcl [1] repl.
2. A toy library for changing DOM element attributes or styles.

See the site for examples.

Some notes:
1. JimTcl is 561K, quite a bit smaller than Tcl (2.8M).
2. The DOM 'library' is a mere 52 lines long [2] and is intended to be a demo of
the ease of hooking up Tcl to JS.
3. Tcl has been reduced by 200K to 2.8M.

There are (still) a bunch of things that don't work in Tcl (and JimTcl), namely anything in the pure Tcl library.
This is solvable, but I'm not going to spend free time on it. Hopefully it gives an interesting taste of the possibilities of Emscripten.

Aidan

p.s. Aside from improving the DOM interaction, future work might look at compiling Tcl to LLVM bitcode, then using Emscripten to convert it direct to JS for a massive speed/size gain. Just a though for anyone ambitious :)

[1] https://github.com/msteveb/jimtcl/
[2] https://github.com/aidanhs/emtcl/blob/master/opt/dom.c

Steve Bennett

unread,
Nov 24, 2014, 7:11:24 PM11/24/14
to
Cool. I'll definitely have a look at this. I'll be interested to see why some things aren't working in Jim Tcl.

Steve Bennett

unread,
Nov 24, 2014, 8:12:45 PM11/24/14
to
Alas, llvm/clang is too old on Ubuntu (14.04) to work.
Too hard.

Aidan Hobson Sayers

unread,
Nov 25, 2014, 6:30:22 PM11/25/14
to
On Tuesday, 25 November 2014 01:12:45 UTC, Steve Bennett wrote:
> Alas, llvm/clang is too old on Ubuntu (14.04) to work.
> Too hard.

You need the emsdk and ~8GB of free space. It needs to compile a custom clang/llvm build (which takes a while).

Sadly the problem is not anything of particular technical interest, it just needs some grunt work. To explain:
- Emscripten has a virtual filesystem (of course)
- all FS calls go via this vfs
- if you want files preloaded on the filesystem, you need to add them
- to do this, you need to add appropriate fs calls to your JS file

A nice example is https://github.com/replit/empythoned/blob/master/map_filesystem.py
It runs through a bunch of files, making createDataFile calls which it dumps to stdout which you would insert into your final .js file so when JimTcl hunts the filesystem for (say) binary.tcl, it will find it.

As I said, pretty dull work.

Steve Bennett

unread,
Nov 26, 2014, 4:51:07 PM11/26/14
to
On Wednesday, November 26, 2014 9:30:22 AM UTC+10, Aidan Hobson Sayers wrote:
>
> A nice example is https://github.com/replit/empythoned/blob/master/map_filesystem.py
> It runs through a bunch of files, making createDataFile calls which it dumps to stdout which you would insert into your final .js file so when JimTcl hunts the filesystem for (say) binary.tcl, it will find it.
>
> As I said, pretty dull work.

By default, Jim Tcl doesn't require anything in the filesystem. All the Tcl extensions (such as binary.tcl and glob.tcl) are compiled in. But you do need to call Jim_InitStaticExtensions() right after Jim_RegisterCoreCommands() otherwise they won't be loaded.

Aidan Hobson Sayers

unread,
Nov 27, 2014, 8:16:19 PM11/27/14
to
Well that'll teach me to make assumptions. Thanks for the hint - https://github.com/aidanhs/emtcl/commit/37a794d60bba6ca07d5c98e0e3597f0a38787817

I've recompiled and pushed and the glob and tree commands now seem to be available.

Unfortunately binary isn't available because it seems to depend on regexp, which I had to disable because it was giving me a headache with multiply defined symbols when linking to libcextra and I don't feel like fighting with it.

Thanks again for the help.

Aidan

Steve Bennett

unread,
Nov 27, 2014, 11:25:27 PM11/27/14
to
Great. You can disable the built-in regexp if you want with: ./configure --disable-jim-regexp
Might make it easier to compile.
0 new messages