SlideShare uma empresa Scribd logo
1 de 34
Baixar para ler offline
Feedbacks from the trenches
François ARMAND @fanf42 - 2016-10
?
Who knows...
?
?JdbcTemplate
Who knows...
?
?JdbcTemplate
?
Who knows...
?
Anorm ??
Who knows...
?JdbcTemplate
?
Anorm ?
Squeryl ? ?JdbcTemplate
?
Who knows...
?
Anorm ?
Squeryl ? ?JdbcTemplate
?
?
Who knows...
?
Anorm ?
Squeryl ? ?JdbcTemplate
?
?
SQL?
Who knows...
OBJECT
MAPPING
PURE
SQL
?
Anorm ?
Squeryl ? ?JdbcTemplate
?
?
SQL?
Love SQL ?
Who knows...
Who’s talkin’ for why?
● 10 years of Scala
● CTO @Normation
● Lead-dev on Rudder
● chose Scala 7y ago for Rudder
Continuous Configuration
for Effective ComplianceFrançois ARMAND / @fanf42
● 10 years of Scala
● CTO @Normation
● Lead-dev on Rudder
● chose Scala 7y ago for Rudder
Continuous Configuration
for Effective Compliance
Squeryl
François ARMAND / @fanf42
Who’s talkin’ for why?
● 10 years of Scala
● CTO @Normation
● Lead-dev on Rudder
● chose Scala 7y ago for Rudder
Continuous Configuration
for Effective Compliance
Squeryl
JdbcTemplate
François ARMAND / @fanf42
Who’s talkin’ for why?
But what ?
● 10 years of Scala
● CTO @Normation
● Lead-dev on Rudder
● chose Scala 7y ago for Rudder
Continuous Configuration
for Effective Compliance
Squeryl
JdbcTemplate
François ARMAND / @fanf42
Who’s talkin’ for why?
Slick 3 ?
● Fairly popular, ~ default choice in 2016 for Scala world
● Let’s test it ! ⇒ ported ~ 50% of Rudder code to it.
● Fairly popular, ~ default choice in 2016 for Scala world
● Let’s test it ! ⇒ ported ~ 50% of Rudder code to it.
● Does not work for us :
● Feels magic and ORM-y, with *Surprises*
○ in generated SQL
■ you can’t precisely control it (that’s the point)
○ in performance (using path of least resistance)
■ ex: run-time compilation for EACH request in the path of least resistance
○ with lift embeding type
■ i.e working with Rep[MyClass] in place of MyClass
● An awful lot of boilerplate
Slick 3 ?
Doobie ?
Use Doobie.
It’s GREAT.
Doobie
Use Doobie.
It’s GREAT.
Questions ?
Doobie
Use Doobie.
It’s GREAT.
● A pure functional database access layer for Scala
Doobie
Use Doobie.
It’s GREAT.
● A pure functional database access layer for Scala
● Mapping is a joy (actually make me smile)
Doobie
Use Doobie.
It’s GREAT.
● A pure functional database access layer for Scala
● Mapping is a joy (actually make me smile)
● No surprises :
○ it just works as expected.
○ Performance are ~ raw JDBC.
○ NO JDBC part is beyond reach.
■ Even dirty things about JDBC connection like SQLXML. Or variable number of params.
Doobie
Use Doobie.
It’s GREAT.
● A pure functional database access layer for Scala
● Mapping is a joy (actually make me smile)
● No surprises :
○ it just works as expected.
○ Performance are ~ raw JDBC.
○ NO JDBC part is beyond reach.
■ Even dirty things about JDBC connection like SQLXML. Or variable number of params.
● Rob Norris (@tpolecat) is über nice and helpful
Doobie
Use Doobie.
It’s GREAT.
● A pure functional database access layer for Scala
● Mapping is a joy (actually make me smile)
● No surprises :
○ it just works as expected.
○ Performance are ~ raw JDBC.
○ NO JDBC part is beyond reach.
■ Even dirty things about JDBC connection like SQLXML. Or variable number of params.
● Rob Norris (@tpolecat) is über nice and helpful
● It actually makes me like SQL
○ (it tooks 15 years, and PostgreSQL helps a lot)
Doobie
Use Doobie.
It’s GREAT.
● A pure functional database access layer for Scala
● Mapping is a joy (actually make me smile)
● No surprises :
○ it just works as expected.
○ Performance are ~ raw JDBC.
○ NO JDBC part is beyond reach.
■ Even dirty things about JDBC connection like SQLXML. Or variable number of params.
● Rob Norris (@tpolecat) is über nice and helpful
● It actually makes me like SQL
○ (it tooks 15 years, and PostgreSQL helps a lot)
Doobie
A pure functional database access layer for Scala
● everything is a value
● standard functional programming idioms apply
● Clear separation of concepts
○ (I won’t talk about Free Monad - oups)
Mapping just works. Returns what you want.
Mapping just works. No boilerplate.
Mapping just works. No boilerplate.
Mapping just works. No boilerplate.
Performance (especially in pure FP) matters
● The exact, 50 lines if you want,
SQL queries you want to write.
● PreparedStatement by default.
● Batch updates are given.
● Comparison with JDBC
Rob Norris @tpolecat
(like, he produced working code for SQLXML mapping. At 3 a.m. Just for me)
(OK, 3 a.m for my timezone. But still :)
is
extremely
nice and
helpful
actually
likes SQL
Yes. Really.
Savant word for
“Makes you love SQL -
No surprise, it just works”
Questions ?
The End
Testing mapping in the repl
References
● Book of Doobie : https://tpolecat.github.io/doobie-0.3.0/00-index.html
● Really nice presentation of concepts:
○ SBTB 2015: Rob Norris, Programs as Values: JDBC Programming with Doobie
■ https://www.youtube.com/watch?v=M5MF6M7FHPo
● https://twitter.com/tpolecat
● https://gitter.im/tpolecat/doobie

