SlideShare una empresa de Scribd logo
1 de 91
Descargar para leer sin conexión
Taming the wild fronteer
Adventures in Clojurescript
by John Stevenson
@jr0cket practicalli.github.io/clojurescript
@jr0cket
Speaker, author, conference organiser
& community obsessed developer.
Loves Clojure, Spacemacs, Cats, Cycling & Agile development.
@Heroku
@SalesforceDevs
In a galaxy far, far away…
Taming The Wild Fronteer
Javascript is a highly pervasive platform...
Javascript as a platform is everywhere
@jr0cket
Many programming
languages have
their quirks…
@jr0cket
www.destroyallsoftware.com/talks/wat
A common view of Javascript as a language
@jr0cket
Complex languages
… are not easily
reasoned about by
humans
@jr0cket
Josh Smith - Tweet
Original Gif
ClojureScript
A general purpose language made from decades of design
From Javascript to Clojurescript
f(x) -> (f x)
;; First element of a list is a function call
var foo = “bar” -> (def foo “bar”)
;; bind a name to a value or function
@jr0cket
Clojurescript - basic syntax
(ns clojure.awesome ) ;; define a namespace (scoping)
(defn function-name [args] (behaviour)) ;; define a function, with arguments
(function-name data) ;; call a function with the data as its argument
(def name “data-or-value”) ;; bind a name to data within the namespace scope
(let [name “data-or-value”]) ;; bind a name to a data within the let scope (local)
:keyword-name ;; a keyword is a name (symbol) that points to itself
;; Chaining functions: Thread the result of the first fn into the argument of the next fn
(-> (function-a “data”)
(function-b ,,,) ;; In Clojure commas , are whitespace
(function-c ,,, “data”))
Built-in immutable data structures
Model state and any other data with built-in (hash) maps,
vectors (arrays), (linked) lists, (unique) sets
(list 1 2 3 4 5) ‘(“fish” “chips” 42)
(vec ‘(1 2 3 4)) [1 2 3 4]
{:key “value”} {:name “John” :skill “conferencing”}
(set ‘(1 2 3 4 4)) #{1 2 3 4}
Clojure - a few core functions
(map fn collection) ;; map a fn over a collection, return new collection
(reduce fn collection) ;; return the value of combining elements in collection with fn
(for [x collection] (fn x)) ;; iterate over the elements of a collection
(filter fn collection) ;; return a collection of values that comply with the filter fn
(get {:veg “kale” :fruit “kiwi”} :fruit) ;; return value pointed to by keyword
(:fruit {:veg “kale” :fruit “kiwi”}) ;; return value pointed to by keyword
(conj collection value) ;; conjoin a value to the collection
(assoc collection coll) ;; add a collection to the collection
(update {:a 1} :a fn) ;; update value pointed to by the key in a map with the fn
ClojureScript:
Managing complexity
A pragmatic approach to purity
The Complexity Iceberg
- @krisajenkins
● complexity is very
dangerous when hidden
● You can't know what a
function does for certain if it
has side effects
Side Effects
Pure Functions
The results of the function are purely determined by its initial output and its own code
- no external influence, a function only uses local values
- referential transparency (the function can be replaced by its value)
Impure Functions - side causes
Eliminating Side Effects
Functional programming is about eliminating side effects where you can,
controlling them where you can't - @krisajenkins
The features in Functional Programming come from a
desire to reduce side effects
Design idiom:
Composing
functions
together
You can think of functional
design as evaluating one or
more functions in series of
functions
The Map Reduce Sandwich
Clojure - the Map Reduce Sandwich
Clojure - the Map Reduce Sandwich
Pure Functions & Immutability = Parallelism
In simple terms: run the same code across multiple CPU’s / Threads
Parallelism - pmap
pmap - the same as map but in parallel
Parallelism - reduce
Significantly lower completion time running in parallel using Immutable data
structures
https://github.com/aphyr/tesser
Managing State
State changes should be managed easily
Safe State changes
Changing state safely by changing it atomically
● Software Transactional Memory (STM)
○ Gives an mechanism like an in-memory atomic database that manages mutable state changes
under the covers
● Atoms
● Refs
● core.async
Concurrency syntax - atoms
An online card game has players that can join and have their winnings tracked
Concurrency syntax - atoms
The join-game function adds players to the atom by their name, but only up to 2
players
Concurrency syntax - refs
join-game-safely adds players to ref & alters their account & game account
ClojureScript - Functional Web
Immutability & composable functions for Web Apps
See Clojurescript for Skeptics:
https://www.youtube.com/watch?v=gsffg5xxFQI&t=4s
jQuery over all JavaScript frameworks
See Clojurescript for Skeptics:
https://www.youtube.com/watch?v=gsffg5xxFQI&t=4s
See Clojurescript for Skeptics:
https://www.youtube.com/watch?v=gsffg5xxFQI&t=4s
Google Closure tools & libraries
See Clojurescript for Skeptics:
https://www.youtube.com/watch?v=gsffg5xxFQI&t=4s
Examples of Clojurescript
● Goya - pixel editor with
undo
https://jackschaedler.githu
b.io/goya/
● CircleCI
● Style.com
● Klipse - web-based dev tool
& library for live-code
examples in blogs /
workshops
Getting Started with
Clojurescript
Clojurescript Environments
Nashorn
- built into JVM, access Java classes
- Oracle Nashorn: A Next-Generation JavaScript Engine for the JVM
Browser-REPL
- built into modern browsers (Chrome, Firefox, etc)
- commonly used for client side web apps
Node.js
- great for command line utilities and microservices!
Common Clojurescript Tooling
Leiningen
- build automation tool for Clojure & Clojurescript
Figwheel (leiningen plugin)
- defacto tool for client side web apps
- live reload
- multi-broadcast (eg simultaneous dev & test outputs)
Full-stack projects: Chestnut
https://github.com/plexus/chestnut
- leiningen template for Clojure/ClojureScript apps based
- with Om, Reagent, or Rum
- instant reloading of Clojure, ClojureScript, and CSS
- browser-connected REPL included
lein new chestnut project-name
Self-hosted Clojurescript Environments
Instant startup times, great for command line tools
Lumo (cross-platform)
- https://github.com/anmonteiro/lumo
Plank (Mac & Linux)
- http://planck-repl.org/
Understanding React
Basic concepts of React
https://facebook.github.io/react/
https://github.com/reactjs
React Basics (conceptual)
React provides an efficient way to update the view
What React Provides
React is only the view
The view should update the state,
not the DOM
Reactive Frameworks
All the varieties of life, plus all the Javascript varieties too...
Javascript & Clojurescript frameworks
Javascript
● React.js via cljsjs
● Vue.js ???
Clojurescript
● Om / Om-next
● Reagent / Reframe
● Rum
More at https://clojurescript.org/community/libraries
React.js
Using React.js within Clojurescript
Simple Calculator with React.js
Reagent
Clojurescript can directly use the React.js library thanks to cljsjs.github.io
React.js
React.js
React.js
React.js
React.js
React.js
Om / Om-next
ClojureScript interface to Facebook's React
Om / Om-next
Models the React.js API
Rapidly re-render the UI from the root due via Immutable data structures
- UIs are snapshot-able and undoable without implementation complexity
Om supports features not currently present in React:
- Global state management facilities built in
- Components may have arbitrary data dependencies, not limited to props & state
- Component construction intercepted via :instrument. Simplifies debugging
- Stream all application state deltas via :tx-listen. Simplifies on/offline sync
- Customizable semantics
Om core functions
om.core/IRender
- Render a Om component into the DOM
- uses reify to provide a specific implementation of the om/IRender interface
om.core/IInitState
- maintains a local state (eg. for managing user input data)
om.core/IRenderState
- Render a Om component into the DOM
- renders component on change in local & global state
Om core functions
om.dom/div attributes content
- creates a <div> tag in react
- all react tags need to be wrapped in a div in order to be rendered
- om.dom/… has all the other tags too - h1, h2, p, a … (sablono can be used instead)
#js
- converts clojure maps into Javascript objects
- nest #js functions to to create JS objects - eg. for inline styles
Om Cursors
A cursor is an atom & a path to a location in the atom
app-state :schedule 0
Components use the cursor to refer to pieces of the app state
- without knowing where they are in the state tree
- updating app state is simple as the cursor is in the correct part of the app
state
Reagent
Interactive development
Reagent
Reagent provides a minimalistic interface between ClojureScript and React
- define efficient React components using nothing but plain ClojureScript
functions and data
- describe your UI using a Hiccup syntax
[:div [:h1 “Heading”]
[:div [:p “Paragraph” ]
[:a {:href “/link.html”} “link text”]]]
- define arbitrarily complex UIs using a couple of basic concepts
- fast enough by default that you rarely have to care about performance.
Reagent Core functions
reagent.core/render
- Render a Reagent component into the DOM
- First argument is either a vector (Reagent Hiccup syntax) or a React element
reagent.core/atom
- Like clojure.core/atom, plus it tracks components that deref atom & re-renders them
Helper functions
Reagent used Clojurescript functions for conversion from
- Clojure Maps to Javascript Objects
- Clojurescript vectors to Javascript arrays
clj->js
- convert from Clojurescript to Javascript
js->clj
- convert from Javascript to Clojurescript
Reagent Examples
http://timothypratley.blogspot.co.uk/2017/01/reagent-deep-dive-part-1.html
- Uses Klipse to display interactive code snippets for Reagent
- Includes use of SVG and Web3D libraries too
Graph example - http://leaderboardx.herokuapp.com/
Reframe
A micro-framework for Reagent
Re-frame
a pattern for writing SPAs in ClojureScript, using Reagent.
a framework with pure functions which transform data
Architecturally implements "a perpetual loop".
Build apps by writing pure functions for certain parts of
the loop that transform the data
- Re-frame looks after the conveyance of data around the
loop, into and out of the transforming functions you write
- tag line of "Derived Values, Flowing".
Rum
A micro-framework for Reagent
Rum
Rum is a client/server library for HTML UI. In ClojureScript, it works as React wrapper, in Clojure, it is a static HTML
generator.
- Simple semantics: Rum is arguably smaller, simpler and more straightforward than React itself.
- Decomplected: Rum is a library, not a framework. Use only the parts you need, throw away or replace what you don’t
need, combine different approaches in a single app, or even combine Rum with other frameworks.
- No enforced state model: Unlike Om, Reagent or Quiescent, Rum does not dictate where to keep your state. Instead, it
works well with any storage: persistent data structures, atoms, DataScript, JavaScript objects, localStorage or any custom
solution you can think of.
- Extensible: the API is stable and explicitly defined, including the API between Rum internals. It lets you build custom
behaviours that change components in significant ways.
- Minimal codebase: You can become a Rum expert just by reading its source code (~900 lines).
Rum - at ClojureX
https://skillsmatter.com/skillscasts/9149-modern-web-apps-with-rum
Other ClojureScript examples
Interactive development
Figwheel (flappy birds example)
Take a journey into Clojurescript
Clojurescript.org & ClojureDocs.org
londonclojurians.org
- 4 events per month
- Possibly the most active language-specific
developer communitie in London
Learning by teaching others
I really started thinking in Clojure when I started talking to & teaching others
- Coding dojos
- talks on Clojure (starting with the basics, showing the art of the possible)
- moving on to running conferences
- workshops at hack days
Thank you
@jr0cket
jr0cket.co.uk
slideshare.net/jr0cket
You unlock this door with
the key of imagination,
Beyond it is another
dimension
… a dimension of sound
Sound design of a language evolved over many
years
… a dimension of sight
REPL driven development showing you clearly
what your code is doing
… a dimension of mind
Thinking Functionally, of pure functions &
immutability
… of things and ideas
Merging of data structures & behaviour in one
syntax - homoiconicity
You have just crossed over to...
The Clojurescript Zone
The boundaries are only your imagination

