Your SlideShare is downloading. ×
Scala dsls-dissecting-and-implementing-rogue
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Scala dsls-dissecting-and-implementing-rogue

374
views

Published on

Just a few simple slides for a presentation at Kraków's Scala User Group. The rest of the session is live coding where we reimplement a tiny subset of Rogue, Foursquares MongoDB DSL.

Just a few simple slides for a presentation at Kraków's Scala User Group. The rest of the session is live coding where we reimplement a tiny subset of Rogue, Foursquares MongoDB DSL.

Published in: Technology

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
374
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
9
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Scala DSLs Dissecting Rogue Konrad Malawski / @ktosopl GDG / PJUG / KSUG / SCKRK ScalaCamp 23.01.2012Wednesday, December 26, 12
  • 2. Wednesday, December 26, 12
  • 3. Querying MongoWednesday, December 26, 12
  • 4. Querying MongoWednesday, December 26, 12
  • 5. Querying MongoWednesday, December 26, 12
  • 6. Querying Mongo QL = Plain JSONWednesday, December 26, 12
  • 7. Querying Mongo QL = Plain JSON JavaScript ConsoleWednesday, December 26, 12
  • 8. Querying Mongo QL = Plain JSON JavaScript Console Java DriverWednesday, December 26, 12
  • 9. Querying Mongo QL = Plain JSON JavaScript Console Java Driver Casbah = Scala DriverWednesday, December 26, 12
  • 10. Querying Mongo QL = Plain JSON JavaScript Console Java Driver Casbah = Scala Driver ... used by RogueWednesday, December 26, 12
  • 11. Querying Mongo: JS Console APIWednesday, December 26, 12
  • 12. Querying Mongo: JS db.inventory.find( {} )Wednesday, December 26, 12
  • 13. Querying Mongo: JS db.inventory.find( {} ) “find all”Wednesday, December 26, 12
  • 14. Querying Mongo: JS db.inventory.find( { qty: { $gt: 20 } } )Wednesday, December 26, 12
  • 15. Querying Mongo: JS db.inventory.find( { qty: { $gt: 20 } } ) gt means >=Wednesday, December 26, 12
  • 16. Querying Mongo: JS db.pople.find( { age: { $gte: 20 }, $or: [ { name: “Ken” }, { name: “Kenshiro” }, { city: “Tokyo” }, ... ] } )Wednesday, December 26, 12
  • 17. Querying Mongo: JS db.pople.find( { age: { $gte: 20 }, $or: [ { name: “Ken” }, $or may contain any clause { name: “Kenshiro” }, { city: “Tokyo” }, ... ] } )Wednesday, December 26, 12
  • 18. Querying Mongo: Java Java API (Morhpia)Wednesday, December 26, 12
  • 19. Querying Mongo: Java ds.find(Employee.class).field("manager").equal(null).get();Wednesday, December 26, 12
  • 20. Querying Mongo: Java ds.find(Employee.class).field("manager").equal(null).get(); You call this typesafe!?Wednesday, December 26, 12
  • 21. Mongo with RogueWednesday, December 26, 12
  • 22. Rogue in Action import com.foursquare.rogue.Rogue._Wednesday, December 26, 12
  • 23. Rogue in Action Person where(_.age gte 18) limit(100) fetch()Wednesday, December 26, 12
  • 24. Rogue in Action Code Completion Code Completion Person where(_.age gte 18) limit(100) fetch() Code Completion Code CompletionWednesday, December 26, 12
  • 25. Rogue in Action Person where(_.age gte “Bazinga”) limit(100) fetch()Wednesday, December 26, 12
  • 26. Rogue in Action Person where(_.age gte “Bazinga”) limit(100) fetch() Won’t compile - age is IntFieldWednesday, December 26, 12
  • 27. Rogue in Action Person where(_.age gte 18) limit(100) fetch()Wednesday, December 26, 12
  • 28. Rogue in Action Person where(_.age gte 18) limit(100) fetch() LimitWednesday, December 26, 12
  • 29. Rogue in Action Person where(_.age gte 18) limit(100) foreach { p => println(”Name: ” + p.firstName) }Wednesday, December 26, 12
  • 30. Rogue in Action gte means >= Person where(_.age gte 18) limit(100) foreach { p => println(”Name: ” + p.firstName) }Wednesday, December 26, 12
  • 31. Rogue in Action Person or( _.where(_.name eqs "Ken"), _.where(_.name eqs "ken") _.whereOpt(Option("Kenshiro")(_.name eqs _)) ) get()Wednesday, December 26, 12
  • 32. Rogue in Action eqs means Equals Person or( _.where(_.name eqs "Ken"), _.where(_.name eqs "ken") _.whereOpt(Option("Kenshiro")(_.name eqs _)) ) get()Wednesday, December 26, 12
  • 33. Rogue in Action eqs means Equals Person or( _.where(_.name eqs "Ken"), _.where(_.name eqs "ken") _.whereOpt(Option("Kenshiro")(_.name eqs _)) ) get() Get me one Person.Wednesday, December 26, 12
  • 34. Rogue in Action eqs means Equals Person or( _.where(_.name eqs "Ken"), _.where(_.name eqs "ken") _.whereOpt(Option("Kenshiro")(_.name eqs _)) ) get() Issue #69: fix in my pull req Get me one Person.Wednesday, December 26, 12
  • 35. Live HackingWednesday, December 26, 12
  • 36. Live HackingWednesday, December 26, 12
  • 37. Live HackingWednesday, December 26, 12
  • 38. Live Hacking Advanced Stuff.Wednesday, December 26, 12
  • 39. Live Hacking Advanced Stuff. Fast.Wednesday, December 26, 12
  • 40. Live Hacking Advanced Stuff. Fast. Ask Questions!Wednesday, December 26, 12
  • 41. Wednesday, December 26, 12
  • 42. def links = • Scala Lang http://www.scala-lang.org/ • Scala Koans http://www.scalakoans.org • Blog.Project13.pl - http://www.blog.project13.pl •MongoDB ref - docs.mongodb.org/manual/reference/operators/ • Foursquare Rogue - https://github.com/foursquare/rogue • Java Morphia - http://code.google.com/p/morphia/ • Kraków Scala UG - http://krakowscala.pl / http://scalacamp.plWednesday, December 26, 12
  • 43. def links = • Scala Lang http://www.scala-lang.org/ • Scala Koans http://www.scalakoans.org • Blog.Project13.pl - http://www.blog.project13.pl •MongoDB ref - docs.mongodb.org/manual/reference/operators/ • Foursquare Rogue - https://github.com/foursquare/rogue • Java Morphia - http://code.google.com/p/morphia/ • Kraków Scala UG - http://krakowscala.pl / http://scalacamp.pl Mailing lists rock!Wednesday, December 26, 12
  • 44. Thanks! Dziękuję! ありがとう! Konrad Malawski / @ktosopl GDG / PJUG / KSUG / SCKRK ScalaCamp 23.01.2012Wednesday, December 26, 12
  • 45. Thanks! Dziękuję! ありがとう! I love feedback! <3 Konrad Malawski / @ktosopl GDG / PJUG / KSUG / SCKRK ScalaCamp 23.01.2012Wednesday, December 26, 12