Skip to content

Instantly share code, notes, and snippets.

@MysteryMachine
Created May 31, 2016 23:46
Show Gist options
  • Save MysteryMachine/9ceca5d506da23b91e35570ab9113394 to your computer and use it in GitHub Desktop.
Save MysteryMachine/9ceca5d506da23b91e35570ab9113394 to your computer and use it in GitHub Desktop.
Jobim Presentation
(ns cljnyc.core
(:require [jobim.core :as jobim])
(:require-macros [jobim.core :as jobim]))
(defonce show-state (jobim/new-show))
(jobim/defcommented-clj code-slide 80
"Jobim utilizes its own simple evaluation strategy to allow you to test code like this"
(def a 5)
(def b 2)
(defn c [d] (+ a b d))
(c 4))
(jobim/defblog intro-to-clojure
show-state
jobim/default-style
(jobim/title "Jobim" "Extensible, Testable Clojurescript Slides")
(jobim/captioned-img "img/sal.jpg" [:div
[:div "Salomão Becker"]
[:a {:href "http://sisyphus.rocks"} "sisyphus.rocks"]
[:div "Twitter : @mysterysal"]
[:div "Github : MysteryMachine"]])
(jobim/captioned-img "img/adaptly.png"
[:p
"I write Clojure for a living at Adaptly. We're awesome, doing very interesting things, "
"and we're looking for talented engineers. Come say hi, after!"])
(jobim/text "Jobim is a set of macros and protocols built on top of Reagent. It was engineered to allow "
"me to to test code samples in my own code. It also exists as a rich DSL meant to replace "
"Markdown."
[:p "It compiles to JavaScript, so it's easily hosted and deployed on the web."]
[:p [:a {:href "https://github.com/MysteryMachine/jobim"} "https://github.com/MysteryMachine/jobim"]])
(jobim/text "A warning: Jobim is still under development, and some of the fancy features on show today might "
"only come out in a future release.")
(jobim/text "(And yes, of course this talk is written in Jobim)")
(jobim/title "Motivation")
(jobim/title "Create a DSL to replace Markdown. It should be interactive, extensible, and testable.")
(jobim/text "I'm REALLY bad at writing code that runs the first time it's written. Writing code snippits in Markdown "
"is just asking for trouble.")
(jobim/text "Additionally, creating interactive components within Markdown is a non-starter.")
(jobim/title "Reagent solves a LOT of my problems.")
(jobim/text "Jobim slides implement a protocol that renders a Reagent component.")
(jobim/text
[:p "And it's a first class citizen in Jobim."]
[:div (jobim/inline (jobim/custom-slide (fn [i] [:div "this is " i])))])
(jobim/text (jobim/inline (text)) " takes a series of strings and/or hiccup."
[:div "This allows you to build things like this."]
"It's the default way of specifying a more custom slide."
[:p "As well, an inline utility is provide to neatly print inline code." (jobim/inline (+ 1 2 3 4))
" Allowing you to do some neat stuff."])
(jobim/pseudo-clj
60
(jobim/text "Text takes a series of strings and/or hiccup."
[:div "This allows you to build things like this."]
"It's the default way of specifying a more custom slide."
[:p "As well, an inline utility is provide to neatly print inline code." (jobim/inline (+ 1 2 3 4))
" Allowing you to do some neat stuff."]))
(jobim/pseudo-clj
60
(jobim/psuedo-clj 60 (this is for writing code that shouldn't be executed))
(jobim/captioned-img "img/img.jpg" "for captioned images")
(jobim/title "title slides" "with subtitles"))
(jobim/pseudo-clj
60
(jobim/captioned-img "img.png" "Some basic helpers are offered. This lets you stay succinct.")
(jobim/captioned-img "img.png" [:p "And most places that take strings also take hiccup"
[:ul
[:li "So slightly more complex slides are easy to build when you need."]]]))
(jobim/text [:p "Then, use the " (jobim/inline (defshow <code>)) " or " (jobim/inline (defblog <code>))
" macros to create your show in slide-show or blog form."])
(jobim/text "Jobim also includes a lein template that sets you up with Figwheel and a small testing plugin.")
(jobim/title "Testability")
(jobim/text "Jobim takes advantage of Clojure's homoiconic nature to do a couple of things"
[:ul {:style {:text-align "left"}}
[:li "Pretty print code"]
[:li "Syntax highlight it"]
[:li "Execute the code in question"]
[:li "Run tests against the code"]])
code-slide
(jobim/pseudo-clj 60
(jobim/defclj code-slide 80
(def a 1)
(def b 2)
(defn c [d] (+ a b d))
(c 4))
(deftest code-slide-test
(let [{:keys [a b c %3]} (jobim/env code-slide)]
(is (= 1 a))
(is (= 2 b))
(is (= 7 (c 4)))
(is (= 7 %3)))))
(jobim/text "The big advantage is you're never writing Markdown. All your code executes "
"unless you specifically say so. This gives you lots of certainty about the code "
"you're showing off.")
(jobim/text "Finally, Jobim ships with a lein plugin to run tests in your browser for you.")
(jobim/title "Extensibility")
(jobim/text "You get a lot of extensibility for free by using Hiccup where you want. "
"But if you want to build slides have have custom behavior for left/right/up/down, "
"there are two protocols you can extend.")
(jobim/pseudo-clj
60
(defprotocol Slide
(render-slide
[this state])
(next-slide
[this state])
(prev-slides
[this state]))
(defprotocol Indexable
(up-slide
[this state])
(down-slide
[this state])
(max-index
[this])))
(jobim/text "But a software talk where I just describe an API is not that fun "
"to listen to.")
(jobim/title "Jobim" "Picking low hanging fruit as a software methodology")
(jobim/text "Clojure's relative youth, and its power as a language mean that "
"a developer can write a lot of cool software with relatively little "
"effort.")
(jobim/text "Doing this requires surveying the field to find software that plays nice together.")
(jobim/bullets "Jobim leverages..."
"reagent : the super heavy backbone of everything"
["react"]
"fipp : for pretty printing code"
"clojure protocols : extensibility"
"core.test"
"figwheel : as a test runner and for live reload"
"lein : for templating"
"hljs : a javascript library for code highlighting")
(jobim/title "Picking out software bits yourself...")
(jobim/text "Clojure : A lot of good stuff exists in Clojure already. Whether it be high performance "
"data structures or good functional programming constructs, or libraries like core.async "
"or core.data, starting with something built into Clojure is often a great way to start.")
(jobim/text "Clojure contrib libraries : similar to the top, just a lot of stuff exists to build the bedrock "
"of any software you may want to write.")
(jobim/text "Clojure ecosystem : A lot of great stuff is out there for Clojure already. Lots of "
"great software can be written just by stringing together existing Clojure libraries.")
(jobim/text "Host ecosystem : nine times out of ten, the final piece of your project "
"may exist as a Java or Javscript library. Leveraging the power of the host is a great "
"last resort.")
(jobim/title "That's nice.")
(jobim/captioned-img "img/lowhanging.jpg" "But sometimes that fruit can be untouched for a reason.")
(jobim/text "What sorts of low hanging fruit are ripe for the picking?")
(jobim/text "You generally want to select Clojure features first, contrib libraries second, Clojure "
"ecosystem libraries third, and host libraries last.")
(jobim/text "Choose Clojure libraries that emphasize reuse, extensibility, and data driveness.")
(jobim/text "Choose host libraries that can work without you building a heavy wrapper around it.")
(jobim/text "Make sure your own approach to software design emphasizes reuse, extensibility, and data.")
(jobim/title "Thanks!"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment