SlideShare una empresa de Scribd logo
1 de 39
Descargar para leer sin conexión
Can functional programming be
liberated from static typing?
@vseloved, 2015-10-31
Can functional programming be
liberated from static typing?
(also how? why? Wtf? …)
Can programming be liberated
from the von Neumann style?
-- John Backus, 1978
https://www.cs.cmu.edu/~crary/819-f09/Backus78.pdf
Conventional programming languages are growing ever more
enormous, but not stronger. Inherent defects at the most
basic level cause them to be both fat and weak: their
primitive word-at-a-time style of programming inherited
from their common ancestor--the von Neumann computer, their
close coupling of semantics to state transitions, their
division of programming into a world of expressions and a
world of statements, their inability to effectively use
powerful combining forms for building new programs from
existing ones, and their lack of useful mathematical
properties for reasoning about programs.
An alternative functional style of programming is founded
on the use of combining forms for creating programs.
Functional programs deal with structured data, are often
nonrepetitive and nonrecursive, are hierarchically
constructed, do not name their arguments, and do not
require the complex machinery of procedure declarations to
become generally applicable. Combining forms can use high
level programs to build still higher level ones in a style
not possible in conventional languages.
www.slideshare.net/ScottWlaschin/fp-patterns-buildstufflt
The Value of Programming
Paradigms
• To be taught in universities
The Value of Programming
Paradigms
• To be taught in universities
• To ignite flamewars
The Value of Programming
Paradigms
• To be taught in universities
• To ignite flamewars
• To characterize programming languages
The Value of Programming
Paradigms
• To be taught in universities
• To ignite flamewars
• To characterize programming languages
• To inspire memes
Programming is a Pop Culture
Binstock: You once referred to computing as pop culture.
Kay: It is. Complete pop culture. I'm not against pop culture. Developed
music, for instance, needs a pop culture. There's a tendency to over-
develop. Brahms and Dvorak needed gypsy music badly by the end of the 19th
century. The big problem with our culture is that it's being dominated,
because the electronic media we have is so much better suited for
transmitting pop-culture content than it is for high-culture content. I
consider jazz to be a developed part of high culture. Anything that's been
worked on and developed and you [can] go to the next couple levels.
Binstock: One thing about jazz aficionados is that they take deep pleasure
in knowing the history of jazz.
Kay: Yes! Classical music is like that, too. But pop culture holds a disdain
for history. Pop culture is all about identity and feeling like you're
participating. It has nothing to do with cooperation, the past or the future
— it's living in the present. I think the same is true of most people who
write code for money. They have no idea where [their culture came from] —
and the Internet was done so well that most people think of it as a natural
resource like the Pacific Ocean, rather than something that was man-made.
When was the last time a technology with a scale like that was so error-
free? The Web, in comparison, is a joke. The Web was done by amateurs.
http://www.drdobbs.com/architecture-and-design/interview-with-alan-kay/24000
3442
The Real Value of
Programming Paradigms
• Taming complexity
• Scaling programming
The Real Value of
Programming Paradigms
• Taming complexity
• Scaling programming
There are only two hard problems
in Computer Science:
cache invalidation
and naming things.
-- Phil Karlton
How?
• Promoting key principles
• Discouraging some approach
(something should be
“considered harmful”)
“Cache Invalidation”
SP: global state considered harmful
OOP: state is incapsulated in objects
FP: state is passed in function calls
“Closures + Hash Tables = As Much OOP
as You’ll Ever Need”
https://lispy.wordpress.com/2007/07/09/closures-hash-tables-as-much-oop-as-youll-ever-n
eed/
Levels of Paradigm Coverage
• In-the-small
• In-the-large
• In-between
From the linguistic point-of-view:
• Syntax
• Semantics
• Pragmatics
Functional Programming
The good:
• Everything is an expression that
returns a value [in-the-small]
• Referential transparency
[in-the-large]
• Composition [in-between]
The ugly:
• mutable state considered harmful
Programming Patterns
Programming Patterns
Funcprog Patterns
• Functions all the way down
• Transformation-oriented programming
• Parametrize all the things
• Be as generic as possible
• Partial application
• Continuations
• Monads (composition of two-tracks
functions): use bind to chain
options/tasks/error handlers
• “Railway-oriented” programming
• Use map to lift functions (functors)
• Use monoids for aggregation
(map-reduce)
Dealing with Errors
There are only two hard problems
in Computer Science:
cache invalidation
naming things,
and off-by-one errors.
-- Anonymous
Type checking
The fundamental observation was that while memory is untyped,
the operations are typed and yield bad results if given
values that were expected to be of a different type than they
actually are, but the computer was utterly unable to report
any of this as a problem because by the time the operations
got their values, the binary representation was assumed to be
that of the type the operations had advertised that they
required. The reason for the compile-time type analysis is
precisely that the execution of the program has no idea
whatsoever which of the many types that map onto to the
binary representation the actual value in
memory is of, and the kind of mistakes that
were made in the past when programmers had
to keep track of this thing by hand was
very expensive.
-- Erik Naggum
https://groups.google.com/forum/#!topic/comp
.lang.lisp/7nhbeh2NIuw%5B126-150%5D
Static Typing
Types are declared for both values and
variables. And they are checked at
compile-time.
Applications:
• Check program correctness
• Inform compiler optimizations
• A tool for domain modeling
• Executable documentation
Type-oriented
Design Patterns
• Strive for purity
• Use types to represent constraints
• Types are cheap
• Strive for totality
• Use types to indicate errors
• Make illegal states unrepresentative
• Use sum types instead of inheritance
• Use sum types for state machines
• It's ok to expose public data
• Types are executable documentation
Functional programming & static typing
are completely orthogonal
Types vs Structures/Objects
Terminology:
• Product types ~ Structures
• Sum types ~ Unions, Inheritance
• Pattern matching ~ Destructuring
“Favor object composition over class
inheritance.”
Dynamic Typing
Values have types, variables don't.
Type-checking happens at run-time.
Address static typing limitations:
• Additional burden on the programmer
• Not all correct programs typecheck
• Limit program development workflow,
rule out some scenarios (interactive
and exploratory programming)
• Premature optimization
A request for more static type checking in Common Lisp is
regarded as a throw-back to the times before we realized
that disjointness is in the eye of the beholder, or as a
missing realization that disjointness does not exist in the
real world and therefore should not exist in the virtual
world we create with our software. Just because computers
are designed a particular way that makes certain types of
values much more efficient to compute with than others, does
not mean that efficiency is /qualitative/. Efficiency is
only quantitative and subordinate to correctness. It is a
very serious error in the Common Lisp world to write a
function that returns the wrong result quickly, but does not
know that it was the wrong result. For this reason, type
correctness is considered to be the responsibility of the
function that makes the requirements, not of the caller or
the compiler. If the programmer who makes those
requirements is sufficiently communicative, however, the
compiler should come to his assistance. The default
behavior, on the other hand, is that functions have to
accept values of type T.
-- Erik Naggum
Gradual/Optional Typing
The Common Lisp declaration facility
(declare (ftype (function (integer list) t) ith)
(ftype (function (number) float) sine))
Gradual/Optional Typing
The Common Lisp declaration facility
(declare (ftype (function (integer list) t) ith)
(ftype (function (number) float) sin))
You can also declare other properties:
• (declare (dynamic-extent item))
• (declare (ignore dummy))
• (declare (call-in traverse))
• (declare (declaration call-in))
Example
> (defun s+ (s1 s2)
(declare (ftype (function (string string) string) s1))
(format nil "~A~A" s1 s2))
> (defun s++ (s1 s2 s3)
(declare (type integer s3))
(s+ s1 (s+ s2 s3)))
; in: DEFUN S++
; (S+ S2 S3)
;
; caught WARNING:
; Derived type of S3 is
; (VALUES INTEGER &OPTIONAL),
; conflicting with its asserted type
; STRING.
Type Checker ~
Garbage Collector
Dynamic typing ~ GC runtimes
Static typing ~ Manual memory
management
Cons of Gradual Typing
“Why we’re no longer using Core.typed”
• Slower iteration time
• Core.typed does not implement the
entire Clojure language
• Third-party code is not covered
http://blog.circleci.com/why-were-no-longer-using-core-typed/
Fractal Programming
The Domain Layer
This is where all the actual domain rules are defined. In
general that means one or more domain specific languages.
This part of the system is what needs to be malleable enough
that it should be possible to change rules in production,
allow domain experts to do things with it, or just plain a
very complicated configuration.
The Dynamic & Stable Layers
The stable layer is the core set of axioms, the hard kernel
or the thin foundation that you can build the rest of your
system in. There is definitely advantages to having this
layer be written in an expressive language, but performance
and static type checking is most interesting here. There is
always a trade-of in giving up static typing, and the point
of having this layer is to make that trade-of smaller. The
dynamic layer runs on top of the stable layer, utilizing
resources and services provided. This is where all
interfaces are defined. But the implementations for them
lives in the dynamic layer, not in the stable. By doing it
this way you can take advantage of static type information
for your API’s while still retaining full flexibility in
implementation of them. It should be fairly small compared
to the rest of the application, and just provide the base
necessary services needed for everything to function.
-- Ola Bini
https://olabini
.com/blog/2008/
06/fractal-prog
ramming/
Static typing is a powerful tool
to help programmers express their
assumptions about the problem
they are trying to solve and
allows them to write more concise
and correct code. Dealing with
uncertain assumptions, dynamism
and (unexepected) change is
becoming increasingly important
in a loosely couple distributed
world. Instead of hammering on
the differences between
dynamically and statically typed
languages, we should instead
strive for a peaceful integration
of static and dynamic aspect in
the same language. Static typing
where possible, dynamic typing
when needed!
-- Erik Meijer
https://www.ics.uci.edu
/~lopes/teaching/inf212
W12/readings/rdl04meije
r.pdf
Summary
• Discussed programming paradigms
• Defined functional programming
• Established that
functional programming ≠ static typing
• Discussed static and dynamic typing
• Described gradual/optional typing

