SlideShare a Scribd company logo
1 of 61
Download to read offline
Clojure / Scala
Diego Pacheco
Clojure
❏ 2007
❏ Rich Hickey
❏ JVM based but also CLR and JavaScript
❏ Functional dialect of Lisp
❏ Immutability & Immutable Data Structures
❏ Great interoperability with Java
❏ But -> Slow and Hard to troubleshoot.
Who is using Clojure?
https://clojure.org/community/companies
“Function as Data, Data as
functions” -- RH.
You don't need classes: Just Functions and Data!
Lisp
Lisp
Getting started with lien (Clojure build system)
❏ Clojure Build System
❏ Compatible with Maven Repos
❏ Super Easy to use https://leiningen.org/
Hello World on lein REPL
From a File (*.clj)
From a File (*.clj)
From a File (*.clj)
Basics
❏ Lists ()
❏ Vectors []
❏ Assign with Let
❏ “Strings”
❏ seq
❏ if
Functions
reduce
reduce
map
map
filter
filter
every?
Pipeline Operator (->>)
Sets
❏ Like Math Sets
❏ Unsorted
❏ NO Duplicates
❏ Efficient:
❏ Checking
❏ Removal
❏ (sorted-set)
SortedSets
Maps
❏ Also known as
❏ Dictionaries
❏ Hash Maps
❏ Assoc k/v pairs
❏ Domain data
❏ (sorted-map)
Working with “Pojos” == Maps.
❏ What can you do with a
Pojo in OOP? Nothing.
❏ In clojure? A lot !!!
❏ Remember “Alan Perlis”
❏ No need to define “schema”
❏ Productivity
❏ Simplicity
defrecord here is our class be happy :-)
https://github.com/clojure/core.match
Clojure also has Pattern Matcher
Web Development ... Compojure & Ring
$ lein new compojure hello-world
$ cd hello-world
$ lein run server-headless
Open your browser on http://localhost:3000/
handler.clj
https://clojuredocs.org/
Exercises
1. Write a function which returns the last element in a sequence without using *last*.
Test data: (A) [10 20 30 40 50] (B) '(10 8 1) (C) ["x" "y" "z"]
2. Write a function which sum of a sequence of numbers without using *reduce*.
Test data: (A) [1 2 3 4 5 6] (B) '(0 0 -1 1 2 3) (C) #{40 50 25 15 10}
3. Write a REST service with clojure, all persistence needs to be done in memory using maps or records.
You will need to create an BANK application with: deposit, withdrawal, check balance, transfer
money into other accounts. You will need do proper validations and also unit tests. Your application
need to use lein and compojure there are no other frameworks/libs allowed.
You cannot use: for, if and let.
Scala
❏ 2004
❏ Functional Programing Language
❏ Based on Haskell
❏ Runs on the JVM also JavaScript
❏ Statically typed
❏ Better Java
❏ Awesome for Big Data / ML
❏ Created by Martin Odersky
SBT
❏ Build System for Scala
❏ IF you are working with scala you also
could do:
❏ Maven
❏ Gradle
❏ In practice SBT is the right choice.
Helloworld Scala + SBT
Helloworld Scala + SBT
SBT has a REPL too ($ sbt console)
Functions
❏ Functions
❏ Lambdas
❏ Are all Objects
❏ Since
implementation in
java (JVM).
Partial Application
❏ Partial
❏ Lazy
❏ Composition
❏ Re-use
Partial Application via Currying
❏ Partial
❏ Lazy
❏ Composition
❏ Re-use
Variable lengths arguments or in java terms varargs.
❏ *
❏ Dynamic
❏ Generic
❏ Similar to
java
OOP in Scala: Class
❏ Scala support OOP
❏ Here is the better
java part starts
❏ Simple
❏ Clean
❏ Less Verbose
OOP in Scala: Class Constructor + String Interpolation
OOP in Scala: Inheritance
❏ Class Hierarchy
❏ Polymorphism
OOP in Scala: Polymorphism Overriding
❏ Class Hierarchy
❏ Polymorphism
❏ Overriding
OOP in Scala: Traits
❏ Similar to Java Interfaces
❏ However you can have code
❏ Fundamental part of type
system (“Algebra”)
❏ One of best things in Scala
❏ Be Careful it can get crazy :D
❏ Stay practical stay clean!
OOP in Scala: Generics + Types
❏ Generics
❏ Types
❏ Abstractions
❏ Leverage
Compiler
❏ Haskell way
Apply
❏ Apply
❏ Code runs
❏ Default in Scala
❏ Like toString
In Java but better
❏ Super useful
OOP in Scala: Objects
❏ Different then Java Objects
❏ Objects are single instance
❏ It's how you do Singletons in Scala
❏ Great for org static functions
❏ Often classes have companion Objects
in Scala.
❏ Functions in Scala are Objects.
Pattern Matcher
❏ One of the best features
In Scala Language.
❏ Support ifs
❏ Support “_”
❏ Support type matching
❏ Better than Switch
Pattern Matcher
Case classes
❏ One of the best features
In Scala Language.
❏ Super charged Classes
❏ Equality & toString
Support
❏ Work on Pattern
Matcher
❏ Super clean syntax
Collections
❏ Like in Java
❏ But much better
❏ Immutable
❏ Mutable
❏ Tupes
❏ Sets, Arrays, Lists,
❏ Maps vs Map
map, filter, foldLeft
❏ Functional
Combinators
❏ Core FP prog
❏ Super useful
❏ Day by Day work
Exercises
1. Write a function which finds the last element in a List without using *last*.
Test data: (A) List(1,2,3,4,5,6,7,8) (B) List(“1”,”2”,”3”) (C) List(1.0,2.0,3.0)
2. Write a function which Flatten a nested list structure.
Test data: (A) flatten(List(List(1, 1), 2, List(3, List(5, 8)))) (B) (List(), 2, List(3,4))
3. Write a REST service with Scala, all persistence needs to be done in memory using maps or records.
You will need to create an BANK application with: deposit, withdrawal, check balance, transfer
money into other accounts. You will need do proper validations and also unit tests. Your application
need to use lein and compojure there are no other frameworks/libs allowed.
You cannot use: for, if and let.
Clojure / Scala
Diego Pacheco

