SlideShare a Scribd company logo
Code as
  Data
as Code




@fogus
me

12 years
   XP
me

12 years           AI
   XP           “Real World”
me

12 years                      AI
      XP                   “Real World”


C -> C++ -> Java ->
Python -> Ruby ->
Scala -> Clojure


      Langs
me

12 years                         AI
      XP                      “Real World”


C -> C++ -> Java ->        * Joy of Clojure
Python -> Ruby ->          * Clojure/core
Scala -> Clojure             - Clojure
                             - ClojureScript

      Langs                      Clojure
me

12 years                         AI
      XP
               I❤             “Real World”



               Java
C -> C++ -> Java ->        * Joy of Clojure
Python -> Ruby ->          * Clojure/core
Scala -> Clojure             - Clojure
                             - ClojureScript

      Langs                      Clojure
me

12 years                         AI
      XP                      “Real World”


C -> C++ -> Java ->        * Joy of Clojure
Python -> Ruby ->          * Clojure/core
Scala -> Clojure             - Clojure
                             - ClojureScript

      Langs                      Clojure
am s
     g r ng
 ro iti
P r          s
 W ram
 P rog
Java
create table COFFEES
  (COF_NAME varchar(32) NOT NULL,
  SUP_ID int NOT NULL,
  PRICE numeric(10,2) NOT NULL,
  SALES integer NOT NULL,
  TOTAL integer NOT NULL,
  PRIMARY KEY (COF_NAME),
  FOREIGN KEY (SUP_ID) REFERENCES SUPPLIERS
(SUP_ID));




                                              Data
create table COFFEES
  (COF_NAME varchar(32) NOT NULL,
  SUP_ID int NOT NULL,
  PRICE numeric(10,2) NOT NULL,
  SALES integer NOT NULL,
  TOTAL integer NOT NULL,
  PRIMARY KEY (COF_NAME),
  FOREIGN KEY (SUP_ID) REFERENCES SUPPLIERS
(SUP_ID));




                                              Data
public static void viewTable(Connection con) throws SQLException {
    Statement stmt = null;
    String query = "select COF_NAME, SUP_ID, " +
                   "PRICE, SALES, TOTAL from " +
                   dbName + ".COFFEES";

    try {
        stmt = con.createStatement();
        ResultSet rs = stmt.executeQuery(query);
        while (rs.next()) {
            String coffeeName = rs.getString("COF_NAME");
            int supplierID = rs.getInt("SUP_ID");
            float price = rs.getFloat("PRICE");
            int sales = rs.getInt("SALES");
            int total = rs.getInt("TOTAL");
            doPrint(coffeeName, supplierID, price, sales, total);
        }
    } catch (SQLException e ) {
        JDBCTutorialUtilities.printSQLException(e);
    } finally {
        if (stmt != null) { stmt.close(); }
    }
}
public static void viewTable(Connection con) throws SQLException {
    Statement stmt = null;
    String query = "select COF_NAME, SUP_ID, " +
                   "PRICE, SALES, TOTAL from " +
                   dbName + ".COFFEES";

    try {
        stmt = con.createStatement();
        ResultSet rs = stmt.executeQuery(query);
        while (rs.next()) {
            String coffeeName = rs.getString("COF_NAME");
            int supplierID = rs.getInt("SUP_ID");
            float price = rs.getFloat("PRICE");
            int sales = rs.getInt("SALES");
            int total = rs.getInt("TOTAL");
            doPrint(coffeeName, supplierID, price, sales, total);
        }
    } catch (SQLException e ) {
        JDBCTutorialUtilities.printSQLException(e);
    } finally {
        if (stmt != null) { stmt.close(); }
    }
}



                                                                     Data
public static void viewTable(Connection con) throws SQLException {
    Statement stmt = null;
    String query = "select COF_NAME, SUP_ID, " +
                   "PRICE, SALES, TOTAL from " +
                   dbName + ".COFFEES";

    try {
        stmt = con.createStatement();
        ResultSet rs = stmt.executeQuery(query);
        while (rs.next()) {
            String coffeeName = rs.getString("COF_NAME");
            int supplierID = rs.getInt("SUP_ID");
            float price = rs.getFloat("PRICE");
            int sales = rs.getInt("SALES");
            int total = rs.getInt("TOTAL");
            doPrint(coffeeName, supplierID, price, sales, total);
        }
    } catch (SQLException e ) {
        JDBCTutorialUtilities.printSQLException(e);
    } finally {
        if (stmt != null) { stmt.close(); }
    }
}



                                                                     Code
OR
  M
public static void viewTable(Connection con) throws SQLException {
    Statement stmt = null;
    String query = "select COF_NAME, SUP_ID, " +
                   "PRICE, SALES, TOTAL from " +
                   dbName + ".COFFEES";

    try {
        stmt = con.createStatement();




                                   ORM
        ResultSet rs = stmt.executeQuery(query);
        while (rs.next()) {
            String coffeeName = rs.getString("COF_NAME");
            int supplierID = rs.getInt("SUP_ID");
            float price = rs.getFloat("PRICE");
            int sales = rs.getInt("SALES");
            int total = rs.getInt("TOTAL");
            doPrint(coffeeName, supplierID, price, sales, total);
        }
    } catch (SQLException e ) {
        JDBCTutorialUtilities.printSQLException(e);
    } finally {
        if (stmt != null) { stmt.close(); }
    }
}
OCaml
from this...
List.map (fun x -> x+1) [1; 2; 3]
to this...
            List.map (fun x -> x+1) [1; 2; 3]




ExApp (loc, ExApp (loc, ExAcc (loc,
   ExUid (loc, "List"), ExLid (loc, "map")),
     ExFun (loc, [(PaLid (loc, "x"), None,
       ExApp (loc, ExApp (loc, ExLid (loc, "+"),
         ExLid (loc, "x")), ExInt (loc, "1")))])),
   ExApp (loc, ExApp (loc, ExUid (loc, "::"),
    ExInt (loc, "1")),
     ExApp (loc, ExApp (loc, ExUid (loc, "::"),
       ExInt (loc, "2")), ExApp (loc,
         ExApp (loc, ExUid (loc, "::"), ExInt (loc, "3")),
         ExUid (loc, "[]")))))
just this...
List.map (fun x -> x+1) [1; 2; 3]
well, this...
      List.map (fun x -> x+1) [1; 2; 3]




<:expr< List.map (fun x -> x+1) [1; 2; 3] >>
the expander
      List.map (fun x -> x+1) [1; 2; 3]




<:expr< List.map (fun x -> x+1) [1; 2; 3] >>




          camlp4::expr
Pure
foil
foil
(x1 + y1) * (x2 + y2)
(x1 + y1) * (x2 + y2)
(x1 + y1) * (x2 + y2)
(x1 * x2)                           First
(x1 * y2)                           Outer
(y1 * x2)                           Inner
(y1 * y2)                           Last
(x1 + y1) * (x2 + y2)=
                    // First
   (x1 * x2)+
                    // Outer
   (x1 * y2)+
                    // Inner
   (y1 * x2)+
                    // Last
   (y1 * y2);
(x + 3) * (x + 5);
//=> x*x+x*5+3*x+15
x*x = x^2;

(x + 3) * (x + 5);
//=> x^2+x*5+3*x+15
Code as Code.
Data as Data.
Code as Code.
Data as Data.
#}({_({}{[)#[]]}}{}{#(#(]#_}#([()_]}[_}{[_]#}]_{}{(](#[)#_#()(}{[#{_{)[])#[[_}[_{]((_#_(_{(#_#_{)}}#}{{){]([)]({_[))][][#}()}_[##)_#]]#]#)
_(]}_{)]#}_##(#]]_(}))(}#{#(_#)(]))#}{{_{[([(_]{)]})_([]}_{[#_][{{[_(_}[_])]]]]_#[((}{{#_)#[#(]{#__()[{#_}))_))]()]{()#}((](]_}(#][{(}}[[_
#]_]}#{}{][)[[_#__[)}]}]]__##[(_{#}#}[)({)}[)(}](_(}{_[_{)){#___]{{](]#(#])_[)[([({{]#)}#(}[]#])##_}{_#{[_))#{)}}_(_#[[{[}#[](([(_((){_[#]
[[[#_}}]#_([#]]_}_]({_]){#{[]((]#}}{[)_{([#]{#({)#{(}###](]{)]{]}_()#]}{{]}_##){)()[#})]]_(}](#)(#]]#]__]]#][_(}]}{{__(_)(()()()[(#(#_}]}_
{##]{{__()#{(_)_()#(#[])_[[)[[[{[(_[()]{#[}(][()}_{(}{)((}[])[_#{}][#[[])[[_(]}]}}[)#{{#{##]{]#_[})(}}(})((#))[)(}}_)#]]{)}_]))_]#](}_{)})
{)]#_([[]()()({(}]}_{{#([(__#_}]{[]}}}#({]#)#{}_)}){)#]([#}))(##(}([[[[}[#{_(}}}[{{(_}_[#)]()}}{#}#(]}}#}[{#}([_)(#]]}#()){)_#()]}(}}}{[{}
){[#((]}#_){[[#{#]]]([}[{}()#{{{[})({_[[__)}#(_)[[][_[)[([{}((][#}]((#[{(([}[#][})(}()}[[(}]]))##}{{)#({##[}{{[_]_}]}}[{)))#{])#}{_[}[_(]]
]_{][#__(_)#_({_{(}})(]{}]{[_({{#}_((_{){{#][)()_{__[{[[}[(((()[}(])[{#()#((}#{{(#}[#((])({}{([__]_{]{{_#{[)(]]}}]))}{##})#)}#{_]{{{#_(]][
{#))_[[({][[}{}{#}})}#[_)__#_](}([]{}(#)##}}[{_{])___{_))]{#]{_[#(}))##__))[)_]_[_]{[][[)]{[{])){({#_]}_{((([]##)}(}]#))}]{(#}(}]}_{[}[(]_
(_[#[{[(({##}#__##}][_[)[}#)]#{{_)__(((((){#]})_)#{{)_{})}(__)}_}_#{))[)(]])}#_](#){}_]_#]]#])(])[(]_[_}}(#[#)_#[]))_{}#]{#[[#{}([(}}_#__)
]}[}}#(}){][_]])}}_]})[#{}}))]#}})(]#}_{)#[}}__))[[[[)##)})#_]##)])]##}}[{{[)#}[)(}_({(]]}[(}_]_[#[(#({})}{}}_}{}][_{]]_#_[(_}[]_[)[{()}#}
))({[]{##)}[}}#))(#(]{{[})_{#[[##[]__#(}{)[)}(})#[{)](_}[}#(}(([[(([#){)#{)]){{}{{]}(()(][_)]##{[}#){[_}_#{(#}_}(_#)[{_[})_{{#_{]{{}}##)#]
#[]##_[(}{(}[_{]){_](__)]][(#[})]{#)]_]}([)[]]){)_[)_#)}_}[()_]]#[[}]][#{[#(_{[)}{)#(})##[(_(_##[](]]_})}{)#[))]_##([[)}{)])_#]#]}(_#(](){
[({#)_()_}([#{[][_)([]}_#[#_)}(](]([(){})}](}{}#_]]}_(#}#__[[_[]]#()#}(([(_{]())]{){_]{((__}}[[[}]_#{{)]]#(#[{}((##(_(])([#{[(_{_(#_){}{[_
#(})}{]}]]][[__[[((]]]}(}]{()#)[(#]}){{[}}_]{#}_{)]#[_))(}](_}#)}}_{))(}]_[__([{))[#}__((]_]}]#}]){}({}#[][_[{}}}]]#(({__}#)#[[_]_]#_}}{](
#}#_{({}_)(_}[}((](##){)}#_([([]_#}[[{[([)_(})_{()(_{}[)#(#_][_##}[}[([[#{)[}{{#}[(_]_()])#[[__(#{}_)))#{)[([{_]_[(]]_#[((_})___(_}[{[#[]_
[](}_#{[]{_][_})])}#]]__]#}_(()){}}]#]}#)[(_[##([(#_[)[#_#__{{}}#[}[}(}#]{}_[)[}{}_}#[)#[{[([){}({(){(){]_[[]}{)_)(({[(])#[_(}]#[](}{[[#]#
{}{{{[([]{}{#_)}(])#)___))}[){[_})[#{##_])#}})[)(]#{[){)((]}_]{]_(){{{])[}]_]{{_)]_){}#{}#({{)[)}#}(_()[[[([(_]#___#([)_{[#][[#)_[{))]])[)
(_}{]]]({#{#)]][[)_{]#(){_}[)({}{#})#_]{]#_[{][]])](#[}##}[)})](]([{)]](]#{)}(#)]{(([{[}_)#()#___]#}#]]})[]#[}](_#_{_[_}[[][__]__#]_{((}[#
#_[}})_]]#[{])_{#){})[]_)_]#({#({){(_{_{_(]){(((#)[[_[{}){}(#]#{#])]]__[}]_[}]}}(}#[{{_}#[{[)(({{)])#[}([#{[((}{}###[}(]{}]}})}(#](#}}_{[{
{}#{{})){(}((){})}]}__{###(_[()(([]{[(##[([#]_#}(#}](}]{(#]_{](}{)}{_})[]{[{_(#(}{}]}}){]{])()_(()([}#_##[}]){{{#())#)_(#{)][]]{[})(_#{])}
_##){_(]({]][(]){}{}(((}#]]})]#({#_]}_#{)]})[{}[}{}}{(_{{[]))}{}([(]_(#)(}(#)_#(_}{[)[}_#{_[]()_#(){_(()(#_}())[]{))#_}}(#}))(}]){#_)(#[])
}#[_({]]([)#(]((}##)[#([_#})({(#(}#_}_#(}(}]{#)]_})}([))#()[_(][#}[{#)}}}[##)}#)_]_{]}}#)#{}()))#[_)}#[_##_(())}##_#)_){[##{]#)_)}][))([[{
#{#{##_[#({(}{}_(){}{[({}[]##_][}#([}}{[#]]#}__{({)][{}_#(_][_)}#)])]{#]]]][{(){][[((](][#[{)(}{{[({[][}(}]_(#[]]_){({{{})(}#{_)))_(_[#]{(
[{[})#[#]})}]#{_#[{])([[#})__})(}#(][)}({)_)#[[_)_{(__{)[{#_()}{[{(#{]}]](_[])]_)]]{])#([[](){}#[_[)}#)[#_]){{}_{{{#}#}{[][)){)[{_}})){[_]
{}#{})(]({)#)]_}[[[#]##(#[{((##[([###]{[]_[{[}{(]_}_[]}{()_#()(]]_}#]{}#{__]))][_)(}{_{)#}]#(#_((#)#_[}_}[{{((]){](([]_{))})[{]]]{#}[)_]))
#]]_[{#}]##()}})))]])#{{)[((]{)]#}[}}{)][#_[{[_{(})]#(_#]#)_}[}##([[{#]_}{]{(}]][}[[(#}#_}_#[((#](_#([]{}}([]((([[)())(_)({#)})]_]]{{)]][}
(#})((]](_[_[{#}##){{)(]_#]_(}#}[([)(_##(_(_[{(#)}(#}_(#{})##(#][[#({}[{(__{#[{}[){]#))_][#}({(_{##[[}]{_([#}]]{]((_{##}]))))__)#[]#(()}{(
]]#([_[##}{)[][[)[[{{_{{_[_)[]{#{{{}]#{##{{){_]][{_})}_})]}#{{{}}]#)#_]#))[)]([#{[)_{#{__[[}]}[)[[]{_][])(](}}#({}}]#}__{)[_((_{{[[}}[_)#_
})#}#_#{[{]}#)_(#}#()){#[(#({][)}})_(}}__{()###[}]]_})({#}]#_#(({_])#[(]{#}{{]{])(_}{#][#[_(})[}##](]{{{{)[]}]#[_{#][]#_#))_}[#(#_]_[_{[[_
(]#(_}}][[{_)_}](]()([][_{_{__[#{){]{)(}(_{#)#__(##(]_])]]#[[]#[_{(()#)[]({_][](_{{[]{#)({#]][]{{}[__)}{#{{}_{][)}(#[][]{[#{[])#}{()#___[#
}][}(}###_]{}{])]])]}]](__()){)(}}[}{_[([}(_]#}#[{[#]{(_{}]_]}}}#](({#[_}_#{{}][{_}#}}(##)_#))]([_))[]))#[#([(]]{[]{]])_{])_(((}]#[({{_]})
[{#}(}[]](#]}}}}]_#[[]{[(]_#____#((](][}(}_)__)[{(([)]})]{#__{{{}#(})#)[#}))}(__[[{]#__([](()()[_]])((_#(]}##(}(_[{{(##[[[}#)#_[)#{{]]](])
#])(}_([]#(}#(##])]_({#)#[)][(#)}__]{]})_#{#}_(({{)]{([##]}}[([_#[}()__[}_)]_[_])##){({()_}#{}[))(]((_]({_###]}#){[[#{[(]_)#)}{{}()#){]([{
}][)))#])[]{[[_}({}__){##}[_])#](}(}#_}_)[#}{_[[[#{{}]([{#]#){[}##{}_{_})([}_(_)#{})(_((#}#_(_[_}(#{}__)}}]_](){####{}]#[({#)#])]{)##}{}]#
){))]{}([(#}_[#_#(#){[_[_](}(}(#{{#[()()((__])]]#{()]##))]]{(}{_#]]()[}[(##[(_({{(#}[})[])])]()_)__{[{][#{)]#}([_(#{#{#{})[])_](#_}[}[][((
_#[({#}(#_]#_)}###{}#({_[]}[)__}}}{{#}{#])[](}[(]}__{{(#(({_)]_{(#])__[{}]()_[#[}_[#]{}#]]{{()#)_[[[{{]}#(}](##[]]}[_][({_#{[)]}]}(]#]{}_[
_[[[[[_{#(#](}#}_}){[)()#([]{()#)_][_#})(}__))}]_})(]{)[#(#]#_#)[)]{##{{[{)#{(}_}([})((#))}__#)_)_{[#((}_(#{}_{]]_[}##{#))_{(#()#][{][})#_
[[{}))[]_[)#_)}#_[({}(({]{)}{))(}})})((([[{){[{())](}]_]}}(}}[#{_](([({)]{}##{_{)}{(__](]#_}#){__}]_)][__{}#_{_[]([)_#{([]}}}{_)}_[[_)#)(#
}}(]]{[}){(][[)#){][{)#[(_}{}##(]_]#{}][]){()}[{))_{_[#{[_[]({{#(]]#_]]}(([((#_{(#)]][#{__{]{}#{_##}}((#([(}][[(((([(#_)(}))##{]_{])[}{[{)
##_#[#_}([_(]]_{)[([#[][[))_(#_{[}]#])}[(](]]}(##[((_}_#()#{#_}_[#}]#_[)[_{_){)#[#___[[__)}(#]{[)]]()}[}_(}({_(#{}[](#{#){(]{[(}[{(]}(__]{
)#_){{}[{_]][{[#)(]][#{#[}([)]{){})}[##)#)]_[()}{(]#)#}#([}[#[]{]]}{]]{{}#{}]__{)#)_(){)#{#}{#[###({{[)(}[}({])]{}_{[]{}#_][_]}((]{[[_}[#]
}_]{_[((#([#__{([#)(])]{#)_())#}__{_##}]_#{##])}}}[##)[(][_})#}_{()(_)]_#]{[_(){)}][}[[]_{#([#[()[()}))_#[{([[}}){(_{((]#[()__}]_#)_{}#{[}
]_]}[__{{[([]#))]}[[(][{])((}[)}))((]}{[[[)#[]{{#][[}]{(_]}]]((_#(_}#(_{_({])__}]###]){_[}#__[)(_([[}[#}{]{__#({]}}(_{[}{)_#{[{(}_]({#))[#
})#}{{[())}[[}{}(])]]({_][{]{(_{[([#}]_)_)#)]){#_{()(_{)#)({{()(#_}{}])[_(}#_}#((_[_(_#[})]##_(__]]}])((){{#)){{([_)({}{(}}#]}}]()](##{(]_
_]}_(_[]#}{{)__{)(](__{##[({#]_#]_}{][#_[##[}))_})[}#({]_}#)}_()(}#[}{_)[)]#][#{_{_{#[({}({_(}[(({}}]#]_)_#[_{]#}[])]}]{})#(]}([{]_([])]_[
}_{#}([](}(({){][((}(({[{[(){#}}#]_(}#[{{#](}}(#])}{)})#(])({)}}_}{})]{]{}(([}}[})[{]#[)[#{[)][}){])]]}]](]{)][){{]}[{___[_#[)]#}}{#_))#)_
][#})(_{#))__][)[[[))[_}}##()]_))}#_)}#[{)([__)]#][}#)]{}#(#{}[)]_]_[{))[](](#{[[_]{])[#}_{###{]([[)[]#}])__[_)#(){[))}})){])]()(_[]#[}}]#
}}]}___{{]#_#}{}##___}_]__]#[([)_}](}_)]}__[[{){[{]}#(][}]_)#(][(#(]))__{{)_]}#){_{]})](}#(#[)#{}{(}[_{)##(][){}(}(]#[{}_)[[({]_#]]}{])}_#
}[{[(__(_]_({([#{_)}#[{##{_#)[[}]}[()]]({{##)_({](_}_{_##_#{#_})_{[}}[(}{))][_{#{[_##[}(}_#}([[{{((]#])}_(][[#)]_{[})(#()]{_[{_){}#((}[_{}
_[#{}[]][}#[]]]{_(}[)([_[)})()##}(]_[][)}__]_###)[#{_[[_(_}#(_)}#_((]]]))]_()_)#}#][##_)##)(]{(_[#_](_)}#){]{{)([({}[(})))[[))[_{#{)}{(}((
]_)[##))#_][#}_#[)_}[#_][]_)((#(}_(]_)#])[}}_##][(({#}])}()))_#(}}_#){[)}[}])()]{]}}){{})[(])#()}})}_{(}}[#]}_[_])(((_#{[##_(}])#)_{])]((}
{})_]#[(])({{({##[{[)__(__#(#(#{()]{[}#}(})]_#[[))]]_}{__{##[({[[}]})#(__(}{(_]]}(_){)[)#)}}[[}}#]])}#]#}_[}}]{((]])[{#]}){[#}{__]}{(#]_][
##{](]}_}#][}_({}(##]#[{#]))}[]_)##}##}{[#[#_][)[]_){)]}#_[##]___)}_#]})]#]#}_{[})}]__){]}({((])(})[(])_]]_{{}#(][#(({}{])]#}[(_[#}_]}]{{{
[}](_#_{}]))[}][#(}[{##)#(_{])}_]_})}#{()_(_}}}})_#([)([#]##]}({[{({{{[))#_{)_(]]({_]}_#}_])[)][(}{}(____{}(}__]}[#){#[}}[})}_{))]([[{{{}}
(_]}()}]]#{[}[)}_{){]]#_(({_})_}]_#)[)#_])}(__[]](]_[#[_[{{})_{}[]]#[{}}}{{]}[#}#}]]]))[[]((]#(#[{]})(][#_()({[[(]#}_{{[((](])[{{}##}{}}()
){}])[#][)][)([]]){)#[]#{__[{}[[}#])_)][}#[]]][_{#[]())[#)]({){()]_}(]_))#])}([)[})[)(#){()[}(_]#](_{{(]#{_#)}}([})})))}}##:F(})({)#]_(({{
)}{_[[(_([__[#}(([#){{][_)]]]}{#])#{_)#}}{)#_]_#_({{[([#)#[]{[]{[#{[(]](]_{_([[{)[##]#(}(#]}_](#{{][{){][_({]){){]))(]{([](]_)]{(_](({]{}_
[]](([}]#[]}){##(]})((]{[][([_]{}_}{#]_#}()[[#[_(_)))#}]((){]]{[(]{[)#)_{(]([][#_[#)]({#}_]((({#{))][#]{(]#)[{}({#[__})[)_)#]#({({[)#[{}[)
Data as Data.
scalar data types
       type         example      java equivalent
       string        "foo"            String
     character        f            Character
       regex        #"fo*"           Pattern
      integer         42        Int/Long/BigInteger
      double        3.14159          Double
     big double    3.14159M        BigDecimal
      boolean        true            Boolean
        nil           nil             null
       ratio         22/7              N/A
      symbol        foo, +             N/A
     keyword      :foo, ::foo          N/A
32
composite data types
      type      properties

                singly-linked,
      list
               insert at front

                   indexed,
     vector
                insert at rear

      map         key/value


      set            key

33
data type literals
     type          literal


      list       (1 2 3)


     vector      [1 2 3]

                 {:a 100
      map
                  :b 90}

      set        #{:a :b}

34
Client   ?    Server




         35
JSON

Client          Server




          36
JSON is...
• Maps (Objects)
• Arrays
• Numbers
• Strings
• true/false
• null
                   37
Client   ?    Server




         38
Client        Server




         39
clojure data are...
•   Maps              •   Keywords

•   Lists             •   Symbols

•   Vectors           •   Strings

•   Sets              •   Chars

•   true/false        •   Integers

•   nil               •   Floats

•   Metadata          •   Ratios



                 40
XML
ML
as Code.
Data
Engine




  44
Specification   Engine




                 45
Specification   Engine




                 46
I’m really
                           doing
                        something
                            cool
Specification   Engine       now




                 47
specification of source

     (defproject marginalia "0.7.0-SNAPSHOT"
       :description "lightweight literate programming for clojure"
       :main marginalia.core
       :dependencies
       [[org.clojure/clojure "1.3.0"]
        [org.clojure/tools.namespace "0.1.1"]
        [org.clojure/tools.cli "0.2.1"]
        [hiccup "0.3.7"]
        [org.markdownj/markdownj "0.3.0-1.0.2b4"]]
       :dev-dependencies
       [[lein-clojars "0.6.0"]
        [jline "0.9.94"]]
       :marginalia {:javascript ["mathjax/MathJax.js"]})




48
awesome.jar
project.clj




              49
specification of sound

     ; Roots of the chord changes, 2 beats   each
     (def gs1-changes
       [:B4 :D4 :G4 :Bb4 :Eb4 :Eb4 :A4       :D4
        :G4 :Bb4 :Eb4 :F#4 :B4 :B4 :F4       :Bb4
        :Eb4 :Eb4 :A4 :D4 :G4 :G4 :C#4       :F#4
        :B4 :B4 :F4 :Bb4 :Eb4 :Eb4 :C#4      :F#4])




50
giant-steps.clj




                  51
specification of behavior
     <project name="clojure" default="all">

       <description>
         Build with "ant" and then start the
         REPL with: "java -cp clojure.jar clojure.main".
       </description>

       <property name="src" location="src"/>
     ...
     <target name="clean"
               description="Remove autogenerated files and
     directories.">
         <delete dir="${target}"/>
         <delete verbose="true">
           <fileset dir="${basedir}" includes="*.jar"/>
           <fileset dir="${basedir}" includes="*.zip"/>
         </delete>
       </target>

     </project>

52
I’m really
                           doing
                        something
                            cool
Specification   Engine       now




                 53
awesome.jar
build.xml




            54
?


 build.xml
<xtra-thing/>




                55
xtra.jar




 build.xml
<xtra-thing/>




                           56
xtra.jar


                                awesome.jar
 build.xml
<xtra-thing/>




                           57
build.xml
<xtra-thing/>
                !=   xtra.jar




                58
app   59
something
                else
              entirely
(foo)




        60
(foo)
macros
(foo)
(foo)
Code
       as Data.
function call

     semantics:    fn call            arg


                   (println "Hello World")



     structure:              symbol   string

                        list

63
function definition

          define a fn   fn name
                                   docstring
             (defn greet
               "Returns a friendly greeting"
               [your-name]
               (str "Hello, " your-name))
     arguments

                         fn body


64
it's all data

          symbol      symbol
                                   string
              (defn greet
                "Returns a friendly greeting"
                [your-name]
                (str "Hello, " your-name))
     vector

                          list


65
metadata

     prefix with ^       class name or
                        arbitrary map
         (defn ^String greet
           "Returns a friendly greeting"
           [your-name]
           (str "Hello, " your-name))




66
code as data benefits
easy to parse
regularity simplifies metaprogramming
data library = metaprogramming library
"language" features are library code
metadata
query-able
Code as Code.
Data as Data.
Code as
Data as
 Code.
Data as
Code as
 Data.
Programs
 Writing
Programs
 Writing
Programs
Minderbinder
http://futureboy.us




           (Specification)
Primacy
                              of
                          Semantics
I also regard syntactical problems as essentially irrelevant to programming languages at
  their present stage ... the urgent task in programming languages is to explore the field
                                                                  of semantic possibilities.
     — Christopher Strachey - “Fundamental Concepts in Programming Languages”
Unit Conversion
   (defn meters->feet [m]
     (* 1250/381 m))

   (defn meters->yards [m]
     (/ (meters->feet m) 3))

   (defn meters->inches [m]
     (* 12 (meters->feet m)))

   (meters->feet 10)
   ;=> ~ 32.81

   (meters->yards 10)
   ;=> ~ 10.9

   (meters->inches 10)
   ;=> ~ 393.7
Unit Conversion

     feet→meters
  inches→meters
   yards→meters
Unit Conversion
      centimeters→shackles
  ramsden-chains→fathoms
                 feet→meters
              inches→meters
               yards→meters
             feet→kilometers
          yards→centimeters
old-british-fathom →meters
Unit Conversion
       centimeters→shackles
   ramsden-chains→fathoms
                  feet→meters
               inches→meters
                yards→meters
              feet→kilometers
           yards→centimeters
 old-british-fathom →meters
Unit Conversion
CM->MI
MM->M          centimeters→shackles
 F->IN     ramsden-chains→fathoms
 IN->Y                    feet→meters
 F->M
                       inches→meters
 Y->M
CM->Y                   yards→meters
F->MM                 feet→kilometers
M->MM              yards→centimeters
CM->M    old-british-fathom →meters
  F->Y
bit->                     t e
      nibbl
     Unit Conversion    y
                 e ab           t e
   CM->MI
   MM->M
                 eg
     me centimeters→shacklesb y
    F->IN
          gm efeet→meters
             ab g        a
         ramsden-chains→fathoms
     >e > minches→meters
    IN->Y
                   yte
    F->M
        -xa > yards→meters
      e t-b             -
     t e y feet→kilometers
    Y->M

    y t            te
   CM->Y
   boc
   F->MM
                 yards→centimeters
    bit->byte →meters
   M->MM
       old-british-fathom
   CM->M
     F->Y
Primacy
                      of
                    Syntax
     one could say that all semantics is being represented as syntax
... semantics has vanished entirely to be replaced with pure syntax.
                                    — John Shutt - “Primacy of Syntax”
Length Specification              - NIST Special Publication 330, 2008 Edition
                 - Checking the Net Contents of Packaged Goods - NIST 133



 Unit of length
 Base unit: meter
 The meter is the length of the path travelled
 by light in vacuum during a time interval of
 1/299,792,458 of a second.

 1 inch == 0.0254 meters
 1 foot == 12 inches
 1 yard == 3 feet
Length Specification              - NIST Special Publication 330, 2008 Edition
                 - Checking the Net Contents of Packaged Goods - NIST 133




 (unit-of ‘length ::meter
 “The meter is the length of the path travelled
 by light in vacuum during a time interval of
 1/299,792,458 of a second.”

  ::inch ‘== 0.0254 ::meter
  ::foot ‘== 12 ::inch
  ::yard ‘== 3 ::foot )
7x6
42
Primacy
   of
 Data
 Acceptable or not, sir, it is the truth.
   — Data - ST:TNG “Coming of Age”
From the DSL

(defunits-of length    ::meter
 “The meter is the length of
the path travelled by light in
vacuum during a time interval
of 1/299,792,458 of a second.”

  ::inch 0.0254
  ::foot [12 ::inch]
  ::yard [3 ::foot])
To a map


{::meter 1,
 ::inch 0.0254,
 ::foot 0.3048,
 ::yard 0.9144}
To another macro
   (defmacro unit-of-length
   [quantity unit]
     `~(*
          (case unit
            ::meter 1
            ::inch 0.0254
            ::foot 0.3048
            ::yard 0.9144)))
To a use

(unit-of-length 1 ::yard)
0.9144
Questions?
                          • Thanks to
                           • Rich Hickey &
                              Clojure/core

                           • Gray Herter
                           • Clojure/dev
                           • Relevance
                           • Manning Publishing
                           • Wife and kids
                           • You
http://joyofclojure.com
        @fogus

More Related Content

What's hot

From Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf Milan
From Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf MilanFrom Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf Milan
From Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf Milan
Fabio Collini
 
はじめてのGroovy
はじめてのGroovyはじめてのGroovy
はじめてのGroovy
Tsuyoshi Yamamoto
 
Groovy ネタ NGK 忘年会2009 ライトニングトーク
Groovy ネタ NGK 忘年会2009 ライトニングトークGroovy ネタ NGK 忘年会2009 ライトニングトーク
Groovy ネタ NGK 忘年会2009 ライトニングトーク
Tsuyoshi Yamamoto
 
JavaScript Survival Guide
JavaScript Survival GuideJavaScript Survival Guide
JavaScript Survival Guide
Giordano Scalzo
 
From java to kotlin beyond alt+shift+cmd+k - Droidcon italy
From java to kotlin beyond alt+shift+cmd+k - Droidcon italyFrom java to kotlin beyond alt+shift+cmd+k - Droidcon italy
From java to kotlin beyond alt+shift+cmd+k - Droidcon italy
Fabio Collini
 
Async code on kotlin: rx java or/and coroutines - Kotlin Night Turin
Async code on kotlin: rx java or/and coroutines - Kotlin Night TurinAsync code on kotlin: rx java or/and coroutines - Kotlin Night Turin
Async code on kotlin: rx java or/and coroutines - Kotlin Night Turin
Fabio Collini
 
Groovy puzzlers по русски с Joker 2014
Groovy puzzlers по русски с Joker 2014Groovy puzzlers по русски с Joker 2014
Groovy puzzlers по русски с Joker 2014
Baruch Sadogursky
 
Explaining ES6: JavaScript History and What is to Come
Explaining ES6: JavaScript History and What is to ComeExplaining ES6: JavaScript History and What is to Come
Explaining ES6: JavaScript History and What is to Come
Cory Forsyth
 
An Intro To ES6
An Intro To ES6An Intro To ES6
An Intro To ES6
FITC
 
Groovy
GroovyGroovy
Groovy
Zen Urban
 
Introduction to Groovy
Introduction to GroovyIntroduction to Groovy
Introduction to Groovy
André Faria Gomes
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
Hans Höchtl
 
Building fast interpreters in Rust
Building fast interpreters in RustBuilding fast interpreters in Rust
Building fast interpreters in Rust
Ingvar Stepanyan
 
SDC - Einführung in Scala
SDC - Einführung in ScalaSDC - Einführung in Scala
SDC - Einführung in Scala
Christian Baranowski
 
The Ring programming language version 1.5.2 book - Part 45 of 181
The Ring programming language version 1.5.2 book - Part 45 of 181The Ring programming language version 1.5.2 book - Part 45 of 181
The Ring programming language version 1.5.2 book - Part 45 of 181
Mahmoud Samir Fayed
 
Go ahead, make my day
Go ahead, make my dayGo ahead, make my day
Go ahead, make my day
Tor Ivry
 
JavaScript Patterns
JavaScript PatternsJavaScript Patterns
JavaScript Patterns
Giordano Scalzo
 
Groovy vs Boilerplate and Ceremony Code
Groovy vs Boilerplate and Ceremony CodeGroovy vs Boilerplate and Ceremony Code
Groovy vs Boilerplate and Ceremony Codestasimus
 
The Ring programming language version 1.3 book - Part 84 of 88
The Ring programming language version 1.3 book - Part 84 of 88The Ring programming language version 1.3 book - Part 84 of 88
The Ring programming language version 1.3 book - Part 84 of 88
Mahmoud Samir Fayed
 

What's hot (20)

From Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf Milan
From Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf MilanFrom Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf Milan
From Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf Milan
 
はじめてのGroovy
はじめてのGroovyはじめてのGroovy
はじめてのGroovy
 
Groovy ネタ NGK 忘年会2009 ライトニングトーク
Groovy ネタ NGK 忘年会2009 ライトニングトークGroovy ネタ NGK 忘年会2009 ライトニングトーク
Groovy ネタ NGK 忘年会2009 ライトニングトーク
 
JavaScript Survival Guide
JavaScript Survival GuideJavaScript Survival Guide
JavaScript Survival Guide
 
From java to kotlin beyond alt+shift+cmd+k - Droidcon italy
From java to kotlin beyond alt+shift+cmd+k - Droidcon italyFrom java to kotlin beyond alt+shift+cmd+k - Droidcon italy
From java to kotlin beyond alt+shift+cmd+k - Droidcon italy
 
Async code on kotlin: rx java or/and coroutines - Kotlin Night Turin
Async code on kotlin: rx java or/and coroutines - Kotlin Night TurinAsync code on kotlin: rx java or/and coroutines - Kotlin Night Turin
Async code on kotlin: rx java or/and coroutines - Kotlin Night Turin
 
Groovy puzzlers по русски с Joker 2014
Groovy puzzlers по русски с Joker 2014Groovy puzzlers по русски с Joker 2014
Groovy puzzlers по русски с Joker 2014
 
Explaining ES6: JavaScript History and What is to Come
Explaining ES6: JavaScript History and What is to ComeExplaining ES6: JavaScript History and What is to Come
Explaining ES6: JavaScript History and What is to Come
 
ECMAScript 6
ECMAScript 6ECMAScript 6
ECMAScript 6
 
An Intro To ES6
An Intro To ES6An Intro To ES6
An Intro To ES6
 
Groovy
GroovyGroovy
Groovy
 
Introduction to Groovy
Introduction to GroovyIntroduction to Groovy
Introduction to Groovy
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
Building fast interpreters in Rust
Building fast interpreters in RustBuilding fast interpreters in Rust
Building fast interpreters in Rust
 
SDC - Einführung in Scala
SDC - Einführung in ScalaSDC - Einführung in Scala
SDC - Einführung in Scala
 
The Ring programming language version 1.5.2 book - Part 45 of 181
The Ring programming language version 1.5.2 book - Part 45 of 181The Ring programming language version 1.5.2 book - Part 45 of 181
The Ring programming language version 1.5.2 book - Part 45 of 181
 
Go ahead, make my day
Go ahead, make my dayGo ahead, make my day
Go ahead, make my day
 
JavaScript Patterns
JavaScript PatternsJavaScript Patterns
JavaScript Patterns
 
Groovy vs Boilerplate and Ceremony Code
Groovy vs Boilerplate and Ceremony CodeGroovy vs Boilerplate and Ceremony Code
Groovy vs Boilerplate and Ceremony Code
 
The Ring programming language version 1.3 book - Part 84 of 88
The Ring programming language version 1.3 book - Part 84 of 88The Ring programming language version 1.3 book - Part 84 of 88
The Ring programming language version 1.3 book - Part 84 of 88
 

Viewers also liked

Introduction to Zeder - a production rules toolkit for Clojure
Introduction to Zeder - a production rules toolkit for ClojureIntroduction to Zeder - a production rules toolkit for Clojure
Introduction to Zeder - a production rules toolkit for ClojureMike Fogus
 
ClojureScript Anatomy
ClojureScript AnatomyClojureScript Anatomy
ClojureScript Anatomy
Mike Fogus
 
The Shape of Functional Programming
The Shape of Functional ProgrammingThe Shape of Functional Programming
The Shape of Functional Programming
Mike Fogus
 
The Return of the Living Datalog
The Return of the Living DatalogThe Return of the Living Datalog
The Return of the Living Datalog
Mike Fogus
 
Confo
ConfoConfo
Confo
Mike Fogus
 
Good Parts of JavaScript Douglas Crockford
Good Parts of JavaScript Douglas CrockfordGood Parts of JavaScript Douglas Crockford
Good Parts of JavaScript Douglas Crockfordrajivmordani
 
Kotlin in action
Kotlin in actionKotlin in action
Kotlin in action
Ciro Rizzo
 
Next Generation Web Application Architecture
Next Generation Web Application ArchitectureNext Generation Web Application Architecture
Next Generation Web Application Architecture
Koji SHIMADA
 
new Objctive-C literal syntax
new Objctive-C literal syntaxnew Objctive-C literal syntax
new Objctive-C literal syntax
Wataru Kimura
 
これからはじめるCoda2とSublime Text 2
これからはじめるCoda2とSublime Text 2これからはじめるCoda2とSublime Text 2
これからはじめるCoda2とSublime Text 2
masaaki komori
 
blogサービスの全文検索の話 - #groonga を囲む夕べ
blogサービスの全文検索の話 - #groonga を囲む夕べblogサービスの全文検索の話 - #groonga を囲む夕べ
blogサービスの全文検索の話 - #groonga を囲む夕べMasahiro Nagano
 
Rubyはとても「人間的」
Rubyはとても「人間的」Rubyはとても「人間的」
Rubyはとても「人間的」
Kazuhiro Serizawa
 
本格的に始めるzsh
本格的に始めるzsh本格的に始めるzsh
本格的に始めるzsh
Hideaki Miyake
 
Ruby1.9のfiberのかっこいい使い方
Ruby1.9のfiberのかっこいい使い方Ruby1.9のfiberのかっこいい使い方
Ruby1.9のfiberのかっこいい使い方Kindai University
 
いまさら聞けないDocker - 第5回コンテナ型仮想化の情報交換会@大阪
いまさら聞けないDocker - 第5回コンテナ型仮想化の情報交換会@大阪いまさら聞けないDocker - 第5回コンテナ型仮想化の情報交換会@大阪
いまさら聞けないDocker - 第5回コンテナ型仮想化の情報交換会@大阪
Kunihiro TANAKA
 
プログラマとして仕事をするために勉強すること
プログラマとして仕事をするために勉強することプログラマとして仕事をするために勉強すること
プログラマとして仕事をするために勉強すること
なおき きしだ
 
Project Lambdaの基礎
Project Lambdaの基礎Project Lambdaの基礎
Project Lambdaの基礎
Yuichi Sakuraba
 
受託開発時におけるAWSクラウド活用術
受託開発時におけるAWSクラウド活用術受託開発時におけるAWSクラウド活用術
受託開発時におけるAWSクラウド活用術
Hiroshi Koyama
 
ARC環境で メモリリークを起こす 7つの方法
ARC環境で メモリリークを起こす 7つの方法ARC環境で メモリリークを起こす 7つの方法
ARC環境で メモリリークを起こす 7つの方法ushiostarfish _
 

Viewers also liked (20)

Introduction to Zeder - a production rules toolkit for Clojure
Introduction to Zeder - a production rules toolkit for ClojureIntroduction to Zeder - a production rules toolkit for Clojure
Introduction to Zeder - a production rules toolkit for Clojure
 
ClojureScript Anatomy
ClojureScript AnatomyClojureScript Anatomy
ClojureScript Anatomy
 
The Shape of Functional Programming
The Shape of Functional ProgrammingThe Shape of Functional Programming
The Shape of Functional Programming
 
The Return of the Living Datalog
The Return of the Living DatalogThe Return of the Living Datalog
The Return of the Living Datalog
 
Confo
ConfoConfo
Confo
 
Good Parts of JavaScript Douglas Crockford
Good Parts of JavaScript Douglas CrockfordGood Parts of JavaScript Douglas Crockford
Good Parts of JavaScript Douglas Crockford
 
Kotlin in action
Kotlin in actionKotlin in action
Kotlin in action
 
Sinatraのススメ
SinatraのススメSinatraのススメ
Sinatraのススメ
 
Next Generation Web Application Architecture
Next Generation Web Application ArchitectureNext Generation Web Application Architecture
Next Generation Web Application Architecture
 
new Objctive-C literal syntax
new Objctive-C literal syntaxnew Objctive-C literal syntax
new Objctive-C literal syntax
 
これからはじめるCoda2とSublime Text 2
これからはじめるCoda2とSublime Text 2これからはじめるCoda2とSublime Text 2
これからはじめるCoda2とSublime Text 2
 
blogサービスの全文検索の話 - #groonga を囲む夕べ
blogサービスの全文検索の話 - #groonga を囲む夕べblogサービスの全文検索の話 - #groonga を囲む夕べ
blogサービスの全文検索の話 - #groonga を囲む夕べ
 
Rubyはとても「人間的」
Rubyはとても「人間的」Rubyはとても「人間的」
Rubyはとても「人間的」
 
本格的に始めるzsh
本格的に始めるzsh本格的に始めるzsh
本格的に始めるzsh
 
Ruby1.9のfiberのかっこいい使い方
Ruby1.9のfiberのかっこいい使い方Ruby1.9のfiberのかっこいい使い方
Ruby1.9のfiberのかっこいい使い方
 
いまさら聞けないDocker - 第5回コンテナ型仮想化の情報交換会@大阪
いまさら聞けないDocker - 第5回コンテナ型仮想化の情報交換会@大阪いまさら聞けないDocker - 第5回コンテナ型仮想化の情報交換会@大阪
いまさら聞けないDocker - 第5回コンテナ型仮想化の情報交換会@大阪
 
プログラマとして仕事をするために勉強すること
プログラマとして仕事をするために勉強することプログラマとして仕事をするために勉強すること
プログラマとして仕事をするために勉強すること
 
Project Lambdaの基礎
Project Lambdaの基礎Project Lambdaの基礎
Project Lambdaの基礎
 
受託開発時におけるAWSクラウド活用術
受託開発時におけるAWSクラウド活用術受託開発時におけるAWSクラウド活用術
受託開発時におけるAWSクラウド活用術
 
ARC環境で メモリリークを起こす 7つの方法
ARC環境で メモリリークを起こす 7つの方法ARC環境で メモリリークを起こす 7つの方法
ARC環境で メモリリークを起こす 7つの方法
 

Similar to Code as data as code.

Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with ClojureDmitry Buzdin
 
DataTypes.ppt
DataTypes.pptDataTypes.ppt
DataTypes.ppt
RithikRaj25
 
The Ring programming language version 1.2 book - Part 79 of 84
The Ring programming language version 1.2 book - Part 79 of 84The Ring programming language version 1.2 book - Part 79 of 84
The Ring programming language version 1.2 book - Part 79 of 84
Mahmoud Samir Fayed
 
Powered by Python - PyCon Germany 2016
Powered by Python - PyCon Germany 2016Powered by Python - PyCon Germany 2016
Powered by Python - PyCon Germany 2016
Steffen Wenz
 
What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)
Pavlo Baron
 
CoffeeScript
CoffeeScriptCoffeeScript
CoffeeScript
Ryan McGeary
 
The Future of JVM Languages
The Future of JVM Languages The Future of JVM Languages
The Future of JVM Languages
VictorSzoltysek
 
Kotlin @ Coupang Backend 2017
Kotlin @ Coupang Backend 2017Kotlin @ Coupang Backend 2017
Kotlin @ Coupang Backend 2017
Sunghyouk Bae
 
pa-pe-pi-po-pure Python Text Processing
pa-pe-pi-po-pure Python Text Processingpa-pe-pi-po-pure Python Text Processing
pa-pe-pi-po-pure Python Text Processing
Rodrigo Senra
 
Fantom and Tales
Fantom and TalesFantom and Tales
Fantom and Tales
kaushik_sathupadi
 
CoffeeScript
CoffeeScriptCoffeeScript
CoffeeScript
Scott Leberknight
 
Damn Fine CoffeeScript
Damn Fine CoffeeScriptDamn Fine CoffeeScript
Damn Fine CoffeeScript
niklal
 
Beginning Haskell, Dive In, Its Not That Scary!
Beginning Haskell, Dive In, Its Not That Scary!Beginning Haskell, Dive In, Its Not That Scary!
Beginning Haskell, Dive In, Its Not That Scary!
priort
 
A Brief Introduction to the Qt Application Framework
A Brief Introduction to the Qt Application FrameworkA Brief Introduction to the Qt Application Framework
A Brief Introduction to the Qt Application Framework
Zachary Blair
 
ES6 is Nigh
ES6 is NighES6 is Nigh
ES6 is Nigh
Domenic Denicola
 
Apache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheelApache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheel
tcurdt
 
Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...
Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...
Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...
DevGAMM Conference
 
oodp elab.pdf
oodp elab.pdfoodp elab.pdf
oodp elab.pdf
SWATIKUMARIRA2111030
 
Elm: give it a try
Elm: give it a tryElm: give it a try
Elm: give it a try
Eugene Zharkov
 
Clojure入門
Clojure入門Clojure入門
Clojure入門
Naoyuki Kakuda
 

Similar to Code as data as code. (20)

Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
DataTypes.ppt
DataTypes.pptDataTypes.ppt
DataTypes.ppt
 
The Ring programming language version 1.2 book - Part 79 of 84
The Ring programming language version 1.2 book - Part 79 of 84The Ring programming language version 1.2 book - Part 79 of 84
The Ring programming language version 1.2 book - Part 79 of 84
 
Powered by Python - PyCon Germany 2016
Powered by Python - PyCon Germany 2016Powered by Python - PyCon Germany 2016
Powered by Python - PyCon Germany 2016
 
What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)
 
CoffeeScript
CoffeeScriptCoffeeScript
CoffeeScript
 
The Future of JVM Languages
The Future of JVM Languages The Future of JVM Languages
The Future of JVM Languages
 
Kotlin @ Coupang Backend 2017
Kotlin @ Coupang Backend 2017Kotlin @ Coupang Backend 2017
Kotlin @ Coupang Backend 2017
 
pa-pe-pi-po-pure Python Text Processing
pa-pe-pi-po-pure Python Text Processingpa-pe-pi-po-pure Python Text Processing
pa-pe-pi-po-pure Python Text Processing
 
Fantom and Tales
Fantom and TalesFantom and Tales
Fantom and Tales
 
CoffeeScript
CoffeeScriptCoffeeScript
CoffeeScript
 
Damn Fine CoffeeScript
Damn Fine CoffeeScriptDamn Fine CoffeeScript
Damn Fine CoffeeScript
 
Beginning Haskell, Dive In, Its Not That Scary!
Beginning Haskell, Dive In, Its Not That Scary!Beginning Haskell, Dive In, Its Not That Scary!
Beginning Haskell, Dive In, Its Not That Scary!
 
A Brief Introduction to the Qt Application Framework
A Brief Introduction to the Qt Application FrameworkA Brief Introduction to the Qt Application Framework
A Brief Introduction to the Qt Application Framework
 
ES6 is Nigh
ES6 is NighES6 is Nigh
ES6 is Nigh
 
Apache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheelApache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheel
 
Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...
Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...
Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...
 
oodp elab.pdf
oodp elab.pdfoodp elab.pdf
oodp elab.pdf
 
Elm: give it a try
Elm: give it a tryElm: give it a try
Elm: give it a try
 
Clojure入門
Clojure入門Clojure入門
Clojure入門
 

Recently uploaded

"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
Fwdays
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 

Recently uploaded (20)

"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 

Code as data as code.

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. * This allows you to deal with data in terms of a language-level construct.\n\n
  9. Here is a data table.\n
  10. Here is a data table.\n
  11. * Here is the code to read the data.\n* Where is the data in this picture?\n
  12. * Right here.\n* Code _works on_ data. \n* Where is the code?\n
  13. * Right here.\n\n
  14. * CoffeeClass\n* How to unify the notion of a ResultSet and the Coffee class?\n* Rhymes with &amp;#x201C;misinform&amp;#x201D;\n
  15. * This allows you to deal with data in terms of a language-level construct.\n\n
  16. * Stitching together of the two models\n* Not here to dis ORMs, heck I&amp;#x2019;ve written my own.\n* The point is code as data.\n
  17. \n
  18. \n
  19. but dealing with this is a pain\n
  20. you really want to deal with this code itself\n
  21. runs through pre-processor that substitutes the AST in place\n
  22. * camlp4 is the preprocessor. As a macro system this is actually not bad. \n* I didn&amp;#x2019;t mention everything (e.g. term-rewriting) \n* But... we came here to talk about...\n
  23. * To understand how Pure works is to understand FOIL\n
  24. first, outer, inner, last\n
  25. * first, outer, inner, last\n* product of two binomials of like terms\n
  26. * multiplying 2 binomials\n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. * With a severe line between\n
  34. * with Clojure there is no line\n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. * XML is near ubiquitous\n
  46. * Clojure data type are currently not extensible\n
  47. \n
  48. \n
  49. \n
  50. \n
  51. * This is the conceptual model for data as code\n
  52. \n
  53. \n
  54. \n
  55. \n
  56. There is nothing particularly unique to Clojure about this... Java example...\n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. * The stuff in one is not the stuff in the other.\n
  63. but we&amp;#x2019;re dealing at the level of the app. what if the engine was the language itself.\n
  64. \n
  65. But how do macros work?\n
  66. But how do macros work?\n
  67. * The key is that in Clojure code is data\n* Homoiconicity a fancy term\n* Sometimes verbosity is fine\n
  68. \n
  69. \n
  70. \n
  71. \n
  72. \n
  73. * With a severe line between\n
  74. * The punchline of the talk\n
  75. * What does this buy us?\n
  76. \n
  77. \n
  78. It started with Frink.\n
  79. I dug into the NIST specifications.\n
  80. * The meaning is king. \n* This is the root of all Turing completeness arguments\n* What is the best &amp;#x201C;programming language&amp;#x201D; to describe minderbinder?\n
  81. \n
  82. What about the inverse?\n
  83. And some more?\n
  84. And what about abbreviations?\n... And what about other kinds of conversions? You see where this is going?\n
  85. And what about abbreviations?\n... And what about other kinds of conversions? You see where this is going?\n
  86. And what about abbreviations?\n... And what about other kinds of conversions? You see where this is going?\n
  87. And what about abbreviations?\n... And what about other kinds of conversions? You see where this is going?\n
  88. And what about abbreviations?\n... And what about other kinds of conversions? You see where this is going?\n
  89. All useful semantics become syntax and some langs include unit conv as syntactic elems. But this tightly couples the semantics with the syntax. People say Lisp has no syntax, but that&amp;#x2019;s not true. It has a lot of syntax... in fact it has an infinite syntax.\n
  90. If semantics are key then anything that implements the spec is fair game right? The best language is the specification from the manual.\n
  91. It&amp;#x2019;s all data. This fact lies at the heart of macrology. So I could generate all of those functions as before, BUT maybe there is a better way.\n
  92. what&amp;#x2019;s the fastest and most efficient way to multiply 2 values?\n
  93. don&amp;#x2019;t multiply it at all.\n
  94. \n
  95. \n
  96. \n
  97. \n
  98. \n
  99. to a value. now that is cool. now I can autogen the m-&gt;ft and yard-&gt;miles fns and their bodies are constants.\n
  100. \n