Más contenido relacionado

La actualidad más candente

Open nlp presentationss
Open nlp presentationssOpen nlp presentationss
Open nlp presentationssChandan Deb
 
AINL 2016: Bastrakova, Ledesma, Millan, Zighed
AINL 2016: Bastrakova, Ledesma, Millan, ZighedAINL 2016: Bastrakova, Ledesma, Millan, Zighed
AINL 2016: Bastrakova, Ledesma, Millan, ZighedLidia Pivovarova
 
OUTDATED Text Mining 5/5: Information Extraction
OUTDATED Text Mining 5/5: Information ExtractionOUTDATED Text Mining 5/5: Information Extraction
OUTDATED Text Mining 5/5: Information ExtractionFlorian Leitner
 
Information extraction for Free Text
Information extraction for Free TextInformation extraction for Free Text
Information extraction for Free Textbutest
 
Natural language processing: feature extraction
Natural language processing: feature extractionNatural language processing: feature extraction
Natural language processing: feature extractionGabriel Hamilton
 
Overview of text mining and NLP (+software)
Overview of text mining and NLP (+software)Overview of text mining and NLP (+software)
Overview of text mining and NLP (+software)Florian Leitner
 
Information Extraction from the Web - Algorithms and Tools
Information Extraction from the Web - Algorithms and ToolsInformation Extraction from the Web - Algorithms and Tools
Information Extraction from the Web - Algorithms and ToolsBenjamin Habegger
 
