Jul 04, 2010 22:02
Another programming milestone passed.
We have an instrument at work, our most popular one, that requires some extensive testing. And then we're developing another one based on the same technology that also requires testing. Our one-one!-programmer simply cannot keep up with his demands and implement the changes I'd like to get some automated testing done.
Well, score one for the PLT group, previously makers of PLT Scheme, now "Racket." (Not sure about the name but whatever.) They have a foreign function interface that is so magical I get a little giddy just thinking about it. I got access to the DLL for our prototype, which also works for our main instrument, and in three days banged out about 16 pages of scheme (ok, ok, Racket) to control it, and get just the data that I want the way I want.
The lovely thing? Apart from a minor control issue (not worth going into details), the code worked perfectly the first time, every time. I always had the possibility of hacking our C++ code, but shuddered at the thought. Better to live with the heartache of manual experiments than muck around in C++. But this week I told myself, "Time to try the FFI," and wham-a functional script. It already generated data I literally could not have collected previously because the C++ code for the prototype is such a hack and doesn't work.
I don't understand why anyone uses C++ for anything. Python, Lua, Lisp, and probably every other decent language in existence is capable of dealing with C code. If you need to get down to the metal, write up some libraries in C. I just don't understand the point of wasting programming time on managing C++ garbage.
Well, anyway, yay! All I need to work on now is some kind of interface to serial ports (maybe possible directly in Racket) and I will be able to have a completely automated testing script. Plug it in, turn it on, and click the button. So awesome.
scheme,
programming