57
XQUERY – THE GETTING STUFF DONE LANGUAGE Jim Fuller, Principle Consultant MarkLogic

XQuery - The GSD (Getting Stuff Done) language

  • View
    4.410

  • Download
    3

Embed Size (px)

DESCRIPTION

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.

Citation preview

Page 1: XQuery - The GSD (Getting Stuff Done) language

XQUERY – THE GETTING STUFF DONE LANGUAGE

Jim Fuller, Principle ConsultantMarkLogic

Page 2: XQuery - The GSD (Getting Stuff Done) language

XQuery - The Getting Stuff Done language

Jim Fulleremail: [email protected] twitter: @xqueryPrincipal Consultant, Europe13/10/11

Page 3: XQuery - The GSD (Getting Stuff Done) language

I will try XQuery

Page 4: XQuery - The GSD (Getting Stuff Done) language

Agenda

The 5 W’s

Cool Stuff

Xquery Overview

Survey Results and Analysis

Summary

Page 5: XQuery - The GSD (Getting Stuff Done) language

5W’s Scientific Method

Page 6: XQuery - The GSD (Getting Stuff Done) language

What’s the problem ?

Page 7: XQuery - The GSD (Getting Stuff Done) language

The Mythical Man Month- Fred Brooks

'All programmers are optimists.’

'Adding manpower to a late software project makes it later.’

'The fundamental problem with program maintenance is that fixing a defect has a substantial (20-50 percent) chance of

introducing another.’

Page 8: XQuery - The GSD (Getting Stuff Done) language

Problem #1 - Programming is hard

'building software will always be hard. There is no silver bullet.'

Page 9: XQuery - The GSD (Getting Stuff Done) language

Data problems

relaxing constraints in vogue

multifarious data models

impedance mismatch

Page 10: XQuery - The GSD (Getting Stuff Done) language

BigData Opportunity* http://gigaom.com/cloud/big-data-equals-big-opportunities-for-businesses-infographic/

Page 11: XQuery - The GSD (Getting Stuff Done) language

BigData Opportunity* http://gigaom.com/cloud/big-data-equals-big-opportunities-for-businesses-infographic/

Page 12: XQuery - The GSD (Getting Stuff Done) language

Problem #2 - Your boss knows about the Big Data opportunity

managing data variability, volume & velocity is hard

Page 13: XQuery - The GSD (Getting Stuff Done) language

Why again ..

Solution #1: Choosing the right language can result in 4-5 times greater productivity

Solution #2 – Choose a language that mitigates risks associated with BigData

Page 14: XQuery - The GSD (Getting Stuff Done) language

XQuery Overview

Page 15: XQuery - The GSD (Getting Stuff Done) language

I will try XQuery

Page 16: XQuery - The GSD (Getting Stuff Done) language

X Q u e r y X Q u e r y

misconceptions

Page 17: XQuery - The GSD (Getting Stuff Done) language

The dynamic functional language

Domain specific language

XPATH^2

Strongly typed

Page 18: XQuery - The GSD (Getting Stuff Done) language

SQL like –Inner Join

SELECT * FROM employee, department WHERE employee.DepartmentID = department.DepartmentID;

for $emp in //employeereturn

