Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.

Doobie : Un JDBC fonctionnel qui ne cache pas SQL

161 vues

Publié le

Par : François Armand (@fanf42)
Doobie se présente par l'accroche principled database access for an unprincipled world. C'est tout à fait intraduisible en français - et c'est bien dommage ! Car cette phrase résume tout l'esprit de cette surcouche de JDBC.

Grâce à Doobie, JDBC, l'incarnation de Java à la mode '90s, des variables globales mutables qui jouent avec des threads, devient une bibliothèque fonctionnelle de pures structures de données composables, échangeables, testables, raisonnables - et tout ceci avec du SQL. Car là où d'autres comme Slickont choisi la voie du mapping objets / base de données, non sans rappeler nos bons vieux ORM honnis, Doobie ne fait que rendre vos requêtes SQL de bonnes citoyennes d'applications fonctionnelles.

Utilisateur récent de Doobie, je me propose dans cette présentation de vous transmettre un retour d'expérience encore chaud et naïf, avec ses bonnes surprises, ses moins bonnes, et pourquoi pas un mot sur Slick 3.1.

Publié dans : Technologie
  • Soyez le premier à commenter

  • Soyez le premier à aimer ceci

Doobie : Un JDBC fonctionnel qui ne cache pas SQL

  1. 1. Feedbacks from the trenches François ARMAND @fanf42 - 2016-10
  2. 2. ? Who knows...
  3. 3. ? ?JdbcTemplate Who knows...
  4. 4. ? ?JdbcTemplate ? Who knows...
  5. 5. ? Anorm ?? Who knows... ?JdbcTemplate
  6. 6. ? Anorm ? Squeryl ? ?JdbcTemplate ? Who knows...
  7. 7. ? Anorm ? Squeryl ? ?JdbcTemplate ? ? Who knows...
  8. 8. ? Anorm ? Squeryl ? ?JdbcTemplate ? ? SQL? Who knows... OBJECT MAPPING PURE SQL
  9. 9. ? Anorm ? Squeryl ? ?JdbcTemplate ? ? SQL? Love SQL ? Who knows...
  10. 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. 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. 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. 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. 14. Slick 3 ? ● Fairly popular, ~ default choice in 2016 for Scala world ● Let’s test it ! ⇒ ported ~ 50% of Rudder code to it.
  15. 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 ?
  16. 16. Doobie ?
  17. 17. Use Doobie. It’s GREAT. Doobie
  18. 18. Use Doobie. It’s GREAT. Questions ? Doobie
  19. 19. Use Doobie. It’s GREAT. ● A pure functional database access layer for Scala Doobie
  20. 20. Use Doobie. It’s GREAT. ● A pure functional database access layer for Scala ● Mapping is a joy (actually make me smile) Doobie
  21. 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. 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. 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. 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. 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. 26. Mapping just works. Returns what you want.
  27. 27. Mapping just works. No boilerplate.
  28. 28. Mapping just works. No boilerplate.
  29. 29. Mapping just works. No boilerplate.
  30. 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. 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. 32. Yes. Really. Savant word for “Makes you love SQL - No surprise, it just works” Questions ? The End
  33. 33. Testing mapping in the repl
  34. 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

×