SlideShare a Scribd company logo
WHATWHATWHATWHATWHATWHAT
WHAT
WHAT
WHAT
WHAT
WHAT
WHAT
WHAT
WHAT
WHATWHAT
JAVA	CAN	LEARN	FROM
HASKELLHASKELLHASKELLHASKELLHASKELLHASKELL
AND	VICE	VERSA
WHATWHATWHATWHATWHATWHAT
WHAT
WHAT
WHAT
WHAT
WHAT
WHAT
WHAT
WHAT
WHATWHAT
JAVA	CAN	LEARN	FROM
HASKELLHASKELLHASKELLHASKELLHASKELLHASKELL
AND	VICE	VERSA
Nick Linker @nick_linkerNick Linker @nick_linker
EXAMPLES	( )
Anchor Applikativ Assertible Borders Beautiful_DestinationsAnchor Applikativ Assertible Borders Beautiful_Destinations
ByteAlly Capital_MatchByteAlly Capital_Match Chordify CircuitHub CommonwealthChordify CircuitHub Commonwealth
Bank DigitalX Elsen Extensibl Facebook FP_CompleteBank DigitalX Elsen Extensibl Facebook FP_Complete
FPInsight Front_Row_Education Helium_SystemsFPInsight Front_Row_Education Helium_Systems
Hooky,_Inc Infinipool Iris_ConnectHooky,_Inc Infinipool Iris_Connect Keera_StudiosKeera_Studios
Kite_&_Lightning Least_Fixed LexisNexis_Risk_SolutionsKite_&_Lightning Least_Fixed LexisNexis_Risk_Solutions
Lumi_GuideLumi_Guide Madriska_Inc. Microsoft MidrollMadriska_Inc. Microsoft Midroll
MyFansDemand Picus_Security Pivot_Cloud PreziMyFansDemand Picus_Security Pivot_Cloud Prezi
Rheo_Systems Scoompa Scrive Scyfy_Technologies SilkRheo_Systems Scoompa Scrive Scyfy_Technologies Silk
SimplyRETS Snowdrift.coopSimplyRETS Snowdrift.coop Soostone Stack_BuildersSoostone Stack_Builders
Standard_Chartered Stitcher Suite_Solutions SumAllStandard_Chartered Stitcher Suite_Solutions SumAll
Swift_Navigation Systor_Vest thoughtbot Tree.isSwift_Navigation Systor_Vest thoughtbot Tree.is
Tsuru_Capital Turing_JumpTsuru_Capital Turing_Jump UpHere VaryWell VFILESUpHere VaryWell VFILES
Virtual_Forge Wagon Wellposed Well-Typed ZaloreVirtual_Forge Wagon Wellposed Well-Typed Zalore
SOURCE
HASKELL	IS	...
Functional
Pure
Lazy (by default)
With advanced type system
GHC
25 years old, but moves fast
last release 2016-05-21
WHAT	JAVA	CAN	LEARN
Expressive syntax
Purity
Expressive Type System
GHCi (REPL)
...
EXPRESSIVE	SYNTAX
EXPRESSIVE	SYNTAX	(1)
size	xs	=	loop	xs	0
		where
				loop	[]	acc	=	acc
				loop	(_	:	xs)	acc	=	loop	xs	(acc	+	1)
--	Usage
size	[1,2,3]
EXPRESSIVE	SYNTAX	(2)
The type of size aboveThe type of size above
In generalIn general
size	::	[t]	->	Integer					--	?
size	::	Num	a	=>	[t]	->	a		--	actuall	type
f	::	(C1	a)	=>	a	->	b	->	c	->	d	->	e
(f	a1)	::											b	->	c	->	d	->	e
(f	a1	b1)	::													c	->	d	->	e
(f	a1	b1	c1)	::															d	->	e
(f	a1	b1	c1	d1)	::																	e
EXPRESSIVE	SYNTAX	(3)
A spherical program in vacuumA spherical program in vacuum
module	My.Foo	where
import	Data.Time	hiding	(Day)
foo	::	IO	()
foo	=	do
		ct	<-	getCurrentTime
		putStrLn	("UTC	time	=	"	++	show	ct)
