Clean 2.0 Rinus Plasmeijer University of Nijmegenwww.cs.kun.nl/~clean At last…..

Slides:



Advertisements
Similar presentations
pa 1 Porting BETA to ROTOR ROTOR Projects Presentation Day, June by Peter Andersen.
Advertisements

Introduction to Compilation of Functional Languages Wanhe Zhang Computing and Software Department McMaster University 16 th, March, 2004.
Debugging Natural Semantics Specifications Adrian Pop and Peter Fritzson Programming Environment Laboratory Department of Computer and Information Science.
CSE341: Programming Languages Lecture 16 Datatype-Style Programming With Lists or Structs Dan Grossman Winter 2013.
Getting started with ML ML is a functional programming language. ML is statically typed: The types of literals, values, expressions and functions in a.
Remote Procedure Call Design issues Implementation RPC programming
Lecture 1: Overview of Computers & Programming
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
Copyright © 2002 W. A. Tucker1 Chapter 1 Lecture Notes Bill Tucker Austin Community College COSC 1315.
Chapter 7 User-Defined Methods. Chapter Objectives  Understand how methods are used in Java programming  Learn about standard (predefined) methods and.
Programming Types of Testing.
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming The software development method algorithms.
Processes CSCI 444/544 Operating Systems Fall 2008.
1/18 CS 693/793 Lecture 09 Special Topics in Domain Specific Languages CS 693/793-1C Spring 2004 Mo, We, Fr 10:10 – 11:00 CH 430.
ML: a quasi-functional language with strong typing Conventional syntax: - val x = 5; (*user input *) val x = 5: int (*system response*) - fun len lis =
Generic Haskell Where to start from. Issues Touched Language Ideas Tools Pitfalls.
1 Lecture 1  Getting ready to program  Hardware Model  Software Model  Programming Languages  The C Language  Software Engineering  Programming.
IFL2002 Madrid 1 a generic test-system Pieter Koopman, Artem Alimarine, Jan Tretmans, Rinus Plasmeijer Nijmegen, NL.
Sparkle A theorem prover for the functional language Clean Maarten de Mol University of Nijmegen February 2002.
C++ vs. Java: Similiarities & Differences Dr. Jeyakesavan Veerasamy Director of CS UTDesign program & CS Teaching Faculty University.
Guide To UNIX Using Linux Third Edition
Type Inference: CIS Seminar, 11/3/2009 Type inference: Inside the Type Checker. A presentation by: Daniel Tuck.
Testing a program Remove syntax and link errors: Look at compiler comments where errors occurred and check program around these lines Run time errors:
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
CSC 8310 Programming Languages Meeting 2 September 2/3, 2014.
CASE Tools And Their Effect On Software Quality Peter Geddis – pxg07u.
OOP Languages: Java vs C++
UPC Runtime Layer Jason Duell. The Big Picture The Runtime layer handles everything that is both: 1) Platform/Environment specific —So compiler can output.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Java Programs COMP 102 #3.
CCSA 221 Programming in C CHAPTER 2 SOME FUNDAMENTALS 1 ALHANOUF ALAMR.
Chapter Introduction to Computers and Programming 1.
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
CIS Computer Programming Logic
Property of Jack Wilson, Cerritos College1 CIS Computer Programming Logic Programming Concepts Overview prepared by Jack Wilson Cerritos College.
CE Operating Systems Lecture 3 Overview of OS functions and structure.
Chapter 1 Introduction Chapter 1 Introduction 1 st Semester 2015 CSC 1101 Computer Programming-1.
8 1 Chapter 8 Advanced SQL Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
C/C++ Programming Environment
Generic Programming ___________ III Rinus Plasmeijer University of Nijmegenclean.cs.ru.nl/
Chapter 1 Introduction. Chapter 1 - Introduction 2 The Goal of Chapter 1 Introduce different forms of language translators Give a high level overview.
RUN-Time Organization Compiler phase— Before writing a code generator, we must decide how to marshal the resources of the target machine (instructions,
Overview of Previous Lesson(s) Over View  A program must be translated into a form in which it can be executed by a computer.  The software systems.
Chapter 8 Advanced SQL Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Chapter 1 Computers, Compilers, & Unix. Overview u Computer hardware u Unix u Computer Languages u Compilers.
Chapter 1 : Overview of Computer and Programming By Suraya Alias
 Programming - the process of creating computer programs.
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Java Programs COMP 102 #3.
Cross Language Clone Analysis Team 2 February 3, 2011.
Computer and Programming. Computer Basics: Outline Hardware and Memory Programs Programming Languages and Compilers.
1 Static Contract Checking for Haskell Dana N. Xu University of Cambridge Joint work with Simon Peyton Jones Microsoft Research Cambridge Koen Claessen.
Compiler Construction CPCS302 Dr. Manal Abdulaziz.
Chapter – 8 Software Tools.
June 21, Reasoning about explicit strictness in a lazy language using mixed lazy/strict semantics Marko van Eekelen Maarten de Mol Nijmegen University,
© Peter Andreae Java Programs COMP 102 # T1 Peter Andreae Computer Science Victoria University of Wellington.
CSCI 161 Lecture 3 Martin van Bommel. Operating System Program that acts as interface to other software and the underlying hardware Operating System Utilities.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
FASTFAST All rights reserved © MEP Make programming fun again.
Assembler, Compiler, MIPS simulator
Chapter 5- Assembling , Linking, and Executing Programs
Sparkle a functional theorem prover
Type Checking Generalizes the concept of operands and operators to include subprograms and assignments Type checking is the activity of ensuring that the.
and Executing Programs
Chapter 11 Introduction to Programming in C
Generic Graphical User Interfaces ___________
Combining Compile-Time and Run-Time Components
point when a program element is bound to a characteristic or property
SPL – PS1 Introduction to C++.
Presentation transcript:

Clean 2.0 Rinus Plasmeijer University of Nijmegenwww.cs.kun.nl/~clean At last…..

Clean Clean version 2.0 New compiler rewritten in Clean (instead of C) Lots of small improvements in language -import mechanism (more precise, cyclic) -rank 2 polymorphism -multi-parameter type constructor classes Support for Lazy / Strict / Unboxed lists Experimental feature: dynamics IDE: easy switching between different compilers / linkers Sparkle ! Not finished on time: support for Generic Programming

Clean Clean version 2.0 New compiler written in Clean (instead of C) Lots of small improvements in language -import mechanism (more precise, cyclic) -rank 2 polymorphism -multi-parameter type constructor classes Support for Lazy / Strict / Unboxed lists Experimental feature: dynamics IDE: easy switching between different compilers / linkers Sparkle ! Not finished on time: support for Generic Programming

Clean Lazy lists in Clean 1.3 Lazy lists are predefined data structures Special syntax, list comprehensions, lots of predefined functions map :: (a  b) [a]  [b] map f [ ] = [ ] map f [x : xs]= [f x : map f xs] One can also define user-defined lists using an algebraic data type :: List a = Cons a (List a) | Nil mapl :: (a  b) (List a)  (List b) mapl f Nil = Nil mapl f (Cons x xs)= Cons (f x) (mapl f xs) Different type as lazy list: cannot use nice syntax, nor any predefined function But: one can make eager and unboxed list variants in this way

Clean Lazy lists in Clean 1.3 Lazy lists are predefined data structures Special syntax, list comprehensions, lots of predefined functions map :: (a  b) [a]  [b] map f [ ] = [ ] map f [x : xs]= [f x : map f xs] One can also define user-defined lists using an algebraic data type :: HList a = HCons !a (HList a) | HNil maph :: (a  b) (HList a)  (HList b) maph f HNil = HNil maph f (HCons x xs)= HCons (f x) (maph f xs) Different type as lazy list: cannot use nice syntax, nor any predefined function But: one can make eager and unboxed list variants in this way

Clean Lazy lists in Clean 1.3 Lazy lists are predefined data structures Special syntax, list comprehensions, lots of predefined functions map :: (a  b) [a]  [b] map f [ ] = [ ] map f [x : xs]= [f x : map f xs] One can also define user-defined lists using an algebraic data type :: EList a = ECons !a !(EList a) | ENil mape :: (a  b) (EList a)  (EList b) mape f ENil = ENil mape f (ECons x xs)= ECons (f x) (mape f xs) Different type as lazy list: cannot use nice syntax, nor any predefined function But: one can make eager and unboxed list variants in this way

Clean Clean 2.0: syntax for lazy, strict, unboxed lists map :: (a  b) [a]  [b]// default lazy list map f [ ] = [ ] map f [x : xs]= [f x : map f xs] Syntax added for strict lists [! ], [ !], [!!] and unboxed lists [# ], [#!] maph :: (a  b) [!a]  [!b]// head strict list maph f [! ]= [! ] maph f [!x : xs]= [!f x : maph f xs] mapu :: (a  b) [#Int!]  [#Int!] // head unboxed+tail strict list of Int mapu f [# !]= [# !] mapu f [#x : xs!]= [#f x : mapu f xs!]

Clean Overloading for lists using the class List map :: (a  b) (m a)  (n b) | List m a & List n b map f [|]= [|] map f [|x : xs]= [|f x : map f xs] This overloaded definition can be used for all representations: [ ], [! ], [ !], [!!], [# ], [#!] Overloading is used in the pattern match ! Overloading mechanism takes care of specialization: Automatically within the same module Exported overloaded functions can be specialized on demand No loss of efficiency

Clean Measurements

Clean Clean version 2.0 New compiler written in Clean (instead of C) Lots of small improvements in language -import mechanism (more precise, cyclic) -rank 2 polymorphism -multi-parameter type constructor classes Support for Lazy / Strict / Unboxed lists Experimental feature: dynamics IDE: easy switching between different compilers / linkers Sparkle ! Not finished on time: support for Generic Programming

Clean Why Dynamics ?  Exchange of data as well as code (!) in an easy and type-safe way get rit of boring code for trivial I/O Output : convert to some (string) format Input: parser needed typical 30% of program code be able to store, retrieve and exchange code add and combine plug-ins in a type-safe way support the development of persistent programs allow communication of arbitrary expressions between distributed applications more expressive power

Clean Hybride Type System  Use keyword dynamic to change an expression of a static type ::  into the dynamic type :: Dynamic 3 :: Intdynamic 3 :: Dynamic map :: (a  b) [a]  [b] dynamic map :: Dynamic map square :: [Int]  [Int] dynamic map square :: Dynamic  Use pattern matching to examine if an argument of dynamic type :: Dynamic is of a particular static type transform :: Dynamic  [Int] transform (n :: Int)= [n] transform (f :: [Int]  [Int]) = f [1..100] transform other= abort ”dynamic type error”

Clean Dynamic Type Unification dynApply :: Dynamic Dynamic  Dynamic dynApply (f :: a  b) (x :: a) = dynamic (f x :: b) dynApply df dx = abort ”dynamic type error” dynApply2 :: Dynamic Dynamic  b | TC b dynApply2 (f :: a  b^) (x :: a)= f x :: b^ dynApply2 df dx = abort ”dynamic type error”  Run-time type checking, unification, type errors

Clean Communicating Dynamics  write + read Dynamics with one instruction writeDynamic :: Dynamic *File  *File readDynamic :: *File  (Dynamic, *File) sendDynamic :: Dynamic *Channel  *Channel

Clean Clean System 2.0 Compiler Clean /C.icl.dcl.abc.obj Code Generator C Static Linker Clean RTS C.obj Application Clean I ntegrated D evelopment E nvironment Project Manager Editor Clean Time Profiler Clean.pcl Heap Profiler Clean.chp Sparkle Clean

Clean Clean Dynamic Linker Compiler Clean /C.icl.dcl.abc.obj Code Generator C RTS C.obj I ntegrated D evelopment E nvironment Project Manager Editor Clean Static Linker Clean Dynamic Linker Clean Plug-in Clean dynamic Applic. 1 Image  obj Applic. 2 Image  obj App 2 Plug-in Clean App 1 Plug-in Clean

Clean Dynamics: Easy to use, hard to implement !  Writing of a Dynamic: Expression is stored, sharing maintained, nested dynamics allowed Type of the Dynamic is stored Store references to applications images containing the code type definitions  Reading of a Dynamic is done lazily: Nothing happens until its type is required in a pattern match Linking of code only happens if all types in the rule match and can be unified and all type definitions involved in the Dynamics and the application are identical If the rule matches, the expression is constructed as far as needed Constructors of the same type must have the same address ! The code needed for evaluation not yet linked in will be linked in (Plug-in)

Clean Demo applications using Dynamics  Visual Editor (work in progress) Resource editor for defining dialogs, windows, menu’s Stores it’s definitions in a Dynamic Definitions are a plug-in for the application Application can change it’s look by using the Visual Editor as plug-in  FAMKE - Functional Micro Kernel Experiment (work in progress)  Very Tiny Operating System: only type safe operations !  Special File Manager: Files contain Dynamics Executables (:: a -> b), Data (:: T a b c)  Process creation and communication using Dynamics  Type safe Unix-like shell (pipes) using process combinators  Data Base support

Clean Clean Compiler version 2.0  Status  Front end compiler completely rewritten in Clean  We have added some interesting new features  All Clean 1.3 applications (IDE, Sparkle, compiler) ported and tested  Speed: about 1.7 slower than C version  See: (13.2 Mb zipped, open source)  Work to do  Test compiler for new features, wrong programs  Dynamics + uniqueness typing, universal quantified types …  Add support for generic programming  Improve fusion algorithm to reduce generics overhead  Port to Mac OS X (carbon/PEF), Linux

Clean The Clean Team  STW crew Diederik van Arkel ( ) Integrated Development Environment Fusion Algorithm Martijn Vervoort ( ) Dynamics + Dynamic Linker Arjen van Weelden ( ) Demo Application: Famke  KUN crew John van Groningen Compiler, Code generator Ronny Wichers - Schreur Compiler Testing  KUN PhD researchers Maarten de Mol Sparkle: Proof System Artem Alimarine Generic Programming  KUN MSc students Arvid Nicolaas Demo Application: V isual Editor  KUN staf Peter Achten Generics / IO / Visual Editor Pieter Koopman compiler (parser/checking) Sjaak Smetsers compiler (typing, testing) Marko van Eekelen Semantics Clean + Sparkle Rinus Plasmeijer Project leader