Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Why Elm

Avatar for Greg Ziegan Greg Ziegan
January 09, 2017

Why Elm

Avatar for Greg Ziegan

Greg Ziegan

January 09, 2017
Tweet

More Decks by Greg Ziegan

Other Decks in Technology

Transcript

  1. W hat is E lm? L angu age (and "fr

    amew or k") for bu ilding w eb fr ont end app licat ions C an be us ed in p lace of HTML , CSS and J av a S cr ipt C omp iles int o t he abov e
  2. T he problem with J ava S cript F ew

    p eop le know all of J av a S cr ipt ‑ in fact it is gett ing mor e and mor e comp lex each y ear. B ad featur es ar e nev er r emov ed, just lint ed D iffer ent p eop le hav e v ery differ ent w ays of us ing t he langu age (object‑or ient ed, fu nct ional, t his‑less, ...)
  3. T he problem with J ava S cript (cont.) W

    it h J av a S cr ipt, anyt hing may su ddenly fail in pr odu ct ion becaus e of an ov ers ight N ot hing can s av e y ou fr om t hat (ex cept may be boat loads of menial t ests: w hat if t his fu nct ion is called w it hout ar gu ments, w it h an empty arr ay...) I t t akes a gr eat deal of dis cip line t o keep code r eadable and adher e t o t he pr oject's code sty le
  4. T he problem with J ava S cript (cont.) H

    u ge p ot ent ial for r egr ess ions w hen r efact or ing E v ery pr oject has a w ildly differ ent bu ild s cheme s ince t her e is no "official" or ev en gener ally s ett led‑up on t oolchain I t is common for bu ilds t o br eak becaus e a libr ary w as up dat ed
  5. J ava S cript is unwieldy in big projects J

    ava S cript is in fact poorly suited for lean development, because refactoring is risky
  6. H ow E lm solves it E lm is a

    s imp le and comp act langu age I t does not hav e t he baggage of J av a S cr ipt's hist ory P ast r eleas es hav e made it s imp ler and s imp ler ‑ t he maint ainers cont inu e t o r emov e confus ing langu age featur es
  7. H ow E lm solves it (cont.) I t has

    a gr eat typ e syst em t hat helps model dat a and app licat ion st at es T his can be us ed t o eliminat e an ent ir e cat egory of bu gs: arr iv ing in imp oss ible st at es I f t he code comp iles, it is corr ect (can st ill hav e logic err ors, of cours e)
  8. H ow E lm solves it (cont.) E lm has

    no n u l l or u n d e f i n e d E lm has no ru nt ime ex cept ions ex cept for D e b u g . c r a s h A ll p ot ent ial cas es need t o be handled ‑ no surpr is es or u nhandled err ors, gu ar ant eed! U s ing T yp e S cr ipt or F low can giv e s ome of t he benefits, but many libr ar ies' typ ings w ill st ill non‑ex haust iv e)
  9. H ow E lm solves it (cont.) E lm enfor

    ces wr it ing code in a s ingle p ar adigm and sty le (fu nct ional, no mut able st at e) I t comes w it h gr eat t ooling out of t he box B u ilds can nev er br eak becaus e of libr ary up dat es, becaus e s emant ic v ers ioning is ensur ed by t he p ackage manager
  10. E lm is very well suited for lean development, because

    refactoring E lm is fun and we can do it with confidence!
  11. B ut a new language, surely it's an additional cost!

    J av a S cr ipt pr ojects us e a combinat ion of e.g. R eact, R edux, r edux‑loop, et c. T hey might ev en be us ing T yp e S cr ipt or F low, w hich ar e langu ages w it h gr eat impr ov ements ov er p lain JS B ut t hey bu ild on t op of JS , and as s aid befor e, few know t he w hole decor at ed p ast of J av a S cr ipt
  12. B ut a new language, surely it's an additional cost!

    T her e is v ery likely no ot her Zendes k pr oject w it h t he ex act s ame libr ar ies and/or code sty le N ew dev in a JS pr oject needs at least a w eek or tw o t o lear n t he pr oject E lm is a s mall langu age I t t akes a coup le of w eeks t o be pr odu ct iv e A bout a mont h or tw o t o mast er all of it T he E lm comp iler is t he st at e of t he art w hen it comes t o fr iendly err or mess ages
  13. B ut a new language, surely it's an additional cost!

    A ll E lm pr ojects follow t he s ame gener al p att er n, becaus e t he langu age does n't allow anyt hing els e E lm code is easy t o r ead as it commu nicat es int ent ions w ell N ew dev can't inadv ert ent ly mess up an E lm pr oject
  14. W hat if the language development is discontinued in a

    year E v en if t he langu age dev elop ment w as dis cont inu ed t oday, it w ou ld be fine T her e's no r eas on w hy a pr oject cou ldn't be us ing an older v ers ion of E lm for y ears t o come JS as a comp ile t ar get is s olid, becaus e all old JS code w ill cont inu e t o w or k in br ows ers als o in t he futur e. (O ne J av a S cr ipt (1JS ) pr incip le)
  15. W hat is E lm a poor fit for M

    ost ly st at ic p ages (e.g. news w ebs it es) V ery s hort pr ojects w her e y ou actu ally w ant t o us e r eady‑made UI comp onents (e.g. MVP admin UI s) L ots of int egr at ion w it h t err ible t hir d‑p arty J av a S cr ipt (adv ert is ements in p art icu lar) S it es t hat need s erv er‑s ide r ender ing A ls o w ort h r emember ing, it can't be us ed t o bu ild a backend
  16. W hat is E lm great for S ingle p

    age app licat ions B esp oke des ign L onger pr oject (> 2 mont hs) E sp ecially help fu l for bigger fr ont end t eams
  17. J avascript E lm V iew R eact L angu

    age S t at e M anagement R edux, M obx, B aobab, ... L angu age I mmut ability I mmut able, s eamless‑immut able L angu age R out ing R eact‑R out er L angu age B u ild T ool W ebp ack L angu age R emot e D at a P r omis es, R x L angu age P ackage M anagement np m/y ar n L angu age S ty ling CSS M odu les, SASS , S ty led C omp onents, et c elm‑css, any T est ing M ocha, J as mine, J est, E nzy me, C apy bar a elm‑t est
  18. J avascript E lm G r ap h QL R

    elay elm‑gr ap hq l A nimat ion R eact‑M ot ion elm‑sty le‑animat ion A ut o‑F or matt ing N one elm‑for mat W eb comp onents ✓ ✓ A dv anced E dit or S upp ort ✓ A ut omat ic V ers ion U p gr ade ✓
  19. P r os: 1. N o ru nt ime err

    ors 2. E xtr emely easy r efact or ing 3. H igh qu ality libr ar ies 4. O bv ious naming for dis cov er ability and collabor at ion 5. E asy t o lear n w/ incr edible err or mess ages 6. E asy/aut omat ed up gr ades 7. C an alw ays eas ily int er op w it h JS /E mber/R eact/et c 8. S ame ar chit ectur e for ev ery app (game/w ebs it e/SPA /et c) 9. M akes dev elop ment fu n
  20. C ons: 1. N ot near ly as many t

    hir d‑p arty libr ar ies 2. A ss et M anagement, next r eleas e 3. S erv er S ide r ender ing, next r eleas e 4. R u nt ime bu ndle w ill not be as s mall as S v elt e 5. S t ill exp er iment al on mobile 6. C annot s har e code on t he s erv er for at least anot her y ear
  21. I hav e been wr it ing E lm for

    1.5 y ears nev er a need t o ju mp int o a JS debu gger. hav e been able t o wr it e JS & E lm w/o issu es hav e put E lm int o R eact apps w/ > 5k lines of app code fellow class mat es able t o be pr odu ct iv e w it hin a w eek bu ilt & bu ilding elm‑aut ocomp let e, elm‑calendar, elm‑ r eor der able st ill a "fu nct ional pr ogr amming" beginner. I don't wr it e H as kell. E lm is pr agmat ic