PURITY
PURITY	(1)
Seriously, what about file system? Network? Random?Seriously, what about file system? Network? Random?
PURITY	(2)
They have the same Java type.They have the same Java type.
However, these functions are not interchangeable!However, these functions are not interchangeable!
long	getLength(String	str)	{
								return	str.length();
}
long	getFileLength(String	path)	{
									return	new	File(path).length();
}
PURITY	(3)
In Haskell they'd have different types:In Haskell they'd have different types:
(Monad tutorial goes here...)(Monad tutorial goes here...)
getLength	::	String	->	Integer
getFileLength	::	String	->	IO	Integer
EXPRESSIVE	TYPES
EXPRESSIVE	TYPES	(1)
NEWTYPES
Milliseconds vs seconds
Username vs password
Paths vs contents
Indices
In Haskell wrapping can be free!In Haskell wrapping can be free!
//	call	this	as	runScript("sql/RunStuff.sql")
Result	runScript(String	script)	{	...}
EXPRESSIVE	TYPES	(2)
NEWTYPES
Looks like a separate type, but low-level representation isLooks like a separate type, but low-level representation is
the same.the same.
--	typesafe	runScript
newtype	Path	=	Path	String
runScript	::	Path	->	IO	Result
EXPRESSIVE	TYPES	(3)
ALGEBRAIC	DATA	TYPES	AND	PATTERN	MATCHING
data	Void
data	X	=	X
data	Y	=	Y	Int	Text	X
data	Z	=	Zx	X	|	Zy	Y
data	Day	=	Mon	|	Tue	|	Wed	|	Thu	|	Fri	|	Sat	|	Sun
data	User	=	User	{	id	::	Int,	name	::	Text,	day	::	Day	}
EXPRESSIVE	TYPES	(4)
ALGEBRAIC	DATA	TYPES	AND	PATTERN	MATCHING
Constructing values and matchingConstructing values and matching
let	z	=	Zy	(Y	123	"Hey"	X)
let	u1	=	User	{	id	=	1,	name	=	"Vasya",	day	=	Mon	}
let	u2	=	User	2	"Petya"	Tue
let	d	=	Sat
wd	::	Day	->	String
wd	d	|	d	`elem`	[Mon,	Tue,	Wed,	Thu]	->	"Working	day"
wd	d	|	d	`elem`	[Sat,	Sun]											->	"Weekend	day"
wd	Fri																															->	"Friday"
case	u1	of
		User	id	name	day	->	...
