SlideShare a Scribd company logo
REAL
                                                 W⊛RLD
                                                 SCALAZ
                          http://speakerdeck.com/u/jrwest/p/real-world-scalaz
changed talk title (“practical scalaz” by Chris Marshall http://skillsmatter.com/podcast/scala/practical-scalaz-2518)
“If you are thinking of using
        Scalaz, stop now while you
        still have your sanity"
* context: java devs learning scala
* source: http://zeroturnaround.com/blog/scala-sink-or-swim-part-1/#scalaz
“How does this help
        you ship features or
        improve your product?”
* context: commenting on the use of lenses
* source: https://twitter.com/#!/coda/status/167794305107361796)
“It will not immediately
        help you write better
        programs that are easy to
        understand”
* hear/read this often
* source: http://zeroturnaround.com/blog/scala-sink-or-swim-part-1/#scalaz
“There are two types of
          [libraries]: the ones people hate
                and the ones nobody uses”
                                - unknown
* applies to scala too
* know correct attribution? contact me
HOW
                                               &
                                              WHY?
* those quotes pretty much boil down to these two questions:
* how: apply tools given by scalaz to real world problems? to handle human scale?
* why would we choose this solution over other ones?
@_jrwest
                                                           github.com/jrwest
                                                           blog.loopedstrange.com




* a little context before we talk about the “how & why?”
I
                                             WORK @



* small team, < 15 engineers
* many have java bg, but not all, most w/ little to no scala experience
* most have oop bg, varying knowledge of FP topics
WE USE SCALA
                         { a lot }
* 15+ public facing services supported by many other internal modules/libs
* most built on netty, also I/O bound
* originally java, now > 70% scala
libraryDependencies +=

      “org.scalaz” %% “scalaz-core” % “6.0.3”



* almost all our services depend on scalaz
* usage levels and parts of scalaz used vary among services
* blocked on upgrading to 6.0.4 b/c of binary compatibility issues
SOME
EXAMPLES
JSON Mapping
   def Fi
          leMani
     def re          festJS
              ad(jso        ONR =
     ma                n: JVa      new JS
         nifest               lue) =       ONR[ Ap
                    NoId.a                         p I D= > F
         field(            pplyJS                             ileMan
                   jsonMa         O N(                               ifest]
        f i e l d(        nifest                                            {
      )(json       change        K e y) ,
               )          LogEnt
  }                              ryCach
                                          edJson
}                                                K e y)




* lift-json-scalaz (https://github.com/lift/framework/tree/master/core/json-scalaz)
* validationnel applicative, error accumulation = better user-facing errors & debugging
* composition
S @-@ A / State[S,A]
           for
               {
          mbE
         _    xis
            <-    ts
        _       man   <-
           <-       ife    man
     } y       cha      stF    ife
         iel       nge       ile   stF
             d m       Log       s -   ile
                 bEx        Ent      = p   s m
                     ist        ryF      ath   emb
                         s          ile            er
                                        s -           pat
                                            =?            h
                                                (pa
                                                    th,
                                                        mbE
                                                            xi          sts
                                                                              >|
                                                                                   fal
                                                                                         se
                                                                                              | t
                                                                                                  rue
                                                                                                      )
* easy manipulation of highly nested case classes (ex: file manifests)
* better implementation hiding
* rich libraries (e.g. MapLens, SetLens, & provided state actions)
sideEffect.pure[IO]
                                                           ble ,X]
                                                 [ Thr owa       = {
                                       io  n NEL         in g])        _))
                              al i dat          st [ Str      mai n] (
                       X ]=V              :  Li           mDo
             y pe  V[           s (ke ys          [Cu sto
           t          tch  K ey
                                       t .fe  tch                       ain ]])
            def   fe           buc  ke                          tom Dom
                          ap (                              Cus
                ke y s.m                           pti on[
                         qu e nce         ce[  V,O
                   .se          seq  uen
                           (_.
                   .  map
               
              }


* can’t guarantee purity, can delineate impurity
* examples: storing data in riak, uploading files to s3 and phonegap build svc
* composition of IO makes side-effecting code much more reusable
Kle




                                                                        ]
       i   sli




                                                                          ]
                         OptionW[A] Tree[A]




                                                                       F[_
                 [M
                   [_]




                                                                    le[
                       ,A,   Pure[P[_]
                          B]           ]




                                                                  ab
                                                                       MAB[M[
                                                                                _],A,B]




                                                                 ld
     Bind[Z[                                            [A]
             _                 ]]                    ro




                                                              Fo
                                       Ze                                          t[ A]
             Tra                                                           ty   Lis
                 ver             Identity                         ] NonEmp
                                                           p [   A
               e [T  s                                    u
      Fun          [_]]        r                        o
         ctor              mig          Appl
              [F[_]     Se                   y[A[_
                    ]      MA[ M[_ ],A]            ]]
* we make use of a lot more as well
* data structures like Validation and NonEmptyList
* most type classes and “enrichments”
ITS NOT ALL OR NOTHING
* shades of grey, not black and white
* scalaz is really many libraries, use the parts you want
* we started using “encrichments” and some data structures, grew from there
--
original image: http://www.chicagonow.com/chicago-tough/files/2012/03/chipsallin.jpg
MAKE BORDERS
* don’t abuse scala’s flexibility & power
* toss pure/impure code into a salad bowl & mixing is a bad idea
* define borders where pure code meets impure code
--
original image: http://media.nowpublic.net/images//59/4/59455eabd625a15e2afb583dcfbb27ce.jpg
Public Interface

                       Implementation
                     Dependency Calls
* your code can be pure
* public interface is the border, it runs IO, throws exceptions, etc
* existing libraries probably aren’t pure -- many are java after all
Outside World

                        Business Logic
* communicate with clients via HTTP
                                   Data Access
* the most important part -- your code -- make pure*
* perform side-effects like talk to database, read/write files, etc
Impure

                                               Pure
                                          Impure
* “the sandwich” - common pattern in our code
--
original image: http://fastfood.ocregister.com/files/2010/05/ice-cream-sandwich1.jpg
:)
* code has become much more DRY/modular and as a result more unit testable
* concurrent code becomes “simpler” to reason about when pure
* FP makes reasoning about bugs simpler, narrow down cause faster
:(
* scala hardsips: bin. compatability problems, tooling deficiencies, type inference limits
* import scalaz._; import Scalaz._ adds a lot of clutter in the current scope
* lack of docs/related content (in Scala!)
scalaz7
* not currently used in our production systems but one or two of my side projects
* much better for teaching (explicit type class instance usage -- w/o syntax ext.)
* addresses some of the issues we have like importing “the scalaz world”
“SCALE”?
“Human Scale”
* the complexity comments may be FUD, but that does not mean there is not stuff to learn here
* how do we help new employees learn scala & scalaz?
HIRE PEOPLE WHO
                      WANT TO LEARN
* hiring from all backgrounds instead of hiring a “scala or java developer” is much easier
* those people need to be open to exploring and learning new tech/methods
Shared Resources
* easy win, shares effort in finding good resources
* dropbox full of downloaded papers and books purchased by the company
* internal talks available on github
* code review/pull requests
                            LEARN TOGETHER
* face to face discussion on a whiteboard
* team talks on fridays, any one can attend, anyone can talk, neither mandatory
ON YOUR OWN
* RTFC -- in the end it all just code
* apply what you know, this is what really makes you learn it
* internal talks mostly make you aware of it, give you starting point, application is key
ITS NOT ALL OR NOTHING
* focus on understanding a part of the library
* break that part down, use it in the repl in a few cases (w/ a few types, examples, etc)
* as you learn more about each part and then more parts the bigger picture emerges
--
original image: http://www.chicagonow.com/chicago-tough/files/2012/03/chipsallin.jpg
Learn You a
                                                                          ??
* not necessary
* understanding syntax, basics can be useful while learning concepts until scala docs fill out
--
haskell logo: http://www.haskell.org/wikistatic/haskellwiki_logo.png
ASK #scalaz
 FOR HELP
BREAK
                                         RULES
* you may hear things you cannot do, “validation is not a monad”
* ignore and explore yourself -- these are the real learning opportunites
* understand how to implement validation monad and why no error accum. happens
PAYING
                                     UPFRONT
* of course this have some upfront cost
* so does writing tests and similarly a good balance pays off
L3
                             L2
                             L1
                             A3
                                                                           Level
                             A2
                             A1
                                                                            Up
* scalaz covers most advanced features in scala language
* great guide for library and code design (to an extent). Scalaz guys have done serious amount of research in this regard
Thanks!
talk recap slide
SOME RESOURCES
• Atlassian’s Typeclassopedia - http://typeclassopedia.bitbucket.org
• Apocalisp Blog - http://apocalisp.wordpress.com/
• “Functional Programming in Scala” MEAP - http://manning.com/bjarnason/
• Eric Torreborre’s Blog - http://etorreborre.blogspot.com/
• StackMob Engineering Blog - http://www.stackmob.com/category/engineering/
• Learn You a Scalaz (my WIP, about to undergo major rework) -
https://github.com/jrwest/learn-you-a-scalaz

• Chris Marshall’s “Practical Scalaz” Talk - http://skillsmatter.com/podcast/scala/
practical-scalaz-2518

More Related Content

Viewers also liked

building blocks of a scalable webcrawler
building blocks of a scalable webcrawlerbuilding blocks of a scalable webcrawler
building blocks of a scalable webcrawler
Marc Seeger
 
Microservices and functional programming
Microservices and functional programmingMicroservices and functional programming
Microservices and functional programming
Michael Neale
 
Building Micro-Services with Scala
Building Micro-Services with ScalaBuilding Micro-Services with Scala
Building Micro-Services with Scala
Yardena Meymann
 
Web Crawling and Data Gathering with Apache Nutch
Web Crawling and Data Gathering with Apache NutchWeb Crawling and Data Gathering with Apache Nutch
Web Crawling and Data Gathering with Apache Nutch
Steve Watt
 
Shift: Real World Migration from MongoDB to Cassandra
Shift: Real World Migration from MongoDB to CassandraShift: Real World Migration from MongoDB to Cassandra
Shift: Real World Migration from MongoDB to Cassandra
DataStax
 
Building microservices with Scala, functional domain models and Spring Boot
Building microservices with Scala, functional domain models and Spring BootBuilding microservices with Scala, functional domain models and Spring Boot
Building microservices with Scala, functional domain models and Spring Boot
Chris Richardson
 
Resilient Applications with Akka Persistence - Scaladays 2014
Resilient Applications with Akka Persistence - Scaladays 2014Resilient Applications with Akka Persistence - Scaladays 2014
Resilient Applications with Akka Persistence - Scaladays 2014
Björn Antonsson
 
Scala - the good, the bad and the very ugly
Scala - the good, the bad and the very uglyScala - the good, the bad and the very ugly
Scala - the good, the bad and the very ugly
Bozhidar Bozhanov
 
Akka persistence == event sourcing in 30 minutes
Akka persistence == event sourcing in 30 minutesAkka persistence == event sourcing in 30 minutes
Akka persistence == event sourcing in 30 minutes
Konrad Malawski
 
Event-sourced architectures with Akka
Event-sourced architectures with AkkaEvent-sourced architectures with Akka
Event-sourced architectures with Akka
Sander Mak (@Sander_Mak)
 
MongoDB as Message Queue
MongoDB as Message QueueMongoDB as Message Queue
MongoDB as Message Queue
MongoDB
 

Viewers also liked (11)

building blocks of a scalable webcrawler
building blocks of a scalable webcrawlerbuilding blocks of a scalable webcrawler
building blocks of a scalable webcrawler
 
Microservices and functional programming
Microservices and functional programmingMicroservices and functional programming
Microservices and functional programming
 
Building Micro-Services with Scala
Building Micro-Services with ScalaBuilding Micro-Services with Scala
Building Micro-Services with Scala
 
Web Crawling and Data Gathering with Apache Nutch
Web Crawling and Data Gathering with Apache NutchWeb Crawling and Data Gathering with Apache Nutch
Web Crawling and Data Gathering with Apache Nutch
 
Shift: Real World Migration from MongoDB to Cassandra
Shift: Real World Migration from MongoDB to CassandraShift: Real World Migration from MongoDB to Cassandra
Shift: Real World Migration from MongoDB to Cassandra
 
Building microservices with Scala, functional domain models and Spring Boot
Building microservices with Scala, functional domain models and Spring BootBuilding microservices with Scala, functional domain models and Spring Boot
Building microservices with Scala, functional domain models and Spring Boot
 
Resilient Applications with Akka Persistence - Scaladays 2014
Resilient Applications with Akka Persistence - Scaladays 2014Resilient Applications with Akka Persistence - Scaladays 2014
Resilient Applications with Akka Persistence - Scaladays 2014
 
Scala - the good, the bad and the very ugly
Scala - the good, the bad and the very uglyScala - the good, the bad and the very ugly
Scala - the good, the bad and the very ugly
 
Akka persistence == event sourcing in 30 minutes
Akka persistence == event sourcing in 30 minutesAkka persistence == event sourcing in 30 minutes
Akka persistence == event sourcing in 30 minutes
 
Event-sourced architectures with Akka
Event-sourced architectures with AkkaEvent-sourced architectures with Akka
Event-sourced architectures with Akka
 
MongoDB as Message Queue
MongoDB as Message QueueMongoDB as Message Queue
MongoDB as Message Queue
 

Similar to Real World Scalaz

Starting with Scala : Frontier Developer's Meetup December 2010
Starting with Scala : Frontier Developer's Meetup December 2010Starting with Scala : Frontier Developer's Meetup December 2010
Starting with Scala : Frontier Developer's Meetup December 2010
Derek Chen-Becker
 
sbt, history of JSON libraries, microservices, and schema evolution (Tokyo ver)
sbt, history of JSON libraries, microservices, and schema evolution (Tokyo ver)sbt, history of JSON libraries, microservices, and schema evolution (Tokyo ver)
sbt, history of JSON libraries, microservices, and schema evolution (Tokyo ver)
Eugene Yokota
 
Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009
Martin Odersky
 
T3chFest 2016 - The polyglot programmer
T3chFest 2016 - The polyglot programmerT3chFest 2016 - The polyglot programmer
T3chFest 2016 - The polyglot programmer
David Muñoz Díaz
 
BCS SPA 2010 - An Introduction to Scala for Java Developers
BCS SPA 2010 - An Introduction to Scala for Java DevelopersBCS SPA 2010 - An Introduction to Scala for Java Developers
BCS SPA 2010 - An Introduction to Scala for Java DevelopersMiles Sabin
 
An Introduction to Scala for Java Developers
An Introduction to Scala for Java DevelopersAn Introduction to Scala for Java Developers
An Introduction to Scala for Java Developers
Miles Sabin
 
Jugar Introduccion a Scala
Jugar Introduccion a ScalaJugar Introduccion a Scala
Jugar Introduccion a Scala
Socialmetrix
 
The Very ^ 2 Basics of R
The Very ^ 2 Basics of RThe Very ^ 2 Basics of R
The Very ^ 2 Basics of R
Winston Chen
 
RESTful Services
RESTful ServicesRESTful Services
RESTful Services
Kurt Cagle
 
From Java to Parellel Clojure - Clojure South 2019
From Java to Parellel Clojure - Clojure South 2019From Java to Parellel Clojure - Clojure South 2019
From Java to Parellel Clojure - Clojure South 2019
Leonardo Borges
 
JSPP: Morphing C++ into Javascript
JSPP: Morphing C++ into JavascriptJSPP: Morphing C++ into Javascript
JSPP: Morphing C++ into JavascriptChristopher Chedeau
 
Pune Clojure Course Outline
Pune Clojure Course OutlinePune Clojure Course Outline
Pune Clojure Course Outline
Baishampayan Ghose
 
Scala in Places API
Scala in Places APIScala in Places API
Scala in Places API
Łukasz Bałamut
 
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of TonguesChoose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
CHOOSE
 
A Brief Introduction to Scala for Java Developers
A Brief Introduction to Scala for Java DevelopersA Brief Introduction to Scala for Java Developers
A Brief Introduction to Scala for Java Developers
Miles Sabin
 
Miles Sabin Introduction To Scala For Java Developers
Miles Sabin Introduction To Scala For Java DevelopersMiles Sabin Introduction To Scala For Java Developers
Miles Sabin Introduction To Scala For Java DevelopersSkills Matter
 
Scala at GenevaJUG by Iulian Dragos
Scala at GenevaJUG by Iulian DragosScala at GenevaJUG by Iulian Dragos
Scala at GenevaJUG by Iulian Dragos
GenevaJUG
 
ComputeFest 2012: Intro To R for Physical Sciences
ComputeFest 2012: Intro To R for Physical SciencesComputeFest 2012: Intro To R for Physical Sciences
ComputeFest 2012: Intro To R for Physical Sciencesalexstorer
 

Similar to Real World Scalaz (20)

Starting with Scala : Frontier Developer's Meetup December 2010
Starting with Scala : Frontier Developer's Meetup December 2010Starting with Scala : Frontier Developer's Meetup December 2010
Starting with Scala : Frontier Developer's Meetup December 2010
 
sbt, history of JSON libraries, microservices, and schema evolution (Tokyo ver)
sbt, history of JSON libraries, microservices, and schema evolution (Tokyo ver)sbt, history of JSON libraries, microservices, and schema evolution (Tokyo ver)
sbt, history of JSON libraries, microservices, and schema evolution (Tokyo ver)
 
Java
JavaJava
Java
 
Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009
 
T3chFest 2016 - The polyglot programmer
T3chFest 2016 - The polyglot programmerT3chFest 2016 - The polyglot programmer
T3chFest 2016 - The polyglot programmer
 
BCS SPA 2010 - An Introduction to Scala for Java Developers
BCS SPA 2010 - An Introduction to Scala for Java DevelopersBCS SPA 2010 - An Introduction to Scala for Java Developers
BCS SPA 2010 - An Introduction to Scala for Java Developers
 
An Introduction to Scala for Java Developers
An Introduction to Scala for Java DevelopersAn Introduction to Scala for Java Developers
An Introduction to Scala for Java Developers
 
Jugar Introduccion a Scala
Jugar Introduccion a ScalaJugar Introduccion a Scala
Jugar Introduccion a Scala
 
The Very ^ 2 Basics of R
The Very ^ 2 Basics of RThe Very ^ 2 Basics of R
The Very ^ 2 Basics of R
 
RESTful Services
RESTful ServicesRESTful Services
RESTful Services
 
From Java to Parellel Clojure - Clojure South 2019
From Java to Parellel Clojure - Clojure South 2019From Java to Parellel Clojure - Clojure South 2019
From Java to Parellel Clojure - Clojure South 2019
 
JSPP: Morphing C++ into Javascript
JSPP: Morphing C++ into JavascriptJSPP: Morphing C++ into Javascript
JSPP: Morphing C++ into Javascript
 
J
JJ
J
 
Pune Clojure Course Outline
Pune Clojure Course OutlinePune Clojure Course Outline
Pune Clojure Course Outline
 
Scala in Places API
Scala in Places APIScala in Places API
Scala in Places API
 
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of TonguesChoose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
 
A Brief Introduction to Scala for Java Developers
A Brief Introduction to Scala for Java DevelopersA Brief Introduction to Scala for Java Developers
A Brief Introduction to Scala for Java Developers
 
Miles Sabin Introduction To Scala For Java Developers
Miles Sabin Introduction To Scala For Java DevelopersMiles Sabin Introduction To Scala For Java Developers
Miles Sabin Introduction To Scala For Java Developers
 
Scala at GenevaJUG by Iulian Dragos
Scala at GenevaJUG by Iulian DragosScala at GenevaJUG by Iulian Dragos
Scala at GenevaJUG by Iulian Dragos
 
ComputeFest 2012: Intro To R for Physical Sciences
ComputeFest 2012: Intro To R for Physical SciencesComputeFest 2012: Intro To R for Physical Sciences
ComputeFest 2012: Intro To R for Physical Sciences
 

More from Skills Matter Talks

(Oleg zhurakousky)spring integration-scala-intro
(Oleg zhurakousky)spring integration-scala-intro(Oleg zhurakousky)spring integration-scala-intro
(Oleg zhurakousky)spring integration-scala-introSkills Matter Talks
 
SCALA DAYS 2012: Ben Parker on Interactivity - Anti-XML in Anger
SCALA DAYS 2012: Ben Parker on Interactivity - Anti-XML in AngerSCALA DAYS 2012: Ben Parker on Interactivity - Anti-XML in Anger
SCALA DAYS 2012: Ben Parker on Interactivity - Anti-XML in AngerSkills Matter Talks
 
Project kepler compile time metaprogramming for scala
Project kepler compile time metaprogramming for scalaProject kepler compile time metaprogramming for scala
Project kepler compile time metaprogramming for scala
Skills Matter Talks
 
Test driven infrastructure
Test driven infrastructureTest driven infrastructure
Test driven infrastructure
Skills Matter Talks
 
CukeUp! 2012: Michael Nacos on Just enough infrastructure for product develop...
CukeUp! 2012: Michael Nacos on Just enough infrastructure for product develop...CukeUp! 2012: Michael Nacos on Just enough infrastructure for product develop...
CukeUp! 2012: Michael Nacos on Just enough infrastructure for product develop...Skills Matter Talks
 
Prediction suretogowrong
Prediction suretogowrongPrediction suretogowrong
Prediction suretogowrong
Skills Matter Talks
 
Martin sustrik future_of_messaging
Martin sustrik future_of_messagingMartin sustrik future_of_messaging
Martin sustrik future_of_messaging
Skills Matter Talks
 

More from Skills Matter Talks (14)

Couch db skillsmatter-prognosql
Couch db skillsmatter-prognosqlCouch db skillsmatter-prognosql
Couch db skillsmatter-prognosql
 
Zaharia spark-scala-days-2012
Zaharia spark-scala-days-2012Zaharia spark-scala-days-2012
Zaharia spark-scala-days-2012
 
Cnc scala-presentation
Cnc scala-presentationCnc scala-presentation
Cnc scala-presentation
 
Arvindsujeeth scaladays12
Arvindsujeeth scaladays12Arvindsujeeth scaladays12
Arvindsujeeth scaladays12
 
(Oleg zhurakousky)spring integration-scala-intro
(Oleg zhurakousky)spring integration-scala-intro(Oleg zhurakousky)spring integration-scala-intro
(Oleg zhurakousky)spring integration-scala-intro
 
SCALA DAYS 2012: Ben Parker on Interactivity - Anti-XML in Anger
SCALA DAYS 2012: Ben Parker on Interactivity - Anti-XML in AngerSCALA DAYS 2012: Ben Parker on Interactivity - Anti-XML in Anger
SCALA DAYS 2012: Ben Parker on Interactivity - Anti-XML in Anger
 
Scala days mizushima
Scala days mizushimaScala days mizushima
Scala days mizushima
 
Project kepler compile time metaprogramming for scala
Project kepler compile time metaprogramming for scalaProject kepler compile time metaprogramming for scala
Project kepler compile time metaprogramming for scala
 
Test driven infrastructure
Test driven infrastructureTest driven infrastructure
Test driven infrastructure
 
CukeUp! 2012: Michael Nacos on Just enough infrastructure for product develop...
CukeUp! 2012: Michael Nacos on Just enough infrastructure for product develop...CukeUp! 2012: Michael Nacos on Just enough infrastructure for product develop...
CukeUp! 2012: Michael Nacos on Just enough infrastructure for product develop...
 
Prediction suretogowrong
Prediction suretogowrongPrediction suretogowrong
Prediction suretogowrong
 
Tmt predictions 2011
Tmt predictions 2011Tmt predictions 2011
Tmt predictions 2011
 
Martin sustrik future_of_messaging
Martin sustrik future_of_messagingMartin sustrik future_of_messaging
Martin sustrik future_of_messaging
 
Marek pubsubhuddle realtime_web
Marek pubsubhuddle realtime_webMarek pubsubhuddle realtime_web
Marek pubsubhuddle realtime_web
 

Recently uploaded

The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..
UiPathCommunity
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 

Recently uploaded (20)

The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 

Real World Scalaz

  • 1. REAL W⊛RLD SCALAZ http://speakerdeck.com/u/jrwest/p/real-world-scalaz changed talk title (“practical scalaz” by Chris Marshall http://skillsmatter.com/podcast/scala/practical-scalaz-2518)
  • 2. “If you are thinking of using Scalaz, stop now while you still have your sanity" * context: java devs learning scala * source: http://zeroturnaround.com/blog/scala-sink-or-swim-part-1/#scalaz
  • 3. “How does this help you ship features or improve your product?” * context: commenting on the use of lenses * source: https://twitter.com/#!/coda/status/167794305107361796)
  • 4. “It will not immediately help you write better programs that are easy to understand” * hear/read this often * source: http://zeroturnaround.com/blog/scala-sink-or-swim-part-1/#scalaz
  • 5. “There are two types of [libraries]: the ones people hate and the ones nobody uses” - unknown * applies to scala too * know correct attribution? contact me
  • 6. HOW & WHY? * those quotes pretty much boil down to these two questions: * how: apply tools given by scalaz to real world problems? to handle human scale? * why would we choose this solution over other ones?
  • 7. @_jrwest github.com/jrwest blog.loopedstrange.com * a little context before we talk about the “how & why?”
  • 8. I WORK @ * small team, < 15 engineers * many have java bg, but not all, most w/ little to no scala experience * most have oop bg, varying knowledge of FP topics
  • 9. WE USE SCALA { a lot } * 15+ public facing services supported by many other internal modules/libs * most built on netty, also I/O bound * originally java, now > 70% scala
  • 10. libraryDependencies += “org.scalaz” %% “scalaz-core” % “6.0.3” * almost all our services depend on scalaz * usage levels and parts of scalaz used vary among services * blocked on upgrading to 6.0.4 b/c of binary compatibility issues
  • 12. JSON Mapping def Fi leMani def re festJS ad(jso ONR =    ma n: JVa new JS nifest lue) = ONR[ Ap NoId.a p I D= > F field( pplyJS ileMan jsonMa O N( ifest] f i e l d( nifest { )(json change K e y) , ) LogEnt   } ryCach edJson } K e y) * lift-json-scalaz (https://github.com/lift/framework/tree/master/core/json-scalaz) * validationnel applicative, error accumulation = better user-facing errors & debugging * composition
  • 13. S @-@ A / State[S,A] for { mbE   _ xis <- ts   _ man <- <- ife man } y cha stF ife iel nge ile stF d m Log s - ile bEx Ent = p s m ist ryF ath emb s ile er s - pat =? h (pa th, mbE xi sts >| fal se | t rue ) * easy manipulation of highly nested case classes (ex: file manifests) * better implementation hiding * rich libraries (e.g. MapLens, SetLens, & provided state actions)
  • 14. sideEffect.pure[IO] ble ,X] [ Thr owa = { io n NEL in g]) _)) al i dat st [ Str mai n] ( X ]=V : Li mDo y pe V[ s (ke ys [Cu sto  t tch K ey t .fe tch ain ]]) def fe buc ke tom Dom ap ( Cus ke y s.m pti on[   qu e nce ce[ V,O   .se seq uen    (_.   . map      } * can’t guarantee purity, can delineate impurity * examples: storing data in riak, uploading files to s3 and phonegap build svc * composition of IO makes side-effecting code much more reusable
  • 15. Kle ] i sli ] OptionW[A] Tree[A] F[_ [M [_] le[ ,A, Pure[P[_] B] ] ab MAB[M[ _],A,B] ld Bind[Z[ [A] _ ]] ro Fo Ze t[ A] Tra ty Lis ver Identity ] NonEmp p [ A e [T s u Fun [_]] r o ctor mig Appl [F[_] Se y[A[_ ] MA[ M[_ ],A] ]] * we make use of a lot more as well * data structures like Validation and NonEmptyList * most type classes and “enrichments”
  • 16. ITS NOT ALL OR NOTHING * shades of grey, not black and white * scalaz is really many libraries, use the parts you want * we started using “encrichments” and some data structures, grew from there -- original image: http://www.chicagonow.com/chicago-tough/files/2012/03/chipsallin.jpg
  • 17. MAKE BORDERS * don’t abuse scala’s flexibility & power * toss pure/impure code into a salad bowl & mixing is a bad idea * define borders where pure code meets impure code -- original image: http://media.nowpublic.net/images//59/4/59455eabd625a15e2afb583dcfbb27ce.jpg
  • 18. Public Interface Implementation Dependency Calls * your code can be pure * public interface is the border, it runs IO, throws exceptions, etc * existing libraries probably aren’t pure -- many are java after all
  • 19. Outside World Business Logic * communicate with clients via HTTP Data Access * the most important part -- your code -- make pure* * perform side-effects like talk to database, read/write files, etc
  • 20. Impure Pure Impure * “the sandwich” - common pattern in our code -- original image: http://fastfood.ocregister.com/files/2010/05/ice-cream-sandwich1.jpg
  • 21. :) * code has become much more DRY/modular and as a result more unit testable * concurrent code becomes “simpler” to reason about when pure * FP makes reasoning about bugs simpler, narrow down cause faster
  • 22. :( * scala hardsips: bin. compatability problems, tooling deficiencies, type inference limits * import scalaz._; import Scalaz._ adds a lot of clutter in the current scope * lack of docs/related content (in Scala!)
  • 23. scalaz7 * not currently used in our production systems but one or two of my side projects * much better for teaching (explicit type class instance usage -- w/o syntax ext.) * addresses some of the issues we have like importing “the scalaz world”
  • 25. “Human Scale” * the complexity comments may be FUD, but that does not mean there is not stuff to learn here * how do we help new employees learn scala & scalaz?
  • 26. HIRE PEOPLE WHO WANT TO LEARN * hiring from all backgrounds instead of hiring a “scala or java developer” is much easier * those people need to be open to exploring and learning new tech/methods
  • 27. Shared Resources * easy win, shares effort in finding good resources * dropbox full of downloaded papers and books purchased by the company * internal talks available on github
  • 28. * code review/pull requests LEARN TOGETHER * face to face discussion on a whiteboard * team talks on fridays, any one can attend, anyone can talk, neither mandatory
  • 29. ON YOUR OWN * RTFC -- in the end it all just code * apply what you know, this is what really makes you learn it * internal talks mostly make you aware of it, give you starting point, application is key
  • 30. ITS NOT ALL OR NOTHING * focus on understanding a part of the library * break that part down, use it in the repl in a few cases (w/ a few types, examples, etc) * as you learn more about each part and then more parts the bigger picture emerges -- original image: http://www.chicagonow.com/chicago-tough/files/2012/03/chipsallin.jpg
  • 31. Learn You a ?? * not necessary * understanding syntax, basics can be useful while learning concepts until scala docs fill out -- haskell logo: http://www.haskell.org/wikistatic/haskellwiki_logo.png
  • 33. BREAK RULES * you may hear things you cannot do, “validation is not a monad” * ignore and explore yourself -- these are the real learning opportunites * understand how to implement validation monad and why no error accum. happens
  • 34. PAYING UPFRONT * of course this have some upfront cost * so does writing tests and similarly a good balance pays off
  • 35. L3 L2 L1 A3 Level A2 A1 Up * scalaz covers most advanced features in scala language * great guide for library and code design (to an extent). Scalaz guys have done serious amount of research in this regard
  • 37. SOME RESOURCES • Atlassian’s Typeclassopedia - http://typeclassopedia.bitbucket.org • Apocalisp Blog - http://apocalisp.wordpress.com/ • “Functional Programming in Scala” MEAP - http://manning.com/bjarnason/ • Eric Torreborre’s Blog - http://etorreborre.blogspot.com/ • StackMob Engineering Blog - http://www.stackmob.com/category/engineering/ • Learn You a Scalaz (my WIP, about to undergo major rework) - https://github.com/jrwest/learn-you-a-scalaz • Chris Marshall’s “Practical Scalaz” Talk - http://skillsmatter.com/podcast/scala/ practical-scalaz-2518