SlideShare a Scribd company logo
SoCal Code Camp 12+13 November 2016
Functional Programming
in Clojure
Troy Miles
• Troy Miles aka the RocknCoder
• Over 37 years of programming
experience
• Speaker and author
• Author of jQuery Essentials
• bit.ly/rc-jquerybook
• rockncoder@gmail.com
• @therockncoder
Build Mobile Apps!
• Develop mobile apps with
Ionic and AngularJS
• Learn the Ionic CLI
• Fetch data via ajax
• Deploy your app to Android &
iOS
• bit.ly/ionicvideo
Slides Online
• http://www.slideshare.net/rockncoder/functional-
programming-in-clojure-68544774
Our Agenda
• Clojure?
• Lisp
• The Java Virtual Machine
• Leiningen
• Functional Programming
Clojure?
–Paul Graham
“Lisp is worth learning for the profound
enlightenment experience you will have when
you finally get it; that experience will make you
a better programmer for the rest of your days,
even if you never actually use Lisp itself a lot.”
What is Clojure?
• A dynamic, general-purpose programming
language
• A Modern Lisp
• Designed to be hosted
• Functional, but practical
Other Hosts for Clojure
• ClojureScript - Compiles to JavaScript
• Clojure CLR - Compiles to IL, for Microsoft’s CLR
ClojureScript
• Clojure + ClojureScript used together by 66% of the
community
• Om / Reagent - Interfaces for Facebook’s React
Library
• Mori - ClojureScript’s Immutable data structure for
vanilla JavaScript
Companies using Clojure
• Walmart Labs
• Puppet Labs
• ThoughtWorks
• Amazon
• Facebook
• Groupon
• Intuit
• Salesforce
• Zendesk
–Paul Graham
“I suppose I should learn Lisp, but it seems so
foreign.”
Lisp? Lisp!
• Created in 1958 by John McCarthy
• Second oldest high-level language still in use today
• Influenced by Alonzo Church’s lambda calculus
• A family of languages including: Common Lisp,
Scheme, Emacs Lisp
Lisp Innovations
• recursive function
• dynamically allocated memory
• garbage collection
• lexical closures
• macros
The Java Virtual Machine
• An abstract computing machine that allows a
computer run a Java program
• Type system
• Garbage collection
• Threads
• Just-in-time compiler (JIT)
• Favorite target of criminal hackers
JVM Languages
• Ceylon - Java competitor from Red Hat
• Groovy - OOP langage
• JRuby - Ruby on the JVM
• Jython - Python on the JVM
• Kotlin - Java competitor from JetBrains
• Rhino/Nashorn - JavaScript engines
• Scala - OOP / Functional language
Build Tools
• Apache Maven
• Leiningen
Leiningen
• A tool for automating Clojure projects
• Written in Clojure
• Open source and maintained by a large community
• A play on another famous build tool, Apache Ant
Using Leiningen
• Searches from repos
• lein new app my-stuff
Directory
├── CHANGELOG.md
├── LICENSE
├── README.md
├── doc
│   └── intro.md
├── project.clj
├── resources
├── src
│   └── my_app
│   └── core.clj
└── test
└── my_app
└── core_test.clj
Editors / IDEs
• Emacs - created in 1976
• Vim - created in 1991
• Eclipse + Counterclockwise - created in 2001
• Intellij IDEA + Cursive - created in 2001
What is Functional Programming?
Key Functional Features
• Pure functions
• First-class / High order functions
• Immutable data
• Recursion
• Referential transparency
Functional vs. Imperative
what? functional imperative
primary construct function class instance
state change bad important
order of execution not important important
flow control
function calls
recursion
loops, conditionals,
method calls
Sample Languages
mostly functional mixed mostly imperative
Lisp/Scheme JavaScript Java
ML Scala C#
Haskell Python C++
Clojure Dart Swift
F# Lua Ruby
Erlang R Kotlin
Pure Functions
• Must return a value
• Must accept at least one argument
• Can’t produce any side-effects
• Must return the same output for a given input
Pure Functions Are Super
• Cacheable
• Portable
• Self-documenting
• Testable
• Reasonable
First-Class Functions
• Assigned to variables
• Stored in arrays
• Passed as arguments to other functions
• Returned from functions
Higher-Order Functions
• Accept other functions as parameter
• And/or return a function
• Allows for the creation of function factories
• This is the core of the curry function
Code Samples
1 (function () {
2 'use strict';
3 const fizzBuzz = function () {
4 for (let i = 1; i <= 100; i += 1) {
5 let printVal = i + ' ';
6 if (i % 3 === 0) {
7 printVal += 'Fizz';
8 }
9 if (i % 5 === 0) {
10 printVal += 'Buzz';
11 }
12 console.info(printVal);
13 }
14 };
15 fizzBuzz();
16 }());
FizzBuzz in JavaScript
FizzBuzz in Clojure
1 (defn fizzbuzz [start finish]
2 (map (fn [n]
3 (cond
4 (zero? (mod n 15)) "FizzBuzz"
5 (zero? (mod n 3)) "Fizz"
6 (zero? (mod n 5)) "Buzz"
7 :else n))
8 (range start finish)))
9
10 (fizzbuzz 1 100)
Links
• Clojure - http://clojure.org/
• ClojureScript - http://clojurescript.org/
• ClojureCLR - http://clojure.org/about/clojureclr
• Clojure Docs - http://clojure-doc.org/
• Try Clojure - http://www.tryclj.com/
More Links
• Om - https://github.com/omcljs/om
• Reagent - https://reagent-project.github.io/
• Mori - https://github.com/swannodette/mori
• Clojure/Android - https://github.com/clojure-android
• Leiningen - http://leiningen.org/
And Even More Links
• SICP Online - http://web.mit.edu/alexmv/6.037/
sicp.pdf
• Paul Graham - http://paulgraham.com/avg.html
Summary
• Clojure is functional language on the JVM
• It is interoperable with Java
• It has a Lisp syntax which is not
–Edsger Dijkstra
“Object-oriented programming is an
exceptionally bad idea which could only have
originated in California.”

More Related Content

What's hot

Lisp Meet Up #31, Clake: a GNU make-like build utility in Common Lisp
Lisp Meet Up #31, Clake: a GNU make-like build utility in Common LispLisp Meet Up #31, Clake: a GNU make-like build utility in Common Lisp
Lisp Meet Up #31, Clake: a GNU make-like build utility in Common Lisp
masayukitakagi
 
Web development with Lua: Introducing Sailor an MVC web framework @ CodingSer...
Web development with Lua: Introducing Sailor an MVC web framework @ CodingSer...Web development with Lua: Introducing Sailor an MVC web framework @ CodingSer...
Web development with Lua: Introducing Sailor an MVC web framework @ CodingSer...
Etiene Dalcol
 
Automating Your Daily Tasks with Scripting - RubyConf 2015 Taiwan
Automating Your Daily Tasks with Scripting - RubyConf 2015 TaiwanAutomating Your Daily Tasks with Scripting - RubyConf 2015 Taiwan
Automating Your Daily Tasks with Scripting - RubyConf 2015 Taiwan
Adler Hsieh
 
Dev112 let's calendar that
Dev112   let's calendar thatDev112   let's calendar that
Dev112 let's calendar that
Howard Greenberg
 
Refactoring @ Mindvalley: Smells, Techniques and Patterns
Refactoring @ Mindvalley: Smells, Techniques and PatternsRefactoring @ Mindvalley: Smells, Techniques and Patterns
Refactoring @ Mindvalley: Smells, Techniques and Patterns
Tristan Gomez
 
ProtoPie with Electron
ProtoPie with ElectronProtoPie with Electron
ProtoPie with Electron
Scotty Kim
 
Dan Persa, Maximilian Fellner - The recipe for scalable frontends - Codemotio...
Dan Persa, Maximilian Fellner - The recipe for scalable frontends - Codemotio...Dan Persa, Maximilian Fellner - The recipe for scalable frontends - Codemotio...
Dan Persa, Maximilian Fellner - The recipe for scalable frontends - Codemotio...
Codemotion
 
Mixing Plone and Django for explosive results
Mixing Plone and Django for explosive resultsMixing Plone and Django for explosive results
Mixing Plone and Django for explosive results
Simone Deponti
 
Life Beyond Rails: Creating Cross Platform Ruby Apps
Life Beyond Rails: Creating Cross Platform Ruby AppsLife Beyond Rails: Creating Cross Platform Ruby Apps
Life Beyond Rails: Creating Cross Platform Ruby Apps
Tristan Gomez
 
Hybrid concurrency patterns
Hybrid concurrency patternsHybrid concurrency patterns
Hybrid concurrency patterns
Kyle Drake
 
