What | Jim Tcl |
Where | http://jim.tcl.tk/ http://jim.tcl-lang.org (alternative URL) https://github.com/msteveb/jimtcl (repository mirror) |
Description | Small footprint re-implementation of Tcl. Particularly suited for embedding. Currently at version 0.82. |
Updated | 2020-10-31 |
Contact | See website |
Recent Changes of this page and other news
Index
Features
Applications using Jim
Jim Static Variables
. proc foo {increment} {{value 0}} {incr value $increment} . foo 1 1 . foo 1 2 . foo 10 12
. set x 10 10 . proc bar {} x {puts $x} . bar 10
# Write a function foo that takes a number n and returns a function that # takes a number i, and returns n incremented by i. Note: (a) that's number, # not integer, (b) that's incremented by, not plus. proc accumulator n { lambda increment n { set n [expr {$n+$increment}] } } set f [accumulator 100] puts [$f 10] puts [$f 20] puts [$f 1.25]
The output is
110 130 131.25
RS: As Jim has prefix operators, I'd write it like this:
proc accumulator n { lambda increment n {set n [+ $n $increment]} }
Other Jim documentation in this Wiki
Commands already implemented
. lsort [info commands] * + - / after alarm alias append array bio break case catch cd clock close collect concat continue curry debug dict env eof error errorInfo eval exec exit expr file {file copy} fileevent finalize flush for foreach format function getref gets glob global if incr info {info nameofexecutable} join kill lambda lambda.finalizer lappend lassign lindex linsert list llength lmap load local lrange lrepeat lreplace lreverse lsearch lset lsort open os.fork os.gethostname os.getids os.uptime os.wait package parray pid popen proc puts pwd rand range read readdir ref regexp regsub rename return scan seek set setref signal sleep socket source split stackdump stacktrace stderr stdin stdout string subst switch syslog tailcall tell throw time try unset update uplevel upvar vwait while
Benchmarks
Here is a comparison of a recent (Oct 2010) version of Jim. Note that Jim appears three times, compiled with -O3, -O2, -Os.
Jim benchmarks - time in milliseconds Jim-O2 Jim-O3 Jim-Os 8.4.19 8.5.8 7.6p2 6.8.1 PI digits 544 444 618 282 326 F F [for] busy loop 216 230 234 164 144 2725 2347 [while] busy loop 406 373 489 165 147 2709 2304 ary 303 280 311 139 175 459 402 ary [dict] 294 264 313 F 171 F F dynamic code 194 180 225 227 422 262 251 dynamic code (list) 80 69 91 102 136 336 312 expand 74 65 98 F 103 F F fibonacci(25) 286 265 338 153 188 1023 944 heapsort 214 199 244 98 72 F F mandel 339 281 341 199 215 2007 F mini loops 204 190 235 165 134 2413 2086 nested loops 246 231 292 99 89 1842 1665 repeat 201 184 228 1641 893 2289 2054 rotate 29 29 35 F F F F sieve 401 358 433 115 180 800 712 sieve [dict] 357 300 397 F 202 F F upvar 226 209 304 196 171 460 407 wiki.tcl.tk/8566 416 380 487 165 158 F
Note that if you plan to write very dyamic code, with a lot of eval/upvar, Jim is probably currently the faster of the three. (See the repeat test).
The source for the benchmarks can be found in the repository as bench.tcl
License
Jim is under the "2 clause" FreeBSD Licence. This means that it's GPL compatible, but like Tcl itself can be used in commercial software without need to distribute the modified source code. In one word Jim is free for both the opensource and the commercial world!.
Commercial Support
Salvatore Sanfilippo, the main author of Jim, will be glad to support in the extension and integration of Jim in embedded systems, as scripting language of existing application, and any other need. For more information write an email to antirez at gmail dot com.
Steve Bennett, the current maintainer of Jim can also provide support [L19 ]
Interested in Jim?
If you want to stay informed about Jim you can subscribe to the jim-devel mailing list. There is a web form to subscribe at http://jim.tcl.tk:8080/cgi-bin/mailman/listinfo/jim-devel . This is the primary forum for ongoing development of Jim. Also check the Jim development page.
Here is a place for your comments about Jim
02mar05 jcw - Jim is fascinating. Great engineering, IMO!
I've got an experimental reader for Metakit database files as well as a tiny Zlib decompressor based on the Vlerq project I'm working on. Should make it possible to support R/O starkits with very low footprint overhead (my guesstimate would be 25..35 Kb on top of Jim itself). The main issue is how to handle opens and globs and reads from things which are not files. As far as I can see, Jim has no I/O yet. Might be an idea to use a lightweight OO model ("$file read") so one can create objects that end up reading from a starkit. Could also be memory-mapped. Lots of ways to go from here...
SS 3-Mar-2005: Thanks for the good words! I followed the metakit discussion on the Feature Request thread but fortunately my lack of skills in metakits makes me unable to help from this point of view, with the exception that I can focus on the I/O extensions ASAP. For the OO, there will be Odys (with some change probably) integrated into the core (assuming I'll be able to implement it in max 1000 lines of code, otherwise I'll be forced to make it an extension, even if the Jim model is "little core, all extension" I really consider the OOP system to be a core language feature). Btw... I'm thinking that for starkits in unix-land another strategy that's possible to follow is to put POSIX I/O things into the jim-posix extension, and write an higher level interface directly in Tcl.
Yes, the Odys object system could work. No need for POSIX I/O if you *only* want to read from a starkit (which could make Jim secure, sort of). The code I have supports mem-mapped access on Windows, Linux, Mac OS X. -jcw
Steve Bennett Discussion on build systems moved to: Jim Tcl as a basis for configure and build system
Googie - How about speed? Are there any benchmarks available? I'm interested much in expr operations, but also others.
SS 2Mar2005: Hello Googie! Jim is currently slower than Tcl, but is faster than Tcl 7.6.
PT 3-Mar-2005: Jim supports dynamically loaded extensions. One of them supports a certain degree of COM automation under windows....
load jim-win32com set ie [ole32 create InternetExplorer.Application] ole32.invoke $ie Navigate2 https://wiki.tcl-lang.org/jim ole32.invoke -put $ie Visible True
The above script results in Internet Explorer displaying this page.
SS 3-Mar-2005: That's cool! And is all merit of Pat. Also there is a start of win32 API binding. To hack with it:
load jim-win32.dll info commands win32.* ...
SS 5Mar2005 - Update: in order to explore the proposal of SEH as well as the ability to run simple starkits with Jim, I'm working on a very simple Jim extension called AIO (Ansi I/O) that exports ANSI C file capabilities to Jim with a OOP Interface (and it is very simple to provide Tcl file API compatibility via some glue procedure). The initial version is on the CVS, people interested in this issue my follow the thread in the Feature Request at http://developer.berlios.de/feature/?group_id=3204 .
On the last days Jim reached a better shape, there are more core commands, it's more binary safe (now all the parsers are binary-safe), and robust. Also the exported C API is more complete.
That's how the AIO extension looks like:
load jim-aio.so set f [aio.open /etc/passwd] set f2 [aio.open /tmp/FOOBAR w] while {[$f gets line] != -1} { $f2 puts "~~ $line ~~" } $f close $f2 close
Very similar to cfile.
LV Anyone have a table comparing features of Tcl and Jim, so that one can more easily understand the differences?
RS Jim is a rapidly moving target, but here's a quick sketch of what I can think of at the moment (see also Jim development for further differences):
On Jimulation I've started to "back-port" some useful Jim features to pure-Tcl, but most recently Jim seduces me to do even C fun projects... see below.
RS: See also Tiny OO with Jim - Jimulation / 2005-03-20: Here's this evening's fun project - adding an ** operator to jim.c (only added lines shown - "Doctor, somehow writing C doesn't hurt any more" :): ... snip... SS: ** added some time ago, thanks. For now it is supported only for integers because every mathlib related thing will probably go inside the math extension. This is so because the Jim core should not depend on the C math library.
RS was heard to aphorize, "Jim - because even simplicity can get simpler".
Felipe Voloch 5 Dec 2005 - I compiled Jim (binary here [L20 ]) for linux on the Jornada 680 handheld (from here [L21 ]). I wanted to compile Tcl but was having trouble with crosscompiling. Jim compiled and runs just fine. Nice stuff.
RJM 2010-10-16 I have put jim in the build tree of blackfin's uclinux-dist. It configures and builds right from the start correclty. I could for example successfully open and use a serial port (but opening pipes is apparently not supported yet).
Steve Bennett 26 Oct 2010 Great. pipes are supported. See: socket pipe, and the popen wrapper in tclcompat, which is used by open "|..."
Ask on the Jim mailing list if it isn't working.
MHo 2010-02-21: How to compile with MinGW???
Steve Bennett 26 Oct 2010 Now the same as all platforms:
./configure && make && make install
Best place for these questions is the Jim mailing list. http://jim.tcl.tk:8080/cgi-bin/mailman/listinfo/jim-devel
jSQLsh :
jSQLsh is an SQLite shell based on the PostgreSQL command line shell. Implemented using the Jim Tcl interpreter. It is intended to be a simple light weight SQLite shell.
Aud By the sounds of it, Jim could be a potential Tcl 9.
MHo: What's definitely required is the possibilty to build jim-based starkits.
MHo: jim should support the glob switch -types!!
MHo 2014-10-23: Tcl:
% glob -directory d:/ -- * d:/bootsqm.dat d:/home d:/htdocs d:/ipconfig-all.txt d:/mount d:/proxy.pac d:/temp d:/var %
Jim (0.75):
. glob -directory d:/ -- * bad option "-directory": must be -directory, -nocomplain, -tails, or -- [error] .
?????????
Steve Bennett - To MHo - glob.tcl is provided. If you want to support more Tcl options, feel free to make any changes you want. And optionally submit those to the mailing list for possible inclusion into the next release.
arjen - 2021-03-29 06:24:56
As a proof of concept, I wrote a very limited Fortran interface for Jim. The method I used allows me to do almost all coding in Fortran, rather than C as an intermediary. Of course, it is not really useful yet, but with a bit more work it should give the possibility to create extensions for Jim written in Fortran or use Jim as a scripting facility in Fortran programs. Mutatis mutandis I want to apply this technique to Tcl itself as well, to modernise my Ftcl package.
GS - 2022-12-11 - Does it exist a binary distribution for windows ? '''MiR - doesn't seem like there is any binary for windows out there. If I find the time I'll to compile win32 and put them on my github, stay tuned. OTH a pure Jim build doesn't really make that much sense, since it is thought to be integrated into larger apps :-) Uploaded a win32 binary [L22 ] Just the shell, none of the more fancy extensions... hope this helps. But I managed to include dynamic loading and compiled a working sqlite extension, that can be loaded into the interp.
Steve Bennett Note that the artifacts from the AppVeyor continuous integration builds for Windows are available: https://ci.appveyor.com/project/msteveb/jimtcl (except they only persist for 30 days). Now I have begun attaching the appveyor build when releasing Jim Tcl. e.g. https://github.com/msteveb/jimtcl/releases/tag/0.82