drasil: from generating code to generating software · context software (re) certification i all...
TRANSCRIPT
![Page 1: Drasil: From generating code to generating software · Context software (re) certification I All software artefacts asevidence: I requirements, software specification, software](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2ab7b45b549d653039ef61/html5/thumbnails/1.jpg)
Drasil: From generating code to generatingsoftware
Jacques Carette, Spencer Smith, Dan Szymczak andSteven Palmer
McMaster University
WG 2.11, August 2016 Meeting
![Page 2: Drasil: From generating code to generating software · Context software (re) certification I All software artefacts asevidence: I requirements, software specification, software](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2ab7b45b549d653039ef61/html5/thumbnails/2.jpg)
![Page 3: Drasil: From generating code to generating software · Context software (re) certification I All software artefacts asevidence: I requirements, software specification, software](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2ab7b45b549d653039ef61/html5/thumbnails/3.jpg)
![Page 4: Drasil: From generating code to generating software · Context software (re) certification I All software artefacts asevidence: I requirements, software specification, software](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2ab7b45b549d653039ef61/html5/thumbnails/4.jpg)
Context
software
(re)
certification
I All software artefacts as evidence:I requirements, software specification, software design,
code, tests, “theory manual”, user manual, . . .
I Massive amounts of knowledge duplicationI Implies that either
I non-code artefacts do not get maintained well enough, ORI are felt to be an expensive nuisance
I duplication harms traceability
![Page 5: Drasil: From generating code to generating software · Context software (re) certification I All software artefacts asevidence: I requirements, software specification, software](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2ab7b45b549d653039ef61/html5/thumbnails/5.jpg)
Context
software (re)certification
I All software artefacts as evidence:I requirements, software specification, software design,
code, tests, “theory manual”, user manual, . . .
I Massive amounts of knowledge duplicationI Implies that either
I non-code artefacts do not get maintained well enough, ORI are felt to be an expensive nuisance
I duplication harms traceability
![Page 6: Drasil: From generating code to generating software · Context software (re) certification I All software artefacts asevidence: I requirements, software specification, software](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2ab7b45b549d653039ef61/html5/thumbnails/6.jpg)
Context
software (re)certificationI All software artefacts as evidence:
I requirements, software specification, software design,code, tests, “theory manual”, user manual, . . .
I Massive amounts of knowledge duplicationI Implies that either
I non-code artefacts do not get maintained well enough, ORI are felt to be an expensive nuisance
I duplication harms traceability
![Page 7: Drasil: From generating code to generating software · Context software (re) certification I All software artefacts asevidence: I requirements, software specification, software](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2ab7b45b549d653039ef61/html5/thumbnails/7.jpg)
Context
software (re)certificationI All software artefacts as evidence:
I requirements, software specification, software design,code, tests, “theory manual”, user manual, . . .
I Massive amounts of knowledge duplicationI Implies that either
I non-code artefacts do not get maintained well enough, ORI are felt to be an expensive nuisance
I duplication harms traceability
![Page 8: Drasil: From generating code to generating software · Context software (re) certification I All software artefacts asevidence: I requirements, software specification, software](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2ab7b45b549d653039ef61/html5/thumbnails/8.jpg)
Example SRS/LP
(see document)
![Page 9: Drasil: From generating code to generating software · Context software (re) certification I All software artefacts asevidence: I requirements, software specification, software](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2ab7b45b549d653039ef61/html5/thumbnails/9.jpg)
Literate Programming
What can we learn from it?
1. Code in most languages is not well organized for humanunderstanding.
2. Code in some languages can not efficiently be brokendown into very small pieces.
3. Chunk labels add convenient traceability information.
![Page 10: Drasil: From generating code to generating software · Context software (re) certification I All software artefacts asevidence: I requirements, software specification, software](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2ab7b45b549d653039ef61/html5/thumbnails/10.jpg)
Literate Programming
What can we learn from it?1. Code in most languages is not well organized for human
understanding.
2. Code in some languages can not efficiently be brokendown into very small pieces.
3. Chunk labels add convenient traceability information.
![Page 11: Drasil: From generating code to generating software · Context software (re) certification I All software artefacts asevidence: I requirements, software specification, software](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2ab7b45b549d653039ef61/html5/thumbnails/11.jpg)
Literate Programming
What can we learn from it?1. Code in most languages is not well organized for human
understanding.2. Code in some languages can not efficiently be broken
down into very small pieces.
3. Chunk labels add convenient traceability information.
![Page 12: Drasil: From generating code to generating software · Context software (re) certification I All software artefacts asevidence: I requirements, software specification, software](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2ab7b45b549d653039ef61/html5/thumbnails/12.jpg)
Literate Programming
What can we learn from it?1. Code in most languages is not well organized for human
understanding.2. Code in some languages can not efficiently be broken
down into very small pieces.3. Chunk labels add convenient traceability information.
![Page 13: Drasil: From generating code to generating software · Context software (re) certification I All software artefacts asevidence: I requirements, software specification, software](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2ab7b45b549d653039ef61/html5/thumbnails/13.jpg)
Drasil
Ideas behind our prototype:1. no information duplication
2. Recipes used to weave together information intodocuments / software artefacts.
Implies:I Bug in one place, bugs everywhere!I Huge up-front investment.I Doesn’t work if you have no theory.
![Page 14: Drasil: From generating code to generating software · Context software (re) certification I All software artefacts asevidence: I requirements, software specification, software](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2ab7b45b549d653039ef61/html5/thumbnails/14.jpg)
Drasil
Ideas behind our prototype:1. no information duplication2. Recipes used to weave together information into
documents / software artefacts.
Implies:I Bug in one place, bugs everywhere!I Huge up-front investment.I Doesn’t work if you have no theory.
![Page 15: Drasil: From generating code to generating software · Context software (re) certification I All software artefacts asevidence: I requirements, software specification, software](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2ab7b45b549d653039ef61/html5/thumbnails/15.jpg)
Drasil
Ideas behind our prototype:1. no information duplication2. Recipes used to weave together information into
documents / software artefacts.
Implies:I Bug in one place, bugs everywhere!
I Huge up-front investment.I Doesn’t work if you have no theory.
![Page 16: Drasil: From generating code to generating software · Context software (re) certification I All software artefacts asevidence: I requirements, software specification, software](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2ab7b45b549d653039ef61/html5/thumbnails/16.jpg)
Drasil
Ideas behind our prototype:1. no information duplication2. Recipes used to weave together information into
documents / software artefacts.
Implies:I Bug in one place, bugs everywhere!I Huge up-front investment.
I Doesn’t work if you have no theory.
![Page 17: Drasil: From generating code to generating software · Context software (re) certification I All software artefacts asevidence: I requirements, software specification, software](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2ab7b45b549d653039ef61/html5/thumbnails/17.jpg)
Drasil
Ideas behind our prototype:1. no information duplication2. Recipes used to weave together information into
documents / software artefacts.
Implies:I Bug in one place, bugs everywhere!I Huge up-front investment.I Doesn’t work if you have no theory.
![Page 18: Drasil: From generating code to generating software · Context software (re) certification I All software artefacts asevidence: I requirements, software specification, software](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2ab7b45b549d653039ef61/html5/thumbnails/18.jpg)
Example (high level)
SRS (LaTeX) SRS (html)SRS (verbose)
MISMG Test cases
MakefileC Code)(checks)
Matlab (nochecks)
Recipes
W = J/s =kg m2 s−3
−∇ · q + q′′′
= ρC ∂T∂t
hc is the heattransfer coeffbetween cladand coolant
L > 0uncertainty,typical val-
ues etc.
![Page 19: Drasil: From generating code to generating software · Context software (re) certification I All software artefacts asevidence: I requirements, software specification, software](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2ab7b45b549d653039ef61/html5/thumbnails/19.jpg)
Sanity checks
Var Constraints Typical Value Uncertainty
L L > 0 1.5 m 10%D D > 0 0.412 m 10%VP VP > 0 0.05 m3 10%AP AP > 0 1.2 m2 10%ρP ρP > 0 1007 kg/m3 10%
EW =
∫ t
0hCAC(TC − TW (t))dt −
∫ t
0hPAP(TW (t)− TP(t))dt
I Sanity checks captured and reusedI Generate guards against invalid inputI Generate test cases
![Page 20: Drasil: From generating code to generating software · Context software (re) certification I All software artefacts asevidence: I requirements, software specification, software](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2ab7b45b549d653039ef61/html5/thumbnails/20.jpg)
Reusability
Ref T1
Label Conservation of energy
Eq −∇ · q + q′′′ = ρC ∂T∂t
Desc. Conservation of energy for time varying heat trans-fer in a material of specific heat capacity C and den-sity ρ, where q is the thermal flux vector, q′′′ is thevolumetric heat generation, T is the temperature,∇is the del operator and t is time.
![Page 21: Drasil: From generating code to generating software · Context software (re) certification I All software artefacts asevidence: I requirements, software specification, software](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2ab7b45b549d653039ef61/html5/thumbnails/21.jpg)
Basic Drasil Design
Chunk (name)
Concept(description)
Quantity(symbol)
Unit (unit)
Unital
DefEqChunk(equation)
RelationChunk(relation)
![Page 22: Drasil: From generating code to generating software · Context software (re) certification I All software artefacts asevidence: I requirements, software specification, software](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2ab7b45b549d653039ef61/html5/thumbnails/22.jpg)
Example Recipevars : : [ EqChunk ]vars = [ h g , h c ]
s1 , s2 , s3 , s4 : : LayoutObjs1= t a b l e o f u n i t s s i u n i t ss2= tab le o f symbo ls varss3=Sect ion 0 (S ” Data D e f i n i t i o n s ” ) $ map ( D e f i n i t i o n . Data ) varss4=Sect ion 0 (S ”Code ” ) $ map ( CodeBlock . toCode CLang Calc ) [ h c ]
s rs : : Quant i t y s => [ s ] −> String −> [ LayoutObj ] −> Documentsrs l s author body =
Document ( ( S ”SRS f o r ” ) : + :( fo ldr1 ( : + : ) ( intersperse (S ” and ” )(map (\ x −> U $ x ˆ . symbol ) l s ) ) ) )(S author ) body
srsBody : : DocumentsrsBody = srs vars ” Spencer Smith ” [ s1 , s2 , s3 , s4 ]
![Page 23: Drasil: From generating code to generating software · Context software (re) certification I All software artefacts asevidence: I requirements, software specification, software](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2ab7b45b549d653039ef61/html5/thumbnails/23.jpg)
Example Recipe
t ab le o f symbo ls : : ( Un i t s , Quant i t y s ) => [ s ] −> LayoutObjtab le o f symbo ls l s =Sect ion 0 (S ” Table o f Sym” ) [ i n t r o , t ab l e l s ]
t ab l e : : ( Un i t s , Quant i t y s ) => [ s ] −> LayoutObjt ab l e l s =Table [S ” Symbol ” ,S ” Desc r i p t i on ” ,S ” Un i ts ” ] ( mkTable
[ ( \ ch −> U ( ch ˆ . symbol ) ) ,(\ ch −> ch ˆ . descr ) ,(\ ch −> Sy $ ch ˆ . u n i t ) ] l s )
(S ” Table o f Symbols ” ) False
Classy Opticsclass Chunk c where
name : : Simple Lens c Stringclass Chunk c => Concept c where
descr : : Simple Lens c Sentence
![Page 24: Drasil: From generating code to generating software · Context software (re) certification I All software artefacts asevidence: I requirements, software specification, software](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2ab7b45b549d653039ef61/html5/thumbnails/24.jpg)
Example Recipe
t ab le o f symbo ls : : ( Un i t s , Quant i t y s ) => [ s ] −> LayoutObjtab le o f symbo ls l s =Sect ion 0 (S ” Table o f Sym” ) [ i n t r o , t ab l e l s ]
t ab l e : : ( Un i t s , Quant i t y s ) => [ s ] −> LayoutObjt ab l e l s =Table [S ” Symbol ” ,S ” Desc r i p t i on ” ,S ” Un i ts ” ] ( mkTable
[ ( \ ch −> U ( ch ˆ . symbol ) ) ,(\ ch −> ch ˆ . descr ) ,(\ ch −> Sy $ ch ˆ . u n i t ) ] l s )
(S ” Table o f Symbols ” ) False
Classy Opticsclass Chunk c where
name : : Simple Lens c Stringclass Chunk c => Concept c where
descr : : Simple Lens c Sentence
![Page 25: Drasil: From generating code to generating software · Context software (re) certification I All software artefacts asevidence: I requirements, software specification, software](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2ab7b45b549d653039ef61/html5/thumbnails/25.jpg)
Units Recipefundamentals : : [ FundUnit ]fundamentals = [ metre , k i logram , second , ke l v in , mole , ampere , candela ]
der ived : : [ DerUChunk ]der ived = [ cent igrade , jou le , watt , c a l o r i e , k i l o w a t t ]
s i u n i t s : : [ Uni tDefn ]s i u n i t s = map UU fundamentals ++ map UU der ived
−−−−−−−−−−−−− Fundamental SI Un i ts −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−fund : : String −> String −> String −> FundUnitfund nam desc sym = UD (CC nam (S desc ) ) (UName $ Atomic sym)
metre , k i logram , second , ke l v in , mole , ampere , candela : : FundUnitmetre = fund ” Metre ” ” leng th ” ”m”k i logram = fund ” Ki logram ” ”mass ” ” kg ”second = fund ” Second ” ” t ime ” ” s ”k e l v i n = fund ” Ke lv in ” ” temperature ” ”K”mole = fund ” Mole ” ” amount o f substance ” ” mol ”ampere = fund ” Ampere ” ” e l e c t r i c cu r ren t ” ”A”candela = fund ” Candela ” ” luminous i n t e n s i t y ” ” cd ”
![Page 26: Drasil: From generating code to generating software · Context software (re) certification I All software artefacts asevidence: I requirements, software specification, software](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2ab7b45b549d653039ef61/html5/thumbnails/26.jpg)
The hc Chunkhc =
2kchb
2kc + τchb
h e a t t r a n s f e r : : DerUChunkh e a t t r a n s f e r = DUC (UD ht con ht symb ) hea t t r ans fe r eqn
ht con : : ConceptChunkht con = makeCC ” Heat t r a n s f e r ” ” Heat t r a n s f e r ”
ht symb : : USymbht symb = from udefn hea t t r ans fe r eqn
hea t t r ans fe r eqn = USynonym ( UProd[ k i logram ˆ . un i t , UPow ( second ˆ . u n i t ) (−3) ,UPow ( cent ig rade ˆ . u n i t ) ( −1) ] )
h c eq : : Exprh c eq = 2∗(C k c ) ∗ (C h b ) / ( 2 ∗ (C k c )+ (C tau c ) ∗ (C h b ) )
h c : : EqChunkh c = fromEqn ” h c ” (S ” convect ive heat t r a n s f e r . . . ” )
( lH ‘ sub ‘ lC ) h e a t t r a n s f e r h c eq
![Page 27: Drasil: From generating code to generating software · Context software (re) certification I All software artefacts asevidence: I requirements, software specification, software](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2ab7b45b549d653039ef61/html5/thumbnails/27.jpg)
Design Documentation
Control Module (M7)
Input Format Module (M2)
Temperature ODEs Module
(M5)Energy Equations
Module (M6)ODE Solver Module (M9)
Plotting Module (M10)
Output Format Module (M4)
Input Parameters Module (M3)
Sequence Data Structure Module
(M8)
Hardware Hiding Module (M1)
![Page 28: Drasil: From generating code to generating software · Context software (re) certification I All software artefacts asevidence: I requirements, software specification, software](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2ab7b45b549d653039ef61/html5/thumbnails/28.jpg)
ApproachI Case studies
I Solar water heating tankI Slope stability analysisI Glass safety analysisI Game physics engineI (medium-sized industrial code)
I Small chunks of knowledgeI Aggressively look for patterns and captureI Currently working on capturing design decisions
![Page 29: Drasil: From generating code to generating software · Context software (re) certification I All software artefacts asevidence: I requirements, software specification, software](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2ab7b45b549d653039ef61/html5/thumbnails/29.jpg)
ApproachI Case studies
I Solar water heating tankI Slope stability analysisI Glass safety analysisI Game physics engineI (medium-sized industrial code)
I Small chunks of knowledgeI Aggressively look for patterns and captureI Currently working on capturing design decisions