Clojurescript up and running
Upcoming SlideShare
Loading in...5

Clojurescript up and running



My talk at Helsinki/JS. I gave short introduction to Clojurescript and how set up your first projects with demos.

My talk at Helsinki/JS. I gave short introduction to Clojurescript and how set up your first projects with demos.



Total Views
Views on SlideShare
Embed Views



1 Embed 26 26



Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution-ShareAlike LicenseCC Attribution-ShareAlike License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

    Clojurescript up and running Clojurescript up and running Presentation Transcript

    • Clojurescript up and running Timo Sulg, @timgluz @Helsinki/JS, 27th November, 2013
    • What? And why? Was? und warum?
    • source: CoffeScript wiki has ~200 langs
    • JS as assembler for web JavaScript is an assembly language. The JavaScript + HTML generate is like a .NET assembly. The browser can execute it, but no human should really care what’s there. - Erik Meijer, author of Rx and Linq source: Scott Hansemal's blog
    • Photoproof
    • Clojure's brith
    • Clojure? 1. Functional 2. Dynamically typed 3. Lisp
    • Clojure/Script? Subset of Clojure No concurrency primitives Influences from Host
    • Inner parts source: Stuart Sierra's "Clojure - getting up and running;"
    • Best parts 1. 2. 3. 4. 5. Generic data primitives Highly composable Expressinevess Extensible core.async
    • Little peak into syntax quick steptrough source: Kanaka's cheatsheet
    • Getting started ; it j cnoe ; no s osl (lgj/osl "el wrd"; .o scnoe Hlo ol!) ; it BosrRP ; no rwe EL (rnl "el wrd) pitn Hlo ol"
    • Code modularity (scj.ol.el n lswrdhlo (rqie'sassn:ssn) :eur [tr.u a u] (ue'paeserh:ny[a,ngt :serh) :s [ ol dy ih] a at])
    • Primitive collections ; ary ; ras (e a(ra) df ary) (e a(ra 123) df ary ) (gta1 ; 2 ae ) ; ; ojc ; bet (e o(soj) df j-b) (e o(soj"o"1"a"2) df j-b fo br )
    • Generic datastructures ; ls ; it (e a(it123) df ls ) (e b'123) df ( ) ; vco ; etr (e c(etr123) df vco ) (e d[ 234) df 1 ] ; st ; es (e f(e 1123) df st ) (e g#123) df {,,} ; hs-as ; ahmp (e h(ahmp:o 1:a 2:a 3) df hs-a fo br bz ) (e i{fo1 :a 2 :a 3) df :o , br , br }
    • Equality (e a[rd "le "re") df "e" bu" gen] (e b[rd "le "re") df "e" bu" gen] ( ab ; = tu = ) ; > re
    • Conditionals (f(o?(on bgnmes) i ps cut u-ubr) (rnl "o rayfrrlae) pitn Nt ed o ees" (rnl "eppsig) pitn Ke uhn") (hn( 0x1) we > 2 (t "ai tevle) sr vld i au") (od cn ( n0 "eaie < ) ngtv" ( n0 "oiie > ) pstv" :le"eo) es zr")
    • Functions #d-m %) (ost 1 (o tebn'lc'#d-m %) .n h-t cik (ost 1) (e fn(n[ (rnl "o o fn") df u f ] pitn Lt f u.)) (enfn[ df u ] (rnl "o o fn") pitn Lt f u.) (e fn df u "eei eapeo mlil aiy hr s xml f utpe rt" (]nl [ i) (_ 1 [] ) (__ 2 [ ] ) (___ 3) [ ] )
    • Destructuring ; cnawy dsrcuei bnigepeso ; a las etutr n idn xrsin ; icuig lt fnto agmns los ec ; nldn, e, ucin ruet, op, t. (e m{frt"o" df :is Bb :ide"" mdl J :at"mt") ls Sih} (e [:es[is mdl ls] m lt {ky frt ide at} ] .. .) (e clr[5 251005) df oo 25 5 0 .] (e [rg_a clr lt [ ] oo] .. .)
    • Variable arguments ; alagmnsbyn towl b pae i a ; l ruet eod w il e lcd n ; sqec budt rs ; eune on o et (enfo[ b&rs] df o a et .. .)
    • Named parameters & defaults (enfo[ {ky [a bz} .. df o & :es br a]] .) (o :a 1:a 2 fo br bz ) (enfo[ {ky [a bz df o & :es br a] :r{a "eal1, o br dfut" bz"eal2}].. a dfut"} .)
    • Iterators (oe [tm[,,] dsq ie 123] (rnl ie) pitn tm) (oie [ 5 (rnl "B") dtms i ] pitn AC) (op[ 0 lo i ] (rnl i pitn ) (eu (n i) rcr ic )) ;frmprdc;itr ;o;a;euefle
    • More Joel Martin, @bus_kanaka, has done great job. Source:
    • Demos Setting up Interop with JS Dommy in Action Core.Async
    • Setting up and getting running
    • Setting up environment Download the lein script (or on Windows lein.bat) Place it on your $PATH where your shell can find it (eg. ~/bin) Set it to be executable (chmod a+x ~/bin/lein) Check the version: $> lein version more info:
    • Starting with new project $> lein help new $> lein new ex1_intro
    • Result
    • Change into this
    • Set up project's file (epoete1ito"..-NPHT dfrjc x_nr 010SASO" :ecito "u iiilpoet" dsrpin Or nta rjc. :r "tp/eapecmFXE ul ht:/xml.o/IM" :ies {nm "cis Pbi Lcne lcne :ae Elpe ulc ies" :r "tp/wwelpeoglglelv0hm" ul ht:/w.cis.r/ea/} :eednis[;ht:/w.esoeecmjv/r.ljr:ljr/.. dpnece ;tp/wwvriny.o/aaogcouecoue151 [r.ljr/ljr ".." ogcouecoue 151] ;ht:/w.esoeecmjv/r.ljr:ljrsrp/.-00 ;tp/wwvriny.o/aaogcouecouecit0023 [r.ljr/ljrsrp ".-00] ogcouecouecit 0023" [enlgtnel".."] li-ih-rp 007] :lgn [li-lsul "..-NPHT]; mkscouecitn ese puis [encjbid 101SASO" ; ae ljrsrpig air [ensmltn".."] li-ipeo 120] :elotos{nelmdlwr [ihtbenelhnlrlgtal-p] rp-pin :rp-ideae lgtal.rp.ade/ihtbeos} ; cmrhnieeape hts/gtu.o/mzseli-lsul/lbmse/ape ; opeesv xml: tp:/ihbcmeeek/encjbidbo/atrsml :lsul { cjbid :uls[ bid { ;Tept t tetplvlCouecitsuc drcoy h ah o h o-ee ljrSrp ore ietr: :orepts[sccj" suc-ah "r/ls] :oplr{ cmie :uptt "eore/ulcj/oej" otu-o rsucspbi/scr.s :piiain :htsae;:oe :ipe :dacd otmztos wiepc nn, sml, avne :annstu wrig re :rtypittu}]) pet-rn re}}
    • ex1_intro/core.cljs (se1itocr n x-nr.oe ; uewe yuwn t rp it ti pg ; s hn o at o el no hs ae (rqie[]) :eur couebosrrp a el) (en^epr mi [ df :xot an ] ;sryaotta ;or bu ht (wiej/ouet .rt sdcmn "h sye""oo:e;">Hlo HlJ!/1" <1 tl=clrrd" el, e/S<h>) ;ti pr i rqie frcnetn it brp ;hs at s eurd o oncig no -el (elcnet"tp/lclot90/el) rp/onc ht:/oahs:00rp")
    • index.html <!<1i ="ra"Frtdm<h> h d ae1>is eo/1 <citsc"j/oej"<srp> srp r=/scr.s>/cit <cittp=tx/xml" srp ye"eteape> /cligorfrtap x_nr.oemi(; /aln u is p; <srp> /cit -> -
    • Run it $> lein deps ;; only when you changed deps $> lein cljsbuild clean ;; $> lein cljsbuild once ;; or use auto $> lein simpleton 3000 file :from resources/public $> goto
    • REPLing with Rhino $> lein trampoline cljsbuild repl-rhino $> (dotimes [i 5] (println i)) $> :cljs/quit
    • Interop with JS Leap.JS
    • Dommy a app for FirefoxOS
    • Run it $> lein repl $> (require '[foxyeye.handler] :reload-all) $> goto: ... $> (foxyeye.handler/stop-server)
    • Mainpage
    • State of project dependencies
    • Search
    • Dommy (en^epr ii [ df :xot nt ] (lgj/osl "erhapi iiilzd) .o scnoe Sac p s ntaie" (om/itn (e1:sac-t):lc o-erh dmylse! sl #erhbn cik nsac) (oe [tm(e :fct-agaeie) dsq ie sl .aeslnug-tm] (om/itn ie :lc tgl-aesie)) dmylse! tm cik ogefct-tm)
    • Templating with Hiccups (eur 'fxeevessac :ssac-iw) rqie [oyy.iw.erh a erhve] .. . (enrne [ cnet df edr & otn] (tl hm5 (nld-s "csmdr.s" icuecs /s/oencs "csmdr-epniecs /s/oenrsosv.s" "csapcs) /s/p.s" [bd.erucs :oymtois [scinapiain{cas"rdcnee" :eto#plcto :ls gi etrd :tl "a-it:30x bcgon:wie" sye mxwdh 8p; akrud ht;} cnet]) otn]) (edr(erhve sac-tm) rne sac-iw erhies) Source:
    • Little Dommy in Action ; gtalslce lnugs ; e l eetd agae (engtslce-ag [ slcos df e-eetdlns & eetr] (pl sr apy t (neps itroe , (o [eetd(e slcos] fr slce sl eetr) (om/trslce :aalnug))) dmyat eetd dt-agae)) Source:
    • Core.async the last demo
    • Links
    • THE END @timgluz