Functional Programming at Verizon

Post on 17-Jun-2015

841 views 1 download

Tags:

description

An experience report detailing how our team at Verizon used functional programming to build our awesome service platform.

Transcript of Functional Programming at Verizon

Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement.

Functional Programming at Verizon OnCue6th September 2014

Timothy Perrett

Service Architect

2Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement.

Secret project.Formally Intel Media; purchased by Verizon in early 2014.

3Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement.

Completely “green field”.Every conceivable system component was being created from scratch.

4Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement.

Scala Services.Using FP for all platform services from day one.

5Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement.

Challenges.We’ve broken our fair share of eggs making this particular omelet.

6Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement.

Explosion in team size.Engineering group expanded by an order of magnitude within the first year.

7Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement.

Utilize market conditions.Market supply of specific skills is nearly always eclipsed by supply of candidates with strong engineering aptitude.

8Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement.

Every engineer is unique.Engineers are people; not pluggable resources.

Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement. 9

Effort of learning FP

Time in a single language

Ease of learning FP

Time

Eff

ort

Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement. 10

Effort of learning FP

Time in a single language

Ease of learning FP

Time

Eff

ort

Less unlearning;FP more intuitive

Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement. 11

Effort of learning FP

Time in a single language

Ease of learning FP

Time

Eff

ort

Large unlearningperiod; FP “is hard”

12Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement.

Perceived difficulty. “Constant struggle against your own instincts”

Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement. 13

Effort of learning FP

Cost of learning FP vs time in multiple PL paradigms

Time in n-PL Ease of learning FP

14Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement.

Strong teams need both.Embrace change, tackle challenges together.

15Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement.

Distribute team education.Centralized education alone is not enough. Use education, pair programming and team sessions.

16Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement.

Provide space to learn.Be prepared to allow the team to make mistakes, give room to learn and encourage experimentation.

Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement. 17

18Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement.

Libraries can be dangerous.Encouraging reuse across a large team results in inconsistent, lossy abstractions.

19Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement.

Functional core. Imperative API.Internally functional libraries can have optional imperative APIs for easier migration / learning curve.

Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement. 20

val config: Task[Config] = knobs.loadImmutable(Required(FileResource(...))) or knobs.loadImmutable(Required(ClassPathResource(...)))

val connection: Task[Connection] = for { cfg <- config usr <- cfg.require[String]("db.username") pwd <- cfg.require[String]("db.password") prt <- cfg.lookup[String]("db.port") } yield Connection(usr,pwd,port)

Code Example

Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement. 21

import instruments.timer

val taken = timer( name = "time-taken", description = "Time taken to compute Foos")

def thing(x: Bar): Foo = taken.time { // compute Foo }

def thingAsync(x: Bar): Task[Foo] = taken.timeTask(taskComputingFoo)

Code Example

22Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement.

Writing from scratch is a winIf you can: build it. Taylor to your orgs’ needs.

23Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement.

Numerous internal libraries.Monitoring. Configuration. Graph Processing. Logging. Functional RPC system… and many more.

24Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement.

Minimal external dependencies*Scalaz. Scalaz-Stream. Scodec. Shapeless.

*working on the jvm often makes this problematic (log4j, slf4j etc).

25Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement.

Was it worth it?100% yes. Choosing to use functional programming has ultimately eased our lives considerably.

26Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement.

Change is easy.So easy we don’t even notice the daily win.

27Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement.

New and exciting wins the day.Happy teams are productive teams.

28Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement.

We’re hiring!At every level of the stack. Yes, really.

29Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unauthorized persons or third parties except by written agreement.

Q&AThank you for listening.