Top Banner
Boaz Rosenan Dept. of Computer Science The Open University of Israel Adviser: Prof. David H. Lorenz Language Oriented Programming with Cedalion
47

Language Oriented Programming with Cedalion

Feb 09, 2022

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Language Oriented Programming with Cedalion

Boaz RosenanDept. of Computer Science

The Open University of Israel

Adviser: Prof. David H. Lorenz

Language Oriented Programmingwith Cedalion

Page 2: Language Oriented Programming with Cedalion

Agenda

● Overview:– Language Oriented Programming (LOP)

– LOP Languages

– Cedalion, as an LOP Language

● Case Study:– DNA Microarray Design

Page 3: Language Oriented Programming with Cedalion

Language Oriented Programming (LOP): Rethinking Software Development

● Traditional Thinking

– Designing our software for a programming language.

● New Thinking

– Design programming languages for our software.

● The Role of DSLs in LOP

– Implement them if you need to.– Keep them focused and interoperable.

Page 4: Language Oriented Programming with Cedalion

LOP: Middle Out

Page 5: Language Oriented Programming with Cedalion

LOP: Middle Out

DSL Definition

Page 6: Language Oriented Programming with Cedalion

LOP: Middle Out

DSL Definition

Sw. Implementation

Page 7: Language Oriented Programming with Cedalion

LOP: Middle Out

DSL Implementation

DSL Definition

Sw. Implementation

Page 8: Language Oriented Programming with Cedalion

LOP: Middle Out

Expressive

DSL Implementation

DSL Definition

Sw. Implementation

Page 9: Language Oriented Programming with Cedalion

LOP: Middle Out

Concise

Expressive

DSL Implementation

DSL Definition

Sw. Implementation

Page 10: Language Oriented Programming with Cedalion

LOP: Middle Out

Concise

Expressive

ReusableDSL Implementation

DSL Definition

Sw. Implementation

Page 11: Language Oriented Programming with Cedalion

State of the Art

Page 12: Language Oriented Programming with Cedalion

State of the Art

Language Workbenches

● IDEs for developing DSLs.

● Use External DSLs.● Use Projectional-Editing

[Fowler05].● DSLs: Easy to use; hard

to implement.● Examples: MPS,

Intentional.

Page 13: Language Oriented Programming with Cedalion

State of the Art

Language Workbenches

● IDEs for developing DSLs.

● Use External DSLs.● Use Projectional-Editing

[Fowler05].● DSLs: Easy to use; hard

to implement.● Examples: MPS,

Intentional.

Internal DSLs

● Internal to a host language.

● First used in Lisp in the 1960s.

● DSLs: Easy to implement; limited by the host language.

Page 14: Language Oriented Programming with Cedalion

State of the Art

Language Workbenches

● IDEs for developing DSLs.

● Use External DSLs.● Use Projectional-Editing

[Fowler05].● DSLs: Easy to use; hard

to implement.● Examples: MPS,

Intentional.

Internal DSLs

● Internal to a host language.

● First used in Lisp in the 1960s.

● DSLs: Easy to implement; limited by the host language.

Page 15: Language Oriented Programming with Cedalion

State of the Art

Language Workbenches

● IDEs for developing DSLs.

● Use External DSLs.● Use Projectional-Editing

[Fowler05].● DSLs: Easy to use; hard

to implement.● Examples: MPS,

Intentional.

Internal DSLs

● Internal to a host language.

● First used in Lisp in the 1960s.

● DSLs: Easy to implement; limited by the host language.

Page 16: Language Oriented Programming with Cedalion

LOP Languages: Rethinking LOP

● LOP Languages

– Programming languages supporting LOP.– Just like OOP languages support OOP.

● Definition

– An LOP Language is a programming language that can host internal DSLs, allows the definition and enforcement of DSL schema, and features extensible projectional-editing.

Page 17: Language Oriented Programming with Cedalion

LOP Language Design Space

Page 18: Language Oriented Programming with Cedalion

LOP Language Design Space

InternalDSLs

Page 19: Language Oriented Programming with Cedalion

