Agile Renaissance


On Semantic Distance and Computer Languages

Print the article

This entry was posted on 4/25/2007 5:48 PM and is filed under Development.

One of the recurring themes that programming oriented bloggers post about is the suitability or lack of some programming language for solving problems. Two excellent examples ( and extremely informative posts in their own right) of this are: Why Why Functional Programming Matters Matters and a commentary on it, Measuring the power of programming languages. What is interesting to me is that none of the posts that I have read have every framed the discussion around the semantic distance between the solution and the capabilities of the language used to implement the solution. Bridging this distance is where most of the effort of development occurs. The closer the execution semantics of the implementation language are to the execution semantics of the solution the less implementation work is required. Reg Braithwaite, the author of the first example, has a number of wonderful examples of this, spread throughout his posts, in fact one could argue that semantic distance is one of the central issues of his intellectual life.

One of the clearest examples of semantic distance is in a wonderful paper, written by Paul Hudak, called Haskell vs. Ada vs. C++ vs. Awk vs. ... An Experiment in Software Prototyping Productivity (beware the paper is only available in PostScript). This paper describes the results of an experiment comparing the suitability of different languages for creating prototypes of systems. One of the most interesting insights for me was the solution developed for the test prototype that needed to be built. The solution was based on a brilliant abstract and I realized that I could use it to solve a similar type problem I had and that I was not able to use Haskell in my solution. I could however imagine that I was able to use Haskell and so I did and developed a solution using Haskell. Now all I needed to do was translate this solution into the language I was using. To do this did not require that I write a badly implemented version of Haskell, rather I was able to quickly implemented a set of abstractions that matched those of my solution and that solved the problem. I used this technique because of my understanding of the concept of semantic distance and how I needed to overcome it to solve the problem. What I have since discovered is that many others use this technique as well.

I was a co-creator/developer of the streaming programming language OmniMark. On a number of occasions I have met former OmniMark programmers and a number of them had said that sometimes when they are faced with tough problems they work out a solution by pretending that they still had OmniMark. Once they have solved the problem using OmniMark they then implement a solution in the language they are using.

If you survey the over 5000 different languages and dialects that humans speak, you find that there is no universal set of equivalent semantics between them. This fact implies that there can never be a computer language which will always have the shortest semantic distance between itself and any solution. Therefore there never will be a universally best programming language. On the other hand, if you cannot use the best language for a solution you can always pretend you can. Once you have a solution then you can implement the solution in the language you have. Two follow on points to this: I hope you now see the value in learning other languages/semantics and that the downside is never being able to use the best language available for the problems you have to solve and always having to use this technique to bridge the semantic distances.

 

What did you think of this article?




Trackbacks
Trackback specific URL for this entry
Comments

    • 4/29/2007 1:10 PM Andreas Krey wrote:
      I agree that learning other languages has a profound effect on the performance in the boss-given language. But I think this still amounts to either greenspunning or being a human compiler, more often the latter.

      And I do not think the conclusion is correct. In the ideal case you can just go and incorporate the idioms you want to use into your target language and close the semantic gap that way. Instead of being a human compiler you write the compiler, and the question is how much your target language supports you in doing that.
      Reply to this
      1. 5/9/2007 8:48 AM Norbert Winklareth wrote:
        Andreas,

        It is impossible to always use the language whose Semantic Execution model is the closest to the Problem-Domain/Problem/Solution. This is true even when you are not in a "boss-given language" context. If there is an implementation there is always a Semantic Distance, otherwise you are doing pure math or reasoning and the developed solution is sufficient. Given this, then the advice to learn as many different languages as you can is valid advice how to improve the quality of your implementations. By the way, you can use a just-in-time learning by classifying the problem/solution type and then looking at which language best matches this classified type.

        The alternative strategy you offer in your second paragraph is one that I have used by the use of DSLs or by writing my friend Roy Amodeo's favorite type of program: one which writes a program that solves the problem. I also see that my attempt at humour in the summary paragraph clouds my point that the semantic distance is always there and there are a number of effective ways to overcome it.

        Thanks for your comments.
        Norbert


        Reply to this
    Leave a comment

    Submitted comments will be subject to moderation before being displayed.

     Enter the above security code (required)

     Name

     Email (will not be published)

     Website

    Your comment is 0 characters limited to 3000 characters.