Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Teaching Functional Programming...in a scaleup company

Teaching Functional Programming...in a scaleup company

Do you want to start doing functional programming in your company and do not know how?. Have you started programming at Scala and are overwhelmed with the amount of things that you seem to have to learn?

In this talk, partially presented at Lambda World 2017, we discussed the fundamental aspects to be taken into account in the training and learning of the functional paradigm through the experience of implementing Scala in real projects. We talked about both what worked well and not so well under our point of view. We reviewed some findings, good practices and mistakes that could save you from wasting your time unnecessarily. Finally, we reviewed those books and resources that helped us the most by contrasting them with those that did not work so well.

Juan-José Vázquez

November 09, 2017
Tweet

More Decks by Juan-José Vázquez

Other Decks in Programming

Transcript

  1. 2 J U A N - J O S É

    V Á Z Q U E Z C T O & P A R T N E R @ T E C S I S A Degree in Physics. 18 years working in the software industry as developer, designer and architect. CTO and partner at Tecsisa since 2005. Formerly devoted to OO programming (mainly Java and C#) applied to on-premises applications, since 2014, building a new generation of cloud solutions for the energy sector based on a microservices architecture developed with Scala and using cutting edge technologies as Akka, Cassandra, Kafka and Spark among others. A BIT ABOUT ME @juanjovazquez juanjovazquez juanjovazquez
  2. 3 2005 Consulting services On-premises JavaEE / Spring A LITTLE

    BIT OF HISTORY 2001 Tecsisa was founded Web develoment and e-learning 2014 Kommodo cloud Scala / Akka microservices
  3. 4 CAVEATS I have no abstract algebra or category theory

    background nor come from academia (but i’m catching up quickly!). N O T A F P E X P E R T I arrived to functional programming searching for a better support for concurrency and distributed programming on the JVM to build cloud native applications. FP was a happy (and exciting) finding. F P WA S N O T T H E P R I O R I T Y The learning process was not clean and linear, it was influenced by the vast amount of technologies that we needed to assess and test quickly. The language was one of these challenges but not the only one. TO O M A N Y C H A N G E S AT O N C E
  4. 5 SCALA T H E P R O G R

    A M M I N G L A N G U A G E T H E P O W E R O F T H E J V M & I T S E C O S Y S T E M In a pre-Kotlin era, Scala became the reasonable choice for a better statically typed language on the JVM. A good support for distributed programming did the rest. T O O L A R G E & S T E E P L E A R N I N G C U R V E The huge size of the language, in terms of features, demands a great cognitive effort in the recognition of patterns, idioms and techniques. Without prior experience in doing FP, the first steps might be painful. W H Y N O T H A S K E L L ? Basically for two reasons: maturity of the JVM and (perception of) immaturity of distributed programming in Haskell. T Y P E S Y S T E M & D E C L A R A T I V E P R O G R A M M I N G Although it's not a pure functional language, Scala offers an excellent support for designing DSLs, and doing statically typed declarative programming.
  5. 6 TRAINING THE TEAM 2-3 weeks period of guided self-training

    aimed at learning the Scala basics O N B O A R D I N G Intensive external training on functional programming in Scala F O R M A L T R A I N I N G Follows the `learn by doing` motto. Developers learn from each other by imitation working on real applications D O I N G Reached certain level of proficiency engineers start working on defining and implementing libraries, templates and definition of best practices D E F I N I N G
  6. 7 WHAT WORKED WELL Immutability, referential transparency, ADT’s, structural recursion,

    HOF’s, type classes, lenses, etc. S T I C K TO T H E B A S I C S F O R A P P L I C AT I O N C O D E Generic programming, full category theory, HKT’s, Free structures, extensible effects, mtl style, etc. M O R E A D VA N C E D T E C H N I Q U E S F O R L I B R A R I E S Don’t bring to the table every single piece of machinery that the language or the library provides. Try to narrow the language according to the context and domain you’re working on. Take advantage of constraints, they’ll make you more creative and smart. F O R G E T A L L T H E S T U F F Y O U D O N ’ T N E E D
  7. 8 FINDINGS e.g. referential transparency and types gives you reduction

    of bugs, especially under refactoring; declarative programming improves readability and makes clearer the intention; category theory provides patterns that leads to coherence and reusability, etc. S E L L T H E B E N E F I T S , N O T T H E TO O L S & T E C H N I Q U E S Try to write the best code possible at any time with the knowledge you have at that time, not with the knowledge you would like to have. Don’t push too hard to get there, mastery will come with practice. B E P R A C T I C A L Celebrate your achievements even if they weren’t reached in the most academic way. Believe in yourself. You know more than you think but sometimes you feel what you lack to learn outweighs what you already know. F I G H T A G A I N S T T H E I M P O S TO R S Y N D R O M E
  8. 9 FINDINGS Lightbend Scala vs Typelevel Scala, Cats vs Scalaz,

    types or not types, Haskell vs Scala, Free vs tagless final… don’t fall into this trap that leads you right to procrastination. Learn and apply what is better for your domain, now!. AV O I D H O L Y WA R S A N D R A D I C A L I S M Educate yourself and ask for help if you need it. But remember, the cool guys excel at abstract algebra and FP but still you're the one who better knows your domain, so you're for sure the best for the job. D O N ’ T L E T A N Y O N E T E L L S Y O U H O W TO D O I T FP has a lot of techniques that will always allow you to rewrite your code in a better way in terms of readability, robustness or maintainability. Learn soon when to stop refactoring. T H E B E S T I S T H E E N E M Y O F T H E G O O D
  9. 10 FINDINGS As a technical leader, be sure that your

    team is aware of your improvements. Spread the knowledge and share your learning process. Choose the right task for every member of the team and help them know how to get started. K E E P A PA C E T H AT Y O U R T E A M C A N F O L L O W Take part of the community as a way to share, learn and improve your skills. Encourage your team to do the same and sponsor these initiatives internally. E N C O U R A G E TO PA R T I C I PAT E I N O S S Leverage your domain knowledge to be concrete. That’s a good thing!. Don’t miss the opportunity to be specific in your application code and more abstract in libraries and building blocks. C A R E F U L W I T H T H E L E V E L O F A B S T R A C T I O N
  10. 11 “It is better to fail in originality than to

    succeed in imitation.” H e r m a n M e l v i l l e A BRIEF NOTE ON BOOKS
  11. 12 A TEXTBOOK FOR LIBRARY WRITERS Top-notch content for advanced

    learners. Without prior training on FP, you might spend hours, maybe days, in understanding certain paragraphs. Maybe not the first choice for newcomers. OVERWHELMING BUNCH OF FEATURES If it's your first Scala book, you'll be aware of the vastness of the Scala language (and you'll feel miserable). You will be impatient for reading other books.
  12. 13 PAINLESS FUNCTIONAL PROGRAMMING It reminds the joy of learning

    how to code from scratch but starting from refreshing FP principles. Applied categor y theor y without the drama. THE BEST FIRST SCALA BOOK It narrows the Scala language focusing on those features that allow to write a great application code with a decent level of functional purity.
  13. 14 A delightful reading that emphasizes the FP core principles.

    THE CL ASSIC A fun socratic dialogue about recursion and referential transparency. ESSEN TIAL TOOLSET An amazing set of blog posts and videos on category theory specially tailored for programmers. THE APPROACHABL E WAY OTHER BOOKS THAT HELPED
  14. 15 “I feel like functional programming should be rebranded as

    declarative programming.” G a b r i e l G o n z a l e z Tw i t t e r 2 1 O c t . 2 0 1 7 - h t t p : / / b i t . l y / 2 g B K Y TG
  15. 16 THANKS! L E A R N M O R

    E @juanjovazquez juanjovazquez juanjovazquez