The world is rapidly moving away from technology-based solutions toward end-user facilitation. Simple grammars provide a surprising solution to the problem of “driving” IT infrastructure to achieve business ends. In this article, Stephen Morris shows you how to use the interpreter design pattern to create a simple C++ grammar, which can be extended to produce surprisingly powerful capabilities.
Business driven logic sometimes means no logic at all.
I rather prefer a sound technical approach above the fuss of marketing speak.
Realistically a pattern is an enabling construct, without any fundamental algorithmic details behind it. This is just a basic introduction to tree based parsers, that isn’t even very useful. If you want to make your application scriptable (and you’d need a good reason) a better bet would be to integrate either the Lua or Spidermonkey scripting engines, instead of reinventing the tree all over again.
Agreed. I use F-Script in most my applications, with uses ranging from configuration to allowing the user to add custom behavior, so I think I’m fairly familiar with the “grammar pattern,” although I’ve been referring to it with slightly less buzzword-enabled words like ‘scripting.’ But the reinventing-boolean-algebra example he used to explain everything was so oversimplified that I really don’t understand what the article was trying to tell me to do. The behavior he provides in the final example really isn’t complicated enough to justify forcing the user to learn a(nother) scripting language; I can already think of one way to enable the user to ask the same question with a GUI.
Can you write a more retarded article intro than that? It’s a pretty darn simple concept, why wrap it up in all that eBusiness-ROI-IT-solution boolsheet?
Anyway, the code itself is horrible. Does the author even know what the keyword ‘explicit’ means? Is he aware of std::string? Does the author know what a memory leak is? It’s written in the old c-with-classes style that was popular 10 years ago. C++ has evolved since, this guy obviously haven’t.
informit articles are worthless and are best avoided. If the synopses don’t give it away, then the juvenile “my first tutorial” nature of the articles will. They’re like little advertisements for books people can generally do better than.
“Any sufficiently complicated C or Fortran program contains an ad hoc informally-specified bug-ridden slow implementation of half of Common Lisp.” — Philip Greenspun’s Tenth Rule of Programming
http://en.wikiquote.org/wiki/Lisp_programming_language
While I agree with you about Lisp, I was reading about this alternative C++ syntax:
http://en.wikipedia.org/wiki/Significantly_Prettier_and_Easier_C++_…
And I realized that, as this syntax makes very clear, C++ is basically a systems-programming version of ML, with a well-designed object system, and enough low-level features to write an operating system.
Sure, people write crap programs in C++, whether because they write C-in-C++, or think that everything should be object-oriented, or other similar reasons. But as awesome as Lisp is, there are definite benefits to static typing in some contexts, and programmers who understand that can use C++ to do amazing things that C or Java programmers can only dream of (and that Lisp simply isn’t safe enough for).
> The world is rapidly moving away from technology-based solutions toward end-user facilitation.
Bingo!
Stephen Morris, in this wonderfully written cornerstone of modern technological journalism, unveils for us the secrets of turning a simple concept akin to “Hello World” into a world-class doctoral essay. Congratulations, Stephen Morris!