SlideShare a Scribd company logo
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.Doobie
● A pure functional, principled database access layer for Scala
Use Doobie.
It’s GREAT.Doobie
● A pure functional, principled database access layer for Scala
● Mapping is a joy (actually make me smile)
Use Doobie.
It’s GREAT.Doobie
● A pure functional, principled database access layer for Scala
● Mapping is a joy (actually make me smile)
● No surprises - particularly in performances and optimization
Use Doobie.
It’s GREAT.Doobie
● A pure functional, principled database access layer for Scala
● Mapping is a joy (actually make me smile)
● No surprises - particularly in performances and optimization
● Rob Norris (@tpolecat) is über nice and helpful
Use Doobie.
It’s GREAT.Doobie
● A pure functional, principled database access layer for Scala
● Mapping is a joy (actually make me smile)
● No surprises - particularly in performances and optimization
● Rob Norris (@tpolecat) is über nice and helpful
● It actually makes me like SQL
○ (it tooks 15 years, and PostgreSQL helps a lot)
Use Doobie.
It’s GREAT.
● A pure functional, principled database access layer for Scala
● Mapping is a joy (actually make me smile)
● No surprises - particularly in performances and optimization
● 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 principled 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. No boilerplate.
Mapping just works. No boilerplate.
Mapping just works. No boilerplate.
Mapping just works. No boilerplate.
Mapping just works. No boilerplate.
Mapping just works. Returns what you want.
No surprises - Sane (performant) defaults
● 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
Update 0.4.0: rainbows and wonders
● Fragments
○ https://tpolecat.github.io/doobie-scalaz-0.4.0/08-Fragments.html
○ Doobie 0.4.0 add fragments, which allows to safely build and factor out part of requests
(typically: “select column1, …, column42 in the_table”)
● Logging
○ https://tpolecat.github.io/doobie-scalaz-0.4.0/10-Logging.html
○ Allows to log queries… based on conditions ! Plus, access to full, fine grained timing.
■ “only the one for which you get an error from Database”
■ Or “all the queries taking more than 200ms” !
○ über easy to connect with your logging framework
● Cats or Scalaz
○ now, you can choose!
Yes. Really.
Savant word for
“Makes you love SQL -
No surprise, it just works”
Questions ?
The End
References
● Book of Doobie : https://tpolecat.github.io/doobie-0.3.0/00-index.html
● Really nice presentation of concepts and use of Free Monad:
○ 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
● The faq is pretty cool: https://tpolecat.github.io/doobie-0.3.0/15-FAQ.html (“in”
clause, outer join, pure SQL strings and more)
● Rudder is full of examples, feel free to read files (importing Doobie) in:
https://github.com/Normation/rudder/tree/branches/rudder/4.0/rudder-core/src/
main/scala/com/normation/rudder/repository/jdbc
Question: testing mapping in the repl ?
This is integrated with
testing frameworks, in
particular scalacheck
Question: more typed, safer queries ?
● Some things are coming in Doobie 0.4.0 !
○ but nothing is fixed for now
○ [update] Actually, was reported post 0.4.0
● I sum-up all the feedback/ideas I get at Scala.io 2016
here: https://github.com/tpolecat/doobie/issues/375
Question: variables number or parameters?
How I deal with a query whose number of parameter is know at runtime ?
Doobie has several level of API:
● sql””” …. “”” : the simplest, but also the less flexible
● Query/Query0: give a return type, a type for parameters, and a string for query: allows to build
queries by string concatenation (ideal for porting from JDBC)
● HC: “high interface”: allows to add parameter by index, “à la” JDBC, but typed.
○ full, complexe example on next page that adapt a query at runtime based on user
parameters, and use HC
● and a low level interface, where all JDBC ugliness is exposed
Question: variables number or parameters?
} Request depends of
parameters of the
function
Query is a pure string
built with concatenation
Dynamically set
parameters
with HPS & HC
Question: retrieving variable depths of
dependent objects?
One big question in data persistance layer is to manage the depth in the dependency graph of
object you are going to retrieve. Typically, with an employee having a property “manager”, which is
an ID in DB but also (of course) an employee, how I manage to get only the first employee with the
manager ID ? The first employee with the full employee manager ? And his manager ?
Rob Norris gave a super talk exactly on that subject at ScalaWorld 2016:
● “Pure Functional Database Programming with Fixpoint Types “
○ slides: http://tpolecat.github.io/presentations/sw2016/slides.html#1
○ video: https://www.youtube.com/watch?v=7xSfLPD6tiQ
License
This work is licensed under a Creative Commons
Attribution-NonCommercial-ShareAlike 4.0 International License.
http://www.slideshare.net/normation