Sailor - A web MVC framework in Lua by Etiene Dalcol (Lua Workshop 2014)
Sailor - A web MVC framework in Lua by Etiene Dalcol (Lua Workshop 2014)Sailor - A web MVC framework in Lua by Etiene Dalcol (Lua Workshop 2014)
Sailor - A web MVC framework in Lua by Etiene Dalcol (Lua Workshop 2014)
Etiene Dalcol
 
Scala Frameworks for Web Application 2016
Scala Frameworks for Web Application 2016Scala Frameworks for Web Application 2016
Scala Frameworks for Web Application 2016
takezoe
 
Introduction to Phoenix Web Framework
Introduction to Phoenix Web FrameworkIntroduction to Phoenix Web Framework
Introduction to Phoenix Web Framework
Riza Fahmi
 
Ruby, the language of devops
Ruby, the language of devopsRuby, the language of devops
Ruby, the language of devops
Rob Kinyon
 
Eugene PHP June 2015 - Let's Talk Laravel
Eugene PHP June 2015 - Let's Talk LaravelEugene PHP June 2015 - Let's Talk Laravel
Eugene PHP June 2015 - Let's Talk Laravel
anaxamaxan
 
RubyConf Taiwan 2016 - Large scale Rails applications
RubyConf Taiwan 2016 - Large scale Rails applicationsRubyConf Taiwan 2016 - Large scale Rails applications
RubyConf Taiwan 2016 - Large scale Rails applications
Florian Dutey
 
Kubernetes: The Very Hard Way
Kubernetes: The Very Hard WayKubernetes: The Very Hard Way
Kubernetes: The Very Hard Way
Rob Boll
 
DEV117 - Unleash the Power of the AppDev Pack and Node.js in Domino
DEV117 - Unleash the Power of the AppDev Pack and Node.js in DominoDEV117 - Unleash the Power of the AppDev Pack and Node.js in Domino
DEV117 - Unleash the Power of the AppDev Pack and Node.js in Domino
Heiko Voigt
 
MJ Berends talk - Women & Non-Binary Focused Intro to AWS
 MJ Berends talk - Women & Non-Binary Focused Intro to AWS MJ Berends talk - Women & Non-Binary Focused Intro to AWS
MJ Berends talk - Women & Non-Binary Focused Intro to AWS
AWS Chicago
 

What's hot (20)

Lisp Meet Up #31, Clake: a GNU make-like build utility in Common Lisp
Lisp Meet Up #31, Clake: a GNU make-like build utility in Common LispLisp Meet Up #31, Clake: a GNU make-like build utility in Common Lisp
Lisp Meet Up #31, Clake: a GNU make-like build utility in Common Lisp
 
Web development with Lua: Introducing Sailor an MVC web framework @ CodingSer...
Web development with Lua: Introducing Sailor an MVC web framework @ CodingSer...Web development with Lua: Introducing Sailor an MVC web framework @ CodingSer...
Web development with Lua: Introducing Sailor an MVC web framework @ CodingSer...
 
Automating Your Daily Tasks with Scripting - RubyConf 2015 Taiwan
Automating Your Daily Tasks with Scripting - RubyConf 2015 TaiwanAutomating Your Daily Tasks with Scripting - RubyConf 2015 Taiwan
Automating Your Daily Tasks with Scripting - RubyConf 2015 Taiwan
 
Dev112 let's calendar that
Dev112   let's calendar thatDev112   let's calendar that
Dev112 let's calendar that
 
Refactoring @ Mindvalley: Smells, Techniques and Patterns
Refactoring @ Mindvalley: Smells, Techniques and PatternsRefactoring @ Mindvalley: Smells, Techniques and Patterns
Refactoring @ Mindvalley: Smells, Techniques and Patterns
 
ProtoPie with Electron
ProtoPie with ElectronProtoPie with Electron
ProtoPie with Electron
 
Dan Persa, Maximilian Fellner - The recipe for scalable frontends - Codemotio...
Dan Persa, Maximilian Fellner - The recipe for scalable frontends - Codemotio...Dan Persa, Maximilian Fellner - The recipe for scalable frontends - Codemotio...
Dan Persa, Maximilian Fellner - The recipe for scalable frontends - Codemotio...
 
Mixing Plone and Django for explosive results
Mixing Plone and Django for explosive resultsMixing Plone and Django for explosive results
Mixing Plone and Django for explosive results
 