EXPRESSIVE	TYPES	(5)
TYPE	CLASSES
Typeclasses decouple the declaration that a typeTypeclasses decouple the declaration that a type
implements an interface from the declaration of the typeimplements an interface from the declaration of the type
itselfitself
Data	Type Eq Ord ToJSON FromJSON
Apple
Orange
More onMore on Intefaces vs TypeclassesIntefaces vs Typeclasses
EXPRESSIVE	TYPES	(5)
TYPE	CLASSES
Typeclasses decouple the declaration that a typeTypeclasses decouple the declaration that a type
implements an interface from the declaration of the typeimplements an interface from the declaration of the type
itselfitself
Data	Type Eq Ord ToJSON FromJSON
Apple Eq
Orange
More onMore on Intefaces vs TypeclassesIntefaces vs Typeclasses
EXPRESSIVE	TYPES	(5)
TYPE	CLASSES
Typeclasses decouple the declaration that a typeTypeclasses decouple the declaration that a type
implements an interface from the declaration of the typeimplements an interface from the declaration of the type
itselfitself
Data	Type Eq Ord ToJSON FromJSON
Apple Eq Ord
Orange
More onMore on Intefaces vs TypeclassesIntefaces vs Typeclasses
EXPRESSIVE	TYPES	(5)
TYPE	CLASSES
Typeclasses decouple the declaration that a typeTypeclasses decouple the declaration that a type
implements an interface from the declaration of the typeimplements an interface from the declaration of the type
itselfitself
Data	Type Eq Ord ToJSON FromJSON
Apple Eq Ord
Orange Eq
More onMore on Intefaces vs TypeclassesIntefaces vs Typeclasses
EXPRESSIVE	TYPES	(5)
TYPE	CLASSES
Typeclasses decouple the declaration that a typeTypeclasses decouple the declaration that a type
implements an interface from the declaration of the typeimplements an interface from the declaration of the type
itselfitself
Data	Type Eq Ord ToJSON FromJSON
Apple Eq Ord
Orange Eq ToJSON
More onMore on Intefaces vs TypeclassesIntefaces vs Typeclasses
EXPRESSIVE	TYPES	(5)
TYPE	CLASSES
Typeclasses decouple the declaration that a typeTypeclasses decouple the declaration that a type
implements an interface from the declaration of the typeimplements an interface from the declaration of the type
itselfitself
Data	Type Eq Ord ToJSON FromJSON
Apple Eq Ord
Orange Eq ToJSON
Lemon Eq Ord ToJSON FromJSON
More onMore on Intefaces vs TypeclassesIntefaces vs Typeclasses
EXPRESSIVE	TYPES	(6)
TYPECLASSES
EXPRESSIVE	TYPES	(7)
IT	IS	POSSIBLE	TO	CHECK	AT	COMPILE	TIME
Arrays bounds
Open vs closed files
Nested transactions
Guaranteed closing resources
REST endpoints
And	test	are	available	too!
AND	MANY	MORE
WHAT	HASKELL	CAN
LEARN
Flat learning curve
Intellij IDEA
Stackoverflow
...
HASKELL	LEARNING
CURVE
LEARNING	CURVE	(1)
HASKELL	LEARNING	CURVE,	COMPARISON
LEARNING	CURVE	(2)
THINGS	TO	LEARN	IN	HASKELL
1. Syntax, functions from Prelude
2. Monads
3. Concurrency & parallelism, STM
4. Libraries
1. Monad transformers
2. Free monads, recursive schemes
3. Arrows, Lens, Type families
4. Type safe DSLs, TH
5. Whatever	you	want
LEARNING	CURVE	(4)
COMPARE	WITH	C++
The	new	book	released,	the	translation	ofThe	new	book	released,	the	translation	of
the	C++17	Standard	Draft	to	Russian.	888the	C++17	Standard	Draft	to	Russian.	888
pages.	You	say,	Haskell	is	too	complex?pages.	You	say,	Haskell	is	too	complex?
Okay...	Okay...	@dshevchenko@dshevchenko
INTELLIJ	IDEA
There is no analog for Haskell.There is no analog for Haskell.
There are plugins/extensions forThere are plugins/extensions for
Atom
Vim
Emacs
Sublime
However, Haskell's stepping debugger (GHCi) is notHowever, Haskell's stepping debugger (GHCi) is not
universal.universal.
STACKOVERFLOW	AND	DOCS
For Java it is easy to find examples and goodFor Java it is easy to find examples and good
documentation.documentation.
For HaskellFor Haskell
The documentation is often poor
Needed to look into the libraries' code
Fortunately I could ask my colleagues directly.
OUR	CASE
OUR	CASE
1. There were communication problems inside the team
2. There was a split between haskellers and javaists
3. ...Despite the pretty good quality of the services itself
4. The productivity would not save us :-/
OUR	CASE
1. There were communication problems inside the team
2. There was a split between haskellers and javaists
3. ...Despite the pretty good quality of the services itself
4. The productivity would not save us :-/
One should take the social aspects into accountOne should take the social aspects into account during theduring the
introduction of the new technologies.introduction of the new technologies.
SO?
IS	IT	WORTH	TO	USE	HASKELL	IN	PRODUCTION?
1. Only if all team members are eager to learn Haskell
2. Maybe for some separate task, e.g. compiler
3. I believe one can grow a team of Haskellers
4. .. but cannot easy switch team to Haskell (you cannot
force people to learn)
Examples: GHC, Corrode, Elm, PureScript, Agda,Examples: GHC, Corrode, Elm, PureScript, Agda,
Kaleidoscope, PandocKaleidoscope, Pandoc
Haskell is not for Production and Other Tales, Katie MillerHaskell is not for Production and Other Tales, Katie Miller
andandVideoVideo SlidesSlides
IS	IT	WORTH	TO	LEARN	HASKELL?	(1)
YES!
1. to get a new way of thinking and to push the boundaries
2. to know how to structure things without inheritance
3. to know the alternatives to the buzzwords: DDD,
Anemic, Patterns, IOC, SOLID, DI, ...
4. to finally understand monads
IS	IT	WORTH	TO	LEARN	HASKELL?	(2)
OO is full of design problemsOO is full of design problems
is hard to get it done right
a lot of buzzwords
as opposite to algorithms there is no clear criteria
whether is one solution better than another
cow.eat(grass)
grass.beEatenBy(cow)
field.eatingInteraction(cow,	grass)
IS	IT	WORTH	TO	LEARN	HASKELL?	(2)
QUESTIONS?