More Related Content

More from RUDDER

What happened in RUDDER in 2018 and what’s next?
What happened in RUDDER in 2018 and what’s next?What happened in RUDDER in 2018 and what’s next?
What happened in RUDDER in 2018 and what’s next?
RUDDER
 
What is RUDDER and when should I use it?
What is RUDDER and when should I use it?What is RUDDER and when should I use it?
What is RUDDER and when should I use it?
RUDDER
 
Fosdem - Configurations do you prove yours?
Fosdem - Configurations  do you prove yours?Fosdem - Configurations  do you prove yours?
Fosdem - Configurations do you prove yours?
RUDDER
 
L'audit en continu : clé de la conformité démontrable (#POSS 2018)
L'audit en continu : clé de la conformité démontrable (#POSS 2018)L'audit en continu : clé de la conformité démontrable (#POSS 2018)
L'audit en continu : clé de la conformité démontrable (#POSS 2018)
RUDDER
 
Fiabilité et conformité continues en production avec Rudder (#BBOOST 2018)
Fiabilité et conformité continues en production avec Rudder (#BBOOST 2018)Fiabilité et conformité continues en production avec Rudder (#BBOOST 2018)
Fiabilité et conformité continues en production avec Rudder (#BBOOST 2018)
RUDDER
 
Stay up - voyage d'un éditeur de logiciels libres
Stay up - voyage d'un éditeur de logiciels libresStay up - voyage d'un éditeur de logiciels libres
Stay up - voyage d'un éditeur de logiciels libres
RUDDER
 
How we scaled Rudder to 10k, and the road to 50k
How we scaled Rudder to 10k, and the road to 50kHow we scaled Rudder to 10k, and the road to 50k
How we scaled Rudder to 10k, and the road to 50k
RUDDER
 
What's new and what's next in Rudder
What's new and what's next in RudderWhat's new and what's next in Rudder
What's new and what's next in Rudder
RUDDER
 
Poss 2017 : gestion des configurations et mise en conformité chez un service ...
Poss 2017 : gestion des configurations et mise en conformité chez un service ...Poss 2017 : gestion des configurations et mise en conformité chez un service ...
Poss 2017 : gestion des configurations et mise en conformité chez un service ...
RUDDER
 
Poss 2017 - la continuité, arme secrète de la gestion du si - cas concret de ...
Poss 2017 - la continuité, arme secrète de la gestion du si - cas concret de ...Poss 2017 - la continuité, arme secrète de la gestion du si - cas concret de ...
Poss 2017 - la continuité, arme secrète de la gestion du si - cas concret de ...
RUDDER
 
POSS 2017 : Comment automatiser son infrastructure quand... on a pas le temps...
POSS 2017 : Comment automatiser son infrastructure quand... on a pas le temps...POSS 2017 : Comment automatiser son infrastructure quand... on a pas le temps...
POSS 2017 : Comment automatiser son infrastructure quand... on a pas le temps...
RUDDER
 
DevOps D-Day 2017 - Gestion des configurations et mise en conformité chez un ...
DevOps D-Day 2017 - Gestion des configurations et mise en conformité chez un ...DevOps D-Day 2017 - Gestion des configurations et mise en conformité chez un ...
DevOps D-Day 2017 - Gestion des configurations et mise en conformité chez un ...
RUDDER
 
RUDDER - Continuous Configuration (configuration management + continuous aud...
 RUDDER - Continuous Configuration (configuration management + continuous aud... RUDDER - Continuous Configuration (configuration management + continuous aud...
RUDDER - Continuous Configuration (configuration management + continuous aud...
RUDDER
 
RUDDER - Continuous Configuration (configuration management + continuous audi...
RUDDER - Continuous Configuration (configuration management + continuous audi...RUDDER - Continuous Configuration (configuration management + continuous audi...
RUDDER - Continuous Configuration (configuration management + continuous audi...
RUDDER
 
OSIS 2017 - Scala REX dans Rudder
OSIS 2017 - Scala REX dans Rudder OSIS 2017 - Scala REX dans Rudder
OSIS 2017 - Scala REX dans Rudder
RUDDER
 
Automating the manual - feedback on including existing systems in configurati...
Automating the manual - feedback on including existing systems in configurati...Automating the manual - feedback on including existing systems in configurati...
Automating the manual - feedback on including existing systems in configurati...
RUDDER
 
Getting data into Rudder
Getting data into RudderGetting data into Rudder
Getting data into Rudder
RUDDER
 
Automate your automation with Rudder’s API! \o/
Automate your automation with Rudder’s API! \o/Automate your automation with Rudder’s API! \o/
Automate your automation with Rudder’s API! \o/
RUDDER
 
Rudder: what's new and what's next? Roadmap, vision and thoughts
Rudder: what's new and what's next? Roadmap, vision and thoughtsRudder: what's new and what's next? Roadmap, vision and thoughts
Rudder: what's new and what's next? Roadmap, vision and thoughts
RUDDER
 
O'Reilly Security - Continuous Auditing For Effective Compliance with Rudder
O'Reilly Security - Continuous Auditing For Effective Compliance with RudderO'Reilly Security - Continuous Auditing For Effective Compliance with Rudder
O'Reilly Security - Continuous Auditing For Effective Compliance with Rudder
RUDDER
 

More from RUDDER (20)

What happened in RUDDER in 2018 and what’s next?
What happened in RUDDER in 2018 and what’s next?What happened in RUDDER in 2018 and what’s next?
What happened in RUDDER in 2018 and what’s next?
 
What is RUDDER and when should I use it?
What is RUDDER and when should I use it?What is RUDDER and when should I use it?
What is RUDDER and when should I use it?
 
Fosdem - Configurations do you prove yours?
Fosdem - Configurations  do you prove yours?Fosdem - Configurations  do you prove yours?
Fosdem - Configurations do you prove yours?
 
L'audit en continu : clé de la conformité démontrable (#POSS 2018)
L'audit en continu : clé de la conformité démontrable (#POSS 2018)L'audit en continu : clé de la conformité démontrable (#POSS 2018)
L'audit en continu : clé de la conformité démontrable (#POSS 2018)
 
Fiabilité et conformité continues en production avec Rudder (#BBOOST 2018)
Fiabilité et conformité continues en production avec Rudder (#BBOOST 2018)Fiabilité et conformité continues en production avec Rudder (#BBOOST 2018)
Fiabilité et conformité continues en production avec Rudder (#BBOOST 2018)
 
Stay up - voyage d'un éditeur de logiciels libres
Stay up - voyage d'un éditeur de logiciels libresStay up - voyage d'un éditeur de logiciels libres
Stay up - voyage d'un éditeur de logiciels libres
 
How we scaled Rudder to 10k, and the road to 50k
How we scaled Rudder to 10k, and the road to 50kHow we scaled Rudder to 10k, and the road to 50k
How we scaled Rudder to 10k, and the road to 50k
 
What's new and what's next in Rudder
What's new and what's next in RudderWhat's new and what's next in Rudder
What's new and what's next in Rudder
 
Poss 2017 : gestion des configurations et mise en conformité chez un service ...
Poss 2017 : gestion des configurations et mise en conformité chez un service ...Poss 2017 : gestion des configurations et mise en conformité chez un service ...
Poss 2017 : gestion des configurations et mise en conformité chez un service ...
 
Poss 2017 - la continuité, arme secrète de la gestion du si - cas concret de ...
Poss 2017 - la continuité, arme secrète de la gestion du si - cas concret de ...Poss 2017 - la continuité, arme secrète de la gestion du si - cas concret de ...
Poss 2017 - la continuité, arme secrète de la gestion du si - cas concret de ...
 
POSS 2017 : Comment automatiser son infrastructure quand... on a pas le temps...
POSS 2017 : Comment automatiser son infrastructure quand... on a pas le temps...POSS 2017 : Comment automatiser son infrastructure quand... on a pas le temps...
POSS 2017 : Comment automatiser son infrastructure quand... on a pas le temps...
 
DevOps D-Day 2017 - Gestion des configurations et mise en conformité chez un ...
DevOps D-Day 2017 - Gestion des configurations et mise en conformité chez un ...DevOps D-Day 2017 - Gestion des configurations et mise en conformité chez un ...
DevOps D-Day 2017 - Gestion des configurations et mise en conformité chez un ...
 
RUDDER - Continuous Configuration (configuration management + continuous aud...
 RUDDER - Continuous Configuration (configuration management + continuous aud... RUDDER - Continuous Configuration (configuration management + continuous aud...
RUDDER - Continuous Configuration (configuration management + continuous aud...
 
RUDDER - Continuous Configuration (configuration management + continuous audi...
RUDDER - Continuous Configuration (configuration management + continuous audi...RUDDER - Continuous Configuration (configuration management + continuous audi...
RUDDER - Continuous Configuration (configuration management + continuous audi...
 
OSIS 2017 - Scala REX dans Rudder
OSIS 2017 - Scala REX dans Rudder OSIS 2017 - Scala REX dans Rudder
OSIS 2017 - Scala REX dans Rudder
 
Automating the manual - feedback on including existing systems in configurati...
Automating the manual - feedback on including existing systems in configurati...Automating the manual - feedback on including existing systems in configurati...
Automating the manual - feedback on including existing systems in configurati...
 
Getting data into Rudder
Getting data into RudderGetting data into Rudder
Getting data into Rudder
 
Automate your automation with Rudder’s API! \o/
Automate your automation with Rudder’s API! \o/Automate your automation with Rudder’s API! \o/
Automate your automation with Rudder’s API! \o/
 
Rudder: what's new and what's next? Roadmap, vision and thoughts
Rudder: what's new and what's next? Roadmap, vision and thoughtsRudder: what's new and what's next? Roadmap, vision and thoughts
Rudder: what's new and what's next? Roadmap, vision and thoughts
 
O'Reilly Security - Continuous Auditing For Effective Compliance with Rudder
O'Reilly Security - Continuous Auditing For Effective Compliance with RudderO'Reilly Security - Continuous Auditing For Effective Compliance with Rudder
O'Reilly Security - Continuous Auditing For Effective Compliance with Rudder
 

Recently uploaded

Russian Girls Call Mumbai 🛵🚡9833363713 💃 Choose Best And Top Girl Service And...
Russian Girls Call Mumbai 🛵🚡9833363713 💃 Choose Best And Top Girl Service And...Russian Girls Call Mumbai 🛵🚡9833363713 💃 Choose Best And Top Girl Service And...
Russian Girls Call Mumbai 🛵🚡9833363713 💃 Choose Best And Top Girl Service And...
dream girl
 
Russian Girls Call Mumbai 🎈🔥9930687706 🔥💋🎈 Provide Best And Top Girl Service ...
Russian Girls Call Mumbai 🎈🔥9930687706 🔥💋🎈 Provide Best And Top Girl Service ...Russian Girls Call Mumbai 🎈🔥9930687706 🔥💋🎈 Provide Best And Top Girl Service ...
Russian Girls Call Mumbai 🎈🔥9930687706 🔥💋🎈 Provide Best And Top Girl Service ...
shanihomely
 
AI - Your Startup Sidekick (Leveraging AI to Bootstrap a Lean Startup).pdf
AI - Your Startup Sidekick (Leveraging AI to Bootstrap a Lean Startup).pdfAI - Your Startup Sidekick (Leveraging AI to Bootstrap a Lean Startup).pdf
AI - Your Startup Sidekick (Leveraging AI to Bootstrap a Lean Startup).pdf
Daniel Zivkovic
 
How to Secure Your Kubernetes Software Supply Chain at Scale
How to Secure Your Kubernetes Software Supply Chain at ScaleHow to Secure Your Kubernetes Software Supply Chain at Scale
How to Secure Your Kubernetes Software Supply Chain at Scale
Anchore
 
Authentication Review-June -2024 AP & TS.pptx
Authentication Review-June -2024 AP & TS.pptxAuthentication Review-June -2024 AP & TS.pptx
Authentication Review-June -2024 AP & TS.pptx
DEMONDUOS
 
SEO Cheat Sheet with Learning Resources by Balti Bloggers.pdf
SEO Cheat Sheet with Learning Resources by Balti Bloggers.pdfSEO Cheat Sheet with Learning Resources by Balti Bloggers.pdf
SEO Cheat Sheet with Learning Resources by Balti Bloggers.pdf
Balti Bloggers
 
Test Polarity: Detecting Positive and Negative Tests (FSE 2024)
Test Polarity: Detecting Positive and Negative Tests (FSE 2024)Test Polarity: Detecting Positive and Negative Tests (FSE 2024)
Test Polarity: Detecting Positive and Negative Tests (FSE 2024)
andrehoraa
 
Old Tools, New Tricks: Unleashing the Power of Time-Tested Testing Tools
Old Tools, New Tricks: Unleashing the Power of Time-Tested Testing ToolsOld Tools, New Tricks: Unleashing the Power of Time-Tested Testing Tools
Old Tools, New Tricks: Unleashing the Power of Time-Tested Testing Tools
Benjamin Bischoff
 
SAP implementation steps PDF - Zyple Software
SAP implementation steps PDF - Zyple SoftwareSAP implementation steps PDF - Zyple Software
SAP implementation steps PDF - Zyple Software
Zyple Software
 
03. Ruby Variables & Regex - Ruby Core Teaching
03. Ruby Variables & Regex - Ruby Core Teaching03. Ruby Variables & Regex - Ruby Core Teaching
03. Ruby Variables & Regex - Ruby Core Teaching
quanhoangd129
 
BATber53 AWS Modernize your applications with purpose-built AWS databases
BATber53 AWS Modernize your applications with purpose-built AWS databasesBATber53 AWS Modernize your applications with purpose-built AWS databases
BATber53 AWS Modernize your applications with purpose-built AWS databases
BATbern
 
🚂🚘 Premium Girls Call Ranchi 🛵🚡000XX00000 💃 Choose Best And Top Girl Service...
🚂🚘 Premium Girls Call Ranchi  🛵🚡000XX00000 💃 Choose Best And Top Girl Service...🚂🚘 Premium Girls Call Ranchi  🛵🚡000XX00000 💃 Choose Best And Top Girl Service...
🚂🚘 Premium Girls Call Ranchi 🛵🚡000XX00000 💃 Choose Best And Top Girl Service...
bahubalikumar09988
 
Predicting Test Results without Execution (FSE 2024)
Predicting Test Results without Execution (FSE 2024)Predicting Test Results without Execution (FSE 2024)
Predicting Test Results without Execution (FSE 2024)
andrehoraa
 
09. Ruby Object Oriented Programming - Ruby Core Teaching
09. Ruby Object Oriented Programming - Ruby Core Teaching09. Ruby Object Oriented Programming - Ruby Core Teaching
09. Ruby Object Oriented Programming - Ruby Core Teaching
quanhoangd129
 
A Step-by-Step Guide to Selecting the Right Automated Software Testing Tools.pdf
A Step-by-Step Guide to Selecting the Right Automated Software Testing Tools.pdfA Step-by-Step Guide to Selecting the Right Automated Software Testing Tools.pdf
A Step-by-Step Guide to Selecting the Right Automated Software Testing Tools.pdf
kalichargn70th171
 
Applitools Autonomous 2.0 Sneak Peek.pdf
Applitools Autonomous 2.0 Sneak Peek.pdfApplitools Autonomous 2.0 Sneak Peek.pdf
Applitools Autonomous 2.0 Sneak Peek.pdf
Applitools
 
DSD-INT 2024 Rainfall nowcasting – now and then - Uijlenhoet
DSD-INT 2024 Rainfall nowcasting – now and then - UijlenhoetDSD-INT 2024 Rainfall nowcasting – now and then - Uijlenhoet
DSD-INT 2024 Rainfall nowcasting – now and then - Uijlenhoet
Deltares
 
InflectraCON 360: Risk-Based Testing for Mission Critical Systems
InflectraCON 360: Risk-Based Testing for Mission Critical SystemsInflectraCON 360: Risk-Based Testing for Mission Critical Systems
InflectraCON 360: Risk-Based Testing for Mission Critical Systems
Inflectra
 
GT degree offer diploma Transcript
GT degree offer diploma TranscriptGT degree offer diploma Transcript
GT degree offer diploma Transcript
attueb
 
Busty Girls Call Mumbai 9930245274 Unlimited Short Providing Girls Service Av...
Busty Girls Call Mumbai 9930245274 Unlimited Short Providing Girls Service Av...Busty Girls Call Mumbai 9930245274 Unlimited Short Providing Girls Service Av...
Busty Girls Call Mumbai 9930245274 Unlimited Short Providing Girls Service Av...
revolutionary575
 

Recently uploaded (20)

Russian Girls Call Mumbai 🛵🚡9833363713 💃 Choose Best And Top Girl Service And...
Russian Girls Call Mumbai 🛵🚡9833363713 💃 Choose Best And Top Girl Service And...Russian Girls Call Mumbai 🛵🚡9833363713 💃 Choose Best And Top Girl Service And...
Russian Girls Call Mumbai 🛵🚡9833363713 💃 Choose Best And Top Girl Service And...
 
Russian Girls Call Mumbai 🎈🔥9930687706 🔥💋🎈 Provide Best And Top Girl Service ...
Russian Girls Call Mumbai 🎈🔥9930687706 🔥💋🎈 Provide Best And Top Girl Service ...Russian Girls Call Mumbai 🎈🔥9930687706 🔥💋🎈 Provide Best And Top Girl Service ...
Russian Girls Call Mumbai 🎈🔥9930687706 🔥💋🎈 Provide Best And Top Girl Service ...
 
AI - Your Startup Sidekick (Leveraging AI to Bootstrap a Lean Startup).pdf
AI - Your Startup Sidekick (Leveraging AI to Bootstrap a Lean Startup).pdfAI - Your Startup Sidekick (Leveraging AI to Bootstrap a Lean Startup).pdf
AI - Your Startup Sidekick (Leveraging AI to Bootstrap a Lean Startup).pdf
 
How to Secure Your Kubernetes Software Supply Chain at Scale
How to Secure Your Kubernetes Software Supply Chain at ScaleHow to Secure Your Kubernetes Software Supply Chain at Scale
How to Secure Your Kubernetes Software Supply Chain at Scale
 
Authentication Review-June -2024 AP & TS.pptx
Authentication Review-June -2024 AP & TS.pptxAuthentication Review-June -2024 AP & TS.pptx
Authentication Review-June -2024 AP & TS.pptx
 
SEO Cheat Sheet with Learning Resources by Balti Bloggers.pdf
SEO Cheat Sheet with Learning Resources by Balti Bloggers.pdfSEO Cheat Sheet with Learning Resources by Balti Bloggers.pdf
SEO Cheat Sheet with Learning Resources by Balti Bloggers.pdf
 
Test Polarity: Detecting Positive and Negative Tests (FSE 2024)
Test Polarity: Detecting Positive and Negative Tests (FSE 2024)Test Polarity: Detecting Positive and Negative Tests (FSE 2024)
Test Polarity: Detecting Positive and Negative Tests (FSE 2024)
 
Old Tools, New Tricks: Unleashing the Power of Time-Tested Testing Tools
Old Tools, New Tricks: Unleashing the Power of Time-Tested Testing ToolsOld Tools, New Tricks: Unleashing the Power of Time-Tested Testing Tools
Old Tools, New Tricks: Unleashing the Power of Time-Tested Testing Tools
 
SAP implementation steps PDF - Zyple Software
SAP implementation steps PDF - Zyple SoftwareSAP implementation steps PDF - Zyple Software
SAP implementation steps PDF - Zyple Software
 
03. Ruby Variables & Regex - Ruby Core Teaching
03. Ruby Variables & Regex - Ruby Core Teaching03. Ruby Variables & Regex - Ruby Core Teaching
03. Ruby Variables & Regex - Ruby Core Teaching
 
BATber53 AWS Modernize your applications with purpose-built AWS databases
BATber53 AWS Modernize your applications with purpose-built AWS databasesBATber53 AWS Modernize your applications with purpose-built AWS databases
BATber53 AWS Modernize your applications with purpose-built AWS databases
 
🚂🚘 Premium Girls Call Ranchi 🛵🚡000XX00000 💃 Choose Best And Top Girl Service...
🚂🚘 Premium Girls Call Ranchi  🛵🚡000XX00000 💃 Choose Best And Top Girl Service...🚂🚘 Premium Girls Call Ranchi  🛵🚡000XX00000 💃 Choose Best And Top Girl Service...
🚂🚘 Premium Girls Call Ranchi 🛵🚡000XX00000 💃 Choose Best And Top Girl Service...
 
Predicting Test Results without Execution (FSE 2024)
Predicting Test Results without Execution (FSE 2024)Predicting Test Results without Execution (FSE 2024)
Predicting Test Results without Execution (FSE 2024)
 
09. Ruby Object Oriented Programming - Ruby Core Teaching
09. Ruby Object Oriented Programming - Ruby Core Teaching09. Ruby Object Oriented Programming - Ruby Core Teaching
09. Ruby Object Oriented Programming - Ruby Core Teaching
 
A Step-by-Step Guide to Selecting the Right Automated Software Testing Tools.pdf
A Step-by-Step Guide to Selecting the Right Automated Software Testing Tools.pdfA Step-by-Step Guide to Selecting the Right Automated Software Testing Tools.pdf
A Step-by-Step Guide to Selecting the Right Automated Software Testing Tools.pdf
 
Applitools Autonomous 2.0 Sneak Peek.pdf
Applitools Autonomous 2.0 Sneak Peek.pdfApplitools Autonomous 2.0 Sneak Peek.pdf
Applitools Autonomous 2.0 Sneak Peek.pdf
 
DSD-INT 2024 Rainfall nowcasting – now and then - Uijlenhoet
DSD-INT 2024 Rainfall nowcasting – now and then - UijlenhoetDSD-INT 2024 Rainfall nowcasting – now and then - Uijlenhoet
DSD-INT 2024 Rainfall nowcasting – now and then - Uijlenhoet
 
InflectraCON 360: Risk-Based Testing for Mission Critical Systems
InflectraCON 360: Risk-Based Testing for Mission Critical SystemsInflectraCON 360: Risk-Based Testing for Mission Critical Systems
InflectraCON 360: Risk-Based Testing for Mission Critical Systems
 
GT degree offer diploma Transcript
GT degree offer diploma TranscriptGT degree offer diploma Transcript
GT degree offer diploma Transcript
 
Busty Girls Call Mumbai 9930245274 Unlimited Short Providing Girls Service Av...
Busty Girls Call Mumbai 9930245274 Unlimited Short Providing Girls Service Av...Busty Girls Call Mumbai 9930245274 Unlimited Short Providing Girls Service Av...
Busty Girls Call Mumbai 9930245274 Unlimited Short Providing Girls Service Av...
 

Doobie - feedbacks from the trenches - Scala.io 2016

  • 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.Doobie ● A pure functional, principled database access layer for Scala
  • 20. Use Doobie. It’s GREAT.Doobie ● A pure functional, principled database access layer for Scala ● Mapping is a joy (actually make me smile)
  • 21. Use Doobie. It’s GREAT.Doobie ● A pure functional, principled database access layer for Scala ● Mapping is a joy (actually make me smile) ● No surprises - particularly in performances and optimization
  • 22. Use Doobie. It’s GREAT.Doobie ● A pure functional, principled database access layer for Scala ● Mapping is a joy (actually make me smile) ● No surprises - particularly in performances and optimization ● Rob Norris (@tpolecat) is über nice and helpful
  • 23. Use Doobie. It’s GREAT.Doobie ● A pure functional, principled database access layer for Scala ● Mapping is a joy (actually make me smile) ● No surprises - particularly in performances and optimization ● Rob Norris (@tpolecat) is über nice and helpful ● It actually makes me like SQL ○ (it tooks 15 years, and PostgreSQL helps a lot)
  • 24. Use Doobie. It’s GREAT. ● A pure functional, principled database access layer for Scala ● Mapping is a joy (actually make me smile) ● No surprises - particularly in performances and optimization ● 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 principled 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. No boilerplate.
  • 27. Mapping just works. No boilerplate.
  • 28. Mapping just works. No boilerplate.
  • 29. Mapping just works. No boilerplate.
  • 30. Mapping just works. No boilerplate.
  • 31. Mapping just works. Returns what you want.
  • 32. No surprises - Sane (performant) defaults ● The exact, 50 lines if you want, SQL queries you want to write. ● PreparedStatement by default. ● Batch updates are given. ● Comparison with JDBC
  • 33. 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
  • 34. Update 0.4.0: rainbows and wonders ● Fragments ○ https://tpolecat.github.io/doobie-scalaz-0.4.0/08-Fragments.html ○ Doobie 0.4.0 add fragments, which allows to safely build and factor out part of requests (typically: “select column1, …, column42 in the_table”) ● Logging ○ https://tpolecat.github.io/doobie-scalaz-0.4.0/10-Logging.html ○ Allows to log queries… based on conditions ! Plus, access to full, fine grained timing. ■ “only the one for which you get an error from Database” ■ Or “all the queries taking more than 200ms” ! ○ über easy to connect with your logging framework ● Cats or Scalaz ○ now, you can choose!
  • 35. Yes. Really. Savant word for “Makes you love SQL - No surprise, it just works” Questions ? The End
  • 36. References ● Book of Doobie : https://tpolecat.github.io/doobie-0.3.0/00-index.html ● Really nice presentation of concepts and use of Free Monad: ○ 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 ● The faq is pretty cool: https://tpolecat.github.io/doobie-0.3.0/15-FAQ.html (“in” clause, outer join, pure SQL strings and more) ● Rudder is full of examples, feel free to read files (importing Doobie) in: https://github.com/Normation/rudder/tree/branches/rudder/4.0/rudder-core/src/ main/scala/com/normation/rudder/repository/jdbc
  • 37. Question: testing mapping in the repl ? This is integrated with testing frameworks, in particular scalacheck
  • 38. Question: more typed, safer queries ? ● Some things are coming in Doobie 0.4.0 ! ○ but nothing is fixed for now ○ [update] Actually, was reported post 0.4.0 ● I sum-up all the feedback/ideas I get at Scala.io 2016 here: https://github.com/tpolecat/doobie/issues/375
  • 39. Question: variables number or parameters? How I deal with a query whose number of parameter is know at runtime ? Doobie has several level of API: ● sql””” …. “”” : the simplest, but also the less flexible ● Query/Query0: give a return type, a type for parameters, and a string for query: allows to build queries by string concatenation (ideal for porting from JDBC) ● HC: “high interface”: allows to add parameter by index, “à la” JDBC, but typed. ○ full, complexe example on next page that adapt a query at runtime based on user parameters, and use HC ● and a low level interface, where all JDBC ugliness is exposed
  • 40. Question: variables number or parameters? } Request depends of parameters of the function Query is a pure string built with concatenation Dynamically set parameters with HPS & HC
  • 41. Question: retrieving variable depths of dependent objects? One big question in data persistance layer is to manage the depth in the dependency graph of object you are going to retrieve. Typically, with an employee having a property “manager”, which is an ID in DB but also (of course) an employee, how I manage to get only the first employee with the manager ID ? The first employee with the full employee manager ? And his manager ? Rob Norris gave a super talk exactly on that subject at ScalaWorld 2016: ● “Pure Functional Database Programming with Fixpoint Types “ ○ slides: http://tpolecat.github.io/presentations/sw2016/slides.html#1 ○ video: https://www.youtube.com/watch?v=7xSfLPD6tiQ
  • 42. License This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. http://www.slideshare.net/normation