Head spinning, eyes rolling into back of the head...
Neo: Whoa! I know Script-fu....
Morpheus (played by GIMP): Show me....
Operator: I think he likes it....
Well, not quite as good as the scene from the movie, but that was exactly what I was thinking, when I realized I needed to script some image exporting.
I've been assimilating GIMP for a while, and I knew that Script-Fu was the scripting language, but I didn't know, until I looked, is that Script-Fu is Scheme!
Well how ironically wonderful!
Yes! I have been embracing the FP mojo more-and-more, and what better dialect than one of the original FP dinosaurs!?
Looking around for examples (they are plentiful) was quite an education, mostly in how not to do it. No Offense to anyone personally, but if you are using begin and while and set! all over the place, that is just fighting the language! Leave that shoehorn-procedural-crap-into-FP nonsense where it belongs!
I was ready. I know how to use for-each and lambda and let*, and that's pretty much all anyone needs to get-R-done, and I did-do.
But not without some scars er, learning. Here are my main take-aways from the whole thing.
- It's all about lists. You are either building a list to traverse later, or traversing a list you built earlier.
- I hate S-expressions!
- Scheme is powerful, if you embrace it!
- I wanted to use commas, but it wouldn't let me. It produces wonderfully vague syntax error messages instead.
- Closures (
lambdapluslet*) make Scheme powerful. - Error messages in GIMP are way vague. Does that suck, or should we just be grateful we get any kind of message? How 1970s!
- Debugging in GIMP is way painful! Can you say
printf? Again, how 1970s! - Did I mention: I hate S-expressions! Simple tasks like arithmetic become a prefix adventure in parentheses!
- It kicks ass anyway!