|Perl Monk, Perl Meditation|
Perl as an Interfaceby RollyGuy (Chaplain)
|on Nov 22, 2004 at 16:47 UTC||Need Help??|
Greetings fellow Monks.
Given the short week (thank you Thanksgiving), I am able to relax at work and join in some PerlMonks fun. I would like to present the idea of Perl as an interface and see other thoughts about using Perl in this fashion.
At work we had the opportunity (or rather the necessity) to rewrite a tool that we had been using for quite some time. The tool (like many we use) was an in-house tool and quite custom. The problem was that the interface was custom as well.
Originally, the tool took a simple input file with simple settings such as x=2, y=3, etc. This, of course, lacked power that some users needed, so the input file eventually evolved into its own language. There were two main problems with this. First, the language wasn't mature and didn't follow closely to other languages and common syntax. Secondly, for those who wanted to learn, the documentation was sparse because the programmers working on it needed time to code, not to document. Most of the learning was done by example code and going straight to the developers and asking, "How do I do this?"
Another item to note about this tool is that the users were constantly waiting on new versions to implement the features that they needed. I'll come back to this point later.
I was fortunate enough to be on the design team for the rewite. There were about five of us plus a manager. We were discussing the user interface for the new tool. One of my colleagues and I were strong advocates of Perl and wanted to attempt to make a perl interface. The idea is that most of the code would stay in C to be fast, but the Perl interface would solve many problems that we faced with our user base. It was a struggle between the older "Keep it the same" coders and the younger "Flexiblity is power" users, but we finally decided on trying the Perl interface.
Fast-forward to today. As I look back, I am certain that we made the right decision. All of the input files are written in Perl so we inherited all of Perl's power in the language. The back-end is still C so that we can reuse the parts of the original tool and keep the right parts fast. The new-hires do not need to learn a new language as Perl is common. If they do not know perl however, they can pick up a book and learn the syntax to use the tool. So we also got some documentation for free. As I pointed out above, our user base is constantly in search of new features. It turns out that by exposing some of the internals to the Perl interface, the power users were able to work through some of the problems until certain features matured.
We did have some difficulties intially getting Perl connected as the interface, but it seems in the end that it was a cheap price to pay for the power it gave us. I do consider it a big win for this small group. However, not everyone here shares my sentiment.
We have other tools that suffer from the same problems and are approaching rewrites. I will push for a Perl interface because I think that it works, and works well.
My questions for you are:
Have you ever done anything like this?
Would you consider doing it again?
What alternatives do you see (Lua)?
What is your favorite color?