Más contenido relacionado

La actualidad más candente

Best Practices in Qt Quick/QML - Part I
Best Practices in Qt Quick/QML - Part IBest Practices in Qt Quick/QML - Part I
Best Practices in Qt Quick/QML - Part IICS
 
Serving QML applications over the network
Serving QML applications over the networkServing QML applications over the network
Serving QML applications over the networkJeremy Lainé
 
Angular 2 Migration - JHipster Meetup 6
Angular 2 Migration - JHipster Meetup 6Angular 2 Migration - JHipster Meetup 6
Angular 2 Migration - JHipster Meetup 6William Marques
 
Introduction to orchestration using Mcollective
Introduction to orchestration using McollectiveIntroduction to orchestration using Mcollective
Introduction to orchestration using McollectivePuppet
 
Building a p2 update site using Buckminster
Building a p2 update site using BuckminsterBuilding a p2 update site using Buckminster
Building a p2 update site using Buckminsterguest5e2b6b
 
Practical pairing of generative programming with functional programming.
Practical pairing of generative programming with functional programming.Practical pairing of generative programming with functional programming.
Practical pairing of generative programming with functional programming.Eugene Lazutkin
 
Idiomatic Gradle Plugin Writing - GradleSummit 2016
Idiomatic Gradle Plugin Writing - GradleSummit 2016Idiomatic Gradle Plugin Writing - GradleSummit 2016
Idiomatic Gradle Plugin Writing - GradleSummit 2016Schalk Cronjé
 
