real world clojure

Download Real World Clojure

Post on 24-Oct-2014

37 views

Category:

Documents

3 download

Embed Size (px)

TRANSCRIPT

Real World ClojureTom Marble March 19, 2012

Contents1 Overview 3

IFI IFP IFQ2

yverviewX opis to over F F F F F F F F F F F F F F F F F F F F ht is tht presenttion toolc F F F F F F F F F F F F F F F F F k3 F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F eout PFIFI PFIFP PFIFQ PFIFR PFIFS PFIFT PFIFU PFIFV PFIFW eout om F F F F F F F F F F F F F F unX tehnil presles during unX tv erformne F F F F unX hvt F F F F F F F F F F F unX ypenthu F F F F F F F F veft un to do strtup F F F fut F F F F F F F F F F F F F F gonsulting F F F F F F F F F F om nd hein F F F F F F F pyhiw F F F F F F F F F F F my lient F F F F F F F F F F F F F F F F F F the dotFom F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F er F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F

Q Q S6

Background

PFI

PFP3

T U V V W II II II II IP IP13

Why Lisp?

QFI QFP QFQ QFR QFS

homoioni F F F F F F F F F F F F F F F F F F F F mrosX ode trnsformtions t ompile time F QFPFI de(ning funtions uses the defn mro F ery esy to work with ode @euse it9s dtA iv F F F F F F F F F F F F F F F F F F F F F F F visp suesses F F F F F F F F F F F F F F F F F F F

IQ IR IR IR IR IS

I

4

Why Clojure?

15

RFI RFP RFQ RFR RFS RFT

RFU

wny enterprise deployments lredy use tv F F F F F F F F xeed the ene(ts of vs nd F F F F F F F F F F F F F F F F F puntionl rogrmming F F F F F F F F F F F F F F F F F F F F oftwre rnstionl wemory F F F F F F F F F F F F F F F F xo speD one implementtion F F F F F F F F F F F F F F F F F tv F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F RFTFI tv E multipltform F F F F F F F F F F F F F F F F F F RFTFP ew looks very good for sizeD ostD het F F F F F F F RFTFQ e re seeing ew everywhere in emedded devies RFTFR tv for the snternet of hings F F F F F F F F F F F RFTFS tv s ssemly lnguge F F F F F F F F F F F F F F F fleeding idge ypenthu fetures F F F F F F F F F F F F F F F RFUFI porkGtoin F F F F F F F F F F F F F F F F F F F F F F F F RFUFP il gll yptimiztion F F F F F F F F F F F F F F F F F RFUFQ snvoke hynmi F F F F F F F F F F F F F F F F F F F F RFUFR wodulriztion @tigswA F F F F F F F F F F F F F F F F wven F F F F veiningen F F edis F F F F F tenkins F F F sing tenkins r F F F F F xoir F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F

F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F

IS IS IS IT IT IU IU IV IV IW PH PH PH PH PI PI22

5

The Tools I am using

SFI SFP SFQ SFR SFS SFT SFU6

PP PQ PQ PQ PR PR PR24

Why Open Source Matters

TFI TFP TFQ TFR TFS7

here re you going to deploy tht permissive vsF restritive liensing F ypen oure nd e ervies F F here is the vluec F F F F F F F F F hy hein F F F F F F F F F F F F F

odec F F F F F F F F F F F F F F F F

PS PS PT PT PT27

Challenges and Next Steps

UFI UFP UFQ UFR UFS

he stte of glojure gontri @is hllengeA F F F F F wy lient will expnd pity from privte to puli esokets F F F F F F F F F F F F F F F F F F F F F F F edis inding hnge F F F F F F F F F F F F F F F F F F ueeping n eye on htomi F F F F F F F F F F F F F F P

F F F F loud F F F F F F F F F F F F

PU PU PU PU PV

UFT UFU8 9

ueeping n eye on glojureript yne F F F F F F F F F F F F F F ixperiment with exposing leeding edge tw fetures in the glojure F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F

PV PV28 29

Conclusion Q/A + Live Hacking

WFI WFP WFQ WFR

gommnd line proessing nd on(gurtion (les retty rint rwv nd wv F F F F F F F F F F F redisPxml F F F F F F F F F F F F F F F F F F F F F F ixmple xoir site F F F F F F F F F F F F F F F F F F

F F F F

F F F F

F F F F

F F F F

F F F F

F F F F

F F F F

PW PW PW QH

1 Overviewel orld glojure (leX GsrGsoftwreEpssionGglojureEglyphFsvg wy journey in using glojure for lient tht is developing multiplyer gme server hosting servieF

1.1 Overview: Topics to coverress f9 to see the list of topis

1.2 What is that presentation tool?ims3 his is org-tree-slide from httpsXGGgithuFomGtkxpGorgEtreeEslide por more on org mode see httpXGGorgmodeForgGorgFhtml es s will shre my slides on my wesite httpXGGtmrleFinfoWFnet

Q

R

1.3 Tack!wy gret grndmother immigrted to the e from weden round IWHH

S

2 Background2.1 About Tom

tmrle

T

2.1.1

Sun: technical presales during the dot.com era

U

2.1.2

Sun: Java Performance

2.1.3

Sun: DLJ

irly PHHTX hvt with hein nd gnonil @untuA

V

2.1.4

Sun: OpenJDK

tvyne PHHTX ih qreen nnounes tht un will open soure tv gore trtegy em row orgnize ommunity governne gopyrightD tent nd rdemrk liensing snfrstruture tools ik liense pirst ypenthu emssdor @s went to lot of onferenesA pyhiw W

psv ygyx

ephegon PHHTX un unfypGrty gopyright PHHT ed veungX httpsXGGseureF)ikrFomGphotosGtwleungGPTVIITPIQG

IH

2.1.5

Left Sun to do a startup

2.1.6

But

he glol (nnil meltdown of PHHV hppened @etFA hidn9t work out X@ end so sF F F got into onsulting32.1.7 Consulting

gyerseurity roilisti wodel eri(tion @iletril ingineeringA oftwre for mrt qrid C enewle inergy glojure2.1.8 Tom and Debian

sing vinux sine IWWT sing hein sine PHHQ relped hein tv kging em sine hvt in PHHT orld with hein nd yrle on meshing tigsw with apt

II

2.1.9

FOSDEM

tv trk yrle histros hevelopers sers vegl sssues rk yrgnized y uren ndlerD frdley uuhnD ihrd pontn nd myE self ghek out the iki httpXGGinfoWFnetGwikiGfosdemGveglsssueshevoomG ghek out the oggst httpXGGfifFusG

2.2 About my clienthe lient heveloping multiplyer gme server hosting servie IP

gomprised of very young developers ss in stelth mode @sorry3A s hve een given the uthority to wke signi(nt hoies out rhiteture qreen light to open soure generi its @this is why i like onsulting XA s9m not the only one @espeilly in xordi ountriesA3

3 Why Lisp?

tohn wgrthy is old shoolX

3.1 homoiconiccode is data

vist @def mylist @I P QAA puntion @defn mydd @C AA glojure is de(ned in terms of the evlution of dt strutures nd not in terms of the syntx of hrter stremsG(lesF IQ

3.2 macros: code transformations at compile timewros o'er hooks for syntti strtion nd there is very little syntxF @defmro nd @ trueA @x xA @x 8 rest @let nd5 x @if nd5 @nd drestA nd5AAAA ellows ode trnsformtion before the reder does evlution defn is mro tht mkes de(ning funtions little simplerF3.2.1 dening functions uses the defn macro

glojure supports rity overloding in single funtion ojetD selfErefereneD nd vrileErity funtions using 8X @defn rgount @ HA @x IA @x y PA @x y 8 more @C @rgount x yA @ount moreAAAA Eb 59userGrgount @rgountA Eb H @rgount IA Eb I @rgount I PA Eb P @rgount I P Q R SA Eb S

3.3 Very easy to work with code (because it's data)vs is the lnguge of hoie when writing homin pei( vnguges @hv9sAF wentioned y heo @tuyA nd worton @evA tody3 ixmple from svg HW t ws elex pukung @okyo niversityA spoke on he tisfyility rolem e hv for e lgorithms sed iologil evolution inspired lgorithm

3.4 REPLhe ed ivl rint voop sntertive ode development snsted of just dump stk tre nd die on n errorF F F you n edit dt nd funtions @they look the smeA nd ontinue your progrm3

IR

3.5 Lisp successeserti(il sntelligene ienti( gomputing visp igv ugments gommon visp with n extensive lirry of ggregteE wise @eqEwiseA opertions on rrysD providing the essentil funtionlity of lnguges suh s evD portrn WHD shv nd wtlF httpXGGwwwFsiginfFomG

4 Why Clojure?4.1 Many enterprise deployments already use Java

glojure dds jr to the gveer @lowers the rrier to ustomer pE provlA imres the power of the tw @defn 5P ropertiesaspropertiesConvertanyseqof pairstoajava.utils.P ropertiesinstance.U sesas strtoconvertbothkeysandvaluesintostrings. {: tagP roperties}[m](let[p(P roperties.)](doseq[[kv]m](.se strk)(as strv)))p)) veverges the welth of existing tv lirries

4.2 Need the benets of LISP andxeed to del with onurreny using ntive threds nd lokingF ithout the downsides of tv kip the oilerplte @to not fetishize omplexityA wultiEmethods insted of the uingdom of xouns @yyA nmoderted muttion simply hs to go @mkes onurreny very di0ultA

4.3 Functional Programmingsmmutle dt C (rstElss funtionsD supporting reursion hynmi polymorphism imphsizes reursive itertion insted of sideEe'et sed looping userb @let myEvetor I P Q R myEmp {Xfred ethel} myElist @list R Q P IA @list @onj myEvetor SA @sso myEmp Xriky luyA @onj myElist SA myEvetor myEmp myElistAA Eb @I P Q R S {Xriky luyD Xfred ethel} @S R Q P IA I P Q R {Xfred ethel} @R Q P IAA IS

4.4 Software Transactional Memorygore dt strutures re immutle nd n esily e shred etween threds wuttion is possile using loks to void on)its dosynD refD setD lterD et lD supports shring hnging