Share via


Many syntaxes for one semantics

This is an example of a Ladder Diagram from the IEC1131 standard:

I find this fascinating! As a computer programmer, it would never have occurred to me to represent logic expressions in this way. But to electrical engineers used to laying out circuits involving relays, it’s obvious: the bars on each side of the ladder are the + and – poles of a power supply; the O symbols are lamps or the coils of relays; |/| is a switch or relay contact normally closed; | | is normally open.

 

So translating to almost-C#:

            Two_vents = V1 && V2 || V1 && V3 || V2 && V3;

            One_vent = !V1 && !V2 && V3 || !V1 && !V3 && V2 || !V2 && !V3 && V1;

            No_vent = !V1 && !V2 && !V3;

            LED = (Timer(high=300, low=200).On_period && (No_vent || One_vent)) || Two_vents; // Continuous if 2 or 3; flashing if 0 or 1

            Alarm = No_vent;

 

But an electronic engineer thinks in terms of logic gates, and their diagrams are derived from the wiring of chips:

Electrical and electronic engineers must think it strange that we like to write things with the outputs first.

 

This example supports some generalizations that we as DSL-tool providers should keep in mind:

·         Diagrammatic notations are a lot less compact than text, and less powerful, and sometimes (to our eyes) more confusing; but nevertheless, people clearly want to use them.

·         The notation people like to use comes from their cultural history as a profession. There are many notations that could represent a given space of variables, but the one you want is the one that requires least shifting within the users’ minds.

 

We are good exemplars of the latter point. Compare our insistence that you’ve got to be able to type it on a telex keyboard with the mathematicians’ whiteboard economy and historical veneration of ancient Greek:

Alan

Comments

  • Anonymous
    November 17, 2004
    Check the diagrams in the patent that Denis Ritchie got in 1973 for the set-UID bit in Unix (U.S. Patent 4,135,240). Because no one thought software was patentable he described the implementation as a logic circuit. I believe it was the first patent ever awarded for a software implementation.

  • Anonymous
    November 17, 2004
    Can't get this from http://patft.uspto.gov/netahtml/search-bool.html -- that number (with or without commas) gives 'not found'.
  • Anonymous
    November 17, 2004
    The comment has been removed
  • Anonymous
    November 23, 2004
    You raise a very interesting point. Check further in <a href='http://www.software.rockwell.com/corporate/reference/Iec1131/'>IEC1131-3</a> and you will find sequential function chart (SFC) and function block diagram language (FBD) specifications in addition to structured text (like C or Pascal) and instruction list (like assembly language) and ladder logic languages. The SFC language looks very similar to UML's sequence diagrams but predates UML by decades. Not only that but these control system languages (created by Siemens, Rockwell, Fisher-Rosemount, etc.) have allowed you to create compilable/executable SFCs for decades!


    Control system languages are quite "domain-specific" and as such they have not had to provide wide applicability like Java, C#, etc. have. These languages have been able to move on to higher levels of abstraction quickly because of their narrow focus.
  • Anonymous
    December 07, 2004
    Actually, the circuit is a pattern. Change the labels, change the semantics. So there are many syntaxes for the pattern, and the semantics are a function of the labeling. I've done a lot of exploring on this topic and am working to release a functional prototype of a software development platform for creating DSL's that's based on an underlying model that's based entirely on recombinant circuit patterns. Good stuff man.
  • Anonymous
    May 30, 2009
    PingBack from http://outdoorceilingfansite.info/story.php?id=3313
  • Anonymous
    May 31, 2009
    PingBack from http://outdoorceilingfansite.info/story.php?id=20949
  • Anonymous
    June 13, 2009
    PingBack from http://homelightingconcept.info/story.php?id=1463