Monday, February 27, 2006

Declarative vs. Procedural

I was somewhat surprised to come across a description of a computer application from Visual Knowledge http://www.visualknowledge.com that stated that it was a “100% declarative application”. What a wonderful concept! I wish more systems were more declarative. But what does this really mean?
Checking the Wikipedia for a precise definition: http://en.wikipedia.org/wiki/Declarative_programming I was not given a clear definition of what a “100% declarative” stamp would imply and what the benefits would be. But is there an under-ground “go declarative” movement starting?
It implies that the solution was created without writing any procedural code using languages such as Java, VB, C#, or C++. That just by creating input specifications and rules you could generate output.
In general I feel that procedural languages tend to dominate our undergraduate education. Declarative programming does not enter most classes until much later. When I teach classes on XSL most of my students don’t even know the difference between procedural and declarative programming. The entire concept of “side effects” is new to them.
I should mention that most of the systems that I built for CIBRS, CriMNet and the Minnesota Department of Education were all heavily based on MDA which is totally driven by transformation of the underlying models. I heavily depended on XDoclet, Ant and XSL to build these systems. Most people involved in these projects gave superior ratings to this approach and indicated that we did much more with fewer people because of this approach. But after I left these projects, there were few people with declarative skills they tend to be underutilized.
I also found that XDoclet was very hard to debug when I was creating complex transforms. Using Java annotations to store metadata still has many drawbacks unless better tools are developed. The lack of standards for Java annotations is still a real challenge when integrating external libraries. Just having a simple tag standard for Object-Relational mapping would be a great start.
I also had a good discussion with several faculty members at the University of Minnesota, Leila Tite and Chase Turner at the CodeFreeze seminar that they also feel that declarative programming is under-taught in the Computer Science curriculum today. They are interested in the Haskel programming language which is used with computer science department to teach declarative programming skills.
It would also appear that the semantic-web and business rule systems would also seem to promote more graphical tools such as data mappers and business rules with workflow systems. This allows more non-programmers to be in charge of day-to-day maintenance of business rules.
So here is my first cut of what a “100% declarative” stamp of approval might be:

  1. No procedural code in Java, C#, C++ or Visual Basic for programmers to maintain
  2. Built entirely with declarative languages (XSLT, Ant, BPML etc)
  3. Fewer concerns about state management and side effects
  4. Higher use of transformed metadata
  5. Works on concert with Model-Driven-Architectures
  6. Allows non-programmers to use visual tools to modify business logic and interfaces

Tell me what do you think! Should declarative programming be emphasized more in higher education and the workplace? Would you consider it an assets of a software application was more declarative? Are declarative systems really easier to maintain? Is the movement to MDA going to drive more declarative skills? How does the lack of accepted metadata standards impact the use of declarative programming?
Keywords: Declarative vs. Procedural, Procedural Programming, Declarative Programming, MDA, XSL, XSLT

No comments: