SlideShare una empresa de Scribd logo
1 de 15
Martin Skarsaune
Developer and Co-Owner
高
馬
丁
Small Lambda Talk
Small lambda talk
• Java 8 introduced lambda expressions
• focus on functional programming
• Also roots in object oriented programming: Smalltalk
Smalltalk – everything is simple
• Illustration, reserved words:
• self (=this), super, nil (=null), true, false
Java reserved words ….
abstract default goto package synchronized
assert do if private this
boolean double implements protected throw
break else import public throws
byte enum instanceof return transient
case extends int short true
catch false interface static try
char final long strictfp void
class finally native super volatile
const float new switch while
continue for null
Ingredient 1: Everything is an object!
• No primitive types
• nil is an object
• No void methods
Ingredient 2: Messages do everything!
• Three types of messages
• Unary
• Binary
• Keyword
Messages - unary
• No arguments
• Invocation example:
• Implementation in class Number:
2 negated
negated
^0 - self
public Number negated() {
return 0 - this;
}
2.negated()
Equivalent “Java” Syntax
Messages - binary
• Exactly one argument
• Message selector (method name) made from special
characters: = , + , - , > etc.
• Invocation
• Implementation in class Object:
a = b
= anObject
^self == anObject
public boolean equals(Object obj){
return this == obj;
}
a.equals(b)
Equivalent “Java” Syntax
Messages - keyword
• One or more arguments
• Each argument is separated by a keyword
• Invocation:
• Implementation:
a at: 1 put: ‘one’
at: key put: value
self cache
at: key put: value
public Object put(Integer key, String value){
this.cache()
.put(key,value);
return this;
}
a.put(1, “one”);
Equivalent “Java” Syntax
OO Conditional Processing
Boolean
True
true
False
false
true false
OO Conditional Processing Example
• Task:
• Use recursion to return root of
tree
• Each node may access its
parent by sending the parent
message
OO branching- blocks
root
^self parent = nil
ifTrue: [self]
ifFalse: [self parent root]
ifTrue: trueBlock ifFalse:
falseBlock
^trueBlock value
ifTrue: trueBlock
ifFalse: falseBlock
^falseBlock value
Implementation in True: Implementation in False:
OO branching- characteristics
• Voilla! We have made if else with only objects and
messages
• Boolean instance is an object
• Code blocks are objects
• Implemented as one message, one expression, one return
value.
root
^self parent = nil
ifTrue: [self]
ifFalse: [self parent root]
More OO conditional logic
and: block
^block value
True implementation:
boolExpr1 and: [boolExpr2].
boolExpr1 or: [boolExpr2].
boolExpr not
and: block
^self
False implementation:
or: block
^self
or: block
^block value
not
^false
not
^true
boolExpr1 && boolExpr2;
boolExpr1 || boolExpr2;
!boolExpr;
Learning points
• Anything may be expressed using objects, messages
and lambdas:
• Branches, loops, exception handling ….
• Common language features may be implemented with
lambdas
• Source code acts as documentation
• Possible to debug
• Many ways to arrange program flow
• Polymorphy
• Behavioural design patterns
Workshop 13:3
0 Room #2
Thank you for your time!
response
^self satisfied
ifTrue: [self clap]
ifFalse: [self boo]

Más contenido relacionado

La actualidad más candente

Object oriented java script
Object oriented java scriptObject oriented java script
Object oriented java scriptvivek p s
 
Oslo.versioned objects - Deep Dive
Oslo.versioned objects - Deep DiveOslo.versioned objects - Deep Dive
Oslo.versioned objects - Deep Divedavanum
 
Lambda Expressions in Java 8
Lambda Expressions in Java 8Lambda Expressions in Java 8
Lambda Expressions in Java 8icarter09
 
Shapeless- Generic programming for Scala
Shapeless- Generic programming for ScalaShapeless- Generic programming for Scala
Shapeless- Generic programming for ScalaKnoldus Inc.
 
Strings in Java
Strings in Java Strings in Java
Strings in Java Hitesh-Java
 
A quick and fast intro to Kotlin
A quick and fast intro to Kotlin A quick and fast intro to Kotlin
A quick and fast intro to Kotlin XPeppers
 
Model with actors and implement with Akka
Model with actors and implement with AkkaModel with actors and implement with Akka
Model with actors and implement with AkkaNgoc Dao
 
Actors and Threads
Actors and ThreadsActors and Threads
Actors and Threadsmperham
 
Kotlin presentation
Kotlin presentation Kotlin presentation
Kotlin presentation MobileAcademy
 
002. Introducere in type script
002. Introducere in type script002. Introducere in type script
002. Introducere in type scriptDmitrii Stoian
 
Thinking Like a Programmer
Thinking Like a ProgrammerThinking Like a Programmer
Thinking Like a ProgrammerCate Huston
 
Getting started with typescript and angular 2
Getting started with typescript  and angular 2Getting started with typescript  and angular 2
Getting started with typescript and angular 2Knoldus Inc.
 
JavaScript Beyond jQuery
JavaScript Beyond jQueryJavaScript Beyond jQuery
JavaScript Beyond jQueryBobby Bryant
 
Basic Javascript
Basic JavascriptBasic Javascript
Basic JavascriptBunlong Van
 
Javascript basic course
Javascript basic courseJavascript basic course
Javascript basic courseTran Khoa
 
Power of introspection
Power of introspectionPower of introspection
Power of introspectionJoseph Jeffrey
 

La actualidad más candente (20)

Object oriented java script
Object oriented java scriptObject oriented java script
Object oriented java script
 
Metaprogramming ruby
Metaprogramming rubyMetaprogramming ruby
Metaprogramming ruby
 
Typescript
TypescriptTypescript
Typescript
 
About Python
About PythonAbout Python
About Python
 
Oslo.versioned objects - Deep Dive
Oslo.versioned objects - Deep DiveOslo.versioned objects - Deep Dive
Oslo.versioned objects - Deep Dive
 
Lambda Expressions in Java 8
Lambda Expressions in Java 8Lambda Expressions in Java 8
Lambda Expressions in Java 8
 
Shapeless- Generic programming for Scala
Shapeless- Generic programming for ScalaShapeless- Generic programming for Scala
Shapeless- Generic programming for Scala
 
Strings in Java
Strings in Java Strings in Java
Strings in Java
 
A quick and fast intro to Kotlin
A quick and fast intro to Kotlin A quick and fast intro to Kotlin
A quick and fast intro to Kotlin
 
Model with actors and implement with Akka
Model with actors and implement with AkkaModel with actors and implement with Akka
Model with actors and implement with Akka
 
Actors and Threads
Actors and ThreadsActors and Threads
Actors and Threads
 
Kotlin presentation
Kotlin presentation Kotlin presentation
Kotlin presentation
 
002. Introducere in type script
002. Introducere in type script002. Introducere in type script
002. Introducere in type script
 
Thinking Like a Programmer
Thinking Like a ProgrammerThinking Like a Programmer
Thinking Like a Programmer
 
Getting started with typescript and angular 2
Getting started with typescript  and angular 2Getting started with typescript  and angular 2
Getting started with typescript and angular 2
 
Coding in kotlin
Coding in kotlinCoding in kotlin
Coding in kotlin
 
JavaScript Beyond jQuery
JavaScript Beyond jQueryJavaScript Beyond jQuery
JavaScript Beyond jQuery
 
Basic Javascript
Basic JavascriptBasic Javascript
Basic Javascript
 
Javascript basic course
Javascript basic courseJavascript basic course
Javascript basic course
 
Power of introspection
Power of introspectionPower of introspection
Power of introspection
 

Destacado

Puasa dan pembentukan disiplin pribadi
Puasa dan pembentukan disiplin pribadiPuasa dan pembentukan disiplin pribadi
Puasa dan pembentukan disiplin pribadiEko Nugroho
 
Race and culture identities
Race and culture identitiesRace and culture identities
Race and culture identitieslbvargas87
 
2014 conference program
2014 conference program2014 conference program
2014 conference programLia Simpson
 
HAPTIC TECHNOLOGY
HAPTIC TECHNOLOGY HAPTIC TECHNOLOGY
HAPTIC TECHNOLOGY Anusha2027
 
Business-Investment scam
Business-Investment scamBusiness-Investment scam
Business-Investment scamMao Hua
 
Increasing Monetization Activities Exploiting LTE Patents
Increasing Monetization Activities Exploiting LTE PatentsIncreasing Monetization Activities Exploiting LTE Patents
Increasing Monetization Activities Exploiting LTE PatentsAlex G. Lee, Ph.D. Esq. CLP
 
RADTEC96_final_Corr
RADTEC96_final_CorrRADTEC96_final_Corr
RADTEC96_final_CorrPatrick Yang
 
TP - Condilomas jennifer y victoria
TP - Condilomas jennifer y victoriaTP - Condilomas jennifer y victoria
TP - Condilomas jennifer y victoriaStella Maris Kuda
 
derechos de autor - andres felipe bolivar
derechos de autor - andres felipe bolivarderechos de autor - andres felipe bolivar
derechos de autor - andres felipe bolivarandres bolivar
 

Destacado (15)

PCL
PCLPCL
PCL
 
Puasa dan pembentukan disiplin pribadi
Puasa dan pembentukan disiplin pribadiPuasa dan pembentukan disiplin pribadi
Puasa dan pembentukan disiplin pribadi
 
Race and culture identities
Race and culture identitiesRace and culture identities
Race and culture identities
 
Amistad
AmistadAmistad
Amistad
 
2014 conference program
2014 conference program2014 conference program
2014 conference program
 
HAPTIC TECHNOLOGY
HAPTIC TECHNOLOGY HAPTIC TECHNOLOGY
HAPTIC TECHNOLOGY
 
Business-Investment scam
Business-Investment scamBusiness-Investment scam
Business-Investment scam
 
Increasing Monetization Activities Exploiting LTE Patents
Increasing Monetization Activities Exploiting LTE PatentsIncreasing Monetization Activities Exploiting LTE Patents
Increasing Monetization Activities Exploiting LTE Patents
 
RADTEC96_final_Corr
RADTEC96_final_CorrRADTEC96_final_Corr
RADTEC96_final_Corr
 
TP - Condilomas jennifer y victoria
TP - Condilomas jennifer y victoriaTP - Condilomas jennifer y victoria
TP - Condilomas jennifer y victoria
 
Unit 1 Motivation
Unit 1 MotivationUnit 1 Motivation
Unit 1 Motivation
 
Hotel gyms app
Hotel gyms appHotel gyms app
Hotel gyms app
 
derechos de autor - andres felipe bolivar
derechos de autor - andres felipe bolivarderechos de autor - andres felipe bolivar
derechos de autor - andres felipe bolivar
 
model1911ad
model1911admodel1911ad
model1911ad
 
5101409018
51014090185101409018
5101409018
 

Similar a Small Lambda Talk @Booster2015

Scala, Play 2.0 & Cloud Foundry
Scala, Play 2.0 & Cloud FoundryScala, Play 2.0 & Cloud Foundry
Scala, Play 2.0 & Cloud FoundryPray Desai
 
Никита Корчагин - Programming Apple iOS with Objective-C
Никита Корчагин - Programming Apple iOS with Objective-CНикита Корчагин - Programming Apple iOS with Objective-C
Никита Корчагин - Programming Apple iOS with Objective-CDataArt
 
Metaprogramming Primer (Part 1)
Metaprogramming Primer (Part 1)Metaprogramming Primer (Part 1)
Metaprogramming Primer (Part 1)Christopher Haupt
 
Static or Dynamic Typing? Why not both?
Static or Dynamic Typing? Why not both?Static or Dynamic Typing? Why not both?
Static or Dynamic Typing? Why not both?Mario Camou Riveroll
 
Java Closures
Java ClosuresJava Closures
Java ClosuresBen Evans
 
First fare 2011 frc-java-introduction
First fare 2011 frc-java-introductionFirst fare 2011 frc-java-introduction
First fare 2011 frc-java-introductionOregon FIRST Robotics
 
Exciting JavaScript - Part I
Exciting JavaScript - Part IExciting JavaScript - Part I
Exciting JavaScript - Part IEugene Lazutkin
 
L9 wrapper classes
L9 wrapper classesL9 wrapper classes
L9 wrapper classesteach4uin
 
Ruby :: Training 1
Ruby :: Training 1Ruby :: Training 1
Ruby :: Training 1Pavel Tyk
 
Slot Composition
Slot CompositionSlot Composition
Slot CompositionESUG
 
Why Java is not a purely object oriented language?
Why Java is not a purely object oriented language?Why Java is not a purely object oriented language?
Why Java is not a purely object oriented language?NexSoftsys
 
Introduction to Kotlin Language and its application to Android platform
Introduction to Kotlin Language and its application to Android platformIntroduction to Kotlin Language and its application to Android platform
Introduction to Kotlin Language and its application to Android platformEastBanc Tachnologies
 
Code Like Pythonista
Code Like PythonistaCode Like Pythonista
Code Like PythonistaChiyoung Song
 
Object Oriented Programming Tutorial.pptx
Object Oriented Programming Tutorial.pptxObject Oriented Programming Tutorial.pptx
Object Oriented Programming Tutorial.pptxethiouniverse
 

Similar a Small Lambda Talk @Booster2015 (20)

Ruby basics
Ruby basicsRuby basics
Ruby basics
 
Scala, Play 2.0 & Cloud Foundry
Scala, Play 2.0 & Cloud FoundryScala, Play 2.0 & Cloud Foundry
Scala, Play 2.0 & Cloud Foundry
 
Javascript
JavascriptJavascript
Javascript
 
Никита Корчагин - Programming Apple iOS with Objective-C
Никита Корчагин - Programming Apple iOS with Objective-CНикита Корчагин - Programming Apple iOS with Objective-C
Никита Корчагин - Programming Apple iOS with Objective-C
 
Java tutorial part 3
Java tutorial part 3Java tutorial part 3
Java tutorial part 3
 
Metaprogramming Primer (Part 1)
Metaprogramming Primer (Part 1)Metaprogramming Primer (Part 1)
Metaprogramming Primer (Part 1)
 
Static or Dynamic Typing? Why not both?
Static or Dynamic Typing? Why not both?Static or Dynamic Typing? Why not both?
Static or Dynamic Typing? Why not both?
 
Java Closures
Java ClosuresJava Closures
Java Closures
 
First fare 2011 frc-java-introduction
First fare 2011 frc-java-introductionFirst fare 2011 frc-java-introduction
First fare 2011 frc-java-introduction
 
Exciting JavaScript - Part I
Exciting JavaScript - Part IExciting JavaScript - Part I
Exciting JavaScript - Part I
 
L9 wrapper classes
L9 wrapper classesL9 wrapper classes
L9 wrapper classes
 
Intermediate JavaScript
Intermediate JavaScriptIntermediate JavaScript
Intermediate JavaScript
 
Ruby :: Training 1
Ruby :: Training 1Ruby :: Training 1
Ruby :: Training 1
 
Slot Composition
Slot CompositionSlot Composition
Slot Composition
 
Slot Composition
Slot CompositionSlot Composition
Slot Composition
 
ppt_on_java.pptx
ppt_on_java.pptxppt_on_java.pptx
ppt_on_java.pptx
 
Why Java is not a purely object oriented language?
Why Java is not a purely object oriented language?Why Java is not a purely object oriented language?
Why Java is not a purely object oriented language?
 
Introduction to Kotlin Language and its application to Android platform
Introduction to Kotlin Language and its application to Android platformIntroduction to Kotlin Language and its application to Android platform
Introduction to Kotlin Language and its application to Android platform
 
Code Like Pythonista
Code Like PythonistaCode Like Pythonista
Code Like Pythonista
 
Object Oriented Programming Tutorial.pptx
Object Oriented Programming Tutorial.pptxObject Oriented Programming Tutorial.pptx
Object Oriented Programming Tutorial.pptx
 