LOP Language Design Space

InternalDSLs

Page 20: Language Oriented Programming with Cedalion

LOP Language Design Space

InternalDSLs

DSLSchema

Page 21: Language Oriented Programming with Cedalion

LOP Language Design Space

InternalDSLs

DSLSchema

ProjectionalEditing

Page 22: Language Oriented Programming with Cedalion

LOP Language Design Space

InternalDSLs

DSLSchema

ProjectionalEditing

Page 23: Language Oriented Programming with Cedalion

LOP Language Design Space

InternalDSLs

DSLSchema

ProjectionalEditing

Haskell

ModelTalk

Lisp

Ruby

IntentionalMPS

Page 24: Language Oriented Programming with Cedalion

LOP Language Design Space

InternalDSLs

DSLSchema

ProjectionalEditing

Haskell

ModelTalk

LOPLanguagesLisp

Ruby

IntentionalMPS

Page 25: Language Oriented Programming with Cedalion

Cedalion: An LOP Language

Cedalion standing on the shoulders of Orion; Nicolas Poussin, 1658

● Logic Programming Language– Hosts internal DSLs

● Uses Projectional Editing– As a way to provide syntactic freedom

● Statically Typed (Type Inference)– As a way to define schema

● Open-source: – http://cedalion.sf.net

Page 26: Language Oriented Programming with Cedalion

Cedalion in Action

Page 27: Language Oriented Programming with Cedalion

Cedalion in Action

DSL Definition

Page 28: Language Oriented Programming with Cedalion

Cedalion in Action

DSL Definition

DSL Implementation

Page 29: Language Oriented Programming with Cedalion

Cedalion in Action

DSL Definition

DSL Implementation

Sw. Implementation

Page 30: Language Oriented Programming with Cedalion

Cedalion Case Studies

● BNF Grammar for Parsing + Evaluation.● Functional Programming.● Process Calculus (CCS) + Modal Logic

(HML).● DNA Sequence Sets

< >[ ]P a b

::=

Page 31: Language Oriented Programming with Cedalion

Related Work

● Language Oriented Programming

– [Ward, 1994] Language-oriented programming. Software-Concepts and Tools, 15(4):147–161, 1994

– [Fowler, 2005] Language workbenches: The killer-app for domain specific languages. 2005.

● Language Workbenches

– [Dmitriev, 2004] Language oriented programming: The next programming paradigm. JetBrains onBoard, 1(2), 2004.

– [Simonyi, Christerson, and Clifford, 2006] Intentional software. ACM SIGPLAN Notices, 41(10):451–464, 2006.

● Internal DSLs

– [Hudak, 1996] Building domain-specific embedded languages. ACM Computing Surveys (CSUR), 28(4es), 1996.

Page 32: Language Oriented Programming with Cedalion

Conclusion● Contributions

– LOP Languages

– Cedalion

● Future Work– Theory

● Further investigate the properties of LOP Languages.● Prove Cedalion type-system correctness.

– Practice● Make Cedalion “ready for prime-time”.● Provide more validation by real life examples.

Page 33: Language Oriented Programming with Cedalion

Case Study

DNA Sequence Setsfor

DNA Microarray Design

Joint work with Itai Beno,Faculty of Biology,

Technion – Israel Institute of Technology

Page 34: Language Oriented Programming with Cedalion

What is DNA?

● Deoxyribonucleic acid.● A double-helix consisting

of nucleotides.● Four types, abbreviated

A,T,C,G.● Stores the “machine code”

of life.● ~3GBase (~750MB) is the

size of the worlds most amazing “software”...

Page 35: Language Oriented Programming with Cedalion

DNA and Cancer Research

● DNA anomalies play a significant role in the formation of Cancer.

● Studying these anomalies is critical in the search for effective treatment for Cancer.

● Certain proteins which participate in cancerous processes interact with DNA.

● These interactions are of extreme importance to this field.

Page 36: Language Oriented Programming with Cedalion

DNA Microarray

● Finding a sequence with certain qualities requires multiple experiments.