More Related Content

What's hot

Event Pipe - Lambda Architecture
Event Pipe - Lambda ArchitectureEvent Pipe - Lambda Architecture
Event Pipe - Lambda ArchitectureBahadir Cambel
 
ELK Wrestling (Leeds DevOps)
ELK Wrestling (Leeds DevOps)ELK Wrestling (Leeds DevOps)
ELK Wrestling (Leeds DevOps)Steve Elliott
 
PSUG #52 Dataflow and simplified reactive programming with Akka-streams
PSUG #52 Dataflow and simplified reactive programming with Akka-streamsPSUG #52 Dataflow and simplified reactive programming with Akka-streams
PSUG #52 Dataflow and simplified reactive programming with Akka-streamsStephane Manciot
 
Scala.js: Next generation front end development in Scala
Scala.js:  Next generation front end development in ScalaScala.js:  Next generation front end development in Scala
Scala.js: Next generation front end development in ScalaOtto Chrons
 
My Gentle Introduction to RxJS
My Gentle Introduction to RxJSMy Gentle Introduction to RxJS
My Gentle Introduction to RxJSMattia Occhiuto
 
Logstash + Elasticsearch + Kibana Presentation on Startit Tech Meetup
Logstash + Elasticsearch + Kibana Presentation on Startit Tech MeetupLogstash + Elasticsearch + Kibana Presentation on Startit Tech Meetup
Logstash + Elasticsearch + Kibana Presentation on Startit Tech MeetupStartit
 