Feature Engineering for NLP
Feature Engineering for NLPFeature Engineering for NLP
Feature Engineering for NLPBill Liu
 
OUTDATED Text Mining 3/5: String Processing
OUTDATED Text Mining 3/5: String ProcessingOUTDATED Text Mining 3/5: String Processing
OUTDATED Text Mining 3/5: String ProcessingFlorian Leitner
 
Natural Language Processing in Practice
Natural Language Processing in PracticeNatural Language Processing in Practice
Natural Language Processing in PracticeVsevolod Dyomkin
 
Webinar: OpenNLP and Solr for Superior Relevance
Webinar: OpenNLP and Solr for Superior RelevanceWebinar: OpenNLP and Solr for Superior Relevance
Webinar: OpenNLP and Solr for Superior RelevanceLucidworks
 
"Data mining и информационный поиск проблемы, алгоритмы, решения"_Краковецкий...
"Data mining и информационный поиск проблемы, алгоритмы, решения"_Краковецкий..."Data mining и информационный поиск проблемы, алгоритмы, решения"_Краковецкий...
"Data mining и информационный поиск проблемы, алгоритмы, решения"_Краковецкий...GeeksLab Odessa
 
RDataMining slides-text-mining-with-r
RDataMining slides-text-mining-with-rRDataMining slides-text-mining-with-r
RDataMining slides-text-mining-with-rYanchang Zhao
 
AINL 2016: Galinsky, Alekseev, Nikolenko
AINL 2016: Galinsky, Alekseev, NikolenkoAINL 2016: Galinsky, Alekseev, Nikolenko
AINL 2016: Galinsky, Alekseev, NikolenkoLidia Pivovarova
 
Mchristy-eMOP-workflows2-24x7
Mchristy-eMOP-workflows2-24x7Mchristy-eMOP-workflows2-24x7
Mchristy-eMOP-workflows2-24x7Matt Christy
 

La actualidad más candente (20)

AINL 2016: Kravchenko
AINL 2016: KravchenkoAINL 2016: Kravchenko
AINL 2016: Kravchenko
 
Open nlp presentationss
Open nlp presentationssOpen nlp presentationss
Open nlp presentationss
 
AINL 2016: Bastrakova, Ledesma, Millan, Zighed
AINL 2016: Bastrakova, Ledesma, Millan, ZighedAINL 2016: Bastrakova, Ledesma, Millan, Zighed
AINL 2016: Bastrakova, Ledesma, Millan, Zighed
 
NLP and LSA getting started
NLP and LSA getting startedNLP and LSA getting started
NLP and LSA getting started
 
OUTDATED Text Mining 5/5: Information Extraction
OUTDATED Text Mining 5/5: Information ExtractionOUTDATED Text Mining 5/5: Information Extraction
OUTDATED Text Mining 5/5: Information Extraction
 
