Thursday, July 10, 2008
The difference between a specification and an implementation
The first time something is done, the step from specification to implementation requires faith. “Let there be light”. What is light? Light has never existed before. So, how can it now exist? Let there be light is a fine specification. But, the implementation cannot be directly derived from the specification. Something has to be added.
Generally, specifications are easy to understand, hard to believe. It’s easy to understand the statement ‘Build a computer that runs at 10 TeraHz’, or ‘Build a spaceship that will fly to the nearest solar system outside of our own.’ It’s hard to believe either can be done.
Implementations are hard to understand, easy to believe—because you’re looking at the thing in action! It’s easy to believe there is light. We are living in the implementation of that specification. Figuring out exactly how light works, on the other hand, that’s hard to understand.
Another example was Bill Gates and Paul Allen. They had a specification to build a BASIC interpreter on the Altair 8800. The specification was simple: Those words, and the BASIC language specification. Easy to understand, hard to believe. Once they completed the implementation, it was easy to believe they had it working.
Now, if you have done something before, then yes, it is possible to join the specification and implementation. You are not really doing anything new, however. You are just doing the same thing over in a modified way. However, if you want to add anything new to the product, specification is again required.
Of course, you can always skip the specification stage, and just write the implementation. This is inefficient. Because you don’t fully understand what you are building, you will undoubtedly make mistakes. Finding mistakes at the specification stage is much cheaper than at the coding staging. Finding mistakes at the coding stage is much cheaper than at the testing stage. Finally, finding mistakes at the testing stage is much cheaper than finding them in the hands of the customer.
Interestingly enough, it should be possible to define a language, and be using it, without thought for what exactly the terms in the language will do. Defining a language should take seconds, not hours, days, or weeks! Creating an implementation (or describing how to create an implementation from a specification), of course, takes time. Again, it’s easy to ‘understand’ a specification. It’s difficult to implement it.
What is needed, then, is a system that allows you to formalize and implement what you have done before, while simultaneously mixing this with specification for what is new in a particular product. Your specification authors, when describing how to display information or what controls exist on a product, will use the formalized specification/implementation language. When describing how the new fangled space travel feature will work, they will use more free-form. The computer consumes the formal parts, and produces code. You, the developer, get to formalize the informal parts, and describe their implementation to the computer. Next time someone needs the space travel feature, they now have a formal language/implementation. Our hope at Precision Software is that we are building exactly that in the language we call Smpl.
I'll close this post with these words: Without faith it is impossible to please God!
Friday, May 9, 2008
Smpl Development Has Begun!
Our grand ideas of storing all product development information in a single database, providing a word processor-like interface to this database, allowing abstraction across all stored information, and transforming the information into code or other artifacts have been set aside.
The real world has humbled us. However, it has also brought out the best in us. We have been squeezed to create exactly and only what is necessary. We're calling it a Simple Modeling and Processing Language, or Smpl for short. It is a textual domain specific modeling language and associated translation based compiler.
It will be thin, light, simple, and yet powerful. Imagine Microsoft DSL Tools or MetaCase MetaEdit without all of the diagram and GUI overhead. It is text--so, yes, it will integrate with all of your existing development tools and processes. You will be able to use it in preprocessor mode, allowing you to smoothly transition from a traditional manual coding approach to full domain specific development.
We are confident you'll like what you see. The new web site will be coming along shortly, along with a two page introduction to Smpl technology. Development is moving forward. Alpha release is expected late 2008.
Thursday, April 10, 2008
When You Are Researching Vs. Developing
A completed (thorough and consistent) specification marks the end of research, and the beginning of development.
Prior to a completed specification, one is doing research (no matter how short or long this time may be). There are still unknowns. Unknowns require research. Research time is not predictable.
After a completed specification, one is doing development. The unknowns are hopefully minimal. Research is not required. Development time is predictable. An incomplete specification will allow research to slip into the development phase, thus making development time unpredictable.
Wednesday, February 20, 2008
Literate Programming
The primary goal of literate programming is to create well documented code. Accordingly, a literate programmer simultaneously authors both the documentation and the code. Macros enable both the abstraction and a more intuitive ordering of code. Abstraction is performed primarily to improve understanding, secondarily to foster reuse. Compilation of the documentation (called “weaving”) produces a well formatted TeX document which contains the embedded code as well, ordered in an intuitive fashion. Compilation of the code (called “tangling”) is a single-level process whereby documentation is eliminated, macros are expanded, and the desired code is thereby generated. Macros have similar capabilities and drawbacks of C macros. CWEB, in fact, employs C macros to do much of its work. The primary advantage of literate programming is nicely formatted, readily approachable documentation of the code base.
Literate programming is missing the following components of a Template Oriented Programming (TOP) system:
- Model syntax
- Multi-level model to model translation
- Custom errors to identify model misuse
- Model queries
- Translation debugging
Most of the CWEB manual focuses on formatting of documentation and code, whereas most of a TOP system focuses on model translation. Only the lowest level textual output of a TOP translation focuses on formatting. In a TOP system, the model serves as the documentation. A model pretty-printer can create a well-formatted, hyperlinked, read-only view of the model. Syntax highlighting within a text editor can be employed to create a reasonably formatted writable version of the model.
Literate programming can be a useful way to organize code. It is hoped that a TOP system will provide many of the benefits of literate programming, but also yield a considerably higher return on investment with respect to abstraction. For example, a literate programmer must always be aware of the underlying code being produced. In contrast, a TOP programmer should be able to think at the level of the model being created, for the most part ignoring the translation of that model to lower level model/code.
Monday, February 18, 2008
Template Oriented Programming
The phrase Template Oriented Programming is new. If you don’t believe me, type that quoted phrase into Google and you’ll find only about 5 unique hits! What is template oriented programming, you ask. This blog post seeks to answer that, and will hopefully, in part, make its way to Wikipedia, and, with any luck at all, to CS201 at your favorite educational institution.
Template oriented programming (TOP), as its title hints, is a programming paradigm that focuses on templates to accomplish a programmer’s goals. Note that when I use the word template here, I am not talking about a specific programming specific language feature such as (C++ template, C# generics, etc). The goal of template oriented programming is not to directly create machine code (or byte codes) to be executed on a (virtual) machine. Instead, the output of TOP is information to be processed by other code (or by humans). This could include familiar template output such as HTML/XML, or more complex code like C/C++/Java/C#, shell scripts, VHDL/Verilog, CAD scripts, etc. TOP allows one to generate one or more tedious artifacts from a simple, user defined model that is input.
This field is similar to that of template meta-programming. Template meta-programming systems are generally applied to a single, existing language. C++ templates, for example, allow adding templates to the C++ language. The focus is how to add compile time abstraction to the C++ language. TOP, on the other hand focuses on the templates, with the output language (or languages) being a secondary concern. In addition, the target language is defined by the programmer.
Template metaprogramming and template processing are not new. What is Precision Software doing that will breath life into these currently niche paradigms? Template solutions today focus on the getting the characters in the right order to produce a computer program. Our solution, however, focuses on a model of the information that is not character based. In this respect, it is similar to Lisp. The system supports translating between input and output, where neither are text—both are model. The closest analogy is to imagine operating on the abstract syntax tree within a compiler. This frees the programmer from having to continually parse the input, and unparsed (convert to text) the output. This approach allows information to be represented in a normalized fashion, translated with one or more stages within the tree format very concisely, and then output to one or more target artifacts.
Friday, February 8, 2008
Intentional Programming
What we provide is a shared fabric for abstraction. Our semantics and visualization are constrained. All information is represented using a common model, and that model is visualized uniformly with only occasional deviations for brevity. Once information is represented as model, templates may be used to abstract that model in a controlled, type-checked fashion. Templates are used both to abstract above a model and to translate higher level model semantics into lower level model semantics.
Due to constrained visualization, our system will not work well as a structured GPL editor. This is one of IP's goals, but is not one of our goals. Instead, we believe that GPL code is stored and edited quite well as text. Whereas an IP code base may consist of quite a lot of structured GPL (this is, in fact, exactly what the IP code base itself does consist of), a code base in our system will consist of layers with a handful of high-level abstractions at the top and textual GPL code at the lowest level leaves. Terse visualization of model is therefore less important, and a uniform way to view and abstract every level is far more important.
One lesson we've learned is that abstraction breaks fancy visualization. Since our whole world is about abstraction, visualization must be quite general and not depend on a fully realized model structure because the model structure within any given template may only be partially realized. On the other hand, the editor is completely context aware, so that even within a highly abstracted model, it can still intelligently prompt for valid relations and termini. Also, templates at all levels must conform to the syntax within which they are operating, yielding a "type-checked" expansion ("reduction" in IP terminology) from top to bottom.