Functional Programming at Verizon

29
Confidential and proprietary materials for authorized Verizon personnel and outside agencies only. Use, disclosure or distribution of this material is not permitted to any unautho Functional Programming at Verizon OnCue 6 th September 2014 Timothy Perrett Service Architect

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

Page 1: 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

Page 2: Functional Programming at Verizon

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.

Page 3: Functional Programming at Verizon

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.

Page 4: Functional Programming at Verizon

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.

Page 5: Functional Programming at Verizon

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.

Page 6: Functional Programming at Verizon

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.

Page 7: Functional Programming at Verizon

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.

Page 8: Functional Programming at Verizon

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.

Page 9: 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. 9

Effort of learning FP

Time in a single language

Ease of learning FP

Time

Eff

ort

Page 10: 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. 10

Effort of learning FP

Time in a single language

Ease of learning FP

Time

Eff

ort

Less unlearning;FP more intuitive

Page 11: 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. 11

Effort of learning FP

Time in a single language

Ease of learning FP

Time

Eff

ort

Large unlearningperiod; FP “is hard”

Page 12: Functional Programming at Verizon

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”

Page 13: 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. 13

Effort of learning FP

Cost of learning FP vs time in multiple PL paradigms

Time in n-PL Ease of learning FP

Page 14: Functional Programming at Verizon

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.

Page 15: Functional Programming at Verizon

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.

Page 16: Functional Programming at Verizon

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.

Page 17: 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. 17

Page 18: Functional Programming at Verizon

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.

Page 19: Functional Programming at Verizon

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.

Page 20: 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. 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

Page 21: 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. 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

Page 22: Functional Programming at Verizon

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.

Page 23: Functional Programming at Verizon

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.

Page 24: Functional Programming at Verizon

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).

Page 25: Functional Programming at Verizon

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.

Page 26: Functional Programming at Verizon

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.

Page 27: Functional Programming at Verizon

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.

Page 28: Functional Programming at Verizon

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.

Page 29: Functional Programming at Verizon

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.