Mais conteúdo relacionado

Último

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 

Último (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 

Destaque

Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Destaque (20)

Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 

Doobie : Un JDBC fonctionnel qui ne cache pas SQL

  • 1. Feedbacks from the trenches François ARMAND @fanf42 - 2016-10
  • 6. ? Anorm ? Squeryl ? ?JdbcTemplate ? Who knows...
  • 7. ? Anorm ? Squeryl ? ?JdbcTemplate ? ? Who knows...
  • 8. ? Anorm ? Squeryl ? ?JdbcTemplate ? ? SQL? Who knows... OBJECT MAPPING PURE SQL
  • 9. ? Anorm ? Squeryl ? ?JdbcTemplate ? ? SQL? Love SQL ? Who knows...
  • 10. Who’s talkin’ for why? ● 10 years of Scala ● CTO @Normation ● Lead-dev on Rudder ● chose Scala 7y ago for Rudder Continuous Configuration for Effective ComplianceFrançois ARMAND / @fanf42
  • 11. ● 10 years of Scala ● CTO @Normation ● Lead-dev on Rudder ● chose Scala 7y ago for Rudder Continuous Configuration for Effective Compliance Squeryl François ARMAND / @fanf42 Who’s talkin’ for why?
  • 12. ● 10 years of Scala ● CTO @Normation ● Lead-dev on Rudder ● chose Scala 7y ago for Rudder Continuous Configuration for Effective Compliance Squeryl JdbcTemplate François ARMAND / @fanf42 Who’s talkin’ for why?
  • 13. But what ? ● 10 years of Scala ● CTO @Normation ● Lead-dev on Rudder ● chose Scala 7y ago for Rudder Continuous Configuration for Effective Compliance Squeryl JdbcTemplate François ARMAND / @fanf42 Who’s talkin’ for why?
  • 14. Slick 3 ? ● Fairly popular, ~ default choice in 2016 for Scala world ● Let’s test it ! ⇒ ported ~ 50% of Rudder code to it.
  • 15. ● Fairly popular, ~ default choice in 2016 for Scala world ● Let’s test it ! ⇒ ported ~ 50% of Rudder code to it. ● Does not work for us : ● Feels magic and ORM-y, with *Surprises* ○ in generated SQL ■ you can’t precisely control it (that’s the point) ○ in performance (using path of least resistance) ■ ex: run-time compilation for EACH request in the path of least resistance ○ with lift embeding type ■ i.e working with Rep[MyClass] in place of MyClass ● An awful lot of boilerplate Slick 3 ?
  • 19. Use Doobie. It’s GREAT. ● A pure functional database access layer for Scala Doobie
  • 20. Use Doobie. It’s GREAT. ● A pure functional database access layer for Scala ● Mapping is a joy (actually make me smile) Doobie
  • 21. Use Doobie. It’s GREAT. ● A pure functional database access layer for Scala ● Mapping is a joy (actually make me smile) ● No surprises : ○ it just works as expected. ○ Performance are ~ raw JDBC. ○ NO JDBC part is beyond reach. ■ Even dirty things about JDBC connection like SQLXML. Or variable number of params. Doobie
  • 22. Use Doobie. It’s GREAT. ● A pure functional database access layer for Scala ● Mapping is a joy (actually make me smile) ● No surprises : ○ it just works as expected. ○ Performance are ~ raw JDBC. ○ NO JDBC part is beyond reach. ■ Even dirty things about JDBC connection like SQLXML. Or variable number of params. ● Rob Norris (@tpolecat) is über nice and helpful Doobie
  • 23. Use Doobie. It’s GREAT. ● A pure functional database access layer for Scala ● Mapping is a joy (actually make me smile) ● No surprises : ○ it just works as expected. ○ Performance are ~ raw JDBC. ○ NO JDBC part is beyond reach. ■ Even dirty things about JDBC connection like SQLXML. Or variable number of params. ● Rob Norris (@tpolecat) is über nice and helpful ● It actually makes me like SQL ○ (it tooks 15 years, and PostgreSQL helps a lot) Doobie
  • 24. Use Doobie. It’s GREAT. ● A pure functional database access layer for Scala ● Mapping is a joy (actually make me smile) ● No surprises : ○ it just works as expected. ○ Performance are ~ raw JDBC. ○ NO JDBC part is beyond reach. ■ Even dirty things about JDBC connection like SQLXML. Or variable number of params. ● Rob Norris (@tpolecat) is über nice and helpful ● It actually makes me like SQL ○ (it tooks 15 years, and PostgreSQL helps a lot) Doobie
  • 25. A pure functional database access layer for Scala ● everything is a value ● standard functional programming idioms apply ● Clear separation of concepts ○ (I won’t talk about Free Monad - oups)
  • 26. Mapping just works. Returns what you want.
  • 27. Mapping just works. No boilerplate.
  • 28. Mapping just works. No boilerplate.
  • 29. Mapping just works. No boilerplate.
  • 30. Performance (especially in pure FP) matters ● The exact, 50 lines if you want, SQL queries you want to write. ● PreparedStatement by default. ● Batch updates are given. ● Comparison with JDBC
  • 31. Rob Norris @tpolecat (like, he produced working code for SQLXML mapping. At 3 a.m. Just for me) (OK, 3 a.m for my timezone. But still :) is extremely nice and helpful actually likes SQL
  • 32. Yes. Really. Savant word for “Makes you love SQL - No surprise, it just works” Questions ? The End
  • 33. Testing mapping in the repl
  • 34. References ● Book of Doobie : https://tpolecat.github.io/doobie-0.3.0/00-index.html ● Really nice presentation of concepts: ○ SBTB 2015: Rob Norris, Programs as Values: JDBC Programming with Doobie ■ https://www.youtube.com/watch?v=M5MF6M7FHPo ● https://twitter.com/tpolecat ● https://gitter.im/tpolecat/doobie