Más de Martin (高馬丁) Skarsaune (11)

jmc-devoxx.pptx
jmc-devoxx.pptxjmc-devoxx.pptx
jmc-devoxx.pptx
 
Flight recordings and mission control through thick clouds
Flight recordings and mission control through thick cloudsFlight recordings and mission control through thick clouds
Flight recordings and mission control through thick clouds
 
Cloud Collaboration with Eclipse Che
Cloud Collaboration with Eclipse CheCloud Collaboration with Eclipse Che
Cloud Collaboration with Eclipse Che
 
CodeOne Java Debugging Tips
CodeOne Java Debugging TipsCodeOne Java Debugging Tips
CodeOne Java Debugging Tips
 
Java Debugging Tips @oredev
Java Debugging Tips @oredevJava Debugging Tips @oredev
Java Debugging Tips @oredev
 
goto java; (Jfokus)
goto java; (Jfokus)goto java; (Jfokus)
goto java; (Jfokus)
 
Tricks
TricksTricks
Tricks
 
Goto devoxx
Goto devoxxGoto devoxx
Goto devoxx
 
Bring your calculations to Scala!
Bring your calculations to Scala!Bring your calculations to Scala!
Bring your calculations to Scala!
 
JavaZone 2014 - goto java;
JavaZone 2014 - goto java;JavaZone 2014 - goto java;
JavaZone 2014 - goto java;
 
JavaZone 2014 - Iteration 2.0: Stream
JavaZone 2014 - Iteration 2.0: StreamJavaZone 2014 - Iteration 2.0: Stream
JavaZone 2014 - Iteration 2.0: Stream
 

Último

Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 

Último (20)

Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 

Small Lambda Talk @Booster2015

  • 1. Martin Skarsaune Developer and Co-Owner 高 馬 丁 Small Lambda Talk
  • 2. Small lambda talk • Java 8 introduced lambda expressions • focus on functional programming • Also roots in object oriented programming: Smalltalk
  • 3. Smalltalk – everything is simple • Illustration, reserved words: • self (=this), super, nil (=null), true, false Java reserved words …. abstract default goto package synchronized assert do if private this boolean double implements protected throw break else import public throws byte enum instanceof return transient case extends int short true catch false interface static try char final long strictfp void class finally native super volatile const float new switch while continue for null
  • 4. Ingredient 1: Everything is an object! • No primitive types • nil is an object • No void methods
  • 5. Ingredient 2: Messages do everything! • Three types of messages • Unary • Binary • Keyword
  • 6. Messages - unary • No arguments • Invocation example: • Implementation in class Number: 2 negated negated ^0 - self public Number negated() { return 0 - this; } 2.negated() Equivalent “Java” Syntax
  • 7. Messages - binary • Exactly one argument • Message selector (method name) made from special characters: = , + , - , > etc. • Invocation • Implementation in class Object: a = b = anObject ^self == anObject public boolean equals(Object obj){ return this == obj; } a.equals(b) Equivalent “Java” Syntax
  • 8. Messages - keyword • One or more arguments • Each argument is separated by a keyword • Invocation: • Implementation: a at: 1 put: ‘one’ at: key put: value self cache at: key put: value public Object put(Integer key, String value){ this.cache() .put(key,value); return this; } a.put(1, “one”); Equivalent “Java” Syntax
  • 10. OO Conditional Processing Example • Task: • Use recursion to return root of tree • Each node may access its parent by sending the parent message
  • 11. OO branching- blocks root ^self parent = nil ifTrue: [self] ifFalse: [self parent root] ifTrue: trueBlock ifFalse: falseBlock ^trueBlock value ifTrue: trueBlock ifFalse: falseBlock ^falseBlock value Implementation in True: Implementation in False:
  • 12. OO branching- characteristics • Voilla! We have made if else with only objects and messages • Boolean instance is an object • Code blocks are objects • Implemented as one message, one expression, one return value. root ^self parent = nil ifTrue: [self] ifFalse: [self parent root]
  • 13. More OO conditional logic and: block ^block value True implementation: boolExpr1 and: [boolExpr2]. boolExpr1 or: [boolExpr2]. boolExpr not and: block ^self False implementation: or: block ^self or: block ^block value not ^false not ^true boolExpr1 && boolExpr2; boolExpr1 || boolExpr2; !boolExpr;
  • 14. Learning points • Anything may be expressed using objects, messages and lambdas: • Branches, loops, exception handling …. • Common language features may be implemented with lambdas • Source code acts as documentation • Possible to debug • Many ways to arrange program flow • Polymorphy • Behavioural design patterns Workshop 13:3 0 Room #2
  • 15. Thank you for your time! response ^self satisfied ifTrue: [self clap] ifFalse: [self boo]

Notas del editor

  1. Hi everyone. My name is Martin Skarsaune, and I am a software developer in Kantega here in Norway. I guess most of you come to this conference to pick up the latest and greatest trends and cool stuff. Now however we will look at some good old stuff. And when I say old I mean that this stuff existed even before I was born. But I still believe that we can learn something from the past.
  2. If you have been going to these kind of conferences the last couple of years, you have probably noticed the massive influence of functional programming. Now the title of this talk “Small Lambda Talk” is no coincidence. We will look at lambdas, but with emphasis on the first and last word combined, Smalltalk. So I though we should look at at lambdas from an object oriented angle. I had the pleasure of working on a Smalltalk application at CSC. And I believe we as Java developers have a lot to learn from it. By the way, do we have any grumpy old Smalltalkers in the audience? Has anyone here done or seen any Smalltalk? Do we have anyone who have never heard about the Smalltalk programming language?
  3. So we need to learn a little bit of Smalltalk. But, don’t worry, it’s all very simple. As an illustration, this is the list of reserved words. By just looking at the screen, you have probably figured it out. And as Java developers, you’re used to a lot more than that….
  4. In a Smalltalk, every tiny piece of the application is an object. What does that mean? There are no primitive types Even nil is an object, so all references point to an object. There are no void methods, so whatever you do produces a result, which must be an object.
  5. So we have objects everywhere, which is nice. But how do we make our application do anything? Well, we remember objects may have state and behaviour, right? So we send the them messages. That is Smalltalk lingo for calling methods. There are three kind of messages, due to slightly different syntax, but conceptually and at runtime the are identical.
  6. The simplest type of message is the unary message. The unary message is comprised of only an identifier. We say we send the message negated to 2. I have added some Java-like syntax beside to make it look more familiar. And the declaration is identical, as the language is dynamically typed and there are no method modifiers the signature also only consists of an identifier. In this case we see that the method is implemented by a single statement. The caret at the beginning means return, or in Smalltalk terminology we say we answer 0 minus myself.
  7. The second kind of message is the binary message. Here the message selector is made from one or more special characters, such as arithmetic operators. Here is an example. We say we send the message equals to a with argument b. If we look at the implementation we see that the default implementation of equals is, as in Java to make an identity comparison.
  8. The third kind of message is the keyword message. A keyword message has one or more arguments. Each argument is separated by a keyword. This gives very good overview of the role of each argument.
  9. The main lesson is that anything can be expressed with objects and messages. I have shown some very simple examples, but the same also applies to things such as loops and exception handling, admittedly with some compiler and vm support. As the required components are so easily accessible, Smalltalk libraries and your own code typically provides a wide range of specialized iteration and testing constructs. For instance if you keep on making the same tests in your code, you might instead create a reusable lambda based test. Then if the underlying conditions changes at some point in time, you can easily track down all code that depends on it. Or if I for instance if I wanted to offer norwegian message names instead of English, for my kids, the Smalltalk way makes it very easy to extend the language In this way. Also if you are working on a domain specific language or an interpreter or something like that, you might want to look at the Smalltalk class libraries for some really elegant solutions to divide an conquer low level functionality. In Brian Goetz futures talk yesterday , there was some discussion on where language enhancements should go, vm, language and compiler or libraries. You will see that the Smalltalk way is the extremely geared towards libraries offloading the language and vm from low level issues.
  10. And with that I would like to thank you for your patience.