$emp[@deptid eq //dept/@id]

Page 19: XQuery - The GSD (Getting Stuff Done) language

SQL like – left Outer Join

for $u in fn:collection(‘customers’)return <customer id={$u/custno} name=“{$u/name}”> { for $p in fn:collection(”purchaseorders”)//po where $u/custno = $p//custno

return <po>{$p/@id}</po> } </customer>

Page 20: XQuery - The GSD (Getting Stuff Done) language

Functions

declare function local:hello($name) { concat("Hello ", $name)};

local:hello(”Aarhus!")

Page 21: XQuery - The GSD (Getting Stuff Done) language

Code in the language of the domain

declare function local:test($a,$b,$c,$d,$e,$f,$g,$h,$i,$k){ …..};

declare function local:test($a as element(record)

){ ……};

Page 22: XQuery - The GSD (Getting Stuff Done) language

Literals and Constructorsxquery version "1.0";

let $names := ("Jim","Gabi","Vojtech","Norm","Nuno","Eric")return<names>{ for $name in $names return <name>{$name}</name> }</names>

(:

element {$computed-element-name}{ attribute {$computed-attr-name}{"some attr value"}}

:)

Page 23: XQuery - The GSD (Getting Stuff Done) language

Broad applicability

http://github.com/xquery/xquerydoc – XQuery parsing XQuery

IBM Developerworks – Classify content with XQuery article

http://try.zorba-xquery.com/

Page 24: XQuery - The GSD (Getting Stuff Done) language

XQuery + database

http://demo.exist-db.org/exist/eXide/index.html

Page 25: XQuery - The GSD (Getting Stuff Done) language

MarkLogic

EVALUATION LAYER

EvaluatorXSLT | XPath | XQuery

Shared-Nothing Protocol

Buffer

DATA LAYERData Cache

Compressed StorageXML | Binary | Text

IndexesValue | Structure | Text | Scalar | Metadata | Security | Geospatial | Reverse

Transaction Journal

Transaction ControllerMultiversion Concurrency Control

APPLICATION SERVICES

HTTP | HTTPS | XDBC | WebDAV | REST | AJAX / JSON

Information Studio API

Library Services APISearch API

Page 26: XQuery - The GSD (Getting Stuff Done) language

Analysis

Page 27: XQuery - The GSD (Getting Stuff Done) language

I will try XQuery

Page 28: XQuery - The GSD (Getting Stuff Done) language

Programming Language ProductivityData compiled from studies by Prechelt and Garret of a particular string processing problem - public domain 2006.

Page 29: XQuery - The GSD (Getting Stuff Done) language

Programming Language ProductivityData compiled from studies by Prechelt and Garret of a particular string processing problem - public domain 2006.

Page 30: XQuery - The GSD (Getting Stuff Done) language

Nooooo!

#loc per FP=

Lines of codePer

Function Point

Methodology

Page 31: XQuery - The GSD (Getting Stuff Done) language

Project Uncertainty Principle

Page 32: XQuery - The GSD (Getting Stuff Done) language

An empirical comparison of C, C++, Java, Perl, Python, Rexx, and Tcl for a

search/string-processing programLutz Prechelt ([email protected]) Fakulta t fu r Informatik ̈ ̈

Universita t Karlsruhe ̈

Language #loc per Function PointC 91

C++ 53Java 54Perl 21

* Designing and writing programs using dynamic languages tended to take half as long as well as resulting in half the code.

Page 33: XQuery - The GSD (Getting Stuff Done) language

Developing an Enterprise Web Application in Xquery - 2009 Martin Kaufmann, Donald Kossmann

Java/J2EE XQueryModel 3100 240View 4100 1500Controller 900 1180

8100 (?) 2920 (3490)

Page 34: XQuery - The GSD (Getting Stuff Done) language

* 28msec – 2011 http://www.28msec.com/html/home

Java XQuerySimpleDB 2905 572S3 8589 1469SNS 2309 455

13803 2496

Page 35: XQuery - The GSD (Getting Stuff Done) language

Review 11 projects

FP AnalysisCalc FP inputs/outputsCalc VAF (0.65 + [ (Ci) / 100])

AVP = VAF * sum(FP)

* FP overview - http://www.softwaremetrics.com/fpafund.htm

#locusing cloc

= #loc per FP

Page 36: XQuery - The GSD (Getting Stuff Done) language

Language #loc per Function PointEiffel 21SQL 13-30

XQuery 27-33Haskell 38Erlang 40Python 42-47

Java 50-80Javascript 50-55Scheme 53

C++ 59-80C 128-140

Page 37: XQuery - The GSD (Getting Stuff Done) language

Do Software Language Engineers Evaluate their Languages?

2011 - CITI, Departamento de Informa tica, Faculdade de Ciˆencias e Tecnologia, FCT, ́Universidade Nova de Lisboa, 2829-516 Caparica, Portugal [email protected],{miguel.goulao,vasco.amaral}@di.fct.unl.pt http://citi.di.fct.unl.pt/

SLE consistently relax language evaluation

no validation from users

recommend systematic approach to DSL evaluation

Page 38: XQuery - The GSD (Getting Stuff Done) language

Xquery 2011 Survey

Page 39: XQuery - The GSD (Getting Stuff Done) language

Preferred Programming Language

73%55%

45%32%

22%

Page 40: XQuery - The GSD (Getting Stuff Done) language

Which data formats do you use the most ?

95%

40%

39%

32%

27%

18%

15%

Page 41: XQuery - The GSD (Getting Stuff Done) language

Written answers

Do you have any opinions if XQuery is more or less productive language versus other programming languages ?

What was different about learning or using XQuery versus other programming languages ?

Page 42: XQuery - The GSD (Getting Stuff Done) language

Choose an option that you most strongly believe in …

66%

14%

10%

Page 43: XQuery - The GSD (Getting Stuff Done) language

Do you think XQuery makes you a more productive programmer ?

67%

14%

10%

8%

Page 44: XQuery - The GSD (Getting Stuff Done) language

Is XQuery more productive then Java in developing web based data applications ?

58%

22%

12%

8%

Page 45: XQuery - The GSD (Getting Stuff Done) language

Cool Stuff

Page 46: XQuery - The GSD (Getting Stuff Done) language

I will try XQuery

Page 47: XQuery - The GSD (Getting Stuff Done) language

Corona

Drop in replacement for NoSQL with no compromise

Open Source development supported by ML

Written in XQuery

Page 48: XQuery - The GSD (Getting Stuff Done) language

Summary

Page 49: XQuery - The GSD (Getting Stuff Done) language

I will try XQuery

Page 50: XQuery - The GSD (Getting Stuff Done) language

Sanity Check

Page 51: XQuery - The GSD (Getting Stuff Done) language

Xquery job search indeed.com

Page 52: XQuery - The GSD (Getting Stuff Done) language

Media Customers

Government Customers

MarkLogic Customers Know

Financial Services and Other Customers

Page 53: XQuery - The GSD (Getting Stuff Done) language

Finally …

Page 54: XQuery - The GSD (Getting Stuff Done) language

Disclaimer: I have used the above subliminal suggestion throughout the

presentation

I will try XQuery

Page 55: XQuery - The GSD (Getting Stuff Done) language

Thank you ...@xquery Questions ?

Page 56: XQuery - The GSD (Getting Stuff Done) language

Tools

Page 57: XQuery - The GSD (Getting Stuff Done) language

Resources and References