SlideShare une entreprise Scribd logo
1  sur  24
Télécharger pour lire hors ligne
Frege: Design & Implementation
A short Overview
Ingo Wechsung
IT Consultant, contexo GmbH
Reutlingen, Germany
Topics
• History
• Language Design
• Runtime
• Compiler Architecture
History
• Frege1
• Frege2
• Frege3
see http://www.infoq.com/news/2015/08/frege-haskell-for-jvm
Design Goals
• pure functional, statically typed, non-strict
– essentially Haskell 2010
– plus higher ranked types
– more GHC features to be implemented on top
• easy integration in JVM ecosystem
– a practical JVM language
– a (more funny) way to write (better) Java code
– be as familiar as possible for JVM programmers
Reminder: Haskell means Laziness
… not now,
please! I can do
that later ….
Principles for Design Decisions
• when in doubt, do it like Haskell 2010
– unless it makes no sense in JVM
• module system, FFI, exceptions, C-ish/POSIX-ish APIs
– unless outdated (Functor/Applicative/Monad)
– maybe a bit simpler in certain cases
– subsetting (e.g. standard/prelude libraries)
• add nice JVM stuff
– regexes out of the box
– long, java.lang.String
– types as name spaces (makes records possible)
To err is human …
• class/instance syntax:
class Eq a => Ord a / instance Eq a => Eq (Maybe a)
class Ord Eq a => a / instance Eq Eq a => Maybe a
thought it would be easier to parse, read and
understand, but really is major annoyance.
• Java comment syntax, package/module
• Underestimation of how important source code
compatibility would be.
Unintended Consequences
• for interoperability and speed: support and use
primitive JVM types, hence
data Bool = pure native boolean
• requires literals
– familiarity concerns suggest true, false
• Haskell users [Confused .. Annoyed]
• Yet can‘t fix this easily without „cheating“ in the
compiler.
Too bad your
compiler doesn’t
know what “True”
and “False” is!
Native Interface (aka FFI)
• not only functions, but also data types
• JVM types appear as abstract data types
– need functions (i.e. JVM methods) too
– (watch out: ADT abbreviates abstract as well as
algebraic data types.)
– primitives, interfaces, classes, arrays
– almost no knowledge about „basic types“ hardwired
in the compiler: it‘s all in the Prelude
• Haskell FFI not fit for JVM, replaced with NI
– code that uses C functions is not portable anyway
Runtime
Runtime
• do as much as possible in the NI
• minimalist
• no dependencies
Runtime Concerns
• provide Java methods where
• synchronized { … }
• try { … } catch … finally { … }
would be needed.
• interfaces and classes for representation of
Frege ADT and functions
• thunks & lazy evaluation
Runtime System Overview (to be changed soon)
interface
Applicable
interface
Value
abstract
Algebraic
abstract
Lambda
abstract
Delayed
function
types
algebraic
data types
interface
Lazy
Created by
applied
functions
Current vs. Upcoming Function Handling
● A FunN
, when applied, creates a
FunN-1
, and Fun1
a Delayed.
● designed to minimize class files,
because it covers partial
applications.
● Create FunN
“function pointers”
for functions as needed.
● Re-use function pointers across
modules.
● Higher order functions do not
care about type/arity of passed
functions.
● no partial application
implemented in Java anymore
● thunks/lazy values are
Callable<X>
● higher order functions expect
functional arguments with exact
arity
● should reduce number of
intermediate instances drastically
● will create less class files in Java
8, more in Java 7
● more type safe calling from Java
into Frege
Example
map (1+) list
map ((+) 1) list
List.map(
plus123.apply(1),
list)
…
Fun2 plus123 = new Fun2() {
public Integer eval(Object a1,
Object a2) {
return Delayed.<Integer>forced(a1) +
Delayed.<Integer>forced(a2); }}
map (1+) list
map (x -> 1+x) list
List.map(
(Func1)(x -> 1 +
Thunk.<Integer>forced(x)),
list)
Encoding of Product Types
data P a b = C a b
data R = Pair { !a, !b :: Int }
final class TP {
final Object m1;
final Object m2;
TP(Object a, Object b) {
m1 = a; m2 = b;
}
}
final class TR {
final int mema, memb;
…
}
Encoding of Sum Types
data S a b = S1 a | S2 b interface TS {
static class DS1 implements TS {
DS1 _S1() { return this; }
DS2 _S2() { return null; }
…
}
static class DS2 implements TS
{ … }
public DS1 _S1();
public DS2 _S2();
}
See the REPL!
● There are no secrets in Frege.
● Just type an example in the REPL and use :java
command!
● Caveat: REPL tells you only how things are today.
● JVM evolution may offer opportunities we cannot
refuse.
○ JVM8: lambdas
○ JVM?: value types
Three classes of values
● Immutable
○ All Frege types and pure native types
○ can be used everywhere
● Mutable only
○ JVM types defined mutable native
○ native functions that use them must be IO actions
● Mutable
○ JVM types defined native
○ can appear in ST actions or pure functions
Marshalling in the NI
● no arguments for static method: () -> ST s R
● nullable arguments of type X:
Maybe X or Maybe (Mutable s X)
● void method: ST s () or IO ()
● let return type be X in Frege
○ mutable? Mutable s X
○ nullable? Maybe (...)
○ exceptions? (Ex1 | Ex2 | …)
○ side effects? ST s (...)
Compiler facts
● multi pass
● pass :: StateT Global IO a
● records information about compiled module in the
form of Java annotations
● creates and compiles Java source code
● concurrent -make option
● IDE friendly
Important Compiler Passes
● Lexer :: String -> [Token]
● Parser :: [Token] -> Maybe [Definition]
● Import
● Name resolution
● Type Check
● Transformations & Optimizations
● Strictness
● generate meta data and code
Background Information
Haskell 2010 Report https://www.haskell.
org/definition/haskell2010.pdf
Implementation of FP-Languages http://research.
microsoft.com/en-
us/um/people/simonpj/papers/slpj-book-1987/slpj-
book-1987.pdf
Calling Frege Code from Java https://github.
com/Frege/frege/wiki/Calling-Frege-Code-from-Java

Contenu connexe

Tendances

Functional Programming in JavaScript & ESNext
Functional Programming in JavaScript & ESNextFunctional Programming in JavaScript & ESNext
Functional Programming in JavaScript & ESNextUnfold UI
 
Integrated Language Definition Testing: Enabling Test-Driven Language Develop...
Integrated Language Definition Testing: Enabling Test-Driven Language Develop...Integrated Language Definition Testing: Enabling Test-Driven Language Develop...
Integrated Language Definition Testing: Enabling Test-Driven Language Develop...lennartkats
 
New c sharp4_features_part_i
New c sharp4_features_part_iNew c sharp4_features_part_i
New c sharp4_features_part_iNico Ludwig
 
Remix Your Language Tooling (JSConf.eu 2012)
Remix Your Language Tooling (JSConf.eu 2012)Remix Your Language Tooling (JSConf.eu 2012)
Remix Your Language Tooling (JSConf.eu 2012)lennartkats
 
07 control+structures
07 control+structures07 control+structures
07 control+structuresbaran19901990
 
Test-driven language development
Test-driven language developmentTest-driven language development
Test-driven language developmentlennartkats
 
Introduction Functional Programming - Tech Hangout #11 - 2013.01.16
Introduction Functional Programming - Tech Hangout #11 - 2013.01.16Introduction Functional Programming - Tech Hangout #11 - 2013.01.16
Introduction Functional Programming - Tech Hangout #11 - 2013.01.16Innovecs
 
Overview of c language
Overview of c languageOverview of c language
Overview of c languageshalini392
 
JDD 2017: Kotlin for Java developers (Tomasz Kleszczyński)
JDD 2017: Kotlin for Java developers (Tomasz Kleszczyński)JDD 2017: Kotlin for Java developers (Tomasz Kleszczyński)
JDD 2017: Kotlin for Java developers (Tomasz Kleszczyński)PROIDEA
 
Polymorphism 140527082302-phpapp01
Polymorphism 140527082302-phpapp01Polymorphism 140527082302-phpapp01
Polymorphism 140527082302-phpapp01Engr.Tazeen Ahmed
 
Developer’s viewpoint on swift programming language
Developer’s viewpoint on swift programming languageDeveloper’s viewpoint on swift programming language
Developer’s viewpoint on swift programming languageAzilen Technologies Pvt. Ltd.
 
Functional programming in TypeScript
Functional programming in TypeScriptFunctional programming in TypeScript
Functional programming in TypeScriptbinDebug WorkSpace
 
Programming Paradigm & Languages
Programming Paradigm & LanguagesProgramming Paradigm & Languages
Programming Paradigm & LanguagesGaditek
 
Language Engineering in the Cloud
Language Engineering in the CloudLanguage Engineering in the Cloud
Language Engineering in the Cloudlennartkats
 
Functional Groovy - Confess
Functional Groovy - ConfessFunctional Groovy - Confess
Functional Groovy - ConfessAndres Almiray
 

Tendances (20)

Functional Programming in JavaScript & ESNext
Functional Programming in JavaScript & ESNextFunctional Programming in JavaScript & ESNext
Functional Programming in JavaScript & ESNext
 
Integrated Language Definition Testing: Enabling Test-Driven Language Develop...
Integrated Language Definition Testing: Enabling Test-Driven Language Develop...Integrated Language Definition Testing: Enabling Test-Driven Language Develop...
Integrated Language Definition Testing: Enabling Test-Driven Language Develop...
 
New c sharp4_features_part_i
New c sharp4_features_part_iNew c sharp4_features_part_i
New c sharp4_features_part_i
 
Remix Your Language Tooling (JSConf.eu 2012)
Remix Your Language Tooling (JSConf.eu 2012)Remix Your Language Tooling (JSConf.eu 2012)
Remix Your Language Tooling (JSConf.eu 2012)
 
07 control+structures
07 control+structures07 control+structures
07 control+structures
 
Test-driven language development
Test-driven language developmentTest-driven language development
Test-driven language development
 
2nd presantation
2nd presantation2nd presantation
2nd presantation
 
Introduction Functional Programming - Tech Hangout #11 - 2013.01.16
Introduction Functional Programming - Tech Hangout #11 - 2013.01.16Introduction Functional Programming - Tech Hangout #11 - 2013.01.16
Introduction Functional Programming - Tech Hangout #11 - 2013.01.16
 
Introductory func prog
Introductory func progIntroductory func prog
Introductory func prog
 
Overview of c language
Overview of c languageOverview of c language
Overview of c language
 
JDD 2017: Kotlin for Java developers (Tomasz Kleszczyński)
JDD 2017: Kotlin for Java developers (Tomasz Kleszczyński)JDD 2017: Kotlin for Java developers (Tomasz Kleszczyński)
JDD 2017: Kotlin for Java developers (Tomasz Kleszczyński)
 
Ruby
RubyRuby
Ruby
 
Polymorphism 140527082302-phpapp01
Polymorphism 140527082302-phpapp01Polymorphism 140527082302-phpapp01
Polymorphism 140527082302-phpapp01
 
phases of compiler
phases of compilerphases of compiler
phases of compiler
 
C# in depth
C# in depthC# in depth
C# in depth
 
Developer’s viewpoint on swift programming language
Developer’s viewpoint on swift programming languageDeveloper’s viewpoint on swift programming language
Developer’s viewpoint on swift programming language
 
Functional programming in TypeScript
Functional programming in TypeScriptFunctional programming in TypeScript
Functional programming in TypeScript
 
Programming Paradigm & Languages
Programming Paradigm & LanguagesProgramming Paradigm & Languages
Programming Paradigm & Languages
 
Language Engineering in the Cloud
Language Engineering in the CloudLanguage Engineering in the Cloud
Language Engineering in the Cloud
 
Functional Groovy - Confess
Functional Groovy - ConfessFunctional Groovy - Confess
Functional Groovy - Confess
 

En vedette

Frege Tutorial at JavaOne 2015
Frege Tutorial at JavaOne 2015Frege Tutorial at JavaOne 2015
Frege Tutorial at JavaOne 2015Dierk König
 
FregeFX - JavaFX with Frege, a Haskell for the JVM
FregeFX - JavaFX with Frege, a Haskell for the JVMFregeFX - JavaFX with Frege, a Haskell for the JVM
FregeFX - JavaFX with Frege, a Haskell for the JVMDierk König
 
Software Transactional Memory (STM) in Frege
Software Transactional Memory (STM) in Frege Software Transactional Memory (STM) in Frege
Software Transactional Memory (STM) in Frege Dierk König
 
Frege - consequently functional programming for the JVM
Frege - consequently functional programming for the JVMFrege - consequently functional programming for the JVM
Frege - consequently functional programming for the JVMDierk König
 
Quick into to Software Transactional Memory in Frege
Quick into to Software Transactional Memory in FregeQuick into to Software Transactional Memory in Frege
Quick into to Software Transactional Memory in FregeDierk König
 
Os Keysholistic
Os KeysholisticOs Keysholistic
Os Keysholisticoscon2007
 
Os Ellistutorial
Os EllistutorialOs Ellistutorial
Os Ellistutorialoscon2007
 
FregeDay: Parallelism in Frege compared to GHC Haskell (Volker Steiss)
FregeDay: Parallelism in Frege compared to GHC Haskell (Volker Steiss) FregeDay: Parallelism in Frege compared to GHC Haskell (Volker Steiss)
FregeDay: Parallelism in Frege compared to GHC Haskell (Volker Steiss) Dierk König
 
J Ruby Whirlwind Tour
J Ruby Whirlwind TourJ Ruby Whirlwind Tour
J Ruby Whirlwind Touroscon2007
 
Os Keyshacks
Os KeyshacksOs Keyshacks
Os Keyshacksoscon2007
 
Solr Presentation5
Solr Presentation5Solr Presentation5
Solr Presentation5oscon2007
 
Os Peytonjones
Os PeytonjonesOs Peytonjones
Os Peytonjonesoscon2007
 
OCaml Labs introduction at OCaml Consortium 2012
OCaml Labs introduction at OCaml Consortium 2012OCaml Labs introduction at OCaml Consortium 2012
OCaml Labs introduction at OCaml Consortium 2012Anil Madhavapeddy
 
From object oriented to functional domain modeling
From object oriented to functional domain modelingFrom object oriented to functional domain modeling
From object oriented to functional domain modelingMario Fusco
 

En vedette (17)

Frege Tutorial at JavaOne 2015
Frege Tutorial at JavaOne 2015Frege Tutorial at JavaOne 2015
Frege Tutorial at JavaOne 2015
 
FregeFX - JavaFX with Frege, a Haskell for the JVM
FregeFX - JavaFX with Frege, a Haskell for the JVMFregeFX - JavaFX with Frege, a Haskell for the JVM
FregeFX - JavaFX with Frege, a Haskell for the JVM
 
Software Transactional Memory (STM) in Frege
Software Transactional Memory (STM) in Frege Software Transactional Memory (STM) in Frege
Software Transactional Memory (STM) in Frege
 
Frege - consequently functional programming for the JVM
Frege - consequently functional programming for the JVMFrege - consequently functional programming for the JVM
Frege - consequently functional programming for the JVM
 
Quick into to Software Transactional Memory in Frege
Quick into to Software Transactional Memory in FregeQuick into to Software Transactional Memory in Frege
Quick into to Software Transactional Memory in Frege
 
Os Napier
Os NapierOs Napier
Os Napier
 
Os Keysholistic
Os KeysholisticOs Keysholistic
Os Keysholistic
 
Os Ellistutorial
Os EllistutorialOs Ellistutorial
Os Ellistutorial
 
FregeDay: Parallelism in Frege compared to GHC Haskell (Volker Steiss)
FregeDay: Parallelism in Frege compared to GHC Haskell (Volker Steiss) FregeDay: Parallelism in Frege compared to GHC Haskell (Volker Steiss)
FregeDay: Parallelism in Frege compared to GHC Haskell (Volker Steiss)
 
J Ruby Whirlwind Tour
J Ruby Whirlwind TourJ Ruby Whirlwind Tour
J Ruby Whirlwind Tour
 
Os Keyshacks
Os KeyshacksOs Keyshacks
Os Keyshacks
 
Os Harkins
Os HarkinsOs Harkins
Os Harkins
 
Solr Presentation5
Solr Presentation5Solr Presentation5
Solr Presentation5
 
Os Raysmith
Os RaysmithOs Raysmith
Os Raysmith
 
Os Peytonjones
Os PeytonjonesOs Peytonjones
Os Peytonjones
 
OCaml Labs introduction at OCaml Consortium 2012
OCaml Labs introduction at OCaml Consortium 2012OCaml Labs introduction at OCaml Consortium 2012
OCaml Labs introduction at OCaml Consortium 2012
 
From object oriented to functional domain modeling
From object oriented to functional domain modelingFrom object oriented to functional domain modeling
From object oriented to functional domain modeling
 

Similaire à Frege: Design & Implementation Overview

New c sharp3_features_(linq)_part_ii
New c sharp3_features_(linq)_part_iiNew c sharp3_features_(linq)_part_ii
New c sharp3_features_(linq)_part_iiNico Ludwig
 
New c sharp4_features_part_vi
New c sharp4_features_part_viNew c sharp4_features_part_vi
New c sharp4_features_part_viNico Ludwig
 
Exciting JavaScript - Part II
Exciting JavaScript - Part IIExciting JavaScript - Part II
Exciting JavaScript - Part IIEugene Lazutkin
 
Dart the Better JavaScript
Dart the Better JavaScriptDart the Better JavaScript
Dart the Better JavaScriptJorg Janke
 
Scalable Data Science with SparkR: Spark Summit East talk by Felix Cheung
Scalable Data Science with SparkR: Spark Summit East talk by Felix CheungScalable Data Science with SparkR: Spark Summit East talk by Felix Cheung
Scalable Data Science with SparkR: Spark Summit East talk by Felix CheungSpark Summit
 
Lambda Expressions Java 8 Features usage
Lambda Expressions  Java 8 Features usageLambda Expressions  Java 8 Features usage
Lambda Expressions Java 8 Features usageAsmaShaikh478737
 
Functional Programming In Jdk8
Functional Programming In Jdk8 Functional Programming In Jdk8
Functional Programming In Jdk8 Bansilal Haudakari
 
Basic info on java intro
Basic info on java introBasic info on java intro
Basic info on java introkabirmahlotra
 
Basic info on java intro
Basic info on java introBasic info on java intro
Basic info on java introkabirmahlotra
 
Beginning Java for .NET developers
Beginning Java for .NET developersBeginning Java for .NET developers
Beginning Java for .NET developersAndrei Rinea
 
The Rise of Functional Programming
The Rise of Functional ProgrammingThe Rise of Functional Programming
The Rise of Functional ProgrammingTjerk Wolterink
 
Got bored by the relational database? Switch to a RDF store!
Got bored by the relational database? Switch to a RDF store!Got bored by the relational database? Switch to a RDF store!
Got bored by the relational database? Switch to a RDF store!benfante
 
Functional programming in Scala
Functional programming in ScalaFunctional programming in Scala
Functional programming in Scaladatamantra
 
Java Closures
Java ClosuresJava Closures
Java ClosuresBen Evans
 
New c sharp4_features_part_iv
New c sharp4_features_part_ivNew c sharp4_features_part_iv
New c sharp4_features_part_ivNico Ludwig
 
The Evolution of Scala
The Evolution of ScalaThe Evolution of Scala
The Evolution of ScalaMartin Odersky
 
Spark - The Ultimate Scala Collections by Martin Odersky
Spark - The Ultimate Scala Collections by Martin OderskySpark - The Ultimate Scala Collections by Martin Odersky
Spark - The Ultimate Scala Collections by Martin OderskySpark Summit
 
The Scheme Language -- Using it on the iPhone
The Scheme Language -- Using it on the iPhoneThe Scheme Language -- Using it on the iPhone
The Scheme Language -- Using it on the iPhoneJames Long
 
An Introduction to Scala - Blending OO and Functional Paradigms
An Introduction to Scala - Blending OO and Functional ParadigmsAn Introduction to Scala - Blending OO and Functional Paradigms
An Introduction to Scala - Blending OO and Functional ParadigmsMiles Sabin
 
JNA - Let's C what it's worth
JNA - Let's C what it's worthJNA - Let's C what it's worth
JNA - Let's C what it's worthIdan Sheinberg
 

Similaire à Frege: Design & Implementation Overview (20)

New c sharp3_features_(linq)_part_ii
New c sharp3_features_(linq)_part_iiNew c sharp3_features_(linq)_part_ii
New c sharp3_features_(linq)_part_ii
 
New c sharp4_features_part_vi
New c sharp4_features_part_viNew c sharp4_features_part_vi
New c sharp4_features_part_vi
 
Exciting JavaScript - Part II
Exciting JavaScript - Part IIExciting JavaScript - Part II
Exciting JavaScript - Part II
 
Dart the Better JavaScript
Dart the Better JavaScriptDart the Better JavaScript
Dart the Better JavaScript
 