Information extraction for Free Text
Information extraction for Free TextInformation extraction for Free Text
Information extraction for Free Text
 
AINL 2016: Maraev
AINL 2016: MaraevAINL 2016: Maraev
AINL 2016: Maraev
 
Natural language processing: feature extraction
Natural language processing: feature extractionNatural language processing: feature extraction
Natural language processing: feature extraction
 
AINL 2016: Kuznetsova
AINL 2016: KuznetsovaAINL 2016: Kuznetsova
AINL 2016: Kuznetsova
 
Overview of text mining and NLP (+software)
Overview of text mining and NLP (+software)Overview of text mining and NLP (+software)
Overview of text mining and NLP (+software)
 
Information Extraction from the Web - Algorithms and Tools
Information Extraction from the Web - Algorithms and ToolsInformation Extraction from the Web - Algorithms and Tools
Information Extraction from the Web - Algorithms and Tools
 
Feature Engineering for NLP
Feature Engineering for NLPFeature Engineering for NLP
Feature Engineering for NLP
 
OUTDATED Text Mining 3/5: String Processing
OUTDATED Text Mining 3/5: String ProcessingOUTDATED Text Mining 3/5: String Processing
OUTDATED Text Mining 3/5: String Processing
 
Natural Language Processing in Practice
Natural Language Processing in PracticeNatural Language Processing in Practice
Natural Language Processing in Practice
 
AINL 2016: Eyecioglu
AINL 2016: EyeciogluAINL 2016: Eyecioglu
AINL 2016: Eyecioglu
 
Webinar: OpenNLP and Solr for Superior Relevance
Webinar: OpenNLP and Solr for Superior RelevanceWebinar: OpenNLP and Solr for Superior Relevance
Webinar: OpenNLP and Solr for Superior Relevance
 
"Data mining и информационный поиск проблемы, алгоритмы, решения"_Краковецкий...
"Data mining и информационный поиск проблемы, алгоритмы, решения"_Краковецкий..."Data mining и информационный поиск проблемы, алгоритмы, решения"_Краковецкий...
"Data mining и информационный поиск проблемы, алгоритмы, решения"_Краковецкий...
 
RDataMining slides-text-mining-with-r
RDataMining slides-text-mining-with-rRDataMining slides-text-mining-with-r
RDataMining slides-text-mining-with-r
 
AINL 2016: Galinsky, Alekseev, Nikolenko
AINL 2016: Galinsky, Alekseev, NikolenkoAINL 2016: Galinsky, Alekseev, Nikolenko
AINL 2016: Galinsky, Alekseev, Nikolenko
 
Mchristy-eMOP-workflows2-24x7
Mchristy-eMOP-workflows2-24x7Mchristy-eMOP-workflows2-24x7
Mchristy-eMOP-workflows2-24x7
 

Destacado

Erlang On Xen @ Kiev Functional Programming event, Aug 3 2013
Erlang On Xen @ Kiev Functional Programming event, Aug 3 2013Erlang On Xen @ Kiev Functional Programming event, Aug 3 2013
Erlang On Xen @ Kiev Functional Programming event, Aug 3 2013Viktor Sovietov
 
Tedxkyiv communication guidelines
Tedxkyiv communication guidelinesTedxkyiv communication guidelines
Tedxkyiv communication guidelinesVsevolod Dyomkin
 
Чему мы можем научиться у Lisp'а?
Чему мы можем научиться у Lisp'а?Чему мы можем научиться у Lisp'а?
Чему мы можем научиться у Lisp'а?Vsevolod Dyomkin
 
Lisp как универсальная обертка
Lisp как универсальная оберткаLisp как универсальная обертка
Lisp как универсальная оберткаVsevolod Dyomkin
 
Новые нереляционные системы хранения данных
Новые нереляционные системы хранения данныхНовые нереляционные системы хранения данных
Новые нереляционные системы хранения данныхVsevolod Dyomkin
 
NLP in the WILD or Building a System for Text Language Identification
NLP in the WILD or Building a System for Text Language IdentificationNLP in the WILD or Building a System for Text Language Identification
NLP in the WILD or Building a System for Text Language IdentificationVsevolod Dyomkin
 
Lisp for Python Programmers
Lisp for Python ProgrammersLisp for Python Programmers
Lisp for Python ProgrammersVsevolod Dyomkin
 
Экосистема Common Lisp
Экосистема Common LispЭкосистема Common Lisp
Экосистема Common LispVsevolod Dyomkin
 
Sugaring Lisp for the 21st Century
Sugaring Lisp for the 21st CenturySugaring Lisp for the 21st Century
Sugaring Lisp for the 21st CenturyVsevolod Dyomkin
 

Destacado (10)