● A DNA Microarray is a device containing O(105) microscopic spots, each containing a different DNA sequence (multiple instances).

● Microarrays can be custom-made for specific experiments.

● Biologists provide the manufacturer a list of all sequences need to be produced.

Page 37: Language Oriented Programming with Cedalion

Case-Study Goals

● Produce a list of O(105) DNA sequences that reflect the desired design.

● Do this “LOP Style”:– Microarray specification is done by biologists

(non-programmers).

– These biologists should use a DSL developed for this purpose.

– All “programming” should be restricted to the DSL and its runtime environment, and should be agnostic of the actual Microarray design.

Page 38: Language Oriented Programming with Cedalion

Before Cedalion...

● The biologist performing this experiment has a programming day-job...

● Programmed ~500 LOC in Java to express a simple design.

✔ Runs fast (few seconds).

✗ This code must change to accommodate any change to the microarray design.

Page 39: Language Oriented Programming with Cedalion

With Cedalion...

● A DSL was provided to express sets of DNA sequences.

● A microarray design can be defined using sets of sequences, with a name and quantity for each.

● A microarray design can be generated into files containing all sequences in the set.

● A 30 LOC Perl-script decimates the sequence files to form the desired output.

Page 40: Language Oriented Programming with Cedalion

DSL for DNA Sequence Sets

● A/T/C/G: Singleton sets of a single nucleotide.

● N:=A∪T∪C∪G● X.Y: The set consisting of an element of X

concatenated to an element of Y.● Xn: A singleton set containing the empty

sequence if n=0, or X.Xn-1 otherwise.● Y=[X]: Evaluates to the members of X. Y is

bound to a singleton set containing that member, e.g., Y=[N2].Y

Page 41: Language Oriented Programming with Cedalion

DSL for DNA Sequence Sets

● Xi n v : The members of X in inverse order.● Xc o n j : The members of X, with all

nucleotides replaced by their conjugates: AT; CG.

● Xc o m p := (Xc o n j )i n v

A T C G

AT CG

3'

5'

5'

3'

Page 42: Language Oriented Programming with Cedalion

Restricting a Set

● Double-stranded DNA is redundant.

● For each sequence S, S and Scomp represent the same double-stranded DNA.

● restrict(X): Contains all members of X, taking only the “smaller” of two sequences representing the same DNA.

● uniformRestrict(X): Same as restrict(X), but taking either the smaller of the greater, at coin-toss.

A T C G

AT CG

3'

5'

5'

3'

Page 43: Language Oriented Programming with Cedalion

Generating a Microarray

● A microarray has a name (base file name) and a list of sections.

● Each section consists of a name, a set of sequences and a quantity – how many sequences we wish to select.

● A context-menu-entry allows the generation of the microarray files, containing all possibilities.

● Running the Perl script in the target directory creates the final, decimated files.

Page 44: Language Oriented Programming with Cedalion

Exercise

● Build a microarray design.

● All sequences will start with ACCGGT and end with TTTTT.

● The middle part consists of a sequence followed by its conjugate.

● The basic sequence consists of the following:

– Experiment: A sequence of 5 bases, with either A or T in the middle. Select 100.

– Control: A sequence of 5 bases, with either C or G in the middle. Select 20.

Page 45: Language Oriented Programming with Cedalion

Case-Study Results

● With some assistance, the biologist was able to specify the microarray design using Cedalion.

● The design was changed twice before reaching the final version. Non of the changes required “programming”.

● Unit-tests were used to assure that the constant parts of the DNA sequences do not contain “interesting” features.

Page 46: Language Oriented Programming with Cedalion

Case-Study: Conclusion

● The microarray design produced by Cedalion was submitted to the manufacturer.

● Pros:

✔ Specification was done by non-programmer.

✔ Modifications to the design were straight-forward.

● Cons:

✗ Runtime performance is bad: x10 to x100 slower then the hand-written Java implementation (6 minutes for ~500,000 sequences).

Page 47: Language Oriented Programming with Cedalion

Boaz RosenanDept. of Computer Science

The Open University of Israel

[email protected]://cedalion.sf.net

Thank You!