Life Beyond Rails: Creating Cross Platform Ruby Apps
Life Beyond Rails: Creating Cross Platform Ruby AppsLife Beyond Rails: Creating Cross Platform Ruby Apps
Life Beyond Rails: Creating Cross Platform Ruby Apps
 
Hybrid concurrency patterns
Hybrid concurrency patternsHybrid concurrency patterns
Hybrid concurrency patterns
 
Sailor - A web MVC framework in Lua by Etiene Dalcol (Lua Workshop 2014)
Sailor - A web MVC framework in Lua by Etiene Dalcol (Lua Workshop 2014)Sailor - A web MVC framework in Lua by Etiene Dalcol (Lua Workshop 2014)
Sailor - A web MVC framework in Lua by Etiene Dalcol (Lua Workshop 2014)
 
Scala Frameworks for Web Application 2016
Scala Frameworks for Web Application 2016Scala Frameworks for Web Application 2016
Scala Frameworks for Web Application 2016
 
Introduction to Phoenix Web Framework
Introduction to Phoenix Web FrameworkIntroduction to Phoenix Web Framework
Introduction to Phoenix Web Framework
 
Ruby, the language of devops
Ruby, the language of devopsRuby, the language of devops
Ruby, the language of devops
 
Eugene PHP June 2015 - Let's Talk Laravel
Eugene PHP June 2015 - Let's Talk LaravelEugene PHP June 2015 - Let's Talk Laravel
Eugene PHP June 2015 - Let's Talk Laravel
 
RubyConf Taiwan 2016 - Large scale Rails applications
RubyConf Taiwan 2016 - Large scale Rails applicationsRubyConf Taiwan 2016 - Large scale Rails applications
RubyConf Taiwan 2016 - Large scale Rails applications
 
Wider than rails
Wider than railsWider than rails
Wider than rails
 
Kubernetes: The Very Hard Way
Kubernetes: The Very Hard WayKubernetes: The Very Hard Way
Kubernetes: The Very Hard Way
 
DEV117 - Unleash the Power of the AppDev Pack and Node.js in Domino
DEV117 - Unleash the Power of the AppDev Pack and Node.js in DominoDEV117 - Unleash the Power of the AppDev Pack and Node.js in Domino
DEV117 - Unleash the Power of the AppDev Pack and Node.js in Domino
 
MJ Berends talk - Women & Non-Binary Focused Intro to AWS
 MJ Berends talk - Women & Non-Binary Focused Intro to AWS MJ Berends talk - Women & Non-Binary Focused Intro to AWS
MJ Berends talk - Women & Non-Binary Focused Intro to AWS
 

Viewers also liked

Learn basics of Clojure/script and Reagent
Learn basics of Clojure/script and ReagentLearn basics of Clojure/script and Reagent
Learn basics of Clojure/script and Reagent
Maty Fedak
 
Reagents
ReagentsReagents
Reagents
Sri Nandan
 
Get into Functional Programming with Clojure
Get into Functional Programming with ClojureGet into Functional Programming with Clojure
Get into Functional Programming with Clojure
John Stevenson
 
Rethink programming: a functional approach
Rethink programming: a functional approachRethink programming: a functional approach
Rethink programming: a functional approach
Francesco Bruni
 
Enjoyable Front-end Development with Reagent
Enjoyable Front-end Development with ReagentEnjoyable Front-end Development with Reagent
Enjoyable Front-end Development with Reagent
Thiago Fernandes Massa
 
Fuel Up JavaScript with Functional Programming
Fuel Up JavaScript with Functional ProgrammingFuel Up JavaScript with Functional Programming
Fuel Up JavaScript with Functional Programming
Shine Xavier
 
Functional Programming in Java - Code for Maintainability
Functional Programming in Java - Code for MaintainabilityFunctional Programming in Java - Code for Maintainability
Functional Programming in Java - Code for Maintainability
Marcin Stepien
 
Functional programming in Scala
Functional programming in ScalaFunctional programming in Scala
Functional programming in Scala
Damian Jureczko
 
Deep Learning through Examples
Deep Learning through ExamplesDeep Learning through Examples
Deep Learning through Examples
Sri Ambati
 

Viewers also liked (9)

Learn basics of Clojure/script and Reagent
Learn basics of Clojure/script and ReagentLearn basics of Clojure/script and Reagent
Learn basics of Clojure/script and Reagent
 
Reagents
ReagentsReagents
Reagents
 
Get into Functional Programming with Clojure
Get into Functional Programming with ClojureGet into Functional Programming with Clojure
Get into Functional Programming with Clojure
 
