Project Fortress
          Alex Miller




                          http://www.flickr.com/photos/micbaun/1216608114/
Wedne...
Dude, isn’t
                          Fortress like
                          FORTRAN or
                           someth...
Um, no.



Wednesday, July 1, 2009
Modern language design

                                  +

                          Scientific computing


Wednesday, Ju...
Features of interest
               Mathematical rendering
               Parallelism
               Software transactiona...
Let’s build some basics




Wednesday, July 1, 2009
Types

               ZZ32, ZZ64 - signed integer types
               RR32, RR64 - floating point types

               St...
juxtaposition


               3 4 evaluates to 12
               “a” “b” evaluates to “ab”

               log 1 evaluate...
Ranges


               5:9 evaluates to [5,6,7,8,9]
               5:9:2 evaluates to [5,7,9]

               5#2 evaluat...
Variables
               Immutable: name[:type] = value
               zero = 0
               zero:ZZ32 = 0
             ...
Now you’re dangerous.




Wednesday, July 1, 2009
A simple example
     component fact
     export Executable

     fact(n:ZZ32): ZZ32 =
       if n = 0 then 1
       else ...
BIG ideas


               But factorial is just a big multiply...use aggregate PROD
               operator ∏ instead.
  ...
More direct implementation
     component factp
     export Executable

     factp(n:ZZ32): ZZ32 =
       PROD [i <- 1:n] ...
Operator overloading



               Would be nice to actually use the right mathematical
               operator ! inst...
Let’s make it an operator
          component facto
          export Executable

          opr(n:ZZ32)! = PROD [i <- 1:n] ...
Lists
           evens = <|[ZZ32] 2,4,6,8,10|>
           println "evens: " evens

           evens2 = <|[ZZ32] 2 x | x <-...
Another example
     component sos
     import List.{...}
     export Executable

     sumOfSquares(n:List[ZZ32]): ZZ64 = ...
Implicit parallelism
               Many things implicitly parallel
                     for loops
                     pa...
Atomic punk
         component sos
         import List.{...}                         Fortress uses Software
         expo...
Traits
         component traitexample
         export Executable
                                                  trait ...
Function contracts
          component factc
          export Executable                   Documentation of
          fact...
