SlideShare a Scribd company logo
Scala @ TomTomEric Bowmaneric.bowman@tomtom.com26 May 2010
What’s He Building In There?Not just PNDsTraffic ServicesLocation ServicesAddress & Local SearchTons of Data -> Tons of AnalysisDeep Commitment to Server-Side Java2
3
4
5Company Confidential21,345 pages
40 reams of paper
5 laptops
8 keyboards
1 back operation
30,000 strands of hair6
7
Tutorial on Good Lisp Programming Style8“Most algorithms can be characterized as:  Searching (some find find-if mismatch)
  Sorting (sort merge remove-duplicates)
  Filtering (remove remove-if mapcan)
  Mapping (map mapcarmapc)
  Combining (reduce mapcan)
  Counting (count count-if)These functions abstract common control patterns. Code that uses them is:  Concise
  Self-documenting
  Easy to understand
  Often reusable
  Usually efficient”    From Peter Norvig’sTutorial on Good Lisp Programming Style, 1993         (http://www.norvig.com/luv-slides.ps)
But...“Lisp is good for:Exploratory programmingRapid prototypingMinimizing time-to-marketSingle-programmer (or single-digit team) projectsSource-to-source or data-to-data transformation” (ibid.)9
I LikeStatic typesRefactoring ToolsLazy SundaysPaying Some Kid To Cut The GrassSpreadsheetsNot Flying The Plane10
What is this Scala thing?11
Scala Is...An escaped research language from EPFL targeting JVM and CLRObject-oriented and functionalStatically typedLisp, ML, Haskell, Erlang, etc.DSL-friendly12
Bi-Scalar Disorder13
Functional Programming?Functions as first class objectsImmutabilityClosuresBinding free variables to enclosing lexical scope Higher-order Functionsfunctions as input and/or outputA different set of idioms...14
Keep Backfor (int i = 1; i <= 256; i++) {   if (array[i-1] == ...15
LOLCrash16
IdiomsReduce cognitive overheadReduce bugsMake intention clearMini-Patterns17
Java Idioms++C++No more 0xDEADBEEFLeads to lots of loops and copies, if you’re doing it rightHard programs get complex doing common thingsNested loops begin to look Harmful...18
19
For Comprehensionsfor(inti=0; i<100; i++) { ... }for (i <- 0 until 100) { ... /* do something with i */ }(0.until(100)).foreach(i => 			/* something with i */)20
For ComprehensionsLists algorithmic “sweet spot”Syntactic Sugar for:foreachmapfilterflatMap21
The Easy Onesfor (i <- 1 to 6) yield i * 2(1 to 6).map(_ * 2)	(2,4,6,8,10,12)for (i <- 1 to 6 if i % 2 == 0) yield i(1 to 6).filter(_ % 2 == 0)	(2,4,6)for (i <- 1 to 6) { println(i + “ “) }(1 to 6).foreach { i => print(i + “ “) }	1 2 3 4 5 622
A Harder One...List<Integer> array = new ArrayList<Integer>();for (i = 1; i <= 3; i++) {  for (j = i; j <= 3; j++) {array.add(j);  }}System.out.println(array);[1, 2, 3, 2, 3, 3]for (i <- 1 to 3; j <- i to 3) yield j(1, 2, 3, 2, 3, 3)(1 to 3).flatMap(i => (i to 3).map(j => j))   23
flatMapSubtle thing...“Applies the given function f to each element, then concatenates the results”Turns a list of lists into a listList(List(1,2,3), List(4,5,6)).flatMap(x => x)List(1, 2, 3, 4, 5, 6)List(“tom”, “tom”).flatMap(_.capitalize).mkStringTomTom“Special sauce” for nested looping constructs(Equivalent to Haskell’s monadic “bind”)24
IteratorIteratorpackage org.hyperic.sigar.util; public static class IteratorIteratorimplements java.util.Iterator { private java.util.ArrayListiterators; public IteratorIterator() {} public void add(java.util.Iteratoriterator) {} public booleanhasNext() {} public java.lang.Object next() {} 	public void remove() {} }25
flatMapflatMapdef foo(arg: Iterable[Int]) {    ... Do something with arg}val some: Iterable[Int] = getSomeIterablefoo(some)val more: Iterable[Int] = getMorefoo(List(some, more).flatMap(x => x))26
Real-Life Example“mntstamarg”Each term has aliasesNeed all permutations27
Java Versionstatic List<String> aliasReplace(String place) {         String[] bits = nospaces.split(place);         List<String> result = new ArrayList<String>();         List<StringBuilder> allAliases = new ArrayList<StringBuilder>(); for (String bit : bits) {             String[] ales = aliases.get(bit); if (ales != null) { 	            if (allAliases.size() == 0) { allAliases.add(new StringBuilder(bit)); for (String alias : ales) { allAliases.add(new StringBuilder(alias));                     }                 } else {                     List<StringBuilder> clones = new              ArrayList<StringBuilder>(); for (StringBuilder a : allAliases) { clones.add(new StringBuilder(a).append(" ").append(                                 bit)); for (String alias : ales) { clones.add(new StringBuilder(a).append(" ").append(                                     alias));                         }                     } allAliases = clones;                 }             } else { if (allAliases.size() == 0) { allAliases.add(new StringBuilder(bit));                 } else { for (StringBuilder b : allAliases) { b.append(" ").append(bit);                     }                 }             }         } for (StringBuildermunge: allAliases) { result.add(munge.toString());         } return result;     }28
29
Ad

More Related Content

What's hot (20)

Haskell for data science
Haskell for data scienceHaskell for data science
Haskell for data science
John Cant
 
Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”
Platonov Sergey
 
The Design of the Scalaz 8 Effect System
The Design of the Scalaz 8 Effect SystemThe Design of the Scalaz 8 Effect System
The Design of the Scalaz 8 Effect System
John De Goes
 
Euro python2011 High Performance Python
Euro python2011 High Performance PythonEuro python2011 High Performance Python
Euro python2011 High Performance Python
Ian Ozsvald
 
Introduction to functional programming using Ocaml
Introduction to functional programming using OcamlIntroduction to functional programming using Ocaml
Introduction to functional programming using Ocaml
pramode_ce
 
Fun with Kotlin
Fun with KotlinFun with Kotlin
Fun with Kotlin
Egor Andreevich
 
Python 101 language features and functional programming
Python 101 language features and functional programmingPython 101 language features and functional programming
Python 101 language features and functional programming
Lukasz Dynowski
 
GECon2017_Cpp a monster that no one likes but that will outlast them all _Ya...
GECon2017_Cpp  a monster that no one likes but that will outlast them all _Ya...GECon2017_Cpp  a monster that no one likes but that will outlast them all _Ya...
GECon2017_Cpp a monster that no one likes but that will outlast them all _Ya...
GECon_Org Team
 
GECon 2017: C++ - a Monster that no one likes but that will outlast them all
GECon 2017: C++ - a Monster that no one likes but that will outlast them allGECon 2017: C++ - a Monster that no one likes but that will outlast them all
GECon 2017: C++ - a Monster that no one likes but that will outlast them all
Yauheni Akhotnikau
 
A tour of Python
A tour of PythonA tour of Python
A tour of Python
Aleksandar Veselinovic
 
Java Performance Puzzlers
Java Performance PuzzlersJava Performance Puzzlers
Java Performance Puzzlers
Doug Hawkins
 
Orthogonal Functional Architecture
Orthogonal Functional ArchitectureOrthogonal Functional Architecture
Orthogonal Functional Architecture
John De Goes
 
Procedural Programming: It’s Back? It Never Went Away
Procedural Programming: It’s Back? It Never Went AwayProcedural Programming: It’s Back? It Never Went Away
Procedural Programming: It’s Back? It Never Went Away
Kevlin Henney
 
Halogen: Past, Present, and Future
Halogen: Past, Present, and FutureHalogen: Past, Present, and Future
Halogen: Past, Present, and Future
John De Goes
 
Taming Asynchronous Transforms with Interstellar
Taming Asynchronous Transforms with InterstellarTaming Asynchronous Transforms with Interstellar
Taming Asynchronous Transforms with Interstellar
Jens Ravens
 
Quark: A Purely-Functional Scala DSL for Data Processing & Analytics
Quark: A Purely-Functional Scala DSL for Data Processing & AnalyticsQuark: A Purely-Functional Scala DSL for Data Processing & Analytics
Quark: A Purely-Functional Scala DSL for Data Processing & Analytics
John De Goes
 
"Немного о функциональном программирование в JavaScript" Алексей Коваленко
"Немного о функциональном программирование в JavaScript" Алексей Коваленко"Немного о функциональном программирование в JavaScript" Алексей Коваленко
"Немного о функциональном программирование в JavaScript" Алексей Коваленко
Fwdays
 
Sneaking inside Kotlin features
Sneaking inside Kotlin featuresSneaking inside Kotlin features
Sneaking inside Kotlin features
Chandra Sekhar Nayak
 
The Functional Programming Triad of Folding, Scanning and Iteration - a first...
The Functional Programming Triad of Folding, Scanning and Iteration - a first...The Functional Programming Triad of Folding, Scanning and Iteration - a first...
The Functional Programming Triad of Folding, Scanning and Iteration - a first...
Philip Schwarz
 
Lambda выражения и Java 8
Lambda выражения и Java 8Lambda выражения и Java 8
Lambda выражения и Java 8
Alex Tumanoff
 
Haskell for data science
Haskell for data scienceHaskell for data science
Haskell for data science
John Cant
 
Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”
Platonov Sergey
 
The Design of the Scalaz 8 Effect System
The Design of the Scalaz 8 Effect SystemThe Design of the Scalaz 8 Effect System
The Design of the Scalaz 8 Effect System
John De Goes
 
Euro python2011 High Performance Python
Euro python2011 High Performance PythonEuro python2011 High Performance Python
Euro python2011 High Performance Python
Ian Ozsvald
 
Introduction to functional programming using Ocaml
Introduction to functional programming using OcamlIntroduction to functional programming using Ocaml
Introduction to functional programming using Ocaml
pramode_ce
 
Python 101 language features and functional programming
Python 101 language features and functional programmingPython 101 language features and functional programming
Python 101 language features and functional programming
Lukasz Dynowski
 
GECon2017_Cpp a monster that no one likes but that will outlast them all _Ya...
GECon2017_Cpp  a monster that no one likes but that will outlast them all _Ya...GECon2017_Cpp  a monster that no one likes but that will outlast them all _Ya...
GECon2017_Cpp a monster that no one likes but that will outlast them all _Ya...
GECon_Org Team
 
GECon 2017: C++ - a Monster that no one likes but that will outlast them all
GECon 2017: C++ - a Monster that no one likes but that will outlast them allGECon 2017: C++ - a Monster that no one likes but that will outlast them all
GECon 2017: C++ - a Monster that no one likes but that will outlast them all
Yauheni Akhotnikau
 
Java Performance Puzzlers
Java Performance PuzzlersJava Performance Puzzlers
Java Performance Puzzlers
Doug Hawkins
 
Orthogonal Functional Architecture
Orthogonal Functional ArchitectureOrthogonal Functional Architecture
Orthogonal Functional Architecture
John De Goes
 
Procedural Programming: It’s Back? It Never Went Away
Procedural Programming: It’s Back? It Never Went AwayProcedural Programming: It’s Back? It Never Went Away
Procedural Programming: It’s Back? It Never Went Away
Kevlin Henney
 
Halogen: Past, Present, and Future
Halogen: Past, Present, and FutureHalogen: Past, Present, and Future
Halogen: Past, Present, and Future
John De Goes
 
Taming Asynchronous Transforms with Interstellar
Taming Asynchronous Transforms with InterstellarTaming Asynchronous Transforms with Interstellar
Taming Asynchronous Transforms with Interstellar
Jens Ravens
 
Quark: A Purely-Functional Scala DSL for Data Processing & Analytics
Quark: A Purely-Functional Scala DSL for Data Processing & AnalyticsQuark: A Purely-Functional Scala DSL for Data Processing & Analytics
Quark: A Purely-Functional Scala DSL for Data Processing & Analytics
John De Goes
 
"Немного о функциональном программирование в JavaScript" Алексей Коваленко
"Немного о функциональном программирование в JavaScript" Алексей Коваленко"Немного о функциональном программирование в JavaScript" Алексей Коваленко
"Немного о функциональном программирование в JavaScript" Алексей Коваленко
Fwdays
 
The Functional Programming Triad of Folding, Scanning and Iteration - a first...
The Functional Programming Triad of Folding, Scanning and Iteration - a first...The Functional Programming Triad of Folding, Scanning and Iteration - a first...
The Functional Programming Triad of Folding, Scanning and Iteration - a first...
Philip Schwarz
 
Lambda выражения и Java 8
Lambda выражения и Java 8Lambda выражения и Java 8
Lambda выражения и Java 8
Alex Tumanoff
 

Viewers also liked (7)

TomTom Q1 2014 Financial Results
TomTom Q1 2014 Financial ResultsTomTom Q1 2014 Financial Results
TomTom Q1 2014 Financial Results
Ludovic Privat
 
Allan Rasmussen TomTom Maps June 16th 2014 - INSPIRE Conference
Allan Rasmussen TomTom Maps June 16th 2014 - INSPIRE ConferenceAllan Rasmussen TomTom Maps June 16th 2014 - INSPIRE Conference
Allan Rasmussen TomTom Maps June 16th 2014 - INSPIRE Conference
Ludovic Privat
 
Tom Tom
Tom TomTom Tom
Tom Tom
Mohamed Abdulla
 
TOM TOM
TOM TOMTOM TOM
TOM TOM
Alejo Colorado
 
TomTom Presentation.
TomTom Presentation.TomTom Presentation.
TomTom Presentation.
alfiepanda
 
Mba Tomtom merger TeleAtlas
Mba Tomtom merger TeleAtlasMba Tomtom merger TeleAtlas
Mba Tomtom merger TeleAtlas
Roel_Kock
 
TomTom Dynamic Routing
TomTom Dynamic RoutingTomTom Dynamic Routing
TomTom Dynamic Routing
Dr. Heiko Schilling, eMBA
 
TomTom Q1 2014 Financial Results
TomTom Q1 2014 Financial ResultsTomTom Q1 2014 Financial Results
TomTom Q1 2014 Financial Results
Ludovic Privat
 
Allan Rasmussen TomTom Maps June 16th 2014 - INSPIRE Conference
Allan Rasmussen TomTom Maps June 16th 2014 - INSPIRE ConferenceAllan Rasmussen TomTom Maps June 16th 2014 - INSPIRE Conference
Allan Rasmussen TomTom Maps June 16th 2014 - INSPIRE Conference
Ludovic Privat
 
TomTom Presentation.
TomTom Presentation.TomTom Presentation.
TomTom Presentation.
alfiepanda
 
Mba Tomtom merger TeleAtlas
Mba Tomtom merger TeleAtlasMba Tomtom merger TeleAtlas
Mba Tomtom merger TeleAtlas
Roel_Kock
 
Ad

Similar to Scala @ TomTom (20)

Real Time Big Data Management
Real Time Big Data ManagementReal Time Big Data Management
Real Time Big Data Management
Albert Bifet
 
Scala introduction
Scala introductionScala introduction
Scala introduction
Alf Kristian Støyle
 
Scala 2 + 2 > 4
Scala 2 + 2 > 4Scala 2 + 2 > 4
Scala 2 + 2 > 4
Emil Vladev
 
What is new in Java 8
What is new in Java 8What is new in Java 8
What is new in Java 8
Sandeep Kr. Singh
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
Dmitry Buzdin
 
Groovy
GroovyGroovy
Groovy
Zen Urban
 
Introduction To Lisp
Introduction To LispIntroduction To Lisp
Introduction To Lisp
kyleburton
 
Design Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on ExamplesDesign Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on Examples
Ganesh Samarthyam
 
Scala as a Declarative Language
Scala as a Declarative LanguageScala as a Declarative Language
Scala as a Declarative Language
vsssuresh
 
Scala in Places API
Scala in Places APIScala in Places API
Scala in Places API
Łukasz Bałamut
 
SDC - Einführung in Scala
SDC - Einführung in ScalaSDC - Einführung in Scala
SDC - Einführung in Scala
Christian Baranowski
 
Scala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar ProkopecScala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar Prokopec
Loïc Descotte
 
Monadologie
MonadologieMonadologie
Monadologie
league
 
Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)
Jonas Bonér
 
Pragmatic Real-World Scala
Pragmatic Real-World ScalaPragmatic Real-World Scala
Pragmatic Real-World Scala
parag978978
 
JBUG 11 - Scala For Java Programmers
JBUG 11 - Scala For Java ProgrammersJBUG 11 - Scala For Java Programmers
JBUG 11 - Scala For Java Programmers
Tikal Knowledge
 
Introduction to Scalding and Monoids
Introduction to Scalding and MonoidsIntroduction to Scalding and Monoids
Introduction to Scalding and Monoids
Hugo Gävert
 
C++11 - A Change in Style - v2.0
C++11 - A Change in Style - v2.0C++11 - A Change in Style - v2.0
C++11 - A Change in Style - v2.0
Yaser Zhian
 
Clojure basics
Clojure basicsClojure basics
Clojure basics
Knoldus Inc.
 
Spark workshop
Spark workshopSpark workshop
Spark workshop
Wojciech Pituła
 
Real Time Big Data Management
Real Time Big Data ManagementReal Time Big Data Management
Real Time Big Data Management
Albert Bifet
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
Dmitry Buzdin
 
Introduction To Lisp
Introduction To LispIntroduction To Lisp
Introduction To Lisp
kyleburton
 
Design Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on ExamplesDesign Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on Examples
Ganesh Samarthyam
 
Scala as a Declarative Language
Scala as a Declarative LanguageScala as a Declarative Language
Scala as a Declarative Language
vsssuresh
 
Scala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar ProkopecScala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar Prokopec
Loïc Descotte
 
Monadologie
MonadologieMonadologie
Monadologie
league
 
Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)
Jonas Bonér
 
Pragmatic Real-World Scala
Pragmatic Real-World ScalaPragmatic Real-World Scala
Pragmatic Real-World Scala
parag978978
 
JBUG 11 - Scala For Java Programmers
JBUG 11 - Scala For Java ProgrammersJBUG 11 - Scala For Java Programmers
JBUG 11 - Scala For Java Programmers
Tikal Knowledge
 
Introduction to Scalding and Monoids
Introduction to Scalding and MonoidsIntroduction to Scalding and Monoids
Introduction to Scalding and Monoids
Hugo Gävert
 
C++11 - A Change in Style - v2.0
C++11 - A Change in Style - v2.0C++11 - A Change in Style - v2.0
C++11 - A Change in Style - v2.0
Yaser Zhian
 
Ad

Recently uploaded (20)

Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 

Scala @ TomTom

  • 2. What’s He Building In There?Not just PNDsTraffic ServicesLocation ServicesAddress & Local SearchTons of Data -> Tons of AnalysisDeep Commitment to Server-Side Java2
  • 3. 3
  • 4. 4
  • 6. 40 reams of paper
  • 11. 7
  • 12. Tutorial on Good Lisp Programming Style8“Most algorithms can be characterized as: Searching (some find find-if mismatch)
  • 13. Sorting (sort merge remove-duplicates)
  • 14. Filtering (remove remove-if mapcan)
  • 15. Mapping (map mapcarmapc)
  • 16. Combining (reduce mapcan)
  • 17. Counting (count count-if)These functions abstract common control patterns. Code that uses them is: Concise
  • 19. Easy to understand
  • 20. Often reusable
  • 21. Usually efficient” From Peter Norvig’sTutorial on Good Lisp Programming Style, 1993 (http://www.norvig.com/luv-slides.ps)
  • 22. But...“Lisp is good for:Exploratory programmingRapid prototypingMinimizing time-to-marketSingle-programmer (or single-digit team) projectsSource-to-source or data-to-data transformation” (ibid.)9
  • 23. I LikeStatic typesRefactoring ToolsLazy SundaysPaying Some Kid To Cut The GrassSpreadsheetsNot Flying The Plane10
  • 24. What is this Scala thing?11
  • 25. Scala Is...An escaped research language from EPFL targeting JVM and CLRObject-oriented and functionalStatically typedLisp, ML, Haskell, Erlang, etc.DSL-friendly12
  • 27. Functional Programming?Functions as first class objectsImmutabilityClosuresBinding free variables to enclosing lexical scope Higher-order Functionsfunctions as input and/or outputA different set of idioms...14
  • 28. Keep Backfor (int i = 1; i <= 256; i++) { if (array[i-1] == ...15
  • 30. IdiomsReduce cognitive overheadReduce bugsMake intention clearMini-Patterns17
  • 31. Java Idioms++C++No more 0xDEADBEEFLeads to lots of loops and copies, if you’re doing it rightHard programs get complex doing common thingsNested loops begin to look Harmful...18
  • 32. 19
  • 33. For Comprehensionsfor(inti=0; i<100; i++) { ... }for (i <- 0 until 100) { ... /* do something with i */ }(0.until(100)).foreach(i => /* something with i */)20
  • 34. For ComprehensionsLists algorithmic “sweet spot”Syntactic Sugar for:foreachmapfilterflatMap21
  • 35. The Easy Onesfor (i <- 1 to 6) yield i * 2(1 to 6).map(_ * 2) (2,4,6,8,10,12)for (i <- 1 to 6 if i % 2 == 0) yield i(1 to 6).filter(_ % 2 == 0) (2,4,6)for (i <- 1 to 6) { println(i + “ “) }(1 to 6).foreach { i => print(i + “ “) } 1 2 3 4 5 622
  • 36. A Harder One...List<Integer> array = new ArrayList<Integer>();for (i = 1; i <= 3; i++) { for (j = i; j <= 3; j++) {array.add(j); }}System.out.println(array);[1, 2, 3, 2, 3, 3]for (i <- 1 to 3; j <- i to 3) yield j(1, 2, 3, 2, 3, 3)(1 to 3).flatMap(i => (i to 3).map(j => j)) 23
  • 37. flatMapSubtle thing...“Applies the given function f to each element, then concatenates the results”Turns a list of lists into a listList(List(1,2,3), List(4,5,6)).flatMap(x => x)List(1, 2, 3, 4, 5, 6)List(“tom”, “tom”).flatMap(_.capitalize).mkStringTomTom“Special sauce” for nested looping constructs(Equivalent to Haskell’s monadic “bind”)24
  • 38. IteratorIteratorpackage org.hyperic.sigar.util; public static class IteratorIteratorimplements java.util.Iterator { private java.util.ArrayListiterators; public IteratorIterator() {} public void add(java.util.Iteratoriterator) {} public booleanhasNext() {} public java.lang.Object next() {} public void remove() {} }25
  • 39. flatMapflatMapdef foo(arg: Iterable[Int]) { ... Do something with arg}val some: Iterable[Int] = getSomeIterablefoo(some)val more: Iterable[Int] = getMorefoo(List(some, more).flatMap(x => x))26
  • 40. Real-Life Example“mntstamarg”Each term has aliasesNeed all permutations27
  • 41. Java Versionstatic List<String> aliasReplace(String place) { String[] bits = nospaces.split(place); List<String> result = new ArrayList<String>(); List<StringBuilder> allAliases = new ArrayList<StringBuilder>(); for (String bit : bits) { String[] ales = aliases.get(bit); if (ales != null) { if (allAliases.size() == 0) { allAliases.add(new StringBuilder(bit)); for (String alias : ales) { allAliases.add(new StringBuilder(alias)); } } else { List<StringBuilder> clones = new ArrayList<StringBuilder>(); for (StringBuilder a : allAliases) { clones.add(new StringBuilder(a).append(" ").append( bit)); for (String alias : ales) { clones.add(new StringBuilder(a).append(" ").append( alias)); } } allAliases = clones; } } else { if (allAliases.size() == 0) { allAliases.add(new StringBuilder(bit)); } else { for (StringBuilder b : allAliases) { b.append(" ").append(bit); } } } } for (StringBuildermunge: allAliases) { result.add(munge.toString()); } return result; }28
  • 42. 29
  • 43. Scala Versiondef alias(query: String, aliases: String => List[String]): List[String] = { def recurse(prefix: List[String], remainder: List[String]): List[List[String]] = { remainder match { case Nil => prefix :: Nilcase head :: tail => aliases(head).flatMap(term => recurse(term :: prefix, tail)) }recurse(Nil,query.split(“\\s”).toList.reverse).map( _.mkString(“ “))}30
  • 44. 31
  • 45. Yeah yeahyeah but“Perl Whitespace Law” “Each line of perl should be surrounded by whitespace equivalent to what it would take to achieve the same functionality in a normal programming language.” -- Don HopkinsIf it compiles, it nearly works. Really.Visual Plane-Oriented ProgrammingI ♥ Idioms“But in Java, each little part is so very simple...”32
  • 46. 33
  • 48. “Weak developers will move heaven and earth to do the wrong thing. You can’t limit the damage they do by locking up the sharp tools. They’ll just swing the blunt tools harder.” – Glenn Vandenburg35
  • 49. @TomTomTestingMiddleware “Smart Content Switch”We needed it quickly...B2B/B2G Traffic Query EngineClustering AlgorithmDSL Templating EngineContent CleanupNext-Generation Geocoder36
  • 50. How To Sneak It InStart with TestingScalaCheckIS AWESOME.Specs, ScalaTest testing DSLsStart with something low riskOk, well, we didn’t do thatPrepare for steep learning curve...followed by a productivity hockey stick37
  • 51. Another Example8000 lines of broken Java -> 400 lines of broken Scala ->hyp.take(1).flatMap(_.dropDistricts) match { case Nil => hyp case head => {hyp.tail.foldLeft(head) {case (run: List[Hypothesis], h: Hypothesis) => { run.flatMap(_.merge(h)) match { case Nil => run case newRun => newRun.removeDuplicates} } } }}*Includes suggested improvements by Martin Odersky, I hope38
  • 52. TestingFunctional architect wrote a bunch of test cases, like:Requirement R.17:D1 -> N1, L1 -> N1, N1, D2 -> L2, L3, N3, D3 should cluster as (L1,N1,D1), (L2,D2), (L3), (N3), (D3)Vim-macro’d into:it should “satisfy R.17” in { cluster(D1 -> N1,L1 -> N1,N1,D2 -> L2,L3,N3,D3) should equal {groups(group(L1,N1,D1),group(L2,D2),group(L3),group(N3),group(D3)))}39
  • 53. ScalaCheckThe Dog’s BollocksSteep Learning Curveobject BinarySpecification extends Properties(“bin”) { specify(“toBinary”,Prop.forAllNoShrink( for{n <- Gen.choose(0d, 0.99999999d) m <- Gen.choose(20,31) } yield Pair(n, m)) { p => Math.abs(toDecimal(toBinary(p._1, p._2)) – p._1 < 1e-10 })}40
  • 54. So little time...TraitsCase classesPattern matchingStructural typesSelf typesXMLOptionCovariance/Contravariance@specialized41
  • 55. This slide left intentionally blank.