Rethink programming: a functional approach
Rethink programming: a functional approachRethink programming: a functional approach
Rethink programming: a functional approach
 
Enjoyable Front-end Development with Reagent
Enjoyable Front-end Development with ReagentEnjoyable Front-end Development with Reagent
Enjoyable Front-end Development with Reagent
 
Fuel Up JavaScript with Functional Programming
Fuel Up JavaScript with Functional ProgrammingFuel Up JavaScript with Functional Programming
Fuel Up JavaScript with Functional Programming
 
Functional Programming in Java - Code for Maintainability
Functional Programming in Java - Code for MaintainabilityFunctional Programming in Java - Code for Maintainability
Functional Programming in Java - Code for Maintainability
 
Functional programming in Scala
Functional programming in ScalaFunctional programming in Scala
Functional programming in Scala
 
Deep Learning through Examples
Deep Learning through ExamplesDeep Learning through Examples
Deep Learning through Examples
 

Similar to Functional Programming in Clojure

Google App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and GaelykGoogle App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and Gaelyk
Guillaume Laforge
 
DanNotes 2013: OpenNTF Domino API
DanNotes 2013: OpenNTF Domino APIDanNotes 2013: OpenNTF Domino API
DanNotes 2013: OpenNTF Domino API
Paul Withers
 
[Struyf] Automate Your Tasks With Azure Functions
[Struyf] Automate Your Tasks With Azure Functions[Struyf] Automate Your Tasks With Azure Functions
[Struyf] Automate Your Tasks With Azure Functions
European Collaboration Summit
 
RubyStack: the easiest way to deploy Ruby on Rails
RubyStack: the easiest way to deploy Ruby on RailsRubyStack: the easiest way to deploy Ruby on Rails
RubyStack: the easiest way to deploy Ruby on Railselliando dias
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
orkaplan
 
Implementing your own Google App Engine
Implementing your own Google App Engine Implementing your own Google App Engine
Implementing your own Google App Engine
Virtual JBoss User Group
 
Peru JUG Micronaut & GraalVM
Peru JUG Micronaut & GraalVMPeru JUG Micronaut & GraalVM
Peru JUG Micronaut & GraalVM
Domingo Suarez Torres
 
Intro to CakePHP
Intro to CakePHPIntro to CakePHP
Intro to CakePHP
Walther Lalk
 
Exploring Java Heap Dumps (Oracle Code One 2018)
Exploring Java Heap Dumps (Oracle Code One 2018)Exploring Java Heap Dumps (Oracle Code One 2018)
Exploring Java Heap Dumps (Oracle Code One 2018)
Ryan Cuprak
 
Raffaele Rialdi
Raffaele RialdiRaffaele Rialdi
Raffaele Rialdi
CodeFest
 
Expert JavaScript Programming
Expert JavaScript ProgrammingExpert JavaScript Programming
Expert JavaScript Programming
Yoshiki Shibukawa
 
O365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
O365Con18 - Automate your Tasks through Azure Functions - Elio StruyfO365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
O365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
NCCOMMS
 
Clojure in real life 17.10.2014
Clojure in real life 17.10.2014Clojure in real life 17.10.2014
Clojure in real life 17.10.2014
Metosin Oy
 
Beyond JVM - YOW Melbourne 2013
Beyond JVM - YOW Melbourne 2013Beyond JVM - YOW Melbourne 2013
Beyond JVM - YOW Melbourne 2013
Charles Nutter
 
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)goccy
 
Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slides
elliando dias
 
From Web to Mobile with Stage 3D
From Web to Mobile with Stage 3DFrom Web to Mobile with Stage 3D
From Web to Mobile with Stage 3D
Jean-Philippe Doiron
 
Introduction to React native
Introduction to React nativeIntroduction to React native
Introduction to React native
Dhaval Barot
 
GraalVM
GraalVMGraalVM

Similar to Functional Programming in Clojure (20)

Google App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and GaelykGoogle App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and Gaelyk
 
DanNotes 2013: OpenNTF Domino API
DanNotes 2013: OpenNTF Domino APIDanNotes 2013: OpenNTF Domino API
DanNotes 2013: OpenNTF Domino API
 
[Struyf] Automate Your Tasks With Azure Functions
[Struyf] Automate Your Tasks With Azure Functions[Struyf] Automate Your Tasks With Azure Functions
[Struyf] Automate Your Tasks With Azure Functions
 