Angular Extreme Performance - V2
Angular Extreme Performance - V2Angular Extreme Performance - V2
Angular Extreme Performance - V2Gustavo Costa
 
Gradle in 45min - JBCN2-16 version
Gradle in 45min - JBCN2-16 versionGradle in 45min - JBCN2-16 version
Gradle in 45min - JBCN2-16 versionSchalk Cronjé
 
React Native Evening
React Native EveningReact Native Evening
React Native EveningTroy Miles
 
GWT 2 Is Smarter Than You
GWT 2 Is Smarter Than YouGWT 2 Is Smarter Than You
GWT 2 Is Smarter Than YouRobert Cooper
 
Javascript Module Patterns
Javascript Module PatternsJavascript Module Patterns
Javascript Module PatternsNicholas Jansma
 
JavaScript in 2016
JavaScript in 2016JavaScript in 2016
JavaScript in 2016Codemotion
 
Puppet Camp DC 2014: Managing Puppet with MCollective
Puppet Camp DC 2014: Managing Puppet with MCollectivePuppet Camp DC 2014: Managing Puppet with MCollective
Puppet Camp DC 2014: Managing Puppet with MCollectivePuppet
 
Idiomatic gradle plugin writing
Idiomatic gradle plugin writingIdiomatic gradle plugin writing
Idiomatic gradle plugin writingSchalk Cronjé
 
Writing code that writes code - Nguyen Luong
Writing code that writes code - Nguyen LuongWriting code that writes code - Nguyen Luong
Writing code that writes code - Nguyen LuongVu Huy
 

La actualidad más candente (20)

Best Practices in Qt Quick/QML - Part I
Best Practices in Qt Quick/QML - Part IBest Practices in Qt Quick/QML - Part I
Best Practices in Qt Quick/QML - Part I
 
Serving QML applications over the network
Serving QML applications over the networkServing QML applications over the network
Serving QML applications over the network
 
Angular 2 Migration - JHipster Meetup 6
Angular 2 Migration - JHipster Meetup 6Angular 2 Migration - JHipster Meetup 6
Angular 2 Migration - JHipster Meetup 6
 
Introduction to orchestration using Mcollective
Introduction to orchestration using McollectiveIntroduction to orchestration using Mcollective
Introduction to orchestration using Mcollective
 
Building a p2 update site using Buckminster
Building a p2 update site using BuckminsterBuilding a p2 update site using Buckminster
Building a p2 update site using Buckminster
 
Vue next
Vue nextVue next
Vue next
 
Practical pairing of generative programming with functional programming.
Practical pairing of generative programming with functional programming.Practical pairing of generative programming with functional programming.
Practical pairing of generative programming with functional programming.
 
Idiomatic Gradle Plugin Writing - GradleSummit 2016
Idiomatic Gradle Plugin Writing - GradleSummit 2016Idiomatic Gradle Plugin Writing - GradleSummit 2016
Idiomatic Gradle Plugin Writing - GradleSummit 2016
 
Angular Extreme Performance - V2
Angular Extreme Performance - V2Angular Extreme Performance - V2
Angular Extreme Performance - V2
 
React native
React nativeReact native
React native
 
Gradle in 45min - JBCN2-16 version
Gradle in 45min - JBCN2-16 versionGradle in 45min - JBCN2-16 version
Gradle in 45min - JBCN2-16 version
 
React Native Evening
React Native EveningReact Native Evening
React Native Evening
 
GWT 2 Is Smarter Than You
GWT 2 Is Smarter Than YouGWT 2 Is Smarter Than You
GWT 2 Is Smarter Than You
 
Gradle in 45min
Gradle in 45minGradle in 45min
Gradle in 45min
 
Let's migrate to Swift 3.0
Let's migrate to Swift 3.0Let's migrate to Swift 3.0
Let's migrate to Swift 3.0
 
Javascript Module Patterns
Javascript Module PatternsJavascript Module Patterns
Javascript Module Patterns
 
JavaScript in 2016
JavaScript in 2016JavaScript in 2016
JavaScript in 2016
 
Puppet Camp DC 2014: Managing Puppet with MCollective
Puppet Camp DC 2014: Managing Puppet with MCollectivePuppet Camp DC 2014: Managing Puppet with MCollective
Puppet Camp DC 2014: Managing Puppet with MCollective
 
Idiomatic gradle plugin writing
Idiomatic gradle plugin writingIdiomatic gradle plugin writing
Idiomatic gradle plugin writing
 
Writing code that writes code - Nguyen Luong
Writing code that writes code - Nguyen LuongWriting code that writes code - Nguyen Luong
Writing code that writes code - Nguyen Luong
 

Similar a Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript

ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...Codemotion
 
Clojure Fundamentals Course For Beginners
Clojure Fundamentals Course For Beginners Clojure Fundamentals Course For Beginners
Clojure Fundamentals Course For Beginners Paddy Lock
 
ClojureScript for the web
ClojureScript for the webClojureScript for the web
ClojureScript for the webMichiel Borkent
 
State management in a GraphQL era
State management in a GraphQL eraState management in a GraphQL era
State management in a GraphQL erakristijanmkd
 
ClojureScript interfaces to React
ClojureScript interfaces to ReactClojureScript interfaces to React
ClojureScript interfaces to ReactMichiel Borkent
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing UpDavid Padbury
 
Thinking Functionally - John Stevenson - Codemotion Rome 2017
Thinking Functionally - John Stevenson - Codemotion Rome 2017Thinking Functionally - John Stevenson - Codemotion Rome 2017
Thinking Functionally - John Stevenson - Codemotion Rome 2017Codemotion
 
Thinking Functionally with Clojure
Thinking Functionally with ClojureThinking Functionally with Clojure
Thinking Functionally with ClojureJohn Stevenson
 
ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015Michiel Borkent
 
IPT High Performance Reactive Java BGOUG 2016
IPT High Performance Reactive Java BGOUG 2016IPT High Performance Reactive Java BGOUG 2016
IPT High Performance Reactive Java BGOUG 2016Trayan Iliev
 
Why scala is not my ideal language and what I can do with this
Why scala is not my ideal language and what I can do with thisWhy scala is not my ideal language and what I can do with this
Why scala is not my ideal language and what I can do with thisRuslan Shevchenko
 
Server side JavaScript: going all the way
Server side JavaScript: going all the wayServer side JavaScript: going all the way
Server side JavaScript: going all the wayOleg Podsechin
 
How to Reverse Engineer Web Applications
How to Reverse Engineer Web ApplicationsHow to Reverse Engineer Web Applications
How to Reverse Engineer Web ApplicationsJarrod Overson
 
Get into Functional Programming with Clojure
Get into Functional Programming with ClojureGet into Functional Programming with Clojure
Get into Functional Programming with ClojureJohn Stevenson
 
Reactive java programming for the impatient
Reactive java programming for the impatientReactive java programming for the impatient
Reactive java programming for the impatientGrant Steinfeld
 
UniRx - Reactive Extensions for Unity(EN)
UniRx - Reactive Extensions for Unity(EN)UniRx - Reactive Extensions for Unity(EN)
UniRx - Reactive Extensions for Unity(EN)Yoshifumi Kawai
 
A React Journey
A React JourneyA React Journey
A React JourneyLinkMe Srl
 

Similar a Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript (20)

ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
 
React native
React nativeReact native
React native
 
Clojure Fundamentals Course For Beginners
Clojure Fundamentals Course For Beginners Clojure Fundamentals Course For Beginners
Clojure Fundamentals Course For Beginners
 
ClojureScript for the web
ClojureScript for the webClojureScript for the web
ClojureScript for the web
 
