Scala for Rubyists – How I Learned to Stop Worrying and Love the Type – Scala has Rubyicity



Scala for Rubyists – How I Learned to Stop Worrying and Love the Type – Scala has Rubyicity

0 0


Scala-For-Rubyists

A gently talk about Scala for the Ruby-Boulets at Liège (5th July 2013)

On Github andypetrella / Scala-For-Rubyists

Scala for Rubyists

or:

How I Learned to Stop Worrying and Love the Type

Scala has Rubyicity

Object Oriented in Nature
Functional Programming in Heart
Expressive

Object Oriented in Nature

Every thing is an object...

Polymorphism is, of course, encouraged.

But several options are possible.

Functional Programming in Heart

Every thing can be a function (λ-calculus).

Possible, but not mandatory.

OTOH, immutability is more than encouraged!

It is expressive

Forget about statements and embrass expressions.

Describe what to do, not how to do.

Scalaness missing? in Ruby

Strongly typed
How?

Strongly typed

Strongly types means:

allowing interesting stuffs with type

So Scala does...

It's not Java, neither C++

A type can describe

  • Immutable structures
  • Composable Behaviors
  • Facets
  • ... and even more

Immutable Structure

`case class` creates immutable objects

Based on the type, the compiler generates `copy`

Composable Behaviors

Describe what you want to do ...

... and choose how/when to execute it

Facets

Some functionnalities can be dependent of the context

The code can adapt to the context

Old code is not touched: Horizontal extension

Lazy to save the work

By-name parameter: avoid computing
Future: compose without blocking

By-name parameter: avoid computing

Pass a by-name parameter to a function...

... its evaluation will be delayed at its first access

Future: compose without blocking

Declare a computation...

Doens't wait for the result

But react on it...

Monkey Patching and not Cheeatah

Add methods to existing types
Without screwing them

Add methods to existing types

Classes can be pimped with new methods...

... contextually

It's up to the dev's choice!

Do it as less often as possible...

Thanks!

Come @WAJUG too we do love Rubyists