RubyStack: the easiest way to deploy Ruby on Rails
RubyStack: the easiest way to deploy Ruby on RailsRubyStack: the easiest way to deploy Ruby on Rails
RubyStack: the easiest way to deploy Ruby on Rails
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
JavaScript Event Loop
JavaScript Event LoopJavaScript Event Loop
JavaScript Event Loop
 
Implementing your own Google App Engine
Implementing your own Google App Engine Implementing your own Google App Engine
Implementing your own Google App Engine
 
Peru JUG Micronaut & GraalVM
Peru JUG Micronaut & GraalVMPeru JUG Micronaut & GraalVM
Peru JUG Micronaut & GraalVM
 
Intro to CakePHP
Intro to CakePHPIntro to CakePHP
Intro to CakePHP
 
Exploring Java Heap Dumps (Oracle Code One 2018)
Exploring Java Heap Dumps (Oracle Code One 2018)Exploring Java Heap Dumps (Oracle Code One 2018)
Exploring Java Heap Dumps (Oracle Code One 2018)
 
Raffaele Rialdi
Raffaele RialdiRaffaele Rialdi
Raffaele Rialdi
 
Expert JavaScript Programming
Expert JavaScript ProgrammingExpert JavaScript Programming
Expert JavaScript Programming
 
O365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
O365Con18 - Automate your Tasks through Azure Functions - Elio StruyfO365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
O365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
 
Clojure in real life 17.10.2014
Clojure in real life 17.10.2014Clojure in real life 17.10.2014
Clojure in real life 17.10.2014
 
Beyond JVM - YOW Melbourne 2013
Beyond JVM - YOW Melbourne 2013Beyond JVM - YOW Melbourne 2013
Beyond JVM - YOW Melbourne 2013
 
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
 
Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slides
 
From Web to Mobile with Stage 3D
From Web to Mobile with Stage 3DFrom Web to Mobile with Stage 3D
From Web to Mobile with Stage 3D
 
Introduction to React native
Introduction to React nativeIntroduction to React native
Introduction to React native
 
GraalVM
GraalVMGraalVM
GraalVM
 

More from Troy Miles

Fast C++ Web Servers
Fast C++ Web ServersFast C++ Web Servers
Fast C++ Web Servers
Troy Miles
 
Node Boot Camp
Node Boot CampNode Boot Camp
Node Boot Camp
Troy Miles
 
AWS Lambda Function with Kotlin
AWS Lambda Function with KotlinAWS Lambda Function with Kotlin
AWS Lambda Function with Kotlin
Troy Miles
 
React Native One Day
React Native One DayReact Native One Day
React Native One Day
Troy Miles
 
React Native Evening
React Native EveningReact Native Evening
React Native Evening
Troy Miles
 
Intro to React
Intro to ReactIntro to React
Intro to React
Troy Miles
 
React Development with the MERN Stack
React Development with the MERN StackReact Development with the MERN Stack
React Development with the MERN Stack
Troy Miles
 
Angular Application Testing
Angular Application TestingAngular Application Testing
Angular Application Testing
Troy Miles
 
ReactJS.NET
ReactJS.NETReactJS.NET
ReactJS.NET
Troy Miles
 
What is Angular version 4?
What is Angular version 4?What is Angular version 4?
What is Angular version 4?
Troy Miles
 
Angular Weekend
Angular WeekendAngular Weekend
Angular Weekend
Troy Miles
 
From MEAN to the MERN Stack
From MEAN to the MERN StackFrom MEAN to the MERN Stack
From MEAN to the MERN Stack
Troy Miles
 
MEAN Stack Warm-up
MEAN Stack Warm-upMEAN Stack Warm-up
MEAN Stack Warm-up
Troy Miles
 
The JavaScript You Wished You Knew
The JavaScript You Wished You KnewThe JavaScript You Wished You Knew
The JavaScript You Wished You Knew
Troy Miles
 
Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1
Troy Miles
 
Build a Game in 60 minutes
Build a Game in 60 minutesBuild a Game in 60 minutes
Build a Game in 60 minutes
Troy Miles
 
Quick & Dirty & MEAN
Quick & Dirty & MEANQuick & Dirty & MEAN
Quick & Dirty & MEAN
Troy Miles
 
A Quick Intro to ReactiveX
A Quick Intro to ReactiveXA Quick Intro to ReactiveX
A Quick Intro to ReactiveX
Troy Miles
 
