7 ms·
The return of the Tcl browser plugin
- favadi 11y agoAny HN reader still uses Tcl in production system? Is it still relevant in 2015?
- aurelian15 11y agoAs it stands, Tcl is still relevant in 2015. It is for example used as a scripting language in hardware design toolchains (such as ModelSim and Xilinx ISE). Furthermore, the "standard" Git tools "gitk" and "git gui" are written in Tcl.
- HarryHirsch 11y agoYes. Yes. NAMD.
- dalke 11y agoBlame me (partially) for that. ;)
- bch 11y agoHere. Extremely enjoyable to code in and easy to integrate with C which makes integrating with arbitrary libraries and syscalls simple. The language rules are strict, but there are few of them, and they allow for surprising customizability (read: DSL). In a nutshell (for me), as competent as any language, and more enjoyable than most. This describes explicit use, outside of cases where you may be using it directly or indirectly and not realize, like Expect, or in your network routers like your F5 iRules, etc. My work is currently specifically Tcl-focused, at ActiveState, but see my other comments for years of enthusiastic Tcl experience from "general" development and operations gigs. I use it where I can, and I can use it in a lot of places.
- cartoonfoxes 11y ago> Here. Extremely enjoyable to code in and easy to integrate with C which makes integrating with arbitrary libraries and syscalls simple. This is definitely a sweet-spot for TCL. It's not surprising that TCL doesn't get more attention when this use case has been so stable for so long.
- tptacek 11y agoPerhaps because Lua is a better language and, like Tcl, was custom-built for that sweet spot.
- mzs 11y agoI've not done any Lua but my oldest son has and he showed me. It really did not stand-out in my mind compared to say python. I guess it's pretty simple, embeddable, interoperable with C. It really was a great first language for him really but so would have js really. Tcl is pretty neat though. It has this feel like lisp and very simple rules plus everything can be a string, which is prefect for gluing text output together between tools.
- tptacek 11y agoI've done a lot of Tcl work; two successive companies I worked at used it as their embedded language. It has its charms, but I would have a hard time working at another company that in 2015 chose Tcl over Lua. Issues I have with Tcl: * The syntax is as idiosyncratic as a Lisp, but has few of the advantages that Lisps get for homoiconicity. * uplevel/upvar is a janky way to get metaprogramming. Compare metaprogramming in Tcl to that of Japanese Tcl errr Ruby. * The Tcl runtime is outmoded. I could probably think of others. There's also the fact that Tcl's vaunted integration with C code has pretty much become par for the course in high level languages. I didn't find writing Ruby extensions to be any more painful than writing Tcl extensions. Modern high level languages also expose full-featured FFIs, so you often don't even need bindings. Tcl was ahead of its time! It was a good embedded high level language before virtually every large project recognized the need for embedded languages. And the event-based model that Tk forced on it turned out to be pretty useful for network servers. It was a great choice in the late 1990s.
- srean 11y agoGiven that it has had a better multithreading model compared to Cpython, JavaScript, has been and is a breeze to extend and embed, comes with lambda and coroutines too.. So why not. Very few other languages give a comparable sense of playfulness
- seiji 11y agoVery few other languages give a comparable sense of playfulness There's an argument that modern software used in production environments shouldn't be imbued with a sense of playfulness just because it's fun. If your choice is between tcl and Python, use Python. If your situation is "I can use waterer I want, tcl sounds fun," still use Python. Nobody wants to maintain sprawling tcl code today, much less in the future after projects get abandoned by their original creators.
- bch 11y ago> There's an argument that modern software used in production environments shouldn't be imbued with a sense of playfulness just because it's fun. Your point is a good one (applicable to any language or technology), but in defense of the OP, bringing fun doesn't preclude usefulness or power. A painful development process doesn't mean "serious software". Additionally, if you don't want to put Tcl in production per se, it can still be part of the development process in a prototyping capacity. It's got great UI facilities (CLI, sockets, GUI), great introspection, and a healthy amount of whip-it-up-atude to get meaningful results quickly (and yes, enjoyably).
- sea6ear 11y agoTcl programs are still far easier to distribute (using Tclkit & Starkits / Starpacks) than for Python, which as far as I can tell requires either an installer or the end user to install a distribution of Python. This one capability puts Tcl in a class that is fairly unique among scripting languages. It gets it into the class of easily distributable languages that usually only includes compiled native binaries like Go, C, C++, Haskell, Ocaml, etc EDIT: Thinking further, perhaps Node compiled statically and Lua may offer similar capabilities to Tcl in terms of being reasonably distributable. Maybe PHP also if you distribute the static cgi binary. I guess it's mostly Python, Ruby, Java, C# and Perl that require a distribution to be installed for programs to be easily run. This is mostly a problem for distributing one-off utilities for someone else to run rather than either major applications where an installer wouldn't be comparatively a lot of extra work, or situations where the computers are all under the programmers control.
- sebcat 11y agoYes. An ncurses-based appliance configuration UI and a seccomp-sandboxed DSL environment. libtcl is really easy to sandbox with seccomp, I recommend it over [interp create -safe]. Run the interpreter in a seccomp-enabled child and have the parent do all privileged operations. Set resource limits on the child. Have them communicate over a socketpair. Have the parent spawn sandboxed children whenever the rlimits run out. For what we're using it for, it works really nice.
- groovy2shoes 11y agoYes. It's used a lot in the EDA world. It's really a neat little language with some cool metaprogramming facilities.
- davidw 11y agoIt's used for the test suites of SQLite and Redis.
- bch 11y agoAnd gcc (via dejagnu) and others. Testing is a good point to bring up; Tcl is pretty nice to use. See http://wiki.tcl.tk/1502 http://wiki.tcl.tk/1502 for descriptions, reactions, and links.
- michaelsbradley 11y agoRe: testing, see also the Caius Project: Caius – A functional testing framework in object-oriented Tcl http://caiusproject.com/ http://caiusproject.com/ https://github.com/tobijk/caius https://github.com/tobijk/caius
- srean 11y agoI find its use in Redis really curious because Antirez is also the author of Jim a leaner, more functional Tcl.
- kryptiskt 11y agoOpenOCD is built on it, so it's very relevant for embedded development.
- mzs 11y agoYes I use it to script telneting into many dinky devices and changing/viewing config all in one fell swoop with expect. I also have some simple tcl/tk scripts to automate some tasks. But most often I do vxWorks dev from the commandline instead of tornado/workbench with the use of tcl scripts that use the WRS provided tcl scripts.
- pascalmemories 11y agoTotally, in business critical systems for all sorts of stuff. Rewriting it would be enormous effort and provide no business benefit and be full or risk of introducing new (or re-introducing old) bugs in the process of converting to some whiz-bang c# or whatever is trendy. We even built custom integration modules (DLLs in Visual C++ 6 for anyone curious). They integrate to legacy AS/400 systems and the interfaces used are totally legacy and unlikely to be easy to integrate with c++ 2015. So, we're absolutely still using Tcl (and Tk) in 2015 and it is still relevant. It will be in use until the company (or the sun) implodes. I do hate the syntax though. Yuk. [edit: I see others commenting that that's the thing they like ! I'm obviously an outlier or our code sucks more than most.]
- pmarin 11y agoMacPorts is written in Tcl https://trac.macports.org/wiki/FAQ#whytcl https://trac.macports.org/wiki/FAQ#whytcl
- acveilleux 11y agoIt's the main scripting language in the Cloverleaf interface engine. One of the bigger player in the healthcare systems integration arena (along with Mirth, Corepoint and a few more.)
- shanemhansen 11y agoTCL is still relevant. I don't think browser plugins are still relevant. TCL + emscripten seems like a great fit here.
- eleh 11y agoDepends. Lets say you have a service that is running on your local PC at some port >1024. It uses a special binary TCP protocol and controls hardware from which images are coming in live stream. You want to display these images in a browser window, on the way there you want to resize them. And then you want to use them in the web application where the window is embedded. You have a stable tested Tcl library to do this in normal client environments, but now the requirement is a web application. How would you get Javascript and emscripten to do this task? I think there are two points, where a browser plugin is still relevant: (1) connect with hardware or resources where a browser has no access, from a web page. That is when you can write a little companion Tclet to do exactly this little task. (2) Deployment of an existing Tcl application to thousands of users. That's so much easier when you just need to drop the .tcl file on a web server, and your users get the update as soon as they press F5 in their browser to reload the page.
- gaius 11y agoLots of places the "full stack" developer will never see. CAD and simulation software, routers, electronics, 3d graphics, industrial control. The web is still only a small corner of the software world.
- dmux 11y agoNot exactly "production" software, but we've started using Tcl as a cleaner alternative to Bash.
- sea6ear 11y agoI've actually used it a lot as a sort of "sane" scripting engine that I could include with other software to deal with various configuration tasks that would be too painful in DOS batch or (somewhat less painfully) bash. So it has gotten used a lot around the edges of other software that I've written in C# or as part of config steps in InnoSetup. It's a great tool for random little messy bits that need to be done where you don't want to deal with installing something larger.
- deleted 11y ago[deleted]
- xiaq 11y agoIt might be much more useful to develop a Tcl-to-JavaScript compiler instead of a browser plugin...
- blacksqr 11y agoYou mean like EmTcl? http://aidanhs.github.io/emtcl/ http://aidanhs.github.io/emtcl/
- eleh 11y agoInterresting project :). Every project in this direction is thriving and fun, no doubt. I am happy to see these developments, hopefully they go on! The browser plugin on the other side is mature and fits in where EmTcl, NaTcl etc. leave off: when it comes to use the full feature set of Tcl and its huge extension library, including Tk windows, in the browser and in production code. Intranet web applications maybe, e.g for the use cases I mentioned above. Therefore it still has its niche, I think. But maybe it will be possible to do things like sockets on arbitrary ports with arbitrary protocols, or driving external hardware, with EmTcl in the future? That would be great :-)!
- kragen 11y agoThis is great! I remember the slide rule I wrote in Tcl/Tk in 1997 was able to run in the browser plugin: http://canonical.org/~kragen/slide-rule.tcl http://canonical.org/~kragen/slide-rule.tcl. I wonder if it still does! The Tcl plugin could have been an awesome alternative to Java applets. Too bad they abandoned it. Unlike others here, I don't think Tcl is "extremely enjoyable to code in", largely due to its lack of first-class aggregate data structures, but it makes doing simple things very simple.
- bch 11y agoI don't know when you last worked with Tcl, but it's got lists (as always), dictionaries, and integrated first-class object system (after years of various extensions). Also, if it's an option, punting structures to C can be nice to organize data. Re: abandoned applets - some see that as dodging a bullet. If it became a Big Deal in the browser, it arguably could have cemented itself into the form it had at that time, because of maintaining compatibility for that audience. It's a thought exercise I haven't completely thought through, to be honest, which just occurred to me because Tcl has done a tremendous job being true to itself anyway, and has a great amount of compatibility with historic versions of itself. Anyway, now I'm off to look at slide rules ;)
- davidw 11y ago> punting structures to C can be nice to organize data I'm a Tcl fan, but the above is actually somewhat problematic, because to hold a reference to the C struct, you have to then manually free it later, losing some of the benefits of a language with automatic memory management. Real dicts, and the new object stuff are big improvements though.
- bch 11y ago> ...the above is actually somewhat problematic, because to hold a reference to the C struct, you have to then manually free it later, losing some of the benefits of a language with automatic memory management. I usually frame the data as clientData passed to a managing command (i.e. custom built first-class command), with appropriate allocation/deallocation. As often as not, I'm creating two commands: an anonymous reference template, and a command-creating-command that will instantiate instances of the "anonymous reference template". Then I can create an arbitrary number of arbitrarily named commands that pack and process their data, including freeing on destruction. To the uninitiated, this sounds like object-oriented programming, which is arguably true, but doesn't automatically come with subclassing, inheritance, etc, etc. Tcl does have first class objects, but what I'm describing here isn't them.
- gwbas1c 11y agoWould be nice if there was some kind of walkthrough. Nothing shows what kind of tags are needed in HTML, what kind of files are uploaded to the web server, how to interact with the DOM, ect, ect.
- kevinwalzer 11y agoTcl is an awesome language for developing cross-platform desktop apps in, and Tk bindings are everywhere. I use Tk as the foundation for Mac (and soon Windows) apps written in Python and Perl as well as Tcl.