Scalable Data Science with SparkR: Spark Summit East talk by Felix Cheung
Scalable Data Science with SparkR: Spark Summit East talk by Felix CheungScalable Data Science with SparkR: Spark Summit East talk by Felix Cheung
Scalable Data Science with SparkR: Spark Summit East talk by Felix Cheung
 
Lambda Expressions Java 8 Features usage
Lambda Expressions  Java 8 Features usageLambda Expressions  Java 8 Features usage
Lambda Expressions Java 8 Features usage
 
Functional Programming In Jdk8
Functional Programming In Jdk8 Functional Programming In Jdk8
Functional Programming In Jdk8
 
Basic info on java intro
Basic info on java introBasic info on java intro
Basic info on java intro
 
Basic info on java intro
Basic info on java introBasic info on java intro
Basic info on java intro
 
Beginning Java for .NET developers
Beginning Java for .NET developersBeginning Java for .NET developers
Beginning Java for .NET developers
 
The Rise of Functional Programming
The Rise of Functional ProgrammingThe Rise of Functional Programming
The Rise of Functional Programming
 
Got bored by the relational database? Switch to a RDF store!
Got bored by the relational database? Switch to a RDF store!Got bored by the relational database? Switch to a RDF store!
Got bored by the relational database? Switch to a RDF store!
 
Functional programming in Scala
Functional programming in ScalaFunctional programming in Scala
Functional programming in Scala
 
Java Closures
Java ClosuresJava Closures
Java Closures
 
New c sharp4_features_part_iv
New c sharp4_features_part_ivNew c sharp4_features_part_iv
New c sharp4_features_part_iv
 
The Evolution of Scala
The Evolution of ScalaThe Evolution of Scala
The Evolution of Scala
 
Spark - The Ultimate Scala Collections by Martin Odersky
Spark - The Ultimate Scala Collections by Martin OderskySpark - The Ultimate Scala Collections by Martin Odersky
Spark - The Ultimate Scala Collections by Martin Odersky
 
The Scheme Language -- Using it on the iPhone
The Scheme Language -- Using it on the iPhoneThe Scheme Language -- Using it on the iPhone
The Scheme Language -- Using it on the iPhone
 
An Introduction to Scala - Blending OO and Functional Paradigms
An Introduction to Scala - Blending OO and Functional ParadigmsAn Introduction to Scala - Blending OO and Functional Paradigms
An Introduction to Scala - Blending OO and Functional Paradigms
 
JNA - Let's C what it's worth
JNA - Let's C what it's worthJNA - Let's C what it's worth
JNA - Let's C what it's worth
 

Dernier

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 

Dernier (20)

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 