Erlang On Xen @ Kiev Functional Programming event, Aug 3 2013
Erlang On Xen @ Kiev Functional Programming event, Aug 3 2013Erlang On Xen @ Kiev Functional Programming event, Aug 3 2013
Erlang On Xen @ Kiev Functional Programming event, Aug 3 2013
 
Tedxkyiv communication guidelines
Tedxkyiv communication guidelinesTedxkyiv communication guidelines
Tedxkyiv communication guidelines
 
Чему мы можем научиться у Lisp'а?
Чему мы можем научиться у Lisp'а?Чему мы можем научиться у Lisp'а?
Чему мы можем научиться у Lisp'а?
 
Lisp как универсальная обертка
Lisp как универсальная оберткаLisp как универсальная обертка
Lisp как универсальная обертка
 
Новые нереляционные системы хранения данных
Новые нереляционные системы хранения данныхНовые нереляционные системы хранения данных
Новые нереляционные системы хранения данных
 
CL-NLP
CL-NLPCL-NLP
CL-NLP
 
NLP in the WILD or Building a System for Text Language Identification
NLP in the WILD or Building a System for Text Language IdentificationNLP in the WILD or Building a System for Text Language Identification
NLP in the WILD or Building a System for Text Language Identification
 
Lisp for Python Programmers
Lisp for Python ProgrammersLisp for Python Programmers
Lisp for Python Programmers
 
Экосистема Common Lisp
Экосистема Common LispЭкосистема Common Lisp
Экосистема Common Lisp
 
Sugaring Lisp for the 21st Century
Sugaring Lisp for the 21st CenturySugaring Lisp for the 21st Century
Sugaring Lisp for the 21st Century
 

Similar a Can functional programming be liberated from static typing?

Trends in Programming Technology you might want to keep an eye on af Bent Tho...
Trends in Programming Technology you might want to keep an eye on af Bent Tho...Trends in Programming Technology you might want to keep an eye on af Bent Tho...
Trends in Programming Technology you might want to keep an eye on af Bent Tho...InfinIT - Innovationsnetværket for it
 
Go language presentation
Go language presentationGo language presentation
Go language presentationparamisoft
 
Swift: A parallel scripting for applications at the petascale and beyond.
Swift: A parallel scripting for applications at the petascale and beyond.Swift: A parallel scripting for applications at the petascale and beyond.
Swift: A parallel scripting for applications at the petascale and beyond.Nagasuri Bala Venkateswarlu
 
Антон Кириллов, ZeptoLab
Антон Кириллов, ZeptoLabАнтон Кириллов, ZeptoLab
Антон Кириллов, ZeptoLabDiana Dymolazova
 
On being a professional software developer
On being a professional software developerOn being a professional software developer
On being a professional software developerAnton Kirillov
 
Life Beyond Rails: Creating Cross Platform Ruby Apps
Life Beyond Rails: Creating Cross Platform Ruby AppsLife Beyond Rails: Creating Cross Platform Ruby Apps
Life Beyond Rails: Creating Cross Platform Ruby AppsTristan Gomez
 
2015 bioinformatics python_introduction_wim_vancriekinge_vfinal
2015 bioinformatics python_introduction_wim_vancriekinge_vfinal2015 bioinformatics python_introduction_wim_vancriekinge_vfinal
2015 bioinformatics python_introduction_wim_vancriekinge_vfinalProf. Wim Van Criekinge
 
Evolving as a professional software developer
Evolving as a professional software developerEvolving as a professional software developer
Evolving as a professional software developerAnton Kirillov
 
Learn a language : LISP
Learn a language : LISPLearn a language : LISP
Learn a language : LISPDevnology
 
Are High Level Programming Languages for Multicore and Safety Critical Conver...
Are High Level Programming Languages for Multicore and Safety Critical Conver...Are High Level Programming Languages for Multicore and Safety Critical Conver...
Are High Level Programming Languages for Multicore and Safety Critical Conver...InfinIT - Innovationsnetværket for it
 
Unit 4 Assignment 1 Comparative Study Of Programming...
Unit 4 Assignment 1 Comparative Study Of Programming...Unit 4 Assignment 1 Comparative Study Of Programming...
Unit 4 Assignment 1 Comparative Study Of Programming...Carmen Sanborn
 
Scales02WhatProgrammingLanguagesShouldWeTeachOurUndergraduates
Scales02WhatProgrammingLanguagesShouldWeTeachOurUndergraduatesScales02WhatProgrammingLanguagesShouldWeTeachOurUndergraduates
Scales02WhatProgrammingLanguagesShouldWeTeachOurUndergraduatesHans Ecke
 
Demystifying Digital Humanities: Winter 2014 Workshop #2: Programming on the ...
Demystifying Digital Humanities: Winter 2014 Workshop #2: Programming on the ...Demystifying Digital Humanities: Winter 2014 Workshop #2: Programming on the ...
Demystifying Digital Humanities: Winter 2014 Workshop #2: Programming on the ...Paige Morgan
 