More Related Content

PDF
Four Languages From Forty Years Ago
PDF
M.c.a (sem iii) paper - i - object oriented programming
PPT
Implementing the Genetic Algorithm in XSLT: PoC
PPTX
Naming Standards, Clean Code
PPT
Everything You Never Wanted To Know About Net Generics
PDF
F# for C# Programmers
PDF
2017-02-04 02 Яков Лило. Решение задач
PDF
2017-02-04 01 Евгений Тюменцев. Выразительные возможности языков программиро...
Four Languages From Forty Years Ago
M.c.a (sem iii) paper - i - object oriented programming
Implementing the Genetic Algorithm in XSLT: PoC
Naming Standards, Clean Code
Everything You Never Wanted To Know About Net Generics
F# for C# Programmers
2017-02-04 02 Яков Лило. Решение задач
2017-02-04 01 Евгений Тюменцев. Выразительные возможности языков программиро...

Viewers also liked (19)

PDF
2017-02-04 03 Алексей Букуров, Игорь Циглер. DSL для правил валидации
PDF
走马观花— Haskell Web 开发
PDF
Fun never stops. introduction to haskell programming language
PDF
2016-09-17 02 Игорь Гончаровский. Техническая и программная сторона VoIP
PDF
2016-10-01 02 Евгений Комаров. Как я сделал IoT-кикер
PDF
Haskellでプレゼン
PDF
2016 06-11 Елена Гальцина. Дизайнер и разработчик. От неловких встреч к долго...
PDF
Functional Programming by Examples using Haskell
DOCX
Alan juarez _eje3_actividad4.doc
PDF
MOBILESHOPPING2016
PPTX
Evaluation question 6
DOCX
Penerapan pancasila
PDF
2016-08-20 01 Дмитрий Рабецкий, Сергей Сорокин. Опыт работы с Android Medi...
PPTX
IRENE PPT
PDF
2016-10-01 01 Звиад Кардава. Welcome to Internet of Things
PDF
2016-11-12 03 Максим Дроздов. Навести порядок быстро, или как спасти оценки н...
PDF
2016-11-12 01 Егор Непомнящих. Агрегация и осведомленность
PDF
2016-12-03 03 Евгений Тюменцев. DSL на коленке
PDF
2016-12-03 01 Вадим Литвинов. От 2D к 3D обзор методов реконструкции поверхно...
2017-02-04 03 Алексей Букуров, Игорь Циглер. DSL для правил валидации
走马观花— Haskell Web 开发
Fun never stops. introduction to haskell programming language
2016-09-17 02 Игорь Гончаровский. Техническая и программная сторона VoIP
2016-10-01 02 Евгений Комаров. Как я сделал IoT-кикер
Haskellでプレゼン
2016 06-11 Елена Гальцина. Дизайнер и разработчик. От неловких встреч к долго...
Functional Programming by Examples using Haskell
Alan juarez _eje3_actividad4.doc
MOBILESHOPPING2016
Evaluation question 6
Penerapan pancasila
2016-08-20 01 Дмитрий Рабецкий, Сергей Сорокин. Опыт работы с Android Medi...
IRENE PPT
2016-10-01 01 Звиад Кардава. Welcome to Internet of Things
2016-11-12 03 Максим Дроздов. Навести порядок быстро, или как спасти оценки н...
2016-11-12 01 Егор Непомнящих. Агрегация и осведомленность
2016-12-03 03 Евгений Тюменцев. DSL на коленке
2016-12-03 01 Вадим Литвинов. От 2D к 3D обзор методов реконструкции поверхно...
Ad

