One of the little tricks (I want to stay away from the word "hack") that I like to use for utility programs is to drive them from a command file. I won't dignify the syntax of these various command files with the word "language" (as in Domain Specific Language), but I find that it makes development much faster for me. I always use a very simple syntax. I don't use XML (why? that's for another day), but rather a very simple character delimited syntax where each command is on its own line, and the first character of each line is the delimiter. I picked up this last idea from sed, where you can start the search-and-replace pattern with any character in case you need to use the standard delimiter (the forward-slash) within your text patterns. This also makes it easy to tokenize the command and parameters with operators like "split."
I've wanted to learn how directly drive a program from the various commands without using if/then or case statements. I've been able to figure this out for the languages I use most (C++, Java, Python and Shell script). I'm not too concerned with performance here, but I do like to be able to reduce the repetition in my code. In scripting-to-compiled-language order, here are the ways that I have implemented this lookup.
The code repository contains one sample program in each language (that I've implemented so far...) and one file of test data that drives all sample programs.
Shell
This is the simplest, and "palm-to-the-forehead" obvious once I figured it out. I create a shell function with the name of each command, and call each function directly.
Python
Here I put each parameter into an array and pass the array. I use a class that has methods that are named the same as the commands.
Java
Here, like Python, I use a class with methods that have the same name as the commands, and use reflection to look up the methods.
C++
No built-in language help here, so I use an array that gets turned into a map for quicker lookup. I know I said above that I wasn't interested in performance. I have, however, developed a distinct distaste for linear algorithms when coding in C++ (it only takes one performance problem to make it obvious) so I tend towards algorithms with better O-numbers (like trees or hashes) whenever possible.
CSharp
Use reflection (similar to Java).
Visual Basic
Use reflection like C#
My web site: http://home.pacbell.net/c_keith