«Большие объёмы данных и сборка мусора в Java
«Большие объёмы данных и сборка мусора в Java«Большие объёмы данных и сборка мусора в Java
«Большие объёмы данных и сборка мусора в JavaOlga Lavrentieva
 
Intro to RxJava/RxAndroid - GDG Munich Android
Intro to RxJava/RxAndroid - GDG Munich AndroidIntro to RxJava/RxAndroid - GDG Munich Android
Intro to RxJava/RxAndroid - GDG Munich AndroidEgor Andreevich
 
Interactive learning analytics dashboards with ELK (Elasticsearch Logstash Ki...
Interactive learning analytics dashboards with ELK (Elasticsearch Logstash Ki...Interactive learning analytics dashboards with ELK (Elasticsearch Logstash Ki...
Interactive learning analytics dashboards with ELK (Elasticsearch Logstash Ki...Andrii Vozniuk
 
Airbnb Search Architecture: Presented by Maxim Charkov, Airbnb
Airbnb Search Architecture: Presented by Maxim Charkov, AirbnbAirbnb Search Architecture: Presented by Maxim Charkov, Airbnb
Airbnb Search Architecture: Presented by Maxim Charkov, AirbnbLucidworks
 
mongodb-aggregation-may-2012
mongodb-aggregation-may-2012mongodb-aggregation-may-2012
mongodb-aggregation-may-2012Chris Westin
 
Distributed Real-Time Stream Processing: Why and How 2.0
Distributed Real-Time Stream Processing:  Why and How 2.0Distributed Real-Time Stream Processing:  Why and How 2.0
Distributed Real-Time Stream Processing: Why and How 2.0Petr Zapletal
 
Logging for OpenStack - Elasticsearch, Fluentd, Logstash, Kibana
Logging for OpenStack - Elasticsearch, Fluentd, Logstash, KibanaLogging for OpenStack - Elasticsearch, Fluentd, Logstash, Kibana
Logging for OpenStack - Elasticsearch, Fluentd, Logstash, KibanaMd Safiyat Reza
 
Logs aggregation and analysis
Logs aggregation and analysisLogs aggregation and analysis
Logs aggregation and analysisDivante
 
Project kepler compile time metaprogramming for scala
Project kepler compile time metaprogramming for scalaProject kepler compile time metaprogramming for scala
Project kepler compile time metaprogramming for scalaSkills Matter Talks
 
Experiences in ELK with D3.js for Large Log Analysis and Visualization
Experiences in ELK with D3.js  for Large Log Analysis  and VisualizationExperiences in ELK with D3.js  for Large Log Analysis  and Visualization
Experiences in ELK with D3.js for Large Log Analysis and VisualizationSurasak Sanguanpong
 
How to start using Scala
How to start using ScalaHow to start using Scala
How to start using ScalaNgoc Dao
 
A dive into akka streams: from the basics to a real-world scenario
A dive into akka streams: from the basics to a real-world scenarioA dive into akka streams: from the basics to a real-world scenario
A dive into akka streams: from the basics to a real-world scenarioGioia Ballin
 

What's hot (20)

Event Pipe - Lambda Architecture
Event Pipe - Lambda ArchitectureEvent Pipe - Lambda Architecture
Event Pipe - Lambda Architecture
 
ELK Wrestling (Leeds DevOps)
ELK Wrestling (Leeds DevOps)ELK Wrestling (Leeds DevOps)
ELK Wrestling (Leeds DevOps)
 
RxJava in practice
RxJava in practice RxJava in practice
RxJava in practice
 
PSUG #52 Dataflow and simplified reactive programming with Akka-streams
PSUG #52 Dataflow and simplified reactive programming with Akka-streamsPSUG #52 Dataflow and simplified reactive programming with Akka-streams
PSUG #52 Dataflow and simplified reactive programming with Akka-streams
 
Scala.js: Next generation front end development in Scala
Scala.js:  Next generation front end development in ScalaScala.js:  Next generation front end development in Scala
Scala.js: Next generation front end development in Scala
 
My Gentle Introduction to RxJS
My Gentle Introduction to RxJSMy Gentle Introduction to RxJS
My Gentle Introduction to RxJS
 
Logstash + Elasticsearch + Kibana Presentation on Startit Tech Meetup
Logstash + Elasticsearch + Kibana Presentation on Startit Tech MeetupLogstash + Elasticsearch + Kibana Presentation on Startit Tech Meetup
Logstash + Elasticsearch + Kibana Presentation on Startit Tech Meetup
 
«Большие объёмы данных и сборка мусора в Java
«Большие объёмы данных и сборка мусора в Java«Большие объёмы данных и сборка мусора в Java
«Большие объёмы данных и сборка мусора в Java
 
Intro to RxJava/RxAndroid - GDG Munich Android
Intro to RxJava/RxAndroid - GDG Munich AndroidIntro to RxJava/RxAndroid - GDG Munich Android
Intro to RxJava/RxAndroid - GDG Munich Android
 
Interactive learning analytics dashboards with ELK (Elasticsearch Logstash Ki...
Interactive learning analytics dashboards with ELK (Elasticsearch Logstash Ki...Interactive learning analytics dashboards with ELK (Elasticsearch Logstash Ki...
Interactive learning analytics dashboards with ELK (Elasticsearch Logstash Ki...
 
Airbnb Search Architecture: Presented by Maxim Charkov, Airbnb
Airbnb Search Architecture: Presented by Maxim Charkov, AirbnbAirbnb Search Architecture: Presented by Maxim Charkov, Airbnb
Airbnb Search Architecture: Presented by Maxim Charkov, Airbnb
 
mongodb-aggregation-may-2012
mongodb-aggregation-may-2012mongodb-aggregation-may-2012
mongodb-aggregation-may-2012
 
Distributed Real-Time Stream Processing: Why and How 2.0
Distributed Real-Time Stream Processing:  Why and How 2.0Distributed Real-Time Stream Processing:  Why and How 2.0
Distributed Real-Time Stream Processing: Why and How 2.0
 
Logging for OpenStack - Elasticsearch, Fluentd, Logstash, Kibana
Logging for OpenStack - Elasticsearch, Fluentd, Logstash, KibanaLogging for OpenStack - Elasticsearch, Fluentd, Logstash, Kibana
Logging for OpenStack - Elasticsearch, Fluentd, Logstash, Kibana
 
Logs aggregation and analysis
Logs aggregation and analysisLogs aggregation and analysis
Logs aggregation and analysis
 
Project kepler compile time metaprogramming for scala
Project kepler compile time metaprogramming for scalaProject kepler compile time metaprogramming for scala
Project kepler compile time metaprogramming for scala
 
Experiences in ELK with D3.js for Large Log Analysis and Visualization
Experiences in ELK with D3.js  for Large Log Analysis  and VisualizationExperiences in ELK with D3.js  for Large Log Analysis  and Visualization
Experiences in ELK with D3.js for Large Log Analysis and Visualization
 
How to start using Scala
How to start using ScalaHow to start using Scala
How to start using Scala
 
ELK Stack
ELK StackELK Stack
ELK Stack
 
A dive into akka streams: from the basics to a real-world scenario
A dive into akka streams: from the basics to a real-world scenarioA dive into akka streams: from the basics to a real-world scenario
A dive into akka streams: from the basics to a real-world scenario
 

Similar to Clojure & Scala

Introduction to Scala language
Introduction to Scala languageIntroduction to Scala language
Introduction to Scala languageAaqib Pervaiz
 
Building Asynchronous Applications
Building Asynchronous ApplicationsBuilding Asynchronous Applications
Building Asynchronous ApplicationsJohan Edstrom
 
CrateDB - Giacomo Ceribelli
CrateDB - Giacomo CeribelliCrateDB - Giacomo Ceribelli
CrateDB - Giacomo Ceribelliceribbo
 
It's Time To Stop Using Lambda Architecture
It's Time To Stop Using Lambda ArchitectureIt's Time To Stop Using Lambda Architecture
It's Time To Stop Using Lambda ArchitectureYaroslav Tkachenko
 
Building Distributed Systems in Scala
Building Distributed Systems in ScalaBuilding Distributed Systems in Scala
Building Distributed Systems in ScalaAlex Payne
 
Scala Days San Francisco
Scala Days San FranciscoScala Days San Francisco
Scala Days San FranciscoMartin Odersky
 
Scala adoption by enterprises
Scala adoption by enterprisesScala adoption by enterprises
Scala adoption by enterprisesMike Slinn
 
Best practices in Java
Best practices in JavaBest practices in Java
Best practices in JavaMudit Gupta
 
JavaScript Coding Guidelines
JavaScript Coding GuidelinesJavaScript Coding Guidelines
JavaScript Coding GuidelinesOleksii Prohonnyi
 
Scala final ppt vinay
Scala final ppt vinayScala final ppt vinay
Scala final ppt vinayViplav Jain
 
Develop realtime web with Scala and Xitrum
Develop realtime web with Scala and XitrumDevelop realtime web with Scala and Xitrum
Develop realtime web with Scala and XitrumNgoc Dao
 
The Why and How of Scala at Twitter
The Why and How of Scala at TwitterThe Why and How of Scala at Twitter
The Why and How of Scala at TwitterAlex Payne
 
Clojure for Java developers
Clojure for Java developersClojure for Java developers
Clojure for Java developersJohn Stevenson
 
Martin Odersky - Evolution of Scala
Martin Odersky - Evolution of ScalaMartin Odersky - Evolution of Scala
Martin Odersky - Evolution of ScalaScala Italy
 
It's Time To Stop Using Lambda Architecture | Yaroslav Tkachenko, Shopify
It's Time To Stop Using Lambda Architecture | Yaroslav Tkachenko, ShopifyIt's Time To Stop Using Lambda Architecture | Yaroslav Tkachenko, Shopify
It's Time To Stop Using Lambda Architecture | Yaroslav Tkachenko, ShopifyHostedbyConfluent
 
Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011Agora Group
 
Java Hands-On Workshop
Java Hands-On WorkshopJava Hands-On Workshop
Java Hands-On WorkshopArpit Poladia
 

Similar to Clojure & Scala (20)

Introduction to Scala language
Introduction to Scala languageIntroduction to Scala language
Introduction to Scala language
 
Building Asynchronous Applications
Building Asynchronous ApplicationsBuilding Asynchronous Applications
Building Asynchronous Applications
 
CrateDB - Giacomo Ceribelli
CrateDB - Giacomo CeribelliCrateDB - Giacomo Ceribelli
CrateDB - Giacomo Ceribelli
 
It's Time To Stop Using Lambda Architecture
It's Time To Stop Using Lambda ArchitectureIt's Time To Stop Using Lambda Architecture
It's Time To Stop Using Lambda Architecture
 
Building Distributed Systems in Scala
Building Distributed Systems in ScalaBuilding Distributed Systems in Scala
Building Distributed Systems in Scala
 
Scala Days San Francisco
Scala Days San FranciscoScala Days San Francisco
Scala Days San Francisco
 
Scala adoption by enterprises
Scala adoption by enterprisesScala adoption by enterprises
Scala adoption by enterprises
 
Best practices in Java
Best practices in JavaBest practices in Java
Best practices in Java
 
JavaScript Coding Guidelines
JavaScript Coding GuidelinesJavaScript Coding Guidelines
JavaScript Coding Guidelines
 
Scala final ppt vinay
Scala final ppt vinayScala final ppt vinay
Scala final ppt vinay
 
Scala-Ls1
Scala-Ls1Scala-Ls1
Scala-Ls1
 
Develop realtime web with Scala and Xitrum
Develop realtime web with Scala and XitrumDevelop realtime web with Scala and Xitrum
Develop realtime web with Scala and Xitrum
 
The Why and How of Scala at Twitter
The Why and How of Scala at TwitterThe Why and How of Scala at Twitter
The Why and How of Scala at Twitter
 
Clojure for Java developers
Clojure for Java developersClojure for Java developers
Clojure for Java developers
 
ES & Kafka
ES & KafkaES & Kafka
ES & Kafka
 
Martin Odersky - Evolution of Scala
Martin Odersky - Evolution of ScalaMartin Odersky - Evolution of Scala
Martin Odersky - Evolution of Scala
 
It's Time To Stop Using Lambda Architecture | Yaroslav Tkachenko, Shopify
It's Time To Stop Using Lambda Architecture | Yaroslav Tkachenko, ShopifyIt's Time To Stop Using Lambda Architecture | Yaroslav Tkachenko, Shopify
It's Time To Stop Using Lambda Architecture | Yaroslav Tkachenko, Shopify
 
Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011
 
Java 9
Java 9Java 9
Java 9
 
Java Hands-On Workshop
Java Hands-On WorkshopJava Hands-On Workshop
Java Hands-On Workshop
 

More from Diego Pacheco

Naming Things Book : Simple Book Review!
Naming Things Book : Simple Book Review!Naming Things Book : Simple Book Review!
Naming Things Book : Simple Book Review!Diego Pacheco
 
Continuous Discovery Habits Book Review.pdf
Continuous Discovery Habits  Book Review.pdfContinuous Discovery Habits  Book Review.pdf
Continuous Discovery Habits Book Review.pdfDiego Pacheco
 
Thoughts about Shape Up
Thoughts about Shape UpThoughts about Shape Up
Thoughts about Shape UpDiego Pacheco
 
Encryption Deep Dive
Encryption Deep DiveEncryption Deep Dive
Encryption Deep DiveDiego Pacheco
 
Management: Doing the non-obvious! III
Management: Doing the non-obvious! IIIManagement: Doing the non-obvious! III
Management: Doing the non-obvious! IIIDiego Pacheco
 
Design is not Subjective
Design is not SubjectiveDesign is not Subjective
Design is not SubjectiveDiego Pacheco
 
Architecture & Engineering : Doing the non-obvious!
Architecture & Engineering :  Doing the non-obvious!Architecture & Engineering :  Doing the non-obvious!
Architecture & Engineering : Doing the non-obvious!Diego Pacheco
 
Management doing the non-obvious II
Management doing the non-obvious II Management doing the non-obvious II
Management doing the non-obvious II Diego Pacheco
 
Testing in production
Testing in productionTesting in production
Testing in productionDiego Pacheco
 
Nine lies about work
Nine lies about workNine lies about work
Nine lies about workDiego Pacheco
 
Management: doing the nonobvious!
Management: doing the nonobvious!Management: doing the nonobvious!
Management: doing the nonobvious!Diego Pacheco
 
Dealing with dependencies
Dealing  with dependenciesDealing  with dependencies
Dealing with dependenciesDiego Pacheco
 
Dealing with dependencies in tests
Dealing  with dependencies in testsDealing  with dependencies in tests
Dealing with dependencies in testsDiego Pacheco
 

More from Diego Pacheco (20)

Naming Things Book : Simple Book Review!
Naming Things Book : Simple Book Review!Naming Things Book : Simple Book Review!
Naming Things Book : Simple Book Review!
 
Continuous Discovery Habits Book Review.pdf
Continuous Discovery Habits  Book Review.pdfContinuous Discovery Habits  Book Review.pdf
Continuous Discovery Habits Book Review.pdf
 
Thoughts about Shape Up
Thoughts about Shape UpThoughts about Shape Up
Thoughts about Shape Up
 
Holacracy
HolacracyHolacracy
Holacracy
 
AWS IAM
AWS IAMAWS IAM
AWS IAM
 
CDKs
CDKsCDKs
CDKs
 
Encryption Deep Dive
Encryption Deep DiveEncryption Deep Dive
Encryption Deep Dive
 
Sec 101
Sec 101Sec 101
Sec 101
 
Reflections on SCM
Reflections on SCMReflections on SCM
Reflections on SCM
 
Management: Doing the non-obvious! III
Management: Doing the non-obvious! IIIManagement: Doing the non-obvious! III
Management: Doing the non-obvious! III
 
Design is not Subjective
Design is not SubjectiveDesign is not Subjective
Design is not Subjective
 
Architecture & Engineering : Doing the non-obvious!
Architecture & Engineering :  Doing the non-obvious!Architecture & Engineering :  Doing the non-obvious!
Architecture & Engineering : Doing the non-obvious!
 
Management doing the non-obvious II
Management doing the non-obvious II Management doing the non-obvious II
Management doing the non-obvious II
 
Testing in production
Testing in productionTesting in production
Testing in production
 
Nine lies about work
Nine lies about workNine lies about work
Nine lies about work
 
Management: doing the nonobvious!
Management: doing the nonobvious!Management: doing the nonobvious!
Management: doing the nonobvious!
 
AI and the Future
AI and the FutureAI and the Future
AI and the Future
 
Dealing with dependencies
Dealing  with dependenciesDealing  with dependencies
Dealing with dependencies
 
Dealing with dependencies in tests
Dealing  with dependencies in testsDealing  with dependencies in tests
Dealing with dependencies in tests
 
Kanban 2020
Kanban 2020Kanban 2020
Kanban 2020
 

Recently uploaded

WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 

Clojure & Scala

  • 2.
  • 3. Clojure ❏ 2007 ❏ Rich Hickey ❏ JVM based but also CLR and JavaScript ❏ Functional dialect of Lisp ❏ Immutability & Immutable Data Structures ❏ Great interoperability with Java ❏ But -> Slow and Hard to troubleshoot.
  • 4. Who is using Clojure? https://clojure.org/community/companies
  • 5.
  • 6.
  • 7. “Function as Data, Data as functions” -- RH. You don't need classes: Just Functions and Data!
  • 8.
  • 10. Lisp
  • 11.
  • 12. Getting started with lien (Clojure build system) ❏ Clojure Build System ❏ Compatible with Maven Repos ❏ Super Easy to use https://leiningen.org/
  • 13. Hello World on lein REPL
  • 14. From a File (*.clj)
  • 15. From a File (*.clj)
  • 16. From a File (*.clj)
  • 17. Basics ❏ Lists () ❏ Vectors [] ❏ Assign with Let ❏ “Strings” ❏ seq ❏ if
  • 21. map
  • 22. map
  • 27. Sets ❏ Like Math Sets ❏ Unsorted ❏ NO Duplicates ❏ Efficient: ❏ Checking ❏ Removal ❏ (sorted-set)
  • 29. Maps ❏ Also known as ❏ Dictionaries ❏ Hash Maps ❏ Assoc k/v pairs ❏ Domain data ❏ (sorted-map)
  • 30. Working with “Pojos” == Maps. ❏ What can you do with a Pojo in OOP? Nothing. ❏ In clojure? A lot !!! ❏ Remember “Alan Perlis” ❏ No need to define “schema” ❏ Productivity ❏ Simplicity
  • 31. defrecord here is our class be happy :-)
  • 33. Web Development ... Compojure & Ring $ lein new compojure hello-world $ cd hello-world $ lein run server-headless
  • 34. Open your browser on http://localhost:3000/
  • 37. Exercises 1. Write a function which returns the last element in a sequence without using *last*. Test data: (A) [10 20 30 40 50] (B) '(10 8 1) (C) ["x" "y" "z"] 2. Write a function which sum of a sequence of numbers without using *reduce*. Test data: (A) [1 2 3 4 5 6] (B) '(0 0 -1 1 2 3) (C) #{40 50 25 15 10} 3. Write a REST service with clojure, all persistence needs to be done in memory using maps or records. You will need to create an BANK application with: deposit, withdrawal, check balance, transfer money into other accounts. You will need do proper validations and also unit tests. Your application need to use lein and compojure there are no other frameworks/libs allowed. You cannot use: for, if and let.
  • 38. Scala ❏ 2004 ❏ Functional Programing Language ❏ Based on Haskell ❏ Runs on the JVM also JavaScript ❏ Statically typed ❏ Better Java ❏ Awesome for Big Data / ML ❏ Created by Martin Odersky
  • 39. SBT ❏ Build System for Scala ❏ IF you are working with scala you also could do: ❏ Maven ❏ Gradle ❏ In practice SBT is the right choice.
  • 42. SBT has a REPL too ($ sbt console)
  • 43. Functions ❏ Functions ❏ Lambdas ❏ Are all Objects ❏ Since implementation in java (JVM).
  • 44. Partial Application ❏ Partial ❏ Lazy ❏ Composition ❏ Re-use
  • 45. Partial Application via Currying ❏ Partial ❏ Lazy ❏ Composition ❏ Re-use
  • 46. Variable lengths arguments or in java terms varargs. ❏ * ❏ Dynamic ❏ Generic ❏ Similar to java
  • 47. OOP in Scala: Class ❏ Scala support OOP ❏ Here is the better java part starts ❏ Simple ❏ Clean ❏ Less Verbose
  • 48. OOP in Scala: Class Constructor + String Interpolation
  • 49. OOP in Scala: Inheritance ❏ Class Hierarchy ❏ Polymorphism
  • 50. OOP in Scala: Polymorphism Overriding ❏ Class Hierarchy ❏ Polymorphism ❏ Overriding
  • 51. OOP in Scala: Traits ❏ Similar to Java Interfaces ❏ However you can have code ❏ Fundamental part of type system (“Algebra”) ❏ One of best things in Scala ❏ Be Careful it can get crazy :D ❏ Stay practical stay clean!
  • 52. OOP in Scala: Generics + Types ❏ Generics ❏ Types ❏ Abstractions ❏ Leverage Compiler ❏ Haskell way
  • 53. Apply ❏ Apply ❏ Code runs ❏ Default in Scala ❏ Like toString In Java but better ❏ Super useful
  • 54. OOP in Scala: Objects ❏ Different then Java Objects ❏ Objects are single instance ❏ It's how you do Singletons in Scala ❏ Great for org static functions ❏ Often classes have companion Objects in Scala. ❏ Functions in Scala are Objects.
  • 55. Pattern Matcher ❏ One of the best features In Scala Language. ❏ Support ifs ❏ Support “_” ❏ Support type matching ❏ Better than Switch
  • 57. Case classes ❏ One of the best features In Scala Language. ❏ Super charged Classes ❏ Equality & toString Support ❏ Work on Pattern Matcher ❏ Super clean syntax
  • 58. Collections ❏ Like in Java ❏ But much better ❏ Immutable ❏ Mutable ❏ Tupes ❏ Sets, Arrays, Lists, ❏ Maps vs Map
  • 59. map, filter, foldLeft ❏ Functional Combinators ❏ Core FP prog ❏ Super useful ❏ Day by Day work
  • 60. Exercises 1. Write a function which finds the last element in a List without using *last*. Test data: (A) List(1,2,3,4,5,6,7,8) (B) List(“1”,”2”,”3”) (C) List(1.0,2.0,3.0) 2. Write a function which Flatten a nested list structure. Test data: (A) flatten(List(List(1, 1), 2, List(3, List(5, 8)))) (B) (List(), 2, List(3,4)) 3. Write a REST service with Scala, all persistence needs to be done in memory using maps or records. You will need to create an BANK application with: deposit, withdrawal, check balance, transfer money into other accounts. You will need do proper validations and also unit tests. Your application need to use lein and compojure there are no other frameworks/libs allowed. You cannot use: for, if and let.