SlideShare a Scribd company logo
Project Fortress
          Alex Miller




                          http://www.flickr.com/photos/micbaun/1216608114/
Wednesday, July 1, 2009
Dude, isn’t
                          Fortress like
                          FORTRAN or
                           something?

                                  http://www.flickr.com/photos/finkle/3111290180/
Wednesday, July 1, 2009
Um, no.



Wednesday, July 1, 2009
Modern language design

                                  +

                          Scientific computing


Wednesday, July 1, 2009
Features of interest
               Mathematical rendering
               Parallelism
               Software transactional memory
               Operator and function overloading
               Objects / traits
               Contracts
               Components / apis


Wednesday, July 1, 2009
Let’s build some basics




Wednesday, July 1, 2009
Types

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

               String
               Boolean




Wednesday, July 1, 2009
juxtaposition


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

               log 1 evaluates to 0




Wednesday, July 1, 2009
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
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
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 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
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
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
Operator overloading



               Would be nice to actually use the right mathematical
               operator ! instead of a function, wouldn’t it?




Wednesday, July 1, 2009
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
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
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
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
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
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
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
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
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
Whither next?


               Currently working on compiler
               Goal is to have it working in 6 months for a real
               bioinformatics project




Wednesday, July 1, 2009
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
Alex Miller


               Twitter: http://twitter.com/puredanger
               Blog: http://tech.puredanger.com
               Presentations: http://slideshare.net/alexmiller




Wednesday, July 1, 2009

More Related Content

PDF
The Ring programming language version 1.7 book - Part 83 of 196
Mahmoud Samir Fayed
 
PDF
Exploiting Concurrency with Dynamic Languages
Tobias Lindaaker
 
PDF
[JavaOne 2011] Models for Concurrent Programming
Tobias Lindaaker
 
PPTX
Seeing with Python presented at PyCon AU 2014
Mark Rees
 
PDF
Александр Гранин, Функциональная 'Жизнь': параллельные клеточные автоматы и к...
Sergey Platonov
 
PPTX
19. algorithms and-complexity
ashishtinku
 
KEY
GoLightly: Building VM-Based Language Runtimes with Google Go
Eleanor McHugh
 
PDF
The Evolution of Async-Programming on .NET Platform (TUP, Full)
jeffz
 
The Ring programming language version 1.7 book - Part 83 of 196
Mahmoud Samir Fayed
 
Exploiting Concurrency with Dynamic Languages
Tobias Lindaaker
 
[JavaOne 2011] Models for Concurrent Programming
Tobias Lindaaker
 
Seeing with Python presented at PyCon AU 2014
Mark Rees
 
Александр Гранин, Функциональная 'Жизнь': параллельные клеточные автоматы и к...
Sergey Platonov
 
19. algorithms and-complexity
ashishtinku
 
GoLightly: Building VM-Based Language Runtimes with Google Go
Eleanor McHugh
 
The Evolution of Async-Programming on .NET Platform (TUP, Full)
jeffz
 

What's hot (20)

PDF
Dive Into PyTorch
Illarion Khlestov
 
PDF
"PyTorch Deep Learning Framework: Status and Directions," a Presentation from...
Edge AI and Vision Alliance
 
PPTX
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeks
JinTaek Seo
 
PPTX
Introduction to PyTorch
Jun Young Park
 
PDF
Swift for tensorflow
규영 허
 