Components and APIs


               Components modularize your program
               Components export and import APIs (...
And more...
               Literal arrays, multi-dimensional arrays
               Maps, sets, skip lists, trees, heaps, s...
Whither next?


               Currently working on compiler
               Goal is to have it working in 6 months for a r...
For more...

               Project Home: http://projectfortress.sun.com/Projects/
               Community
              ...
Alex Miller


               Twitter: http://twitter.com/puredanger
               Blog: http://tech.puredanger.com
      ...
Upcoming SlideShare
Loading in...5
×

Project Fortress

3,958

Published on

An overview of Project Fortress, a research language being developed at Sun, focusing on scientific and large-scale computing.

Published in: Technology, Education
1 Comment
4 Likes
Statistics
Notes
No Downloads
Views
Total Views
3,958
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
45
Comments
1
Likes
4
Embeds 0
No embeds

No notes for slide

Project Fortress

  1. 1. Project Fortress Alex Miller http://www.flickr.com/photos/micbaun/1216608114/ Wednesday, July 1, 2009
  2. 2. Dude, isn’t Fortress like FORTRAN or something? http://www.flickr.com/photos/finkle/3111290180/ Wednesday, July 1, 2009
  3. 3. Um, no. Wednesday, July 1, 2009
  4. 4. Modern language design + Scientific computing Wednesday, July 1, 2009
  5. 5. Features of interest Mathematical rendering Parallelism Software transactional memory Operator and function overloading Objects / traits Contracts Components / apis Wednesday, July 1, 2009
  6. 6. Let’s build some basics Wednesday, July 1, 2009
  7. 7. Types ZZ32, ZZ64 - signed integer types RR32, RR64 - floating point types String Boolean Wednesday, July 1, 2009
  8. 8. juxtaposition 3 4 evaluates to 12 “a” “b” evaluates to “ab” log 1 evaluates to 0 Wednesday, July 1, 2009
  9. 9. Ranges 5:9 evaluates to [5,6,7,8,9] 5:9:2 evaluates to [5,7,9] 5#2 evaluates to [5,6] Wednesday, July 1, 2009
  10. 10. Variables Immutable: name[:type] = value zero = 0 zero:ZZ32 = 0 Mutable: var name[:type] = value OR name[:type] := value var sum = 0 sum := 0 Wednesday, July 1, 2009
  11. 11. Now you’re dangerous. Wednesday, July 1, 2009
  12. 12. A simple example component fact export Executable fact(n:ZZ32): ZZ32 = if n = 0 then 1 else n fact(n-1) end run():()=do for k<-seq(1:10) do println " fact(" k ") = " fact(k) end end end Executable - a trait juxtaposition as operator defining run() Parallelism - in terms, in for Rendering: ZZ32, <-, fonts seq() - force sequential Wednesday, July 1, 2009
  13. 13. BIG ideas But factorial is just a big multiply...use aggregate PROD operator ∏ instead. This is known as a BIG operator. Wednesday, July 1, 2009
  14. 14. More direct implementation component factp export Executable factp(n:ZZ32): ZZ32 = PROD [i <- 1:n] i run():()=do for k<-seq(1:10) do println " factp(" k ") = " factp(k) end end end PROD = aggregate Known as “BIG” product operators SUM = summation You can make your own! Wednesday, July 1, 2009
  15. 15. Operator overloading Would be nice to actually use the right mathematical operator ! instead of a function, wouldn’t it? Wednesday, July 1, 2009
  16. 16. Let’s make it an operator component facto export Executable opr(n:ZZ32)! = PROD [i <- 1:n] i run():()=do for k<-seq(1:10) do println k "! = " k! end end end opr() used to define a Also can do prefix, infix, postfix operator here nofix, multifix, or enclosing! Wednesday, July 1, 2009
  17. 17. Lists evens = <|[ZZ32] 2,4,6,8,10|> println "evens: " evens evens2 = <|[ZZ32] 2 x | x <- 1:5|> println "evens2: " evens2 odds = <|[ZZ32] e - 1 | e <- evens |> println "odds: " odds evens: <|2, 4, 6, 8, 10|> evens2: <|2, 4, 6, 8, 10|> odds: <|1, 3, 5, 7, 9|> Wednesday, July 1, 2009
  18. 18. Another example component sos import List.{...} export Executable sumOfSquares(n:List[ZZ32]): ZZ64 = do sum:ZZ64 := 0 for i<-0#|n| do sum += (n[i])^2 end sum end run():()=do theList = <|[ZZ32] x | x<-1#100|> println "sumOfSquares = " sumOfSquares(theList) end end What’s the bug? (Hint: think parallelism) Wednesday, July 1, 2009
  19. 19. Implicit parallelism Many things implicitly parallel for loops parameters to a function call do ... also ... end construct Here, for loop is parallel, so sum += is a data race Use atomic to fix Wednesday, July 1, 2009
  20. 20. Atomic punk component sos import List.{...} Fortress uses Software export Executable Transactional Memory sumOfSquares(n:List[ZZ32]): ZZ64 = do atomic blocks executed all sum:ZZ64 := 0 for i<-0#|n| do or nothing atomic sum += (n[i])^2 end sum Retry on collision end run():()=do theList = <|[ZZ32] x | x<-1#100|> println "sumOfSquares = " Transactions may nest sumOfSquares(theList) end tryatomic end Wednesday, July 1, 2009
  21. 21. Traits component traitexample export Executable trait - like Java interface trait Animal talk():String end methods - abstract or trait Fuzzy concrete howFuzzy():String end object - like Java final class trait Cat extends Animal fields, methods getter name():String talk() = "meow" end object Whiskers extends {Cat, Fuzzy} constructors name() = "Whiskers" howFuzzy() = "real fuzzy" end multiple inheritance run():() = do w:Whiskers = Whiskers getter / setter - metadata println w.name() " is " w.howFuzzy() end end Wednesday, July 1, 2009
  22. 22. Function contracts component factc export Executable Documentation of factorial(n:ZZ32):ZZ32 semantic constraints requires { n >= 0 } ensures { outcome >= 0 } beyond the type system. = PROD [i <- 1:n] i run():() = do requires - specifies pre- conditions on incoming for k<-seq(1:10) do println k "! = " factorial(k) arguments end end end ensures - specifies post- condition on “outcome” Wednesday, July 1, 2009
  23. 23. Components and APIs Components modularize your program Components export and import APIs (NEVER other components, just APIs) APIs are explicitly defined in their own file type Repository for components Wednesday, July 1, 2009
  24. 24. And more... Literal arrays, multi-dimensional arrays Maps, sets, skip lists, trees, heaps, sparse vectors and matrices, quick sort, etc in library Explicit thread spawn, memory region tree Function overloading Tuples Tests Functions as first class objects Exceptions Wednesday, July 1, 2009
  25. 25. Whither next? Currently working on compiler Goal is to have it working in 6 months for a real bioinformatics project Wednesday, July 1, 2009
  26. 26. For more... Project Home: http://projectfortress.sun.com/Projects/ Community David Chase: http://www.infoq.com/presentations/ chase-fortress Guy Steele, Eric Allen: http://tinyurl.com/md6f6g Wednesday, July 1, 2009
  27. 27. Alex Miller Twitter: http://twitter.com/puredanger Blog: http://tech.puredanger.com Presentations: http://slideshare.net/alexmiller Wednesday, July 1, 2009
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×