JavaScript Foundations Day1
JavaScript Foundations Day1JavaScript Foundations Day1
JavaScript Foundations Day1
Troy Miles
 
AngularJS Beginner Day One
AngularJS Beginner Day OneAngularJS Beginner Day One
AngularJS Beginner Day One
Troy Miles
 

More from Troy Miles (20)

Fast C++ Web Servers
Fast C++ Web ServersFast C++ Web Servers
Fast C++ Web Servers
 
Node Boot Camp
Node Boot CampNode Boot Camp
Node Boot Camp
 
AWS Lambda Function with Kotlin
AWS Lambda Function with KotlinAWS Lambda Function with Kotlin
AWS Lambda Function with Kotlin
 
React Native One Day
React Native One DayReact Native One Day
React Native One Day
 
React Native Evening
React Native EveningReact Native Evening
React Native Evening
 
Intro to React
Intro to ReactIntro to React
Intro to React
 
React Development with the MERN Stack
React Development with the MERN StackReact Development with the MERN Stack
React Development with the MERN Stack
 
Angular Application Testing
Angular Application TestingAngular Application Testing
Angular Application Testing
 
ReactJS.NET
ReactJS.NETReactJS.NET
ReactJS.NET
 
What is Angular version 4?
What is Angular version 4?What is Angular version 4?
What is Angular version 4?
 
Angular Weekend
Angular WeekendAngular Weekend
Angular Weekend
 
From MEAN to the MERN Stack
From MEAN to the MERN StackFrom MEAN to the MERN Stack
From MEAN to the MERN Stack
 
MEAN Stack Warm-up
MEAN Stack Warm-upMEAN Stack Warm-up
MEAN Stack Warm-up
 
The JavaScript You Wished You Knew
The JavaScript You Wished You KnewThe JavaScript You Wished You Knew
The JavaScript You Wished You Knew
 
Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1
 
Build a Game in 60 minutes
Build a Game in 60 minutesBuild a Game in 60 minutes
Build a Game in 60 minutes
 
Quick & Dirty & MEAN
Quick & Dirty & MEANQuick & Dirty & MEAN
Quick & Dirty & MEAN
 
A Quick Intro to ReactiveX
A Quick Intro to ReactiveXA Quick Intro to ReactiveX
A Quick Intro to ReactiveX
 
JavaScript Foundations Day1
JavaScript Foundations Day1JavaScript Foundations Day1
JavaScript Foundations Day1
 
AngularJS Beginner Day One
AngularJS Beginner Day OneAngularJS Beginner Day One
AngularJS Beginner Day One
 

Recently uploaded

Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
Tendenci - The Open Source AMS (Association Management Software)
 
RISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent EnterpriseRISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent Enterprise
Srikant77
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Jay Das
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 

Recently uploaded (20)

Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
RISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent EnterpriseRISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent Enterprise
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 

