Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Higher Order Software for Node.js

Higher Order Software for Node.js

Exploring the rationale for a possible implementation of Higher Order Software for Node.js

Chris Munt

March 30, 2012
Tweet

Other Decks in Technology

Transcript

  1. “The attempt to build a discipline of software engineering on

    such shoddy foundations must surely be doomed … like trying to base astronomy on the assumption of a flat earth.” C. A. R. Hoare The Engineering of Software: A startling Contradiction Computer Bulletin (BCS). Software Engineering
  2. “The attempt to build a discipline of software engineering on

    such shoddy foundations must surely be doomed … like trying to base astronomy on the assumption of a flat earth.” C. A. R. Hoare The Engineering of Software: A startling Contradiction Computer Bulletin (BCS). 1975. Software Engineering
  3. Node.js Wish List • Ubiquitous • The definitive server-side scripting

    environment – JavaScript is the definitive client-side scripting environment. • Everyone should use it (or be able to use it) • Longevity
  4. Development Environment Wish List • High Productivity • Robust Deliverables

    • Deliverable conforms to specification • Ease of Maintenance • Accessible
  5. Development Environment Wish List • High Productivity – Development tools

    • Robust Deliverables – Software Engineering discipline – Formal methods • Deliverable conforms to specification – Automatically transform specification into code
  6. Development Environment Wish List • Ease of Maintenance – Self

    documenting • Accessible – Transparency of concepts and development paradigm
  7. Project Lifecycle : Reality • Analysis of requirements is on-going

    • Design evolves – Cannot know all requirements in advance • Technology shifts – Rising expectations – Accessing applications on mobile devices etc …
  8. HOS : Background • Elimination of computer errors – Research

    sponsored by NASA: 1970s • Apollo and Skylab projects • Margaret Hamilton and Saydean Zeldin • Error correction program: USE.IT • Computer Language: AXES – Functions created in natural language • E.g. English – Automatic code generation • Mathematical underpinnings hidden
  9. HOS : First Deployment • US Department of Defence project:

    1981 • Increased productivity by 600% • Reduced costs by 83%
  10. HOS : Current Status and Future • Hamilton Technologies Inc.

    – Product: 001 (‘double oh one’) – http://www.htius.com/ • Development Before The Fact (DBFT) – Based on Formal Systems Theory – System Oriented Objects (SOOs) • Integrates planning, systems and software engineering disciplines
  11. HOS : Basics • Functional Programming Environment – Functional decomposition

    – Non-procedural environment • Reusability through Library Functions • Defined Structures – Partially-defined functions with plug-in points – Call-backs
  12. HOS : Implementation • Graphical tree-based representation of functions –

    ‘HOS Trees’ • HOS Tree nodes == A function • HOS Trees verified according to rules – ‘HOS Verifier’ • Developer forced to correct errors and inconsistencies • Code generated automatically – ‘HOS Compiler’ • Code is bug free
  13. HOS : Benefits • Bug free code produced – Interfaces

    verified – Referential transparency • Most conventional programming errors caused by reassigned/undefined variables • Self documenting – Tree nodes separate the ‘what it does’ from the ‘how it does it’ of an operation
  14. Functional Decomposition : Example percent = ((amount / total) *

    100) z = (amount / total) percent = (z * 100)
  15. Primitive Control Structures : OR y = f₀(x, B) y

    = f₂(x, B) y = f₁(x, B) O P(x, B) is true P(x, B) is false
  16. Non-Primitive Co-Control Structures : COINCLUDE (y₁, y₂) = f₀(x₁, x₂,

    a, b) y₁ = f₁(x₁, a, b) y₂ = f₂(x₂, a) CI
  17. Non-Primitive Co-Control Structures : COOR y = f₀(x, a, b,

    B) y = f₂(x, a, b, B) y = f₁(x, a, B) CO P(B) is true P(B) is false
  18. Non-Primitive Co-Control Structures : CONCUR (y₁, y₂) = f₀(x₁, x₂,

    a, b) y₁ = f₁(x₁, y₂, a, b) y₂ = f₂(x₂, a) CC
  19. HOS : Leaf Node Types • P: Primitive Operation –

    Basic operation rigorously defined – Usually embedded in HOS compiler – System level read/write operations – Embedded lexical functions – Basic mathematical operators – System level niladic functions
  20. HOS : Leaf Node Types • OP: Operation Defined Elsewhere

    – Function decomposed elsewhere – OP: Defined in current tree – LX: Defined as other tree • Library functions • Repository of HOS trees • Reusability
  21. HOS : Leaf Node Types • R: Recursive Operation –

    Functional recursion – Iteration and loops • XO: External Operation – External program not written in HOS – Call-outs to native language environment – Interfacing
  22. HOS Recursion y = f₀(x) y = f₅(c;1) y =

    f₂(c;1) O P(c;1, B) is true P(c;1, B) is false R c = f₁(x) y = f₂(c) c;1 = f₃(c) y = f₄(c;1, B)
  23. HOS at the Royal Marsden Hospital • Implemented in late

    1980s • M11+ on DEC PDP 11/70 Mini – M11+ == InterSystems MUMPS (now Caché) – 8K Partitions! • Used to create comprehensive Hospital Information System • Developers are creatively Application- focused rather than Technology-focused
  24. HOS at the Royal Marsden Hospital • Extended through 1990

    and 2000s – Extended Higher Order Software (ETHOS) – Allow formal expressions – SQL implemented and integrated with HOS • Embed SQL in HOS trees and vice versa – Active Data Dictionary • Full referential actions • Still used today – Better Windows based editors – Server-side development role – Database management
  25. HOS Tree : ‘Menu’ Library P MPI LX {Options {Options

    OptionNo Display Menu Aggregate Menu Execute Option Option 1 Option 3 Option 2 “My Option 1” “My Option 2” “My Option 3”
  26. What use do the Medical Staff make of IM&T? IRTR37

    M: % of information items obtained by paper only % Queen Victoria Clatterbridge Birm Womens Cardiothoracic Ctr RNH RheumDis Walton Neuro Papworth Moorfields Christie Ryl Bromptn Harefld Liverpool Womens Ryl Marsden 0 10 20 30 40 50 60 70 80 90 100 % of information items obtained by paper only 2003/04
  27. How much do Trusts spend on IM&T? Ryl Marsden vs

    Acute Specialist within All Trusts % Christie Ryl Marsden Ryl Bromptn Harefld Queen Victoria Birm Womens Clatterbridge Papworth RNH RheumDis Liverpool Womens Moorfields Total IM&T expenditure as % of total trust revenue 2003/04
  28. Does the Trust obtain value for money from its IM&T

    investment? Ryl Marsden vs Acute Specialist within All Trusts Residual (observed - predicted score). Scores < 0 show VFM Ryl Marsden Christie Ryl Bromptn Harefld Liverpool Womens Papworth Moorfields RNH RheumDis Birm Womens Clatterbridge Queen Victoria Total expenditure and obtaining information 2003/04
  29. HOS for JavaScript/Node.js • Same benefits as for other base

    environments – Productivity and Maintenance – Self documenting – Formal basis – ‘Provably correct’ code – Accessible to a wider audience
  30. HOS for JavaScript/Node.js : Toolkit Implementation • Editor, Verifier and

    Compiler implemented in JavaScript • Compiler Generates JavaScript/Node.js code • Basic JavaScript operations and functions map directly to HOS primitives
  31. HOS for JavaScript/Node.js : Compiler Implementation • The HOS COINCLUDE

    control structure – Parallel processing – Operations completing asynchronously in multiple child processes • HOS functional decomposition and plug-ins – Intelligible way of handling call-backs – Avoid ‘call-back hell’ • Functions are first class objects in JavaScript – Lends itself to the defined structure/plug-in constructs defined in HOS.
  32. HOS for JavaScript/Node.js : Example MyDB.Open({path:"/mydb/"}, function(error, result) { if

    (!error) { MyDB.GetRecord({file:"MyFile", key:[1]}, function(error, result) { if (!error) { console.log("Data: " + JSON.stringify(result, null, '\t')); } else { console.log("ERROR: " + JSON.stringify(result, null, '\t')); } MyDB.Close(); }); } else { console.log("ERROR: " + JSON.stringify(result, null, '\t')); } });
  33. HOS for JavaScript/Node.js : Example LX PI LX {file:"MyFile", key:[1]}

    result MyDB.GetRecord Process Error error result MyDB.Close {path:"/mydb/"} Console.log Success “Data : “ result MyDB.GetRecord Callback MyDB.Open Callback MyDB.Open Test for error Process Error error result error result error result Test for error PI CO CO LX P LX error result error result
  34. HOS : References • Higher Order Software – A Methodology

    for Defining Software – M. Hamilton and S. Zeldin, IEEE Transactions on Software Engineering, Vol. SE 2 No 1, March 1976 • System Design From Provably Correct Constructs – James Martin, Prentice-Hall, 1985 • The ETHOS toolset and methodology – J. Milan and C. E. Munt, CASE on Trial, BCS, John Wiley & Sons, 1990