Frege: Design & Implementation Overview

  • 1. Frege: Design & Implementation A short Overview Ingo Wechsung IT Consultant, contexo GmbH Reutlingen, Germany
  • 2. Topics • History • Language Design • Runtime • Compiler Architecture
  • 3. History • Frege1 • Frege2 • Frege3 see http://www.infoq.com/news/2015/08/frege-haskell-for-jvm
  • 4. Design Goals • pure functional, statically typed, non-strict – essentially Haskell 2010 – plus higher ranked types – more GHC features to be implemented on top • easy integration in JVM ecosystem – a practical JVM language – a (more funny) way to write (better) Java code – be as familiar as possible for JVM programmers
  • 5. Reminder: Haskell means Laziness … not now, please! I can do that later ….
  • 6. Principles for Design Decisions • when in doubt, do it like Haskell 2010 – unless it makes no sense in JVM • module system, FFI, exceptions, C-ish/POSIX-ish APIs – unless outdated (Functor/Applicative/Monad) – maybe a bit simpler in certain cases – subsetting (e.g. standard/prelude libraries) • add nice JVM stuff – regexes out of the box – long, java.lang.String – types as name spaces (makes records possible)
  • 7. To err is human … • class/instance syntax: class Eq a => Ord a / instance Eq a => Eq (Maybe a) class Ord Eq a => a / instance Eq Eq a => Maybe a thought it would be easier to parse, read and understand, but really is major annoyance. • Java comment syntax, package/module • Underestimation of how important source code compatibility would be.
  • 8. Unintended Consequences • for interoperability and speed: support and use primitive JVM types, hence data Bool = pure native boolean • requires literals – familiarity concerns suggest true, false • Haskell users [Confused .. Annoyed] • Yet can‘t fix this easily without „cheating“ in the compiler.
  • 9. Too bad your compiler doesn’t know what “True” and “False” is!
  • 10. Native Interface (aka FFI) • not only functions, but also data types • JVM types appear as abstract data types – need functions (i.e. JVM methods) too – (watch out: ADT abbreviates abstract as well as algebraic data types.) – primitives, interfaces, classes, arrays – almost no knowledge about „basic types“ hardwired in the compiler: it‘s all in the Prelude • Haskell FFI not fit for JVM, replaced with NI – code that uses C functions is not portable anyway
  • 12. Runtime • do as much as possible in the NI • minimalist • no dependencies
  • 13. Runtime Concerns • provide Java methods where • synchronized { … } • try { … } catch … finally { … } would be needed. • interfaces and classes for representation of Frege ADT and functions • thunks & lazy evaluation
  • 14. Runtime System Overview (to be changed soon) interface Applicable interface Value abstract Algebraic abstract Lambda abstract Delayed function types algebraic data types interface Lazy Created by applied functions
  • 15. Current vs. Upcoming Function Handling ● A FunN , when applied, creates a FunN-1 , and Fun1 a Delayed. ● designed to minimize class files, because it covers partial applications. ● Create FunN “function pointers” for functions as needed. ● Re-use function pointers across modules. ● Higher order functions do not care about type/arity of passed functions. ● no partial application implemented in Java anymore ● thunks/lazy values are Callable<X> ● higher order functions expect functional arguments with exact arity ● should reduce number of intermediate instances drastically ● will create less class files in Java 8, more in Java 7 ● more type safe calling from Java into Frege
  • 16. Example map (1+) list map ((+) 1) list List.map( plus123.apply(1), list) … Fun2 plus123 = new Fun2() { public Integer eval(Object a1, Object a2) { return Delayed.<Integer>forced(a1) + Delayed.<Integer>forced(a2); }} map (1+) list map (x -> 1+x) list List.map( (Func1)(x -> 1 + Thunk.<Integer>forced(x)), list)
  • 17. Encoding of Product Types data P a b = C a b data R = Pair { !a, !b :: Int } final class TP { final Object m1; final Object m2; TP(Object a, Object b) { m1 = a; m2 = b; } } final class TR { final int mema, memb; … }
  • 18. Encoding of Sum Types data S a b = S1 a | S2 b interface TS { static class DS1 implements TS { DS1 _S1() { return this; } DS2 _S2() { return null; } … } static class DS2 implements TS { … } public DS1 _S1(); public DS2 _S2(); }
  • 19. See the REPL! ● There are no secrets in Frege. ● Just type an example in the REPL and use :java command! ● Caveat: REPL tells you only how things are today. ● JVM evolution may offer opportunities we cannot refuse. ○ JVM8: lambdas ○ JVM?: value types
  • 20. Three classes of values ● Immutable ○ All Frege types and pure native types ○ can be used everywhere ● Mutable only ○ JVM types defined mutable native ○ native functions that use them must be IO actions ● Mutable ○ JVM types defined native ○ can appear in ST actions or pure functions
  • 21. Marshalling in the NI ● no arguments for static method: () -> ST s R ● nullable arguments of type X: Maybe X or Maybe (Mutable s X) ● void method: ST s () or IO () ● let return type be X in Frege ○ mutable? Mutable s X ○ nullable? Maybe (...) ○ exceptions? (Ex1 | Ex2 | …) ○ side effects? ST s (...)
  • 22. Compiler facts ● multi pass ● pass :: StateT Global IO a ● records information about compiled module in the form of Java annotations ● creates and compiles Java source code ● concurrent -make option ● IDE friendly
  • 23. Important Compiler Passes ● Lexer :: String -> [Token] ● Parser :: [Token] -> Maybe [Definition] ● Import ● Name resolution ● Type Check ● Transformations & Optimizations ● Strictness ● generate meta data and code
  • 24. Background Information Haskell 2010 Report https://www.haskell. org/definition/haskell2010.pdf Implementation of FP-Languages http://research. microsoft.com/en- us/um/people/simonpj/papers/slpj-book-1987/slpj- book-1987.pdf Calling Frege Code from Java https://github. com/Frege/frege/wiki/Calling-Frege-Code-from-Java