Backus turingaward lecture
Backus turingaward lectureBackus turingaward lecture
Backus turingaward lectureKulOusemnes
 
Brownfield Domain Driven Design
Brownfield Domain Driven DesignBrownfield Domain Driven Design
Brownfield Domain Driven DesignNicolò Pignatelli
 
Can Programming Be Liberated from the von Neumann Style? by John Backus
Can Programming Be Liberated from the von Neumann Style? by John BackusCan Programming Be Liberated from the von Neumann Style? by John Backus
Can Programming Be Liberated from the von Neumann Style? by John Backusmustafa sarac
 

Similar a Can functional programming be liberated from static typing? (20)

Trends in Programming Technology you might want to keep an eye on af Bent Tho...
Trends in Programming Technology you might want to keep an eye on af Bent Tho...Trends in Programming Technology you might want to keep an eye on af Bent Tho...
Trends in Programming Technology you might want to keep an eye on af Bent Tho...
 
Plc part 1
Plc part 1Plc part 1
Plc part 1
 
Go language presentation
Go language presentationGo language presentation
Go language presentation
 
Swift: A parallel scripting for applications at the petascale and beyond.
Swift: A parallel scripting for applications at the petascale and beyond.Swift: A parallel scripting for applications at the petascale and beyond.
Swift: A parallel scripting for applications at the petascale and beyond.
 
Paradigms
ParadigmsParadigms
Paradigms
 
Антон Кириллов, ZeptoLab
Антон Кириллов, ZeptoLabАнтон Кириллов, ZeptoLab
Антон Кириллов, ZeptoLab
 
On being a professional software developer
On being a professional software developerOn being a professional software developer
On being a professional software developer
 
Rust presentation convergeconf
Rust presentation convergeconfRust presentation convergeconf
Rust presentation convergeconf
 
Life Beyond Rails: Creating Cross Platform Ruby Apps
Life Beyond Rails: Creating Cross Platform Ruby AppsLife Beyond Rails: Creating Cross Platform Ruby Apps
Life Beyond Rails: Creating Cross Platform Ruby Apps
 
2015 bioinformatics python_introduction_wim_vancriekinge_vfinal
2015 bioinformatics python_introduction_wim_vancriekinge_vfinal2015 bioinformatics python_introduction_wim_vancriekinge_vfinal
2015 bioinformatics python_introduction_wim_vancriekinge_vfinal
 
Evolving as a professional software developer
Evolving as a professional software developerEvolving as a professional software developer
Evolving as a professional software developer
 
02paradigms.ppt
02paradigms.ppt02paradigms.ppt
02paradigms.ppt
 
Learn a language : LISP
Learn a language : LISPLearn a language : LISP
Learn a language : LISP
 
Are High Level Programming Languages for Multicore and Safety Critical Conver...
Are High Level Programming Languages for Multicore and Safety Critical Conver...Are High Level Programming Languages for Multicore and Safety Critical Conver...
Are High Level Programming Languages for Multicore and Safety Critical Conver...
 
Unit 4 Assignment 1 Comparative Study Of Programming...
Unit 4 Assignment 1 Comparative Study Of Programming...Unit 4 Assignment 1 Comparative Study Of Programming...
Unit 4 Assignment 1 Comparative Study Of Programming...
 
Scales02WhatProgrammingLanguagesShouldWeTeachOurUndergraduates
Scales02WhatProgrammingLanguagesShouldWeTeachOurUndergraduatesScales02WhatProgrammingLanguagesShouldWeTeachOurUndergraduates
Scales02WhatProgrammingLanguagesShouldWeTeachOurUndergraduates
 
Demystifying Digital Humanities: Winter 2014 Workshop #2: Programming on the ...
Demystifying Digital Humanities: Winter 2014 Workshop #2: Programming on the ...Demystifying Digital Humanities: Winter 2014 Workshop #2: Programming on the ...
Demystifying Digital Humanities: Winter 2014 Workshop #2: Programming on the ...
 
Backus turingaward lecture
Backus turingaward lectureBackus turingaward lecture
Backus turingaward lecture
 
Brownfield Domain Driven Design
Brownfield Domain Driven DesignBrownfield Domain Driven Design
Brownfield Domain Driven Design
 
Can Programming Be Liberated from the von Neumann Style? by John Backus
Can Programming Be Liberated from the von Neumann Style? by John BackusCan Programming Be Liberated from the von Neumann Style? by John Backus
Can Programming Be Liberated from the von Neumann Style? by John Backus
 

Último

Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
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
 
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
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 