State management in a GraphQL era
State management in a GraphQL eraState management in a GraphQL era
State management in a GraphQL era
 
ClojureScript interfaces to React
ClojureScript interfaces to ReactClojureScript interfaces to React
ClojureScript interfaces to React
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
 
Thinking Functionally - John Stevenson - Codemotion Rome 2017
Thinking Functionally - John Stevenson - Codemotion Rome 2017Thinking Functionally - John Stevenson - Codemotion Rome 2017
Thinking Functionally - John Stevenson - Codemotion Rome 2017
 
Thinking Functionally with Clojure
Thinking Functionally with ClojureThinking Functionally with Clojure
Thinking Functionally with Clojure
 
ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015
 
IPT High Performance Reactive Java BGOUG 2016
IPT High Performance Reactive Java BGOUG 2016IPT High Performance Reactive Java BGOUG 2016
IPT High Performance Reactive Java BGOUG 2016
 
Why scala is not my ideal language and what I can do with this
Why scala is not my ideal language and what I can do with thisWhy scala is not my ideal language and what I can do with this
Why scala is not my ideal language and what I can do with this
 
Play framework
Play frameworkPlay framework
Play framework
 
React october2017
React october2017React october2017
React october2017
 
Server side JavaScript: going all the way
Server side JavaScript: going all the wayServer side JavaScript: going all the way
Server side JavaScript: going all the way
 
How to Reverse Engineer Web Applications
How to Reverse Engineer Web ApplicationsHow to Reverse Engineer Web Applications
How to Reverse Engineer Web Applications
 
Get into Functional Programming with Clojure
Get into Functional Programming with ClojureGet into Functional Programming with Clojure
Get into Functional Programming with Clojure
 
Reactive java programming for the impatient
Reactive java programming for the impatientReactive java programming for the impatient
Reactive java programming for the impatient
 
UniRx - Reactive Extensions for Unity(EN)
UniRx - Reactive Extensions for Unity(EN)UniRx - Reactive Extensions for Unity(EN)
UniRx - Reactive Extensions for Unity(EN)
 
A React Journey
A React JourneyA React Journey
A React Journey
 

Más de John Stevenson

ClojureX Conference 2017 - 10 amazing years of Clojure
ClojureX Conference 2017 - 10 amazing years of ClojureClojureX Conference 2017 - 10 amazing years of Clojure
ClojureX Conference 2017 - 10 amazing years of ClojureJohn Stevenson
 
Confessions of a developer community builder
Confessions of a developer community builderConfessions of a developer community builder
Confessions of a developer community builderJohn Stevenson
 
Communication improbable
Communication improbableCommunication improbable
Communication improbableJohn Stevenson
 
Getting into public speaking at conferences
Getting into public speaking at conferencesGetting into public speaking at conferences
Getting into public speaking at conferencesJohn Stevenson
 
Functional web with clojure
Functional web with clojureFunctional web with clojure
Functional web with clojureJohn Stevenson
 
Guiding people into Clojure
Guiding people into ClojureGuiding people into Clojure
Guiding people into ClojureJohn Stevenson
 
Git and github - Verson Control for the Modern Developer
Git and github - Verson Control for the Modern DeveloperGit and github - Verson Control for the Modern Developer
Git and github - Verson Control for the Modern DeveloperJohn Stevenson
 
Get Functional Programming with Clojure
Get Functional Programming with ClojureGet Functional Programming with Clojure
Get Functional Programming with ClojureJohn Stevenson
 
So you want to run a developer event, are you crazy?
So you want to run a developer event, are you crazy?So you want to run a developer event, are you crazy?
So you want to run a developer event, are you crazy?John Stevenson
 
Trailhead live - Overview of Salesforce App Cloud
Trailhead live - Overview of Salesforce App CloudTrailhead live - Overview of Salesforce App Cloud
Trailhead live - Overview of Salesforce App CloudJohn Stevenson
 
Clojure for Java developers
Clojure for Java developersClojure for Java developers
Clojure for Java developersJohn Stevenson
 
Introducing the Salesforce platform
Introducing the Salesforce platformIntroducing the Salesforce platform
Introducing the Salesforce platformJohn Stevenson
 
Dreamforce14 Metadata Management with Git Version Control
Dreamforce14 Metadata Management with Git Version ControlDreamforce14 Metadata Management with Git Version Control
Dreamforce14 Metadata Management with Git Version ControlJohn Stevenson
 
Getting started with Clojure
Getting started with ClojureGetting started with Clojure
Getting started with ClojureJohn Stevenson
 
Salesforce Summer of Hacks London - Introduction
Salesforce Summer of Hacks London - IntroductionSalesforce Summer of Hacks London - Introduction
Salesforce Summer of Hacks London - IntroductionJohn Stevenson
 
Heroku Introduction: Scaling customer facing apps & services
Heroku Introduction: Scaling customer facing apps & servicesHeroku Introduction: Scaling customer facing apps & services
Heroku Introduction: Scaling customer facing apps & servicesJohn Stevenson
 
Developers guide to the Salesforce1 Platform
Developers guide to the Salesforce1 PlatformDevelopers guide to the Salesforce1 Platform
Developers guide to the Salesforce1 PlatformJohn Stevenson
 
