Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Xquery – The Getting Stuff Done Language<br />Jim Fuller, Principle Consultant<br />MarkLogic<br />
XQuery - The Getting Stuff Done language<br />Jim Fuller<br />email: jim.fuller@marklogic.com  twitter: @xquery<br />Princ...
I will try XQuery<br />
Agenda<br />The 5 W’s <br />Xquery Overview <br />Survey Results and Analysis<br />Cool Stuff<br />Summary <br />
5W’s Scientific Method<br />
What’s the problem ? <br />
The Mythical Man Month- Fred Brooks<br />'All programmers are optimists.’<br />'Adding manpower to a late software project...
'building software will always be hard. There is no silver bullet.'<br />Problem #1 - Programming is hard<br />
Data problems<br />impedance mismatch<br />multifarious data models<br />relaxing constraints in vogue<br />
BigData Opportunity<br />* http://gigaom.com/cloud/big-data-equals-big-opportunities-for-businesses-infographic/<br />
BigData Opportunity<br />* http://gigaom.com/cloud/big-data-equals-big-opportunities-for-businesses-infographic/<br />
managing data variability, volume & velocity is hard<br />Problem #2 - Your boss knows about the Big Data opportunity<br />
Why again ..<br />Solution #1:  Choosing the right language can result in 4-5 times greater productivity<br />Solution #2 ...
XQuery Overview<br />
I will try XQuery<br />
misconceptions<br />X Q u e r y  <br />X Q u e r y<br />
The dynamicfunctional language<br />XPATH^2<br />Domain specific language<br />Strongly typed<br />
SQL like –Inner Join<br />SELECT * FROM employee, department 	WHERE employee.DepartmentID = department.DepartmentID;<br />...
SQL like – left Outer Join<br />for $u in fn:collection(‘customers’)<br />return <br /><customer id={$u/custno} name=“{$u/...
Functions<br />declare function local:hello($name) {<br />concat("Hello ", $name)<br />};<br />local:hello(”Aarhus!")<br />
Code in the language of the domain<br />declare function local:test(<br />	$a,$b,$c,$d,$e,$f,$g,$h,$i,$k){ <br />	…..};<br...
Literals and Constructors<br />xquery version "1.0";<br />let $names := ("Jim","Gabi","Vojtech","Norm","Nuno","Eric")<br /...
Inline Caching<br />xquery version "1.0-ml";<br />(: xquerymemoization example for use with MarkLogic :)<br />declare vari...
Broad applicability<br />http://github.com/xquery/xquerydoc – XQuery parsing XQuery<br />IBM Developerworks – Classify con...
XQuery + database<br />http://demo.exist-db.org/exist/eXide/index.html<br />
MarkLogic <br />HTTP | HTTPS | XDBC | WebDAV | REST | AJAX / JSON<br />APPLICATION SERVICES<br />Information Studio API<br...
XQuery + database<br />
Analysis<br />
I will try XQuery<br />
Programming Language ProductivityData compiled from studies by Precheltand Garret of a particular string processingproblem...
Programming Language ProductivityData compiled from studies by Precheltand Garret of a particular string processing proble...
Nooooo!<br />Methodology<br />#loc per FP<br />=<br />Lines of code<br />Per<br />Function Point<br />
Project Uncertainty Principle<br />
An empirical comparison of C, C++, Java, Perl, Python, Rexx, and Tclfor a search/string-processing programLutz Prechelt (p...
Historical #loc per FP<br />
Developing an Enterprise Web Application in Xquery- 2009 Martin Kaufmann, Donald Kossmann<br />
* 28msec – 2011 http://www.28msec.com/html/home<br />
Review 11 projects<br /> = #loc per FP<br />* FP overview - http://www.softwaremetrics.com/fpafund.htm<br />
* Cloudera– 2011 http://www.cloudera.com/videos/introduction-to-apache-pig<br />PigLatin is a DSL for data for apache hado...
Do Software Language Engineers Evaluate their Languages? <br />2011 - CITI, Departamento de Informa ́tica, Faculdade de Ci...
Xquery 2011 Survey<br />
Preferred Programming Language<br />73%<br />55%<br />45%<br />32%<br />22%<br />
Which data formats do you use the most ?<br />95%<br />40%<br />39%<br />32%<br />27%<br />18%<br />15%<br />
Written answers<br />What was different about learning or using XQuery versus other programming languages ?<br />Do you ha...
Choose an option that you most strongly believe in …<br />66%<br />14%<br />10%<br />
Do you think XQuery makes you a more productive programmer ?<br />67%<br />14%<br />10%<br />8%<br />
Is XQuery more productive then Java in developing web based data applications ?<br />58%<br />22%<br />12%<br />8%<br />
Cool Stuff<br />
I will try XQuery<br />
Corona<br />Drop in replacement for NoSQL with no compromise<br />Open Source development supported by ML<br />Written in ...
Summary<br />
I will try XQuery<br />
Sanity Check<br />
Xquery job search indeed.com<br />
MarkLogic Customers Know<br />Government Customers<br />Media Customers<br />Financial Services and Other Customers<br />
Finally …<br />
Upcoming SlideShare
Loading in …5
×

XQuery - The GSD (Getting Stuff Done) language

6,732 views

Published on

One of the hidden gems of the XML technology milieu is XQuery ... even if XML is not your thing (for example you work only with JSON) I will show you how XQuery is especially adept and super fast in terms of pure web development. And if you do happen to have a lot of XML I will also demonstrate how this concise, small data orientated language can result in serious productivity gains over other programming languages. XQuery is available today on the server, in the browser (mobile devices) and large deployments in both commercial and open source environments.

This talk will present both anecdotal and evidence based analysis showing how using XQuery can result in quicker development times over other programming languages when applied to the right scenarios and will try to help give a starting point to those wishing to investigate this extremely powerful little language.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

XQuery - The GSD (Getting Stuff Done) language

  1. 1. Xquery – The Getting Stuff Done Language<br />Jim Fuller, Principle Consultant<br />MarkLogic<br />
  2. 2. XQuery - The Getting Stuff Done language<br />Jim Fuller<br />email: jim.fuller@marklogic.com twitter: @xquery<br />Principal Consultant, Europe<br />13/10/11<br />
  3. 3. I will try XQuery<br />
  4. 4. Agenda<br />The 5 W’s <br />Xquery Overview <br />Survey Results and Analysis<br />Cool Stuff<br />Summary <br />
  5. 5. 5W’s Scientific Method<br />
  6. 6. What’s the problem ? <br />
  7. 7. The Mythical Man Month- Fred Brooks<br />'All programmers are optimists.’<br />'Adding manpower to a late software project makes it later.’<br />'The fundamental problem with program maintenance is that fixing a defect has a substantial (20-50 percent) chance of introducing another.’<br />
  8. 8. 'building software will always be hard. There is no silver bullet.'<br />Problem #1 - Programming is hard<br />
  9. 9. Data problems<br />impedance mismatch<br />multifarious data models<br />relaxing constraints in vogue<br />
  10. 10. BigData Opportunity<br />* http://gigaom.com/cloud/big-data-equals-big-opportunities-for-businesses-infographic/<br />
  11. 11. BigData Opportunity<br />* http://gigaom.com/cloud/big-data-equals-big-opportunities-for-businesses-infographic/<br />
  12. 12. managing data variability, volume & velocity is hard<br />Problem #2 - Your boss knows about the Big Data opportunity<br />
  13. 13. Why again ..<br />Solution #1: Choosing the right language can result in 4-5 times greater productivity<br />Solution #2 – Choose a language that mitigates risks associated with BigData<br />
  14. 14. XQuery Overview<br />
  15. 15. I will try XQuery<br />
  16. 16. misconceptions<br />X Q u e r y <br />X Q u e r y<br />
  17. 17. The dynamicfunctional language<br />XPATH^2<br />Domain specific language<br />Strongly typed<br />
  18. 18. SQL like –Inner Join<br />SELECT * FROM employee, department WHERE employee.DepartmentID = department.DepartmentID;<br />for $emp in //employee<br />return<br /> $emp[@deptideq //dept/@id]<br />
  19. 19. SQL like – left Outer Join<br />for $u in fn:collection(‘customers’)<br />return <br /><customer id={$u/custno} name=“{$u/name}”> {<br /> for $p in fn:collection(”purchaseorders”)//po where $u/custno = $p//custno<br /> return <po>{$p/@id}</po> <br />} </customer><br />
  20. 20. Functions<br />declare function local:hello($name) {<br />concat("Hello ", $name)<br />};<br />local:hello(”Aarhus!")<br />
  21. 21. Code in the language of the domain<br />declare function local:test(<br /> $a,$b,$c,$d,$e,$f,$g,$h,$i,$k){ <br /> …..};<br />declare function local:test(<br />$a as element(record)<br />){ ……};<br />
  22. 22. Literals and Constructors<br />xquery version "1.0";<br />let $names := ("Jim","Gabi","Vojtech","Norm","Nuno","Eric")<br />return<br /><names>{<br /> for $name in $names<br /> return <br /> <name>{$name}</name> <br />}</names><br />(:<br />element {$computed-element-name}{<br /> attribute {$computed-attr-name}{"some attr value"}<br />}<br />:) <br />
  23. 23. Inline Caching<br />xquery version "1.0-ml";<br />(: xquerymemoization example for use with MarkLogic :)<br />declare variable $cache := map:map();<br />declare function local:factorial($n as xs:integer) as xs:integer {<br />if ($n < 0) then<br /> (0)<br />else if ($n = 0) then<br /> (1)<br />else<br /> $n * local:factorial($n - 1)<br />};<br />declare function local:memoize($func,$var){<br /> let $key := xdmp:md5(concat($func,string($var)))<br /> return<br /> if(map:get($cache,$key)) then<br /> (map:get($cache,$key), xdmp:log('cache hit'))<br /> else<br /> let $result := xdmp:apply($func,$var)<br /> return<br /> (map:put($cache,$key,$result), $result)<br />};<br />let $memoize := xdmp:function(xs:QName("local:memoize"))<br />let $factorial := xdmp:function(xs:QName("local:factorial"))<br />let $a:= xdmp:apply($memoize, $factorial, 20)<br />let $b:= xdmp:apply($memoize, $factorial, 20)<br />let $c:= xdmp:apply($memoize, $factorial, 20)<br />let $d:= xdmp:apply($memoize, $factorial, 20)<br />let $e:= xdmp:apply($memoize, $factorial, 20)<br />return<br />$a<br />
  24. 24. Broad applicability<br />http://github.com/xquery/xquerydoc – XQuery parsing XQuery<br />IBM Developerworks – Classify content with XQuery article<br />http://try.zorba-xquery.com/<br />
  25. 25. XQuery + database<br />http://demo.exist-db.org/exist/eXide/index.html<br />
  26. 26. MarkLogic <br />HTTP | HTTPS | XDBC | WebDAV | REST | AJAX / JSON<br />APPLICATION SERVICES<br />Information Studio API<br />Library Services API<br />Search API<br />Transaction Controller<br />Multiversion Concurrency Control<br />EVALUATION LAYER<br />Evaluator<br />XSLT | XPath | XQuery<br />Data Cache<br />Transaction Journal<br />Buffer<br />Indexes<br />Value | Structure | Text | Scalar | Metadata | Security | Geospatial | Reverse<br />Shared-Nothing Protocol<br />Compressed Storage<br />XML | Binary | Text<br />DATA LAYER<br />
  27. 27. XQuery + database<br />
  28. 28. Analysis<br />
  29. 29. I will try XQuery<br />
  30. 30. Programming Language ProductivityData compiled from studies by Precheltand Garret of a particular string processingproblem- public domain 2006.<br />
  31. 31. Programming Language ProductivityData compiled from studies by Precheltand Garret of a particular string processing problem- public domain 2006.<br />
  32. 32. Nooooo!<br />Methodology<br />#loc per FP<br />=<br />Lines of code<br />Per<br />Function Point<br />
  33. 33. Project Uncertainty Principle<br />
  34. 34. An empirical comparison of C, C++, Java, Perl, Python, Rexx, and Tclfor a search/string-processing programLutz Prechelt (prechelt@ira.uka.de) Fakulta ̈t fu ̈r InformatikUniversita ̈t Karlsruhe<br />* Designing and writing programs using dynamic languages tended to take half as long as well as resulting in half the code.<br />
  35. 35. Historical #loc per FP<br />
  36. 36. Developing an Enterprise Web Application in Xquery- 2009 Martin Kaufmann, Donald Kossmann<br />
  37. 37. * 28msec – 2011 http://www.28msec.com/html/home<br />
  38. 38. Review 11 projects<br /> = #loc per FP<br />* FP overview - http://www.softwaremetrics.com/fpafund.htm<br />
  39. 39.
  40. 40. * Cloudera– 2011 http://www.cloudera.com/videos/introduction-to-apache-pig<br />PigLatin is a DSL for data for apache hadoop<br />
  41. 41. Do Software Language Engineers Evaluate their Languages? <br />2011 - CITI, Departamento de Informa ́tica, Faculdade de Ciˆencias e Tecnologia, FCT, Universidade Nova de Lisboa, 2829-516 Caparica, Portugal pedrohgabriel@gmail.com,{miguel.goulao,vasco.amaral}@di.fct.unl.pt http://citi.di.fct.unl.pt/<br />SLE consistently relax language evaluation<br />no validation from users<br />recommend systematic approach to DSL evaluation<br />
  42. 42. Xquery 2011 Survey<br />
  43. 43. Preferred Programming Language<br />73%<br />55%<br />45%<br />32%<br />22%<br />
  44. 44. Which data formats do you use the most ?<br />95%<br />40%<br />39%<br />32%<br />27%<br />18%<br />15%<br />
  45. 45. Written answers<br />What was different about learning or using XQuery versus other programming languages ?<br />Do you have any opinions if XQuery is more or less productive language versus other programming languages ?<br />
  46. 46. Choose an option that you most strongly believe in …<br />66%<br />14%<br />10%<br />
  47. 47. Do you think XQuery makes you a more productive programmer ?<br />67%<br />14%<br />10%<br />8%<br />
  48. 48. Is XQuery more productive then Java in developing web based data applications ?<br />58%<br />22%<br />12%<br />8%<br />
  49. 49. Cool Stuff<br />
  50. 50. I will try XQuery<br />
  51. 51. Corona<br />Drop in replacement for NoSQL with no compromise<br />Open Source development supported by ML<br />Written in XQuery<br />
  52. 52. Summary<br />
  53. 53. I will try XQuery<br />
  54. 54. Sanity Check<br />
  55. 55. Xquery job search indeed.com<br />
  56. 56. MarkLogic Customers Know<br />Government Customers<br />Media Customers<br />Financial Services and Other Customers<br />
  57. 57. Finally …<br />
  58. 58. I will try XQuery<br />Disclaimer: I have used the above subliminal suggestion throughout the presentation<br />
  59. 59. Thank you ...@xquery Questions ?<br />
  60. 60. Tools<br />
  61. 61. Resources and References<br />

×