Functional Programming in Clojure

  • 1. SoCal Code Camp 12+13 November 2016 Functional Programming in Clojure
  • 2. Troy Miles • Troy Miles aka the RocknCoder • Over 37 years of programming experience • Speaker and author • Author of jQuery Essentials • bit.ly/rc-jquerybook • rockncoder@gmail.com • @therockncoder
  • 3. Build Mobile Apps! • Develop mobile apps with Ionic and AngularJS • Learn the Ionic CLI • Fetch data via ajax • Deploy your app to Android & iOS • bit.ly/ionicvideo
  • 5. Our Agenda • Clojure? • Lisp • The Java Virtual Machine • Leiningen • Functional Programming
  • 7. –Paul Graham “Lisp is worth learning for the profound enlightenment experience you will have when you finally get it; that experience will make you a better programmer for the rest of your days, even if you never actually use Lisp itself a lot.”
  • 8. What is Clojure? • A dynamic, general-purpose programming language • A Modern Lisp • Designed to be hosted • Functional, but practical
  • 9. Other Hosts for Clojure • ClojureScript - Compiles to JavaScript • Clojure CLR - Compiles to IL, for Microsoft’s CLR
  • 10. ClojureScript • Clojure + ClojureScript used together by 66% of the community • Om / Reagent - Interfaces for Facebook’s React Library • Mori - ClojureScript’s Immutable data structure for vanilla JavaScript
  • 11. Companies using Clojure • Walmart Labs • Puppet Labs • ThoughtWorks • Amazon • Facebook • Groupon • Intuit • Salesforce • Zendesk
  • 12. –Paul Graham “I suppose I should learn Lisp, but it seems so foreign.”
  • 13. Lisp? Lisp! • Created in 1958 by John McCarthy • Second oldest high-level language still in use today • Influenced by Alonzo Church’s lambda calculus • A family of languages including: Common Lisp, Scheme, Emacs Lisp
  • 14. Lisp Innovations • recursive function • dynamically allocated memory • garbage collection • lexical closures • macros
  • 15. The Java Virtual Machine • An abstract computing machine that allows a computer run a Java program • Type system • Garbage collection • Threads • Just-in-time compiler (JIT) • Favorite target of criminal hackers
  • 16. JVM Languages • Ceylon - Java competitor from Red Hat • Groovy - OOP langage • JRuby - Ruby on the JVM • Jython - Python on the JVM • Kotlin - Java competitor from JetBrains • Rhino/Nashorn - JavaScript engines • Scala - OOP / Functional language
  • 17. Build Tools • Apache Maven • Leiningen
  • 18. Leiningen • A tool for automating Clojure projects • Written in Clojure • Open source and maintained by a large community • A play on another famous build tool, Apache Ant
  • 19. Using Leiningen • Searches from repos • lein new app my-stuff
  • 20. Directory ├── CHANGELOG.md ├── LICENSE ├── README.md ├── doc │   └── intro.md ├── project.clj ├── resources ├── src │   └── my_app │   └── core.clj └── test └── my_app └── core_test.clj
  • 21. Editors / IDEs • Emacs - created in 1976 • Vim - created in 1991 • Eclipse + Counterclockwise - created in 2001 • Intellij IDEA + Cursive - created in 2001
  • 22. What is Functional Programming?
  • 23. Key Functional Features • Pure functions • First-class / High order functions • Immutable data • Recursion • Referential transparency
  • 24. Functional vs. Imperative what? functional imperative primary construct function class instance state change bad important order of execution not important important flow control function calls recursion loops, conditionals, method calls
  • 25. Sample Languages mostly functional mixed mostly imperative Lisp/Scheme JavaScript Java ML Scala C# Haskell Python C++ Clojure Dart Swift F# Lua Ruby Erlang R Kotlin
  • 26. Pure Functions • Must return a value • Must accept at least one argument • Can’t produce any side-effects • Must return the same output for a given input
  • 27. Pure Functions Are Super • Cacheable • Portable • Self-documenting • Testable • Reasonable
  • 28. First-Class Functions • Assigned to variables • Stored in arrays • Passed as arguments to other functions • Returned from functions
  • 29. Higher-Order Functions • Accept other functions as parameter • And/or return a function • Allows for the creation of function factories • This is the core of the curry function
  • 31. 1 (function () { 2 'use strict'; 3 const fizzBuzz = function () { 4 for (let i = 1; i <= 100; i += 1) { 5 let printVal = i + ' '; 6 if (i % 3 === 0) { 7 printVal += 'Fizz'; 8 } 9 if (i % 5 === 0) { 10 printVal += 'Buzz'; 11 } 12 console.info(printVal); 13 } 14 }; 15 fizzBuzz(); 16 }()); FizzBuzz in JavaScript
  • 32. FizzBuzz in Clojure 1 (defn fizzbuzz [start finish] 2 (map (fn [n] 3 (cond 4 (zero? (mod n 15)) "FizzBuzz" 5 (zero? (mod n 3)) "Fizz" 6 (zero? (mod n 5)) "Buzz" 7 :else n)) 8 (range start finish))) 9 10 (fizzbuzz 1 100)
  • 33. Links • Clojure - http://clojure.org/ • ClojureScript - http://clojurescript.org/ • ClojureCLR - http://clojure.org/about/clojureclr • Clojure Docs - http://clojure-doc.org/ • Try Clojure - http://www.tryclj.com/
  • 34. More Links • Om - https://github.com/omcljs/om • Reagent - https://reagent-project.github.io/ • Mori - https://github.com/swannodette/mori • Clojure/Android - https://github.com/clojure-android • Leiningen - http://leiningen.org/
  • 35. And Even More Links • SICP Online - http://web.mit.edu/alexmv/6.037/ sicp.pdf • Paul Graham - http://paulgraham.com/avg.html
  • 36. Summary • Clojure is functional language on the JVM • It is interoperable with Java • It has a Lisp syntax which is not
  • 37. –Edsger Dijkstra “Object-oriented programming is an exceptionally bad idea which could only have originated in California.”