Richard Bucker

Embedding TCL in my Go application

Posted at — Mar 2, 2015

This has interesting potential as I consider the extensibility of both my Macroinator and Flow based programming projects. (flow is not published yet as it is in the middle of a complete refactoring)The target OS, for this example, is OS X Yosemite. And the first dependency to install is TCL. I’m using homebrew to install tcl (alternatively Jim) instead of the Apple version or the source from the source.It’s important to note that while brew works in userspace and is highly curated this is still an attack vector for the bad guys.1) install tcl with brewbrew updatebrew install homebrew/dupes/tcl-tk** note that tcl-tk is located in the homebrew/dupes folder. This is to indicate that the project tcl-tk duplicates some of the features in OSX.** brew installs the proper tcl-tk, not jim, and does not offer Jim as an alternative. The tk portion of the install requires some legacy X11 libraries and that makes me very sad.For the next step I need to install the tcl/go bindings. Looking at the landing page for gotcl I noticed that there are plenty of missing elements in the project so I’m going to try gothic. (Gothic also supports tcl/tk 8.6 which is what we installed in step 1.2) install Gothic.goenv GOPATH=/Users/rbucker/gocode go get github.com/nsf/gothicAt this point unless you’ve previously installed X11 header files and libraries you’re going to get a compile error about a missing header file. So at this point I abandoned all hope of the tcl-tk working.3) uninstall tcl-tkbrew uninstall tcl-tk4) install caskbrew install caskroom/cask/brew-cask** cask is a set of edge case brew tools. I’m not sure if there is any additional risk loading from here but I’m trying anyway. My bunny sense is telling me I should have created an OS X VM and practiced there.5) install tclbrew cask install tcl** This is a different version of tcl. This one happens to be from ActiveState. I like those guys. I’m not exactly sure how much is their code but if tcl is going to work these guys are awesome. If you’re going to write proper tcl you might want to try their tools. I think they can produce proper cross platform executables but it has been a while since I read anything about them.** one other note about installing this tcl.  I was prompted for my admin password. So my bunny sense was justified.  Onward we go.6) install gothicI tried the same command again.  And got the same response. So now I’m unwinding cask just so I’m not giving up too much space etc.7) uninstall cask tclbrew cask uninstall tcl8) uninstall caskbrew uninstall caskroom/cask/brew-cask** even though something was installed as an admin user; when I uninstalled I was not prompted for the same admin credentials to remove them. Hmmm…Now that this was a FAIL… there is one other thing I’m thinking about. The piccolo project shows just how easy it is to implement a variation of the tcl language. In this case batteries are not included but it feels like something I might want to do instead of building my own parser/compiler…. although with my new found experience with generate it might just be an option. But it’s a topic for another conversation.Another link to more tcl info.UPDATE: This is an interesting implementation from the CoreOS team.  Mayday is a monitoring tool but their task design makes the whole thing interesting and more like I am intending except I still need a hybrid in order to be more general purpose.