Último (20)

Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
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
 
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
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Can functional programming be liberated from static typing?

  • 1. Can functional programming be liberated from static typing? @vseloved, 2015-10-31
  • 2. Can functional programming be liberated from static typing? (also how? why? Wtf? …)
  • 3. Can programming be liberated from the von Neumann style? -- John Backus, 1978 https://www.cs.cmu.edu/~crary/819-f09/Backus78.pdf
  • 4. Conventional programming languages are growing ever more enormous, but not stronger. Inherent defects at the most basic level cause them to be both fat and weak: their primitive word-at-a-time style of programming inherited from their common ancestor--the von Neumann computer, their close coupling of semantics to state transitions, their division of programming into a world of expressions and a world of statements, their inability to effectively use powerful combining forms for building new programs from existing ones, and their lack of useful mathematical properties for reasoning about programs. An alternative functional style of programming is founded on the use of combining forms for creating programs. Functional programs deal with structured data, are often nonrepetitive and nonrecursive, are hierarchically constructed, do not name their arguments, and do not require the complex machinery of procedure declarations to become generally applicable. Combining forms can use high level programs to build still higher level ones in a style not possible in conventional languages.
  • 6.
  • 7. The Value of Programming Paradigms • To be taught in universities
  • 8. The Value of Programming Paradigms • To be taught in universities • To ignite flamewars
  • 9. The Value of Programming Paradigms • To be taught in universities • To ignite flamewars • To characterize programming languages
  • 10. The Value of Programming Paradigms • To be taught in universities • To ignite flamewars • To characterize programming languages • To inspire memes
  • 11.
  • 12.
  • 13. Programming is a Pop Culture Binstock: You once referred to computing as pop culture. Kay: It is. Complete pop culture. I'm not against pop culture. Developed music, for instance, needs a pop culture. There's a tendency to over- develop. Brahms and Dvorak needed gypsy music badly by the end of the 19th century. The big problem with our culture is that it's being dominated, because the electronic media we have is so much better suited for transmitting pop-culture content than it is for high-culture content. I consider jazz to be a developed part of high culture. Anything that's been worked on and developed and you [can] go to the next couple levels. Binstock: One thing about jazz aficionados is that they take deep pleasure in knowing the history of jazz. Kay: Yes! Classical music is like that, too. But pop culture holds a disdain for history. Pop culture is all about identity and feeling like you're participating. It has nothing to do with cooperation, the past or the future — it's living in the present. I think the same is true of most people who write code for money. They have no idea where [their culture came from] — and the Internet was done so well that most people think of it as a natural resource like the Pacific Ocean, rather than something that was man-made. When was the last time a technology with a scale like that was so error- free? The Web, in comparison, is a joke. The Web was done by amateurs. http://www.drdobbs.com/architecture-and-design/interview-with-alan-kay/24000 3442
  • 14. The Real Value of Programming Paradigms • Taming complexity • Scaling programming
  • 15. The Real Value of Programming Paradigms • Taming complexity • Scaling programming There are only two hard problems in Computer Science: cache invalidation and naming things. -- Phil Karlton
  • 16. How? • Promoting key principles • Discouraging some approach (something should be “considered harmful”)
  • 17. “Cache Invalidation” SP: global state considered harmful OOP: state is incapsulated in objects FP: state is passed in function calls “Closures + Hash Tables = As Much OOP as You’ll Ever Need” https://lispy.wordpress.com/2007/07/09/closures-hash-tables-as-much-oop-as-youll-ever-n eed/
  • 18. Levels of Paradigm Coverage • In-the-small • In-the-large • In-between From the linguistic point-of-view: • Syntax • Semantics • Pragmatics
  • 19. Functional Programming The good: • Everything is an expression that returns a value [in-the-small] • Referential transparency [in-the-large] • Composition [in-between] The ugly: • mutable state considered harmful
  • 20.
  • 23. Funcprog Patterns • Functions all the way down • Transformation-oriented programming • Parametrize all the things • Be as generic as possible • Partial application • Continuations • Monads (composition of two-tracks functions): use bind to chain options/tasks/error handlers • “Railway-oriented” programming • Use map to lift functions (functors) • Use monoids for aggregation (map-reduce)
  • 24. Dealing with Errors There are only two hard problems in Computer Science: cache invalidation naming things, and off-by-one errors. -- Anonymous
  • 25. Type checking The fundamental observation was that while memory is untyped, the operations are typed and yield bad results if given values that were expected to be of a different type than they actually are, but the computer was utterly unable to report any of this as a problem because by the time the operations got their values, the binary representation was assumed to be that of the type the operations had advertised that they required. The reason for the compile-time type analysis is precisely that the execution of the program has no idea whatsoever which of the many types that map onto to the binary representation the actual value in memory is of, and the kind of mistakes that were made in the past when programmers had to keep track of this thing by hand was very expensive. -- Erik Naggum https://groups.google.com/forum/#!topic/comp .lang.lisp/7nhbeh2NIuw%5B126-150%5D
  • 26. Static Typing Types are declared for both values and variables. And they are checked at compile-time. Applications: • Check program correctness • Inform compiler optimizations • A tool for domain modeling • Executable documentation
  • 27. Type-oriented Design Patterns • Strive for purity • Use types to represent constraints • Types are cheap • Strive for totality • Use types to indicate errors • Make illegal states unrepresentative • Use sum types instead of inheritance • Use sum types for state machines • It's ok to expose public data • Types are executable documentation
  • 28. Functional programming & static typing are completely orthogonal
  • 29. Types vs Structures/Objects Terminology: • Product types ~ Structures • Sum types ~ Unions, Inheritance • Pattern matching ~ Destructuring “Favor object composition over class inheritance.”
  • 30. Dynamic Typing Values have types, variables don't. Type-checking happens at run-time. Address static typing limitations: • Additional burden on the programmer • Not all correct programs typecheck • Limit program development workflow, rule out some scenarios (interactive and exploratory programming) • Premature optimization
  • 31. A request for more static type checking in Common Lisp is regarded as a throw-back to the times before we realized that disjointness is in the eye of the beholder, or as a missing realization that disjointness does not exist in the real world and therefore should not exist in the virtual world we create with our software. Just because computers are designed a particular way that makes certain types of values much more efficient to compute with than others, does not mean that efficiency is /qualitative/. Efficiency is only quantitative and subordinate to correctness. It is a very serious error in the Common Lisp world to write a function that returns the wrong result quickly, but does not know that it was the wrong result. For this reason, type correctness is considered to be the responsibility of the function that makes the requirements, not of the caller or the compiler. If the programmer who makes those requirements is sufficiently communicative, however, the compiler should come to his assistance. The default behavior, on the other hand, is that functions have to accept values of type T. -- Erik Naggum
  • 32. Gradual/Optional Typing The Common Lisp declaration facility (declare (ftype (function (integer list) t) ith) (ftype (function (number) float) sine))
  • 33. Gradual/Optional Typing The Common Lisp declaration facility (declare (ftype (function (integer list) t) ith) (ftype (function (number) float) sin)) You can also declare other properties: • (declare (dynamic-extent item)) • (declare (ignore dummy)) • (declare (call-in traverse)) • (declare (declaration call-in))
  • 34. Example > (defun s+ (s1 s2) (declare (ftype (function (string string) string) s1)) (format nil "~A~A" s1 s2)) > (defun s++ (s1 s2 s3) (declare (type integer s3)) (s+ s1 (s+ s2 s3))) ; in: DEFUN S++ ; (S+ S2 S3) ; ; caught WARNING: ; Derived type of S3 is ; (VALUES INTEGER &OPTIONAL), ; conflicting with its asserted type ; STRING.
  • 35. Type Checker ~ Garbage Collector Dynamic typing ~ GC runtimes Static typing ~ Manual memory management
  • 36. Cons of Gradual Typing “Why we’re no longer using Core.typed” • Slower iteration time • Core.typed does not implement the entire Clojure language • Third-party code is not covered http://blog.circleci.com/why-were-no-longer-using-core-typed/
  • 37. Fractal Programming The Domain Layer This is where all the actual domain rules are defined. In general that means one or more domain specific languages. This part of the system is what needs to be malleable enough that it should be possible to change rules in production, allow domain experts to do things with it, or just plain a very complicated configuration. The Dynamic & Stable Layers The stable layer is the core set of axioms, the hard kernel or the thin foundation that you can build the rest of your system in. There is definitely advantages to having this layer be written in an expressive language, but performance and static type checking is most interesting here. There is always a trade-of in giving up static typing, and the point of having this layer is to make that trade-of smaller. The dynamic layer runs on top of the stable layer, utilizing resources and services provided. This is where all interfaces are defined. But the implementations for them lives in the dynamic layer, not in the stable. By doing it this way you can take advantage of static type information for your API’s while still retaining full flexibility in implementation of them. It should be fairly small compared to the rest of the application, and just provide the base necessary services needed for everything to function. -- Ola Bini https://olabini .com/blog/2008/ 06/fractal-prog ramming/
  • 38. Static typing is a powerful tool to help programmers express their assumptions about the problem they are trying to solve and allows them to write more concise and correct code. Dealing with uncertain assumptions, dynamism and (unexepected) change is becoming increasingly important in a loosely couple distributed world. Instead of hammering on the differences between dynamically and statically typed languages, we should instead strive for a peaceful integration of static and dynamic aspect in the same language. Static typing where possible, dynamic typing when needed! -- Erik Meijer https://www.ics.uci.edu /~lopes/teaching/inf212 W12/readings/rdl04meije r.pdf
  • 39. Summary • Discussed programming paradigms • Defined functional programming • Established that functional programming ≠ static typing • Discussed static and dynamic typing • Described gradual/optional typing