Why you should (not) use Scala in your project

Ola Kunysz & Konrad Zdanowicz

Wrocław Nov 23rd 2016

What is Scala

http://vasnake.blogspot.com/2016/03/functional-programming-principles-in.html

You already know that well

Scala in a nutshell

  • dynamic typing?
  • weak typing?

Scala REPL

http://www.slideshare.net/sagiedavidovich/scala-2013-review-16169814

Case class is your friend

Pattern matching

http://www.slideshare.net/czechscala/scala-essentials-pattern-matching-and-case-classes

  • Lambdas
  • Currying, higher order functions
  • Immutable collections
  • Rich collections API
  • flatMap everything
    • Option, Future, Either, Seq...

Lots of cool things you already know

Lots of not so common concepts you will like

 

  • For-comprehensions
  • Type classes
  • Streams, lazy structures
  • Implicits

Functional programming

Scala peregrination:

science => business

 

 

def learnNew(style:Paradigm = Paradigm("imperative"))

Functional programming in underground since 50s,

now brought to mainstream

by Scala

Why do I care?

Where is Scala today?

https://en.wikipedia.org/wiki/Hype_cycle

Now

Koryto rozczarowania

* hype boom

* reflection - did we really need Scala?!

* way easier when you have a mentor

What you may not like

no backwards compatibility

 

 

Tooling: Compile time, not perfect IDE support and integration

Learning curve

Not foolproof?

Lack of enough experience in the industry

Job security patterns (even unintentional)

You'll feel you don't know a thing

but then you accept it and the life is easier when the expectations are lower

Compile time

https://simonjgrey.wordpress.com

Conversations about category theory

Community?

A2*/L1** Scala dev

Being good enough

* Level A2: Intermediate application programmer

** Level L1: Junior library designer

  • [Simplic, Flexibil, Scalabil]+ ity
  • REPL
  • One class != one file (?)
  • No NPE!*
  • Defensive programming done for you

You will like

You will not need design patterns

16 out of the 23 design patterns found in the GOF book are invisible or simpler in dynamic languages

Builder

Singleton

Dependency injection 

Cake pattern

  • algorithm pattern
  • decorator pattern
  • strategy pattern
  • adapter pattern
  • ???

Not enough?

You get that all thanks to the function being an ordinary value  

Who said Scala cannot duck type?

You will need

Style consistency

and discipline

Good inter-team communication

Scala is dead

It sucks

 good CR/QA automated process

 

software engineering fundamentals

 

FP feeling

Good mentor

The most elegant code

 is useless

if it’s not maintainable.

Now you choose 

Our applications are no longer simple forms sitting in front of database tables,

they’re invaluable tools that help us

get shit done in our daily lives.

 

Good Scala applications

  • middleware services
  • telecom (Erlang roots)
  • data processing (Scala is the new Cobol?)
  • stateless (high-traffic) web services
  • *machine learning (need your opinion)
  • developing Scala compiler :)

Less good Scala applications

  • MVPs, proof of concepts (unless you sleep talk Scala)
  • enterprise projects with a limited control
  • mental legacyness environment
  • simple CRUDs

Bad Scala applications?

Interesting Scala applications

  • Scala.JS
  • Android?
  • Native?

Scala for Java developer

  • http://javatoscala.com/
  • Scala has variables too
  • Scala is compatible with Java libraries
  • builtin Java->Scala converters for collections
  • OO in Scala is like Java but cooler
    • traits
    • multiple inheritance
    • objects, classes, case classes

Java 8 > Scala

You don't need Scala, when all you care is:

  • Arrow functions
  • functional interface for collections
  • compiler and static type check
  • options, futures

FP in Java 8 is fun, limited and noisy,

but still possible and fun

Anybody with Java 8 and Scala exp can relate?

- me

PHP/NodeJS/Python/Ruby -> Scala

  • Mind shift towards the static typing
  • Less tests needed to make sure the code works
  • *Native* multithreading is a breeze
  • Play! is your Rails, Spray is your Express
  • Syntax is easier than it may seem

Enterprise -> Scala?

  • Mainstream languages development converges into better functional programming support

time

programming languages support for FP

pure FP

Scala

Java

Where is your language?

JavaScript

recently introduced classes!

20% of Scala features

The rest 80% of Scala features I don't understand

Scala code I see in real projects chart

Scala is not a functional programming language only

Scala is

Scala is so much more

when you notice its OO support

https://www.coursera.org/specializations/scala

 

Programming in Scala (Odersky, Spoon, and Venners)

 

Functional Programming in Scala ( Chiusano and Bjarnason)

 

Learn You a Haskell  http://learnyouahaskell.com

 

Transitioning to Scala
https://medium.com/@kvnwbbr/transitioning-to-scala-d1818f25b2b7

5 years of Scala and counting...
http://manuel.bernhardt.io/2015/11/13/5-years-of-scala-and-counting-debunking-some-myths-about-the-language-and-its-environment

 

We recommend:

Thank you

Why you should (not) use Scala on production

By Ola Kunysz

Why you should (not) use Scala on production

  • 2,035