Developer week EMEA - Salesforce1 Mobile App overview
Developer week EMEA - Salesforce1 Mobile App overviewDeveloper week EMEA - Salesforce1 Mobile App overview
Developer week EMEA - Salesforce1 Mobile App overviewJohn Stevenson
 
Dreamforce 13 developer session: Git for Force.com developers
Dreamforce 13 developer session: Git for Force.com developersDreamforce 13 developer session: Git for Force.com developers
Dreamforce 13 developer session: Git for Force.com developersJohn Stevenson
 
Dreamforce 13 developer session: Introduction to Heroku
Dreamforce 13 developer session: Introduction to HerokuDreamforce 13 developer session: Introduction to Heroku
Dreamforce 13 developer session: Introduction to HerokuJohn Stevenson
 

Más de John Stevenson (20)

ClojureX Conference 2017 - 10 amazing years of Clojure
ClojureX Conference 2017 - 10 amazing years of ClojureClojureX Conference 2017 - 10 amazing years of Clojure
ClojureX Conference 2017 - 10 amazing years of Clojure
 
Confessions of a developer community builder
Confessions of a developer community builderConfessions of a developer community builder
Confessions of a developer community builder
 
Communication improbable
Communication improbableCommunication improbable
Communication improbable
 
Getting into public speaking at conferences
Getting into public speaking at conferencesGetting into public speaking at conferences
Getting into public speaking at conferences
 
Functional web with clojure
Functional web with clojureFunctional web with clojure
Functional web with clojure
 
Guiding people into Clojure
Guiding people into ClojureGuiding people into Clojure
Guiding people into Clojure
 
Git and github - Verson Control for the Modern Developer
Git and github - Verson Control for the Modern DeveloperGit and github - Verson Control for the Modern Developer
Git and github - Verson Control for the Modern Developer
 
Get Functional Programming with Clojure
Get Functional Programming with ClojureGet Functional Programming with Clojure
Get Functional Programming with Clojure
 
So you want to run a developer event, are you crazy?
So you want to run a developer event, are you crazy?So you want to run a developer event, are you crazy?
So you want to run a developer event, are you crazy?
 
Trailhead live - Overview of Salesforce App Cloud
Trailhead live - Overview of Salesforce App CloudTrailhead live - Overview of Salesforce App Cloud
Trailhead live - Overview of Salesforce App Cloud
 
Clojure for Java developers
Clojure for Java developersClojure for Java developers
Clojure for Java developers
 
Introducing the Salesforce platform
Introducing the Salesforce platformIntroducing the Salesforce platform
Introducing the Salesforce platform
 
Dreamforce14 Metadata Management with Git Version Control
Dreamforce14 Metadata Management with Git Version ControlDreamforce14 Metadata Management with Git Version Control
Dreamforce14 Metadata Management with Git Version Control
 
Getting started with Clojure
Getting started with ClojureGetting started with Clojure
Getting started with Clojure
 
Salesforce Summer of Hacks London - Introduction
Salesforce Summer of Hacks London - IntroductionSalesforce Summer of Hacks London - Introduction
Salesforce Summer of Hacks London - Introduction
 
Heroku Introduction: Scaling customer facing apps & services
Heroku Introduction: Scaling customer facing apps & servicesHeroku Introduction: Scaling customer facing apps & services
Heroku Introduction: Scaling customer facing apps & services
 
Developers guide to the Salesforce1 Platform
Developers guide to the Salesforce1 PlatformDevelopers guide to the Salesforce1 Platform
Developers guide to the Salesforce1 Platform
 
Developer week EMEA - Salesforce1 Mobile App overview
Developer week EMEA - Salesforce1 Mobile App overviewDeveloper week EMEA - Salesforce1 Mobile App overview
Developer week EMEA - Salesforce1 Mobile App overview
 
Dreamforce 13 developer session: Git for Force.com developers
Dreamforce 13 developer session: Git for Force.com developersDreamforce 13 developer session: Git for Force.com developers
Dreamforce 13 developer session: Git for Force.com developers
 
Dreamforce 13 developer session: Introduction to Heroku
Dreamforce 13 developer session: Introduction to HerokuDreamforce 13 developer session: Introduction to Heroku
Dreamforce 13 developer session: Introduction to Heroku
 

Último

The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 

Último (20)

