SlideShare a Scribd company logo
ClojureScript in
Magento 2
/me
Freelance Developer & Consultant
Web Developer since 1997
Magento since 2008
ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
ClojureScript in Magento 2 - PHPUGMRN
Topic for today:
Frontend Development with
ClojureScript in Magento 2
ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
WTF?!
Why?
ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
Magento 2 has a "sophisticated" frontend architecture.
$ find vendor/magento/*/view/ -name '*.js' | xargs wc -l
.
.
.
43 vendor/magento/module-user/view//adminhtml/web/app-config.js
159 vendor/magento/module-weee/view//base/web/js/price/adjustment.js
240 vendor/magento/module-wishlist/view//frontend/web/js/wishlist.js
110823 total
ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
Don't fight the framework!
We need to GET STUFF DONE!!
ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
I don't want to fight.
But sometimes it feels like
the framework is fighting me.
ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
As an eCommerce developer,
I want to build sites with Magento,
without being frustrated
by tangled UI Components,
so I can deliver work on time.
ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
I would love to love all UI Components.
But it hasn't happened for me.
ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
How do I work with Magento and deliver on time?
Go "headless"?
ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
Consequences of going headless:
* Need to rebuild every feature.
* Incompatible with all extensions
   containing frontend functionality.
* Fun but f'ing expensive.
ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
I need to find a tool that allows me to
* Use Magento as much as possible.
* Selectively rebuild the parts
    that I do not want to work with.
* Make the choice on a case-by-case basis.
ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
Options:
* JavaScript
* TypeScript
* ScalaJS
* ClojureScript
* Elm
* PureScript
ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
What is ClojureScript?
ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
LISP
(List + Processor)
ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
Clojure
Hosted Language
  * JVM
  * JavaScript (Browser & Node)
  * CLR
(Clojure, ClojureScript, ClojureCLR)
ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
Clojure
Embraces the host runtime -> interop
ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
Clojure
One thing which seems important at first
turns out to be a non-issue:
Parenthesis
ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
PHP
print("Magento")
Clojure
(print "Magento")
ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
But JS haz Objects...!
ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
JavaScript
"Magento".toLowerCase()
// => "magento"
ClojureScript
(.toLowerCase "Magento")
;; => "magento"
ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
JS
console.log("debug");
ClojureScript
(.log js/console "debug")
;; alternative syntactic JS interop sugar
(js/console.log "debug")
ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
Core Data Structures
PHP JS Clojure
Array [1, 2, 3] [1, 2, 3] [1 2 3]
List [1, 2, 3] [1, 2, 3] (1 2 3)
Map ['foo' => 'bar'] {foo: 'bar'} {:foo "bar"}
Set new
DsSet([2,
42, 5)
new Set([2,
42, 5])
#{2 42 5}
ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
Why do we need different data structures?
ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
Language guaranteed characteristics
For example:
Vectors: indexed access O(1),
             cheap to grow at end
(def my-vec [4 5 6 2 12 42 33 4 5 1 5])
(get my-vec 5) => 42
Lists: indexed access O(n),
         cheap to grow at front
(def my-list (range 100))
(nth my-list 34) => 34
ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
CLJS in Magento
* In Magento module:
   compiled to view/frontend/web/js/
* In Magento base dir:
   compiled to pub/js/
* The <script src="..."> tag
   needs to precede requirejs
ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
Demo
ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
Clojure
* Quick feedback loop
* Lovely developer experience
ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
Clojure
* stable
* 10 years of growth
ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
Clojure
* More Clojure devs than Clojure jobs
ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
So many good ideas in ClojureScript...
I want talk about all of them!
That would take days...
But I can't just leave them out!
ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
Wow, much good, such benefits!
- Immutability by default
- Large consistent core library
- Google Closure Compiler Inlining and Dead Code Elimination
- Dead Code Elimination also for external node modules
- Closure Spec
- Great concurrency story
- React Native
- GCC module splitting and cross module code motion
- Direct access to the giant JavaScript and Java library ecosystem
- Great testing story
- Modern frontend architecture
- Podcasts, YouTube Channels, International Conferences
- User groups and workshops
- Very cool people and projects to be inspired by
- And much more...
ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
Want to dig in?
Clojure for the Brave and True
ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
Thank you!
Questions,
Thoughts,
Ideas?
Demo Source: https://github.com/Vinai/magento-cljs-giftlist
ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22

More Related Content

PDF
Writing Testable Code (for Magento 1 and 2) 2016 Romaina
PDF
Getting your hands dirty testing Magento 2 (at MageTitansIT)
PDF
Magento 2: New and Innovative? - php[world] 2015
PDF
Last Month in PHP - May 2018
PDF
Writing Testable Code (for Magento 1 and 2)
PDF
The journey of mastering Magento 2 for Magento 1 developers
PPTX
Magento 2 development
PDF
TangoWebapp insights
Writing Testable Code (for Magento 1 and 2) 2016 Romaina
Getting your hands dirty testing Magento 2 (at MageTitansIT)
Magento 2: New and Innovative? - php[world] 2015
Last Month in PHP - May 2018
Writing Testable Code (for Magento 1 and 2)
The journey of mastering Magento 2 for Magento 1 developers
Magento 2 development
TangoWebapp insights

Similar to ClojureScript in Magento 2 - PHPUGMRN (20)

PPTX
GraphQL in Magento 2
PDF
Testing with Codeception
PDF
How to create a Vue Storefront theme
PDF
Gerrit Analytics applied to Android source code
PPT
Palestra "Ionic Framework 2 - O que vem por aí?" TDC 2016
PDF
Fundamentals of Extending Magento 2 - php[world] 2015
PDF
Angular 2 : learn TypeScript already with Angular 1
PDF
Elastic network of things with mqtt and micro python
PPTX
Grails & Angular: unleashing the dynamic duo
PDF
Angular 2 : le réveil de la force
PDF
Becoming Certified - MageTitansMCR 2018
PDF
Magento 2 TDD Code Kata Intro
PDF
Front End Development for Back End Developers - UberConf 2017
PPTX
MidwestPHP - Getting Started with Magento 2
PDF
Sprint 127
PPTX
#2 Hanoi Magento Meetup - Part 2: Knockout JS
PDF
markedj: The best of markdown processor on JVM
PDF
Magento Commerce Global contribution day 2020
PDF
2018 September - The Month in PHP
PDF
Testing Magento 2
GraphQL in Magento 2
Testing with Codeception
How to create a Vue Storefront theme
Gerrit Analytics applied to Android source code
Palestra "Ionic Framework 2 - O que vem por aí?" TDC 2016
Fundamentals of Extending Magento 2 - php[world] 2015
Angular 2 : learn TypeScript already with Angular 1
Elastic network of things with mqtt and micro python
Grails & Angular: unleashing the dynamic duo
Angular 2 : le réveil de la force
Becoming Certified - MageTitansMCR 2018
Magento 2 TDD Code Kata Intro
Front End Development for Back End Developers - UberConf 2017
MidwestPHP - Getting Started with Magento 2
Sprint 127
#2 Hanoi Magento Meetup - Part 2: Knockout JS
markedj: The best of markdown processor on JVM
Magento Commerce Global contribution day 2020
2018 September - The Month in PHP
Testing Magento 2
Ad

More from vinaikopp (15)

PPTX
Building Mage-OS - MageTitans 2023
PDF
Hyvä: Compatibility Modules
PDF
Hyvä from a developer perspective
PDF
Property Based Testing in PHP
PDF
Property based testing - MageTestFest 2019
PDF
SOS UiComponents
PDF
Magento 2 TDD Code Kata
PDF
ClojureScript in Magento 2 - MageTitansMCR 2017
PDF
Lizards & Pumpkins Catalog Replacement at mm17de
PDF
Stories from the other side
PDF
Writing testable Code (MageTitans Mini 2016)
PDF
Getting your Hands Dirty Testing Magento 2 (at London Meetup)
PDF
Architecture in-the-small-slides
PPT
Modern Module Architecture
PPT
The beautiful Magento module - MageTitans 2014
Building Mage-OS - MageTitans 2023
Hyvä: Compatibility Modules
Hyvä from a developer perspective
Property Based Testing in PHP
Property based testing - MageTestFest 2019
SOS UiComponents
Magento 2 TDD Code Kata
ClojureScript in Magento 2 - MageTitansMCR 2017
Lizards & Pumpkins Catalog Replacement at mm17de
Stories from the other side
Writing testable Code (MageTitans Mini 2016)
Getting your Hands Dirty Testing Magento 2 (at London Meetup)
Architecture in-the-small-slides
Modern Module Architecture
The beautiful Magento module - MageTitans 2014
Ad

Recently uploaded (20)

PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PPTX
L1 - Introduction to python Backend.pptx
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
PTS Company Brochure 2025 (1).pdf.......
PPTX
Introduction to Artificial Intelligence
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
medical staffing services at VALiNTRY
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
System and Network Administraation Chapter 3
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPT
Introduction Database Management System for Course Database
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Digital Strategies for Manufacturing Companies
PDF
Softaken Excel to vCard Converter Software.pdf
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
L1 - Introduction to python Backend.pptx
wealthsignaloriginal-com-DS-text-... (1).pdf
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PTS Company Brochure 2025 (1).pdf.......
Introduction to Artificial Intelligence
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
medical staffing services at VALiNTRY
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Upgrade and Innovation Strategies for SAP ERP Customers
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
System and Network Administraation Chapter 3
Design an Analysis of Algorithms II-SECS-1021-03
Introduction Database Management System for Course Database
Internet Downloader Manager (IDM) Crack 6.42 Build 41
VVF-Customer-Presentation2025-Ver1.9.pptx
Which alternative to Crystal Reports is best for small or large businesses.pdf
How to Migrate SBCGlobal Email to Yahoo Easily
Digital Strategies for Manufacturing Companies
Softaken Excel to vCard Converter Software.pdf

ClojureScript in Magento 2 - PHPUGMRN

  • 2. /me Freelance Developer & Consultant Web Developer since 1997 Magento since 2008 ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
  • 4. Topic for today: Frontend Development with ClojureScript in Magento 2 ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
  • 5. WTF?! Why? ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
  • 6. Magento 2 has a "sophisticated" frontend architecture. $ find vendor/magento/*/view/ -name '*.js' | xargs wc -l . . . 43 vendor/magento/module-user/view//adminhtml/web/app-config.js 159 vendor/magento/module-weee/view//base/web/js/price/adjustment.js 240 vendor/magento/module-wishlist/view//frontend/web/js/wishlist.js 110823 total ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
  • 7. Don't fight the framework! We need to GET STUFF DONE!! ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
  • 8. I don't want to fight. But sometimes it feels like the framework is fighting me. ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
  • 9. As an eCommerce developer, I want to build sites with Magento, without being frustrated by tangled UI Components, so I can deliver work on time. ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
  • 10. I would love to love all UI Components. But it hasn't happened for me. ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
  • 11. How do I work with Magento and deliver on time? Go "headless"? ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
  • 12. Consequences of going headless: * Need to rebuild every feature. * Incompatible with all extensions    containing frontend functionality. * Fun but f'ing expensive. ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
  • 13. I need to find a tool that allows me to * Use Magento as much as possible. * Selectively rebuild the parts     that I do not want to work with. * Make the choice on a case-by-case basis. ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
  • 14. Options: * JavaScript * TypeScript * ScalaJS * ClojureScript * Elm * PureScript ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
  • 15. What is ClojureScript? ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
  • 16. LISP (List + Processor) ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
  • 17. Clojure Hosted Language   * JVM   * JavaScript (Browser & Node)   * CLR (Clojure, ClojureScript, ClojureCLR) ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
  • 18. Clojure Embraces the host runtime -> interop ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
  • 19. Clojure One thing which seems important at first turns out to be a non-issue: Parenthesis ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
  • 20. PHP print("Magento") Clojure (print "Magento") ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
  • 21. But JS haz Objects...! ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
  • 22. JavaScript "Magento".toLowerCase() // => "magento" ClojureScript (.toLowerCase "Magento") ;; => "magento" ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
  • 23. JS console.log("debug"); ClojureScript (.log js/console "debug") ;; alternative syntactic JS interop sugar (js/console.log "debug") ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
  • 24. Core Data Structures PHP JS Clojure Array [1, 2, 3] [1, 2, 3] [1 2 3] List [1, 2, 3] [1, 2, 3] (1 2 3) Map ['foo' => 'bar'] {foo: 'bar'} {:foo "bar"} Set new DsSet([2, 42, 5) new Set([2, 42, 5]) #{2 42 5} ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
  • 25. Why do we need different data structures? ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
  • 26. Language guaranteed characteristics For example: Vectors: indexed access O(1),              cheap to grow at end (def my-vec [4 5 6 2 12 42 33 4 5 1 5]) (get my-vec 5) => 42 Lists: indexed access O(n),          cheap to grow at front (def my-list (range 100)) (nth my-list 34) => 34 ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
  • 27. CLJS in Magento * In Magento module:    compiled to view/frontend/web/js/ * In Magento base dir:    compiled to pub/js/ * The <script src="..."> tag    needs to precede requirejs ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
  • 28. Demo ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
  • 29. Clojure * Quick feedback loop * Lovely developer experience ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
  • 30. Clojure * stable * 10 years of growth ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
  • 31. Clojure * More Clojure devs than Clojure jobs ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
  • 32. So many good ideas in ClojureScript... I want talk about all of them! That would take days... But I can't just leave them out! ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
  • 33. Wow, much good, such benefits! - Immutability by default - Large consistent core library - Google Closure Compiler Inlining and Dead Code Elimination - Dead Code Elimination also for external node modules - Closure Spec - Great concurrency story - React Native - GCC module splitting and cross module code motion - Direct access to the giant JavaScript and Java library ecosystem - Great testing story - Modern frontend architecture - Podcasts, YouTube Channels, International Conferences - User groups and workshops - Very cool people and projects to be inspired by - And much more... ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
  • 34. Want to dig in? Clojure for the Brave and True ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22
  • 35. Thank you! Questions, Thoughts, Ideas? Demo Source: https://github.com/Vinai/magento-cljs-giftlist ClojureScript in Magento 2 - (c) @VinaiKopp - #PHPUGMRN - 2018-02-22