PDF
The Evolution of Async-Programming on .NET Platform (.Net China, C#)
jeffz
 
PPTX
Fun with Lambdas: C++14 Style (part 2)
Sumant Tambe
 
PDF
O caml2014 leroy-slides
OCaml
 
PDF
JIT compilation for CPython
delimitry
 
PDF
Software transactional memory. pure functional approach
Alexander Granin
 
PDF
Hw09 Hadoop + Clojure
Cloudera, Inc.
 
PPTX
Node.js System: The Landing
Haci Murat Yaman
 
PDF
Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014
PyData
 
PDF
Computer Vision using Ruby and libJIT - RubyConf 2009
Jan Wedekind
 
PDF
Dynamic C++ ACCU 2013
aleks-f
 
ZIP
Cleanup and new optimizations in WPython 1.1
PyCon Italia
 
KEY
Objective-Cひとめぐり
Kenji Kinukawa
 
PDF
SPU Optimizations-part 1
Naughty Dog
 
PDF
Functional programming in C++ LambdaNsk
Alexander Granin
 
PDF
The STL
adil raja
 
Dive Into PyTorch
Illarion Khlestov
 
"PyTorch Deep Learning Framework: Status and Directions," a Presentation from...
Edge AI and Vision Alliance
 
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeks
JinTaek Seo
 
Introduction to PyTorch
Jun Young Park
 
Swift for tensorflow
규영 허
 
The Evolution of Async-Programming on .NET Platform (.Net China, C#)
jeffz
 
Fun with Lambdas: C++14 Style (part 2)
Sumant Tambe
 
O caml2014 leroy-slides
OCaml
 
JIT compilation for CPython
delimitry
 
Software transactional memory. pure functional approach
Alexander Granin
 
Hw09 Hadoop + Clojure
Cloudera, Inc.
 
Node.js System: The Landing
Haci Murat Yaman
 
Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014
PyData
 
Computer Vision using Ruby and libJIT - RubyConf 2009
Jan Wedekind
 
Dynamic C++ ACCU 2013
aleks-f
 
Cleanup and new optimizations in WPython 1.1
PyCon Italia
 
Objective-Cひとめぐり
Kenji Kinukawa
 
SPU Optimizations-part 1
Naughty Dog
 
Functional programming in C++ LambdaNsk
Alexander Granin
 
The STL
adil raja
 
Ad

Viewers also liked (20)

PDF
Groovy concurrency
Alex Miller
 
PDF
Caching In The Cloud
Alex Miller
 
PDF
Innovative Software
Alex Miller
 
PDF
Releasing Relational Data to the Semantic Web
Alex Miller
 
PDF
Scaling Your Cache
Alex Miller
 
PDF
Blogging ZOMG
Alex Miller
 
PDF
Cold Hard Cache
Alex Miller
 
PDF
Stream Execution with Clojure and Fork/join
Alex Miller
 
PDF
Scaling Hibernate with Terracotta
Alex Miller
 
PDF
Java Concurrency Gotchas
Alex Miller
 
PDF
Cracking clojure
Alex Miller
 
PDF
Clojure: The Art of Abstraction
Alex Miller
 
PDF
Visualising Data on Interactive Maps
Anna Pawlicka
 
PDF
Java Concurrency Gotchas
Alex Miller
 
PPT
Lecture on Java Concurrency Day 4 on Feb 18, 2009.
Kyung Koo Yoon
 
ODP
GPars: Groovy Parallelism for Java
Russel Winder
 
PPTX
Basics of Java Concurrency
kshanth2101
 
PPTX
concurrency gpars
Paul King
 
PPT
Java concurrency
ducquoc_vn
 
PDF
groovy and concurrency
Paul King
 
Groovy concurrency
Alex Miller
 
Caching In The Cloud
Alex Miller
 
Innovative Software
Alex Miller
 
Releasing Relational Data to the Semantic Web
Alex Miller
 
Scaling Your Cache
Alex Miller
 
Blogging ZOMG
Alex Miller
 
Cold Hard Cache
Alex Miller
 
Stream Execution with Clojure and Fork/join
Alex Miller
 
Scaling Hibernate with Terracotta
Alex Miller
 
Java Concurrency Gotchas
Alex Miller
 
Cracking clojure
Alex Miller
 
Clojure: The Art of Abstraction
Alex Miller
 
Visualising Data on Interactive Maps
Anna Pawlicka
 
Java Concurrency Gotchas
Alex Miller
 
Lecture on Java Concurrency Day 4 on Feb 18, 2009.
Kyung Koo Yoon
 
GPars: Groovy Parallelism for Java
Russel Winder
 
Basics of Java Concurrency
kshanth2101
 
concurrency gpars
Paul King
 
Java concurrency
ducquoc_vn
 
groovy and concurrency
Paul King
 
Ad

Similar to Project Fortress (20)

PDF
Write Your Own JVM Compiler
Erin Dees
 
PDF
Scala Functional Patterns
league
 
PDF
Marathon - RV2011
Julian Dolby
 
KEY
Five Languages in a Moment
Sergio Gil
 
PDF
11 - Programming languages
Tudor Girba
 
PDF
High-Performance Haskell
Johan Tibell
 
PDF
Peyton jones-2011-type classes
Takayuki Muranushi
 
PDF
Scala by Luc Duponcheel
Stephan Janssen
 
PPTX
Good functional programming is good programming
kenbot
 
PPTX
Functional Programming Fundamentals
OleksiyTereshchenko
 
PDF
Lecture 5: Functional Programming
Eelco Visser
 
PDF
Ti1220 Lecture 2: Names, Bindings, and Scopes
Eelco Visser
 
PDF
Functional programming in ruby
Koen Handekyn
 
PDF
The Next Great Functional Programming Language
John De Goes
 
PDF
03 expressions.ppt
Business man
 
PDF
Appengine ja-night-10
John Woodell
 
PDF
Dimitry Solovyov - The imminent threat of functional programming
Dmitry Buzdin
 
PDF
Dont Drive on the Railroad Tracks
Eugene Wallingford
 
KEY
Pontificating quantification
Aaron Bedra
 
PDF
A taste of Functional Programming
Jordan Open Source Association
 
Write Your Own JVM Compiler
Erin Dees
 
Scala Functional Patterns
league
 
Marathon - RV2011
Julian Dolby
 
Five Languages in a Moment
Sergio Gil
 
11 - Programming languages
Tudor Girba
 
High-Performance Haskell
Johan Tibell
 
Peyton jones-2011-type classes
Takayuki Muranushi
 
Scala by Luc Duponcheel
Stephan Janssen
 
Good functional programming is good programming
kenbot
 
Functional Programming Fundamentals
OleksiyTereshchenko
 
Lecture 5: Functional Programming
Eelco Visser
 
Ti1220 Lecture 2: Names, Bindings, and Scopes
Eelco Visser
 
Functional programming in ruby
Koen Handekyn
 
The Next Great Functional Programming Language
John De Goes
 
03 expressions.ppt
Business man
 
Appengine ja-night-10
John Woodell
 
Dimitry Solovyov - The imminent threat of functional programming
Dmitry Buzdin
 
Dont Drive on the Railroad Tracks
Eugene Wallingford
 
Pontificating quantification
Aaron Bedra
 
A taste of Functional Programming
Jordan Open Source Association
 

More from Alex Miller (12)

PDF
Clojure/West Overview (12/1/11)
Alex Miller
 
PDF
Concurrent Stream Processing
Alex Miller
 
PDF
Tree Editing with Zippers
Alex Miller
 
PDF
Scaling Your Cache And Caching At Scale
Alex Miller
 
PDF
Marshmallow Test
Alex Miller
 
PDF
Strange Loop Conference 2009
Alex Miller
 
PDF
Java Collections API
Alex Miller
 
PDF
Java Concurrency Idioms
Alex Miller
 
PDF
Design Patterns Reconsidered
Alex Miller
 
PDF
Java 7 Preview
Alex Miller
 
PDF
Exploring Terracotta
Alex Miller
 
PDF
Actor Concurrency
Alex Miller
 
Clojure/West Overview (12/1/11)
Alex Miller
 
Concurrent Stream Processing
Alex Miller
 
Tree Editing with Zippers
Alex Miller
 
Scaling Your Cache And Caching At Scale
Alex Miller
 
Marshmallow Test
Alex Miller
 
Strange Loop Conference 2009
Alex Miller
 
Java Collections API
Alex Miller
 
Java Concurrency Idioms
Alex Miller
 
Design Patterns Reconsidered
Alex Miller
 
Java 7 Preview
Alex Miller
 
Exploring Terracotta
Alex Miller
 
Actor Concurrency
Alex Miller
 

Recently uploaded (20)

PDF
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
 
PDF
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
PDF
The Future of Artificial Intelligence (AI)
Mukul
 
PPTX
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
PDF
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
PDF
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PDF
Doc9.....................................
SofiaCollazos
 
PDF
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
PPTX
The Future of AI & Machine Learning.pptx
pritsen4700
 
PPTX
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
PPTX
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
PDF
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
PDF
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
Brief History of Internet - Early Days of Internet
sutharharshit158
 
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
The Future of Artificial Intelligence (AI)
Mukul
 
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
Doc9.....................................
SofiaCollazos
 
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
The Future of AI & Machine Learning.pptx
pritsen4700
 
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 

Project Fortress

  • 1. Project Fortress Alex Miller http://www.flickr.com/photos/micbaun/1216608114/ Wednesday, July 1, 2009
  • 2. Dude, isn’t Fortress like FORTRAN or something? http://www.flickr.com/photos/finkle/3111290180/ Wednesday, July 1, 2009
  • 4. Modern language design + Scientific computing Wednesday, July 1, 2009
  • 5. Features of interest Mathematical rendering Parallelism Software transactional memory Operator and function overloading Objects / traits Contracts Components / apis Wednesday, July 1, 2009
  • 6. Let’s build some basics Wednesday, July 1, 2009
  • 7. Types ZZ32, ZZ64 - signed integer types RR32, RR64 - floating point types String Boolean Wednesday, July 1, 2009
  • 8. juxtaposition 3 4 evaluates to 12 “a” “b” evaluates to “ab” log 1 evaluates to 0 Wednesday, July 1, 2009
  • 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. 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
  • 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. 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. 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. Operator overloading Would be nice to actually use the right mathematical operator ! instead of a function, wouldn’t it? Wednesday, July 1, 2009
  • 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. Alex Miller Twitter: http://twitter.com/puredanger Blog: http://tech.puredanger.com Presentations: http://slideshare.net/alexmiller Wednesday, July 1, 2009