The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 

Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript

  • 1. Taming the wild fronteer Adventures in Clojurescript by John Stevenson @jr0cket practicalli.github.io/clojurescript
  • 2. @jr0cket Speaker, author, conference organiser & community obsessed developer. Loves Clojure, Spacemacs, Cats, Cycling & Agile development. @Heroku @SalesforceDevs In a galaxy far, far away…
  • 3. Taming The Wild Fronteer Javascript is a highly pervasive platform...
  • 4. Javascript as a platform is everywhere @jr0cket
  • 5. Many programming languages have their quirks… @jr0cket www.destroyallsoftware.com/talks/wat
  • 6. A common view of Javascript as a language @jr0cket
  • 7. Complex languages … are not easily reasoned about by humans @jr0cket Josh Smith - Tweet Original Gif
  • 8. ClojureScript A general purpose language made from decades of design
  • 9. From Javascript to Clojurescript f(x) -> (f x) ;; First element of a list is a function call var foo = “bar” -> (def foo “bar”) ;; bind a name to a value or function @jr0cket
  • 10. Clojurescript - basic syntax (ns clojure.awesome ) ;; define a namespace (scoping) (defn function-name [args] (behaviour)) ;; define a function, with arguments (function-name data) ;; call a function with the data as its argument (def name “data-or-value”) ;; bind a name to data within the namespace scope (let [name “data-or-value”]) ;; bind a name to a data within the let scope (local) :keyword-name ;; a keyword is a name (symbol) that points to itself ;; Chaining functions: Thread the result of the first fn into the argument of the next fn (-> (function-a “data”) (function-b ,,,) ;; In Clojure commas , are whitespace (function-c ,,, “data”))
  • 11. Built-in immutable data structures Model state and any other data with built-in (hash) maps, vectors (arrays), (linked) lists, (unique) sets (list 1 2 3 4 5) ‘(“fish” “chips” 42) (vec ‘(1 2 3 4)) [1 2 3 4] {:key “value”} {:name “John” :skill “conferencing”} (set ‘(1 2 3 4 4)) #{1 2 3 4}
  • 12. Clojure - a few core functions (map fn collection) ;; map a fn over a collection, return new collection (reduce fn collection) ;; return the value of combining elements in collection with fn (for [x collection] (fn x)) ;; iterate over the elements of a collection (filter fn collection) ;; return a collection of values that comply with the filter fn (get {:veg “kale” :fruit “kiwi”} :fruit) ;; return value pointed to by keyword (:fruit {:veg “kale” :fruit “kiwi”}) ;; return value pointed to by keyword (conj collection value) ;; conjoin a value to the collection (assoc collection coll) ;; add a collection to the collection (update {:a 1} :a fn) ;; update value pointed to by the key in a map with the fn
  • 14. The Complexity Iceberg - @krisajenkins ● complexity is very dangerous when hidden ● You can't know what a function does for certain if it has side effects
  • 16. Pure Functions The results of the function are purely determined by its initial output and its own code - no external influence, a function only uses local values - referential transparency (the function can be replaced by its value)
  • 17. Impure Functions - side causes
  • 18. Eliminating Side Effects Functional programming is about eliminating side effects where you can, controlling them where you can't - @krisajenkins The features in Functional Programming come from a desire to reduce side effects
  • 19. Design idiom: Composing functions together You can think of functional design as evaluating one or more functions in series of functions
  • 20. The Map Reduce Sandwich
  • 21. Clojure - the Map Reduce Sandwich
  • 22. Clojure - the Map Reduce Sandwich
  • 23. Pure Functions & Immutability = Parallelism In simple terms: run the same code across multiple CPU’s / Threads
  • 24. Parallelism - pmap pmap - the same as map but in parallel
  • 25. Parallelism - reduce Significantly lower completion time running in parallel using Immutable data structures https://github.com/aphyr/tesser
  • 26. Managing State State changes should be managed easily
  • 27. Safe State changes Changing state safely by changing it atomically ● Software Transactional Memory (STM) ○ Gives an mechanism like an in-memory atomic database that manages mutable state changes under the covers ● Atoms ● Refs ● core.async
  • 28. Concurrency syntax - atoms An online card game has players that can join and have their winnings tracked
  • 29. Concurrency syntax - atoms The join-game function adds players to the atom by their name, but only up to 2 players
  • 30. Concurrency syntax - refs join-game-safely adds players to ref & alters their account & game account
  • 31. ClojureScript - Functional Web Immutability & composable functions for Web Apps
  • 32. See Clojurescript for Skeptics: https://www.youtube.com/watch?v=gsffg5xxFQI&t=4s
  • 33.
  • 34. jQuery over all JavaScript frameworks See Clojurescript for Skeptics: https://www.youtube.com/watch?v=gsffg5xxFQI&t=4s
  • 35. See Clojurescript for Skeptics: https://www.youtube.com/watch?v=gsffg5xxFQI&t=4s
  • 36. Google Closure tools & libraries
  • 37. See Clojurescript for Skeptics: https://www.youtube.com/watch?v=gsffg5xxFQI&t=4s
  • 38.
  • 39. Examples of Clojurescript ● Goya - pixel editor with undo https://jackschaedler.githu b.io/goya/ ● CircleCI ● Style.com ● Klipse - web-based dev tool & library for live-code examples in blogs / workshops
  • 41. Clojurescript Environments Nashorn - built into JVM, access Java classes - Oracle Nashorn: A Next-Generation JavaScript Engine for the JVM Browser-REPL - built into modern browsers (Chrome, Firefox, etc) - commonly used for client side web apps Node.js - great for command line utilities and microservices!
  • 42. Common Clojurescript Tooling Leiningen - build automation tool for Clojure & Clojurescript Figwheel (leiningen plugin) - defacto tool for client side web apps - live reload - multi-broadcast (eg simultaneous dev & test outputs)
  • 43. Full-stack projects: Chestnut https://github.com/plexus/chestnut - leiningen template for Clojure/ClojureScript apps based - with Om, Reagent, or Rum - instant reloading of Clojure, ClojureScript, and CSS - browser-connected REPL included lein new chestnut project-name
  • 44. Self-hosted Clojurescript Environments Instant startup times, great for command line tools Lumo (cross-platform) - https://github.com/anmonteiro/lumo Plank (Mac & Linux) - http://planck-repl.org/
  • 47. React Basics (conceptual) React provides an efficient way to update the view
  • 48. What React Provides React is only the view The view should update the state, not the DOM
  • 49. Reactive Frameworks All the varieties of life, plus all the Javascript varieties too...
  • 50. Javascript & Clojurescript frameworks Javascript ● React.js via cljsjs ● Vue.js ??? Clojurescript ● Om / Om-next ● Reagent / Reframe ● Rum More at https://clojurescript.org/community/libraries
  • 53. Reagent Clojurescript can directly use the React.js library thanks to cljsjs.github.io
  • 60. Om / Om-next ClojureScript interface to Facebook's React
  • 61. Om / Om-next Models the React.js API Rapidly re-render the UI from the root due via Immutable data structures - UIs are snapshot-able and undoable without implementation complexity Om supports features not currently present in React: - Global state management facilities built in - Components may have arbitrary data dependencies, not limited to props & state - Component construction intercepted via :instrument. Simplifies debugging - Stream all application state deltas via :tx-listen. Simplifies on/offline sync - Customizable semantics
  • 62. Om core functions om.core/IRender - Render a Om component into the DOM - uses reify to provide a specific implementation of the om/IRender interface om.core/IInitState - maintains a local state (eg. for managing user input data) om.core/IRenderState - Render a Om component into the DOM - renders component on change in local & global state
  • 63. Om core functions om.dom/div attributes content - creates a <div> tag in react - all react tags need to be wrapped in a div in order to be rendered - om.dom/… has all the other tags too - h1, h2, p, a … (sablono can be used instead) #js - converts clojure maps into Javascript objects - nest #js functions to to create JS objects - eg. for inline styles
  • 64. Om Cursors A cursor is an atom & a path to a location in the atom app-state :schedule 0 Components use the cursor to refer to pieces of the app state - without knowing where they are in the state tree - updating app state is simple as the cursor is in the correct part of the app state
  • 65.
  • 67.
  • 68. Reagent Reagent provides a minimalistic interface between ClojureScript and React - define efficient React components using nothing but plain ClojureScript functions and data - describe your UI using a Hiccup syntax [:div [:h1 “Heading”] [:div [:p “Paragraph” ] [:a {:href “/link.html”} “link text”]]] - define arbitrarily complex UIs using a couple of basic concepts - fast enough by default that you rarely have to care about performance.
  • 69. Reagent Core functions reagent.core/render - Render a Reagent component into the DOM - First argument is either a vector (Reagent Hiccup syntax) or a React element reagent.core/atom - Like clojure.core/atom, plus it tracks components that deref atom & re-renders them
  • 70. Helper functions Reagent used Clojurescript functions for conversion from - Clojure Maps to Javascript Objects - Clojurescript vectors to Javascript arrays clj->js - convert from Clojurescript to Javascript js->clj - convert from Javascript to Clojurescript
  • 71. Reagent Examples http://timothypratley.blogspot.co.uk/2017/01/reagent-deep-dive-part-1.html - Uses Klipse to display interactive code snippets for Reagent - Includes use of SVG and Web3D libraries too Graph example - http://leaderboardx.herokuapp.com/
  • 72.
  • 74. Re-frame a pattern for writing SPAs in ClojureScript, using Reagent. a framework with pure functions which transform data Architecturally implements "a perpetual loop". Build apps by writing pure functions for certain parts of the loop that transform the data - Re-frame looks after the conveyance of data around the loop, into and out of the transforming functions you write - tag line of "Derived Values, Flowing".
  • 76. Rum Rum is a client/server library for HTML UI. In ClojureScript, it works as React wrapper, in Clojure, it is a static HTML generator. - Simple semantics: Rum is arguably smaller, simpler and more straightforward than React itself. - Decomplected: Rum is a library, not a framework. Use only the parts you need, throw away or replace what you don’t need, combine different approaches in a single app, or even combine Rum with other frameworks. - No enforced state model: Unlike Om, Reagent or Quiescent, Rum does not dictate where to keep your state. Instead, it works well with any storage: persistent data structures, atoms, DataScript, JavaScript objects, localStorage or any custom solution you can think of. - Extensible: the API is stable and explicitly defined, including the API between Rum internals. It lets you build custom behaviours that change components in significant ways. - Minimal codebase: You can become a Rum expert just by reading its source code (~900 lines).
  • 77. Rum - at ClojureX https://skillsmatter.com/skillscasts/9149-modern-web-apps-with-rum
  • 80. Take a journey into Clojurescript
  • 82.
  • 83. londonclojurians.org - 4 events per month - Possibly the most active language-specific developer communitie in London
  • 84. Learning by teaching others I really started thinking in Clojure when I started talking to & teaching others - Coding dojos - talks on Clojure (starting with the basics, showing the art of the possible) - moving on to running conferences - workshops at hack days
  • 86. You unlock this door with the key of imagination, Beyond it is another dimension
  • 87. … a dimension of sound Sound design of a language evolved over many years
  • 88. … a dimension of sight REPL driven development showing you clearly what your code is doing
  • 89. … a dimension of mind Thinking Functionally, of pure functions & immutability
  • 90. … of things and ideas Merging of data structures & behaviour in one syntax - homoiconicity
  • 91. You have just crossed over to... The Clojurescript Zone The boundaries are only your imagination