designing grace
play

Designing Grace Why Now? Happy teaching Java next 3-5 years Can an - PowerPoint PPT Presentation

Designing Grace Why Now? Happy teaching Java next 3-5 years Can an Introductory Programming In 2015, Java will be 20 years old Language Support the Teaching of Java 8 is coming Software Engineering? State of the art has advanced - patches


  1. Designing Grace Why Now? Happy teaching Java next 3-5 years Can an Introductory Programming In 2015, Java will be 20 years old Language Support the Teaching of Java 8 is coming… Software Engineering? State of the art has advanced - patches look like … patches James Noble Andrew Black Essential difficulties vs Accidental difficulties To be ready in 2015, we need to start now. Michael Homer Kim Bruce gracelang.org 2 1 Grace Example Grace User Model method average(in : InputStream) -> Number First year students in OO CS1 or CS2 / / ! reads numbers from in stream and averages them { ! var total := 0 objects early or late, ! var count := 0 static or dynamic types, ! while { ! in.atEnd } do { functionals first or scriptings first or … ! count := count + 1 ! total := total + in.readNumber } Second year students if (count == 0) then {return 0} Faculty & TAs — assignments and libraries ! return total / count } Researchers wanting an experimental vehicle Language Designers wanting a good example 3 4

  2. Object constructors Method Requests object { def x = 2 aPerson.printOn(outputStream) def y = 3 method distanceTo(other) { ((x - other.x)^2 + (y - other.y)^2) } printOn(outputStream) / / implicit self } ((x + y) > z) && !q ! ! / / operators are requests while { ! in.atEnd } do { print (in.readNumber) } ! ! ! ! ! ! ! ! ! ! / / multi-part method name 5 6 Object constructors Object constructors object { object { def x = 2 def x = 2 def y = 3 def y = 3 method distanceTo(other) { method distanceTo(other) { ((x - other.x)^2 + (y - other.y)^2) } ((x - other.x)^2 + (y - other.y)^2) } } } x 2 y 3 distanceTo(Point) ... 6 6

  3. Classes class CartesianPoint.new(x’, y’) { def x = x’ def y = y’ Can an Introductory Programming method distanceTo(other) { ((x - other.x)^2 + (y - other.y)^2) } Language Support the Teaching of } Software Engineering? x 2 x 2 x 2 x 2 y 3 y 3 y 3 new(x,y) distanceTo(Point) y ... 3 distanceTo(Point) ... distanceTo(Point) ... distanceTo(Point) ... 7 8 Consistency Consistency Syntactic Consistency: Syntactic Consistency: if ( count == 0 ) { return 0 } / / C/Java if ( count == 0 ) { return 0 } / / C/Java if ( count == 0 ) then { return 0 } / / Grace if ( count == 0 ) then { return 0 } / / Grace Semantic Consistency: while ( x > 0 ) { other.iterate } / / C/Java while { x > 0 } do { other.iterate } / / Grace 9 10

  4. Static vs. Dynamic Types Static vs. Dynamic Types class CartesianPoint.new(x’ , class CartesianPoint.new(x’ : Number , y ’ ) y ’ : Number ) -> Point { { def x = x‘ def x : Number = x‘ def y = y’ def y : Number = y’ method distanceTo ( other ) { method distanceTo(other : Point ) -> Number { ((x - other.x)^2 + (y - other.y)^2) } ((x - other.x)^2 + (y - other.y)^2) } } } 11 12 Implicit vs. Explicit Types vs Classes Declarations type Point = { JavaScript, FORTRAN: x -> Number y -> Number countr = counter + delta distanceTo(other : Point ) -> Number Pascal, C, Java, Ada… } def delta = 3 Types are separate from classes var counter := 0 Types need to be defined separately counter := counter + delta if (counter == 100) then { … } 13 14

  5. Information Hiding Information Hiding def joe = object { def joe = object { var forename := "Joe" var forename is public, readable := "Joe" var surname := "Bloggs" var surname is public, readable := "Bloggs" var id := 234567 var id := 234567 method asString method asString is public {"Name: {forename} {surname} Id: {id}"} {"Name: {forename} {surname} Id: {id}"} } } print "joe is {joe}." / / error here print "joe is {joe}." / / works now 15 16 Formal Reasoning Formal Reasoning method gcd(m, n) { assert {(letters.size > 0) && (letters.size < 20)} assert {(m >= 0) & (n >= 0) & ((m != 0) | (n != 0))} var a := max(m,n) / / implementation of assert var b := min(m,n) method assert (block : Block<Boolean>) { while {b != 0} if ( ! block.apply ) invariant { a >= b } then {error "Assertion Failed"} do {def remainder = a % b } a := b b := remainder variant {b} return a } 17 18

  6. Formal Reasoning Dialects dialect "loopinvariant" method for(collection) invariant( inv ) do( blk ) { import "mgcollections" as collections for (collection) do {element-> if (! inv.apply) then { def data = collections.list.new(2, 3, 4, 5) InvariantFailure.raise "Loop invariant not satisfied. ” } blk.apply(element) var sum : Number := 0 } for (data) invariant { sum >= 0 } do if (! inv.apply) then { { item : Number -> sum := sum + item } InvariantFailure.raise "Loop invariant not satisfied." } } 19 20 Can an Introductory Programming No conclusions — Language Support the Teaching of Software Engineering? we aren’ t done yet Grace : objects and method requests Questions Consistency: syntactic vs semantics Static vs Dynamic Types Comments Types vs Classes Suggestions Information Hiding Formal Reasoning Brickbats Dialects 21 22

  7. Help! Teachers Supporters Students Programmers http:/ /gracelang.org Tech Writers Implementers Library Writers Textbook Authors IDE Developers!!!! Blog editors Testers Community Builders 23 24

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend