Verizon Labs is home to one of the largest Scala-based functional programming teams in North America, and in this talk Timothy Perrett provides an insight into the work of his infrastructure engineering team, in driving adoption of pure-functional programming in a fortune 15 company: from language education and proliferation within the team, to the specific positives and negatives of purely functional programming, when applied at massive scale
12. EDUCATION.
➤ Evangelize functional programming
benefits to team.
➤ Users initially self-directed learning from
texts and online resources.
➤ Dissemination of techniques from staff
(typically the team lead or coworkers)
➤ Practice. Practice. Practice. Pull requests
provide a path to learn every day.
➤ Internal courses and materials for
learning more advanced FP techniques.
➤ Further practice and experience. Rinse
and repeat :-)
15. HLIST.
➤ It’s THE gateway drug for advanced Scala.
➤ Easy to understand.
➤ Untold numbers of business uses.
➤ One of the most used third-party
construct across our internal eco-system.
61. case GET -> Root / "v1" / "datacenters" / dcname & IsAuthenticated(session) =>
jsonF(Nelson.fetchDatacenterByName(dcname)){ option =>
option match {
case Some(dc) => Ok(dc.asJson)
case None => NotFound(s"datacenter '$dcname' does not exist")
}
}
sorry, there aren’t really ways to simplify this.
protocol specifics
62. case GET -> Root / "v1" / "datacenters" / dcname & IsAuthenticated(session) =>
jsonF(Nelson.fetchDatacenterByName(dcname)){ option =>
option match {
case Some(dc) => Ok(dc.asJson)
case None => NotFound(s"datacenter '$dcname' does not exist")
}
}
sorry, there aren’t really ways to simplify this.
domain function
64. APPLICATION DESIGN.
➤ All your I/O boundaries - from a systems
perspective - should be a Free algebra.
➤ Database access.
➤ Network access.
➤ Any other random things you can’t
sensibly reason about.
➤ Be extremely selective about the edge of
the world.
➤ Understand the semantics of running
your Task.
66. TECHNICAL DEBT
➤ Accept it will happen. Minimization is
the best you can hope for.
➤ Proactively push debt repositories to the
leaves of your system graph.
➤ Libraries are the key battleground in debt
avoidance. Choose wisely.
➤ Be consistent with different library
APIs; this drives adoption and avoids
accidental debt when users do the
unexpected.
68. CHALENGES.
➤ Scala is not a pure FP language.
➤ Ironically a positive and enabling thing
for both beginners, and the business.
➤ Community libraries can be a mixed bag.
➤ Not everyone prioritizes maintaining
binary compatible releases.
➤ Many internal forks to stabilize deps.
➤ GC is a real and present danger.
➤ Ensuring users don’t revert to Java
without the semicolons is a definite and
on-going challenge.
* Both fleshy and technical challenges
* Generally speaking, hiring for Scala
has not been a big issue.
70. WINS.
➤ Doing FP has allowed us to recruit and
retain some brilliant minds.
➤ The application of Free, Cofree, Fix and
other advanced type-level paradigms
make your software easier to refactor, and
cheaper over time.
➤
72. CONCLUSIONS.
➤ Free & Coproduct allow us to build modular, testable, systems from discrete
programs.
➤ Your program has programs.
➤ Running Scala at scale is not zero-cost. Far from it.
➤ You need expertise in the JVM to understand corner cases (happens for Java too).
➤ Purely functional stream programming currently struggles at high-load due
to GC pauses.
➤ Team education is a hard problem.
➤ Don’t hire for quantity. Hire for quality and aptitude.