Similar to 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот (20)

PDF
Scala - from "Hello, World" to "Heroku Scale"
PPTX
Scala - The Simple Parts, SFScala presentation
PDF
Java for android developers
PDF
Stammtisch plus ui5 lessons learned
PPTX
flatMap Oslo presentation slides
PPTX
PPT
Scala Days San Francisco
PDF
Martin Odersky - Evolution of Scala
PPTX
javascript
PDF
LLMs in Production: Tooling, Process, and Team Structure
PDF
Flow or Type - how to React to that?
PPT
PDF
Oop basic concepts
PDF
Presentation
PPT
Douglas Crockford Presentation Goodparts
PPTX
Introduction to scala for a c programmer
PDF
Deep Generative Models
PDF
Haskell: What To Do When Success Can’t Be Avoided
PDF
Declarative Multilingual Information Extraction with SystemT
PPTX
Tech breakfast 18
Scala - from "Hello, World" to "Heroku Scale"
Scala - The Simple Parts, SFScala presentation
Java for android developers
Stammtisch plus ui5 lessons learned
flatMap Oslo presentation slides
Scala Days San Francisco
Martin Odersky - Evolution of Scala
javascript
LLMs in Production: Tooling, Process, and Team Structure
Flow or Type - how to React to that?
Oop basic concepts
Presentation
Douglas Crockford Presentation Goodparts
Introduction to scala for a c programmer
Deep Generative Models
Haskell: What To Do When Success Can’t Be Avoided
Declarative Multilingual Information Extraction with SystemT
Tech breakfast 18
Ad

More from Омские ИТ-субботники (18)

PDF
2017-08-12 01 Алексей Коровянский. Привет, ARKit!
PDF
2017-08-12 02 Антон Ковалев. Texture a.k.a AsyncDisplayKit
PDF
2017-05-06 02 Илья Сиганов. Зачем учить машины?
PDF
2017 04-08 03 Максим Верзаков. Docker — жизнь, вселенная и все остальное
PDF
2017-04-08 01 Евгений Оськин. Video streaming: от идеи до нагруженной системы
PDF
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
PDF
2017-03-11 01 Игорь Родионов. Docker swarm vs Kubernetes
PDF
2016-12-03 02 Алексей Городецкий. Как пишут компиляторы
PDF
2016-10-01 03 Андрей Аржанников. Что такое Bluetooth Low Energy?
PDF
2016-09-17 03 Василий Полозов. WebRTC
PDF
2016-09-17 01 Василий Полозов. Обзор понятий и технологий VoIP
PDF
2016-08-20 02 Антон Ковалев, Антон Кормаков. Viper. Чистая архитектура для iOS
PDF
2016-08-20 03 Сергей Горбачев. Planning poker в Scrum
PDF
2016 06-11 Ирина Мещрякова. Выяснять задачу, формулировать задачу, доносить з...
PDF
2016 06-11 Дмитрий Алексеенков. Android Data Binding
PDF
2016 06-11 Данил Перевалов. Создание простых анимаций на андроид
PDF
2016-04-30 05 Даниил Валов. Apiary - где-то между фронтендом и бэкэндом
PPTX
2016-04-30 04 Ольга Конорева. Взлеты и падения идеального внутреннего проекта
2017-08-12 01 Алексей Коровянский. Привет, ARKit!
2017-08-12 02 Антон Ковалев. Texture a.k.a AsyncDisplayKit
2017-05-06 02 Илья Сиганов. Зачем учить машины?
2017 04-08 03 Максим Верзаков. Docker — жизнь, вселенная и все остальное
2017-04-08 01 Евгений Оськин. Video streaming: от идеи до нагруженной системы
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 01 Игорь Родионов. Docker swarm vs Kubernetes
2016-12-03 02 Алексей Городецкий. Как пишут компиляторы
2016-10-01 03 Андрей Аржанников. Что такое Bluetooth Low Energy?
2016-09-17 03 Василий Полозов. WebRTC
2016-09-17 01 Василий Полозов. Обзор понятий и технологий VoIP
2016-08-20 02 Антон Ковалев, Антон Кормаков. Viper. Чистая архитектура для iOS
2016-08-20 03 Сергей Горбачев. Planning poker в Scrum
2016 06-11 Ирина Мещрякова. Выяснять задачу, формулировать задачу, доносить з...
2016 06-11 Дмитрий Алексеенков. Android Data Binding
2016 06-11 Данил Перевалов. Создание простых анимаций на андроид
2016-04-30 05 Даниил Валов. Apiary - где-то между фронтендом и бэкэндом
2016-04-30 04 Ольга Конорева. Взлеты и падения идеального внутреннего проекта

Recently uploaded (20)

PDF
Introduction to the IoT system, how the IoT system works
PDF
The Internet -By the Numbers, Sri Lanka Edition
PPTX
Slides PPTX World Game (s) Eco Economic Epochs.pptx
PDF
How to Ensure Data Integrity During Shopify Migration_ Best Practices for Sec...
PDF
An introduction to the IFRS (ISSB) Stndards.pdf
PDF
Slides PDF The World Game (s) Eco Economic Epochs.pdf
PDF
RPKI Status Update, presented by Makito Lay at IDNOG 10
PPTX
E -tech empowerment technologies PowerPoint
PPTX
CHE NAA, , b,mn,mblblblbljb jb jlb ,j , ,C PPT.pptx
PPT
isotopes_sddsadsaadasdasdasdasdsa1213.ppt
PPTX
PptxGenJS_Demo_Chart_20250317130215833.pptx
PDF
Unit-1 introduction to cyber security discuss about how to secure a system
PPTX
Power Point - Lesson 3_2.pptx grad school presentation
PPTX
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
DOCX
Unit-3 cyber security network security of internet system
PDF
Vigrab.top – Online Tool for Downloading and Converting Social Media Videos a...
PPT
tcp ip networks nd ip layering assotred slides
PPT
Design_with_Watersergyerge45hrbgre4top (1).ppt
PPTX
Introduction to Information and Communication Technology
PPTX
Job_Card_System_Styled_lorem_ipsum_.pptx
Introduction to the IoT system, how the IoT system works
The Internet -By the Numbers, Sri Lanka Edition
Slides PPTX World Game (s) Eco Economic Epochs.pptx
How to Ensure Data Integrity During Shopify Migration_ Best Practices for Sec...
An introduction to the IFRS (ISSB) Stndards.pdf
Slides PDF The World Game (s) Eco Economic Epochs.pdf
RPKI Status Update, presented by Makito Lay at IDNOG 10
E -tech empowerment technologies PowerPoint
CHE NAA, , b,mn,mblblblbljb jb jlb ,j , ,C PPT.pptx
isotopes_sddsadsaadasdasdasdasdsa1213.ppt
PptxGenJS_Demo_Chart_20250317130215833.pptx
Unit-1 introduction to cyber security discuss about how to secure a system
Power Point - Lesson 3_2.pptx grad school presentation
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
Unit-3 cyber security network security of internet system
Vigrab.top – Online Tool for Downloading and Converting Social Media Videos a...
tcp ip networks nd ip layering assotred slides
Design_with_Watersergyerge45hrbgre4top (1).ppt
Introduction to Information and Communication Technology
Job_Card_System_Styled_lorem_ipsum_.pptx

2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот