2016-11-12 02 Николай Линкер. Чему java может поучиться у haskell и...
TRANSCRIPT
![Page 1: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/1.jpg)
WHATWHATWHATWHATWHATWHAT
WHAT
WHAT
WHAT
WHAT
WHAT
WHAT
WHAT
WHAT
WHATWHATJAVACANLEARNFROM
HASKELLHASKELLHASKELLHASKELLHASKELLHASKELL
HASKELL
HASKELL
HASKELL
HASKELL
HASKELL
HASKELL
HASKELL
HASKELL
HASKELLHASKELLANDVICEVERSA
![Page 2: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/2.jpg)
WHATWHATWHATWHATWHATWHAT
WHAT
WHAT
WHAT
WHAT
WHAT
WHAT
WHAT
WHAT
WHATWHATJAVACANLEARNFROM
HASKELLHASKELLHASKELLHASKELLHASKELLHASKELL
HASKELL
HASKELL
HASKELL
HASKELL
HASKELL
HASKELL
HASKELL
HASKELL
HASKELLHASKELLANDVICEVERSA
Nick Linker @nick_linkerNick Linker @nick_linker
![Page 3: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/3.jpg)
EXAMPLES( )
Anchor Applikativ Assertible Borders Beautiful_DestinationsAnchor Applikativ Assertible Borders Beautiful_DestinationsByteAlly Capital_Match ByteAlly Capital_Match Chordify CircuitHub CommonwealthChordify CircuitHub Commonwealth
Bank DigitalX Elsen Extensibl Facebook FP_CompleteBank DigitalX Elsen Extensibl Facebook FP_CompleteFPInsight Front_Row_Education Helium_SystemsFPInsight Front_Row_Education Helium_SystemsHooky,_Inc Infinipool Iris_Connect Hooky,_Inc Infinipool Iris_Connect Keera_StudiosKeera_Studios
Kite_&_Lightning Least_Fixed LexisNexis_Risk_SolutionsKite_&_Lightning Least_Fixed LexisNexis_Risk_SolutionsLumi_Guide Lumi_Guide Madriska_Inc. Microsoft MidrollMadriska_Inc. Microsoft Midroll
MyFansDemand Picus_Security Pivot_Cloud PreziMyFansDemand Picus_Security Pivot_Cloud PreziRheo_Systems Scoompa Scrive Scyfy_Technologies SilkRheo_Systems Scoompa Scrive Scyfy_Technologies SilkSimplyRETS Snowdrift.coop SimplyRETS Snowdrift.coop Soostone Stack_BuildersSoostone Stack_BuildersStandard_Chartered Stitcher Suite_Solutions SumAllStandard_Chartered Stitcher Suite_Solutions SumAll
Swift_Navigation Systor_Vest thoughtbot Tree.isSwift_Navigation Systor_Vest thoughtbot Tree.isTsuru_Capital Turing_Jump Tsuru_Capital Turing_Jump UpHere VaryWell VFILESUpHere VaryWell VFILESVirtual_Forge Wagon Wellposed Well-Typed ZaloreVirtual_Forge Wagon Wellposed Well-Typed Zalore
SOURCE
![Page 4: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/4.jpg)
HASKELLIS...FunctionalPureLazy (by default)With advanced type systemGHC
25 years old, but moves fastlast release 2016-05-21
![Page 5: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/5.jpg)
WHATJAVACANLEARNExpressive syntaxPurityExpressive Type SystemGHCi (REPL)...
![Page 6: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/6.jpg)
EXPRESSIVESYNTAX
![Page 7: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/7.jpg)
EXPRESSIVESYNTAX(1)sizexs=loopxs0whereloop[]acc=accloop(_:xs)acc=loopxs(acc+1)
--Usagesize[1,2,3]
![Page 8: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/8.jpg)
EXPRESSIVESYNTAX(2)
The type of size aboveThe type of size above
In generalIn general
size::[t]->Integer--?
size::Numa=>[t]->a--actualltype
f::(C1a)=>a->b->c->d->e(fa1)::b->c->d->e(fa1b1)::c->d->e(fa1b1c1)::d->e(fa1b1c1d1)::e
![Page 9: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/9.jpg)
EXPRESSIVESYNTAX(3)
A spherical program in vacuumA spherical program in vacuum
moduleMy.Foowhere
importData.Timehiding(Day)
foo::IO()foo=doct<-getCurrentTimeputStrLn("UTCtime="++showct)
![Page 10: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/10.jpg)
PURITY
![Page 11: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/11.jpg)
PURITY(1)
Seriously, what about file system? Network? Random?Seriously, what about file system? Network? Random?
![Page 12: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/12.jpg)
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!
longgetLength(Stringstr){returnstr.length();}
longgetFileLength(Stringpath){returnnewFile(path).length();}
![Page 13: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/13.jpg)
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->IOInteger
![Page 14: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/14.jpg)
EXPRESSIVETYPES
![Page 15: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/15.jpg)
EXPRESSIVETYPES(1)
NEWTYPES
Milliseconds vs secondsUsername vs passwordPaths vs contentsIndices
In Haskell wrapping can be free!In Haskell wrapping can be free!
//callthisasrunScript("sql/RunStuff.sql")ResultrunScript(Stringscript){...}
![Page 16: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/16.jpg)
EXPRESSIVETYPES(2)
NEWTYPES
Looks like a separate type, but low-level representation isLooks like a separate type, but low-level representation isthe same.the same.
--typesaferunScriptnewtypePath=PathString
runScript::Path->IOResult
![Page 17: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/17.jpg)
EXPRESSIVETYPES(3)
ALGEBRAICDATATYPESANDPATTERNMATCHINGdataVoiddataX=XdataY=YIntTextXdataZ=ZxX|ZyYdataDay=Mon|Tue|Wed|Thu|Fri|Sat|SundataUser=User{id::Int,name::Text,day::Day}
![Page 18: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/18.jpg)
EXPRESSIVETYPES(4)
ALGEBRAICDATATYPESANDPATTERNMATCHING
Constructing values and matchingConstructing values and matching
letz=Zy(Y123"Hey"X)letu1=User{id=1,name="Vasya",day=Mon}letu2=User2"Petya"Tueletd=Sat
wd::Day->Stringwdd|d`elem`[Mon,Tue,Wed,Thu]->"Workingday"wdd|d`elem`[Sat,Sun]->"Weekendday"wdFri->"Friday"
caseu1ofUseridnameday->...
![Page 19: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/19.jpg)
EXPRESSIVETYPES(5)
TYPECLASSES
Typeclasses decouple the declaration that a typeTypeclasses decouple the declaration that a typeimplements an interface from the declaration of the typeimplements an interface from the declaration of the type
itselfitself
DataType Eq Ord ToJSON FromJSON
Apple
Orange
More on More on Intefaces vs TypeclassesIntefaces vs Typeclasses
![Page 20: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/20.jpg)
EXPRESSIVETYPES(5)
TYPECLASSES
Typeclasses decouple the declaration that a typeTypeclasses decouple the declaration that a typeimplements an interface from the declaration of the typeimplements an interface from the declaration of the type
itselfitself
DataType Eq Ord ToJSON FromJSON
Apple Eq
Orange
More on More on Intefaces vs TypeclassesIntefaces vs Typeclasses
![Page 21: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/21.jpg)
EXPRESSIVETYPES(5)
TYPECLASSES
Typeclasses decouple the declaration that a typeTypeclasses decouple the declaration that a typeimplements an interface from the declaration of the typeimplements an interface from the declaration of the type
itselfitself
DataType Eq Ord ToJSON FromJSON
Apple Eq Ord
Orange
More on More on Intefaces vs TypeclassesIntefaces vs Typeclasses
![Page 22: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/22.jpg)
EXPRESSIVETYPES(5)
TYPECLASSES
Typeclasses decouple the declaration that a typeTypeclasses decouple the declaration that a typeimplements an interface from the declaration of the typeimplements an interface from the declaration of the type
itselfitself
DataType Eq Ord ToJSON FromJSON
Apple Eq Ord
Orange Eq
More on More on Intefaces vs TypeclassesIntefaces vs Typeclasses
![Page 23: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/23.jpg)
EXPRESSIVETYPES(5)
TYPECLASSES
Typeclasses decouple the declaration that a typeTypeclasses decouple the declaration that a typeimplements an interface from the declaration of the typeimplements an interface from the declaration of the type
itselfitself
DataType Eq Ord ToJSON FromJSON
Apple Eq Ord
Orange Eq ToJSON
More on More on Intefaces vs TypeclassesIntefaces vs Typeclasses
![Page 24: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/24.jpg)
EXPRESSIVETYPES(5)
TYPECLASSES
Typeclasses decouple the declaration that a typeTypeclasses decouple the declaration that a typeimplements an interface from the declaration of the typeimplements an interface from the declaration of the type
itselfitself
DataType Eq Ord ToJSON FromJSON
Apple Eq Ord
Orange Eq ToJSON
Lemon Eq Ord ToJSON FromJSON
More on More on Intefaces vs TypeclassesIntefaces vs Typeclasses
![Page 25: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/25.jpg)
EXPRESSIVETYPES(6)
TYPECLASSES
![Page 26: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/26.jpg)
EXPRESSIVETYPES(7)
ITISPOSSIBLETOCHECKATCOMPILETIME
Arrays boundsOpen vs closed filesNested transactionsGuaranteed closing resourcesREST endpointsAndtestareavailabletoo!
![Page 27: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/27.jpg)
ANDMANYMORE
![Page 28: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/28.jpg)
WHATHASKELLCANLEARN
Flat learning curveIntellij IDEAStackoverflow...
![Page 29: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/29.jpg)
HASKELLLEARNINGCURVE
![Page 30: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/30.jpg)
LEARNINGCURVE(1)
HASKELLLEARNINGCURVE,COMPARISON
![Page 31: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/31.jpg)
LEARNINGCURVE(2)
THINGSTOLEARNINHASKELL
1. Syntax, functions from Prelude2. Monads3. Concurrency & parallelism, STM4. Libraries
1. Monad transformers2. Free monads, recursive schemes3. Arrows, Lens, Type families4. Type safe DSLs, TH5. Whateveryouwant
![Page 32: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/32.jpg)
LEARNINGCURVE(4)
COMPAREWITHC++
Thenewbookreleased,thetranslationofThenewbookreleased,thetranslationoftheC++17StandardDrafttoRussian.888theC++17StandardDrafttoRussian.888
pages.Yousay,Haskellistoocomplex?pages.Yousay,Haskellistoocomplex?Okay...Okay...@dshevchenko@dshevchenko
![Page 33: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/33.jpg)
INTELLIJIDEA
There is no analog for Haskell.There is no analog for Haskell.
There are plugins/extensions forThere are plugins/extensions for
AtomVimEmacsSublime
However, Haskell's stepping debugger (GHCi) is notHowever, Haskell's stepping debugger (GHCi) is notuniversal.universal.
![Page 34: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/34.jpg)
STACKOVERFLOWANDDOCS
For Java it is easy to find examples and goodFor Java it is easy to find examples and gooddocumentation.documentation.
For HaskellFor Haskell
The documentation is often poorNeeded to look into the libraries' codeFortunately I could ask my colleagues directly.
![Page 35: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/35.jpg)
OURCASE
![Page 36: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/36.jpg)
OURCASE
1. There were communication problems inside the team2. There was a split between haskellers and javaists3. ...Despite the pretty good quality of the services itself4. The productivity would not save us :-/
![Page 37: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/37.jpg)
OURCASE
1. There were communication problems inside the team2. There was a split between haskellers and javaists3. ...Despite the pretty good quality of the services itself4. The productivity would not save us :-/
One should take the social aspects into account One should take the social aspects into account during theduring theintroduction of the new technologies.introduction of the new technologies.
![Page 38: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/38.jpg)
SO?
![Page 39: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/39.jpg)
ISITWORTHTOUSEHASKELLINPRODUCTION?
1. Only if all team members are eager to learn Haskell2. Maybe for some separate task, e.g. compiler3. I believe one can grow a team of Haskellers4. .. 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 and and VideoVideo SlidesSlides
![Page 40: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/40.jpg)
ISITWORTHTOLEARNHASKELL?(1)
YES!1. to get a new way of thinking and to push the boundaries2. to know how to structure things without inheritance3. to know the alternatives to the buzzwords: DDD,
Anemic, Patterns, IOC, SOLID, DI, ...4. to finally understand monads
![Page 41: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/41.jpg)
ISITWORTHTOLEARNHASKELL?(2)
OO is full of design problemsOO is full of design problems
is hard to get it done righta lot of buzzwordsas opposite to algorithms there is no clear criteriawhether is one solution better than anothercow.eat(grass)grass.beEatenBy(cow)field.eatingInteraction(cow,grass)
![Page 42: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/42.jpg)
ISITWORTHTOLEARNHASKELL?(2)
![Page 43: 2016-11-12 02 Николай Линкер. Чему Java может поучиться у Haskell и наоборот](https://reader033.vdocuments.site/reader033/viewer/2022042907/587d551e1a28abee158b5749/html5/thumbnails/43.jpg)
QUESTIONS?