SlideShare una empresa de Scribd logo
1 de 27
Introduction to Scala
August 2014 Meetup
Rahul Jain
@rahuldausa
Agenda
• Introduction to Functional
Programming
• Basics of Scala
• Scala Use-casses
• Examples
• Code Samples/Walk-through
2
Function Programming
• programs are executed by evaluating expressions, in
contrast with imperative programming where
programs are composed of statements which change
global state when executed. Functional programming
typically avoids using mutable state.
• Functional programming requires that functions
are first-class, which means that they are treated like
any other values and can be passed as arguments to
other functions or be returned as a result of a function.
• Being first-class also means that it is possible to define
and manipulate functions from within other functions.
About Scala
• Scala, short for Scalable Language, is a hybrid
functional programming language
• created by Martin Odersky and it was first
released in 2003.
• features of object-oriented and functional
languages
• run on the Java Virtual Machine
• Not a statically typed language
• www.scala-lang.org
Scala IDE
• Eclipse:
– http://scala-ide.org/
• IntelliJIdea :
– http://www.jetbrains.com/idea/features/scala.ht
ml
Scala in the Enterprise
• The Scala programming language is used by many
companies to develop commercial software and
production systems
• For e.g. :
– LinkedIn, EDFT,Twitter, Novell, the
Guardian, Xebia, Xerox, FourSquare, Sony, Siemens, Th
atcham, OPower, GridGain, AppJet, Reaktorand
many others.
• http://www.scala-lang.org/old/node/1658.html
• http://www.quora.com/Startups/What-startups-
or-tech-companies-are-using-Scala
Credit: http://alvinalexander.com/scala/whos-using-scala-akka-play-framework
Popular Frameworks built on Scala
• Akka
• Play framework
• Lift web
• Apache Kafka
• Scalding (from twitter)
• Gizzard (from twitter)
• Kestrel
• and many more…
Data Types
Byte : 8 bit signed value. Range from -128 to 127
Short : 16 bit signed value. Range -32768 to 32767
Int : 32 bit signed value. Range -2147483648 to 2147483647
Long : 64 bit signed value. -9223372036854775808 to 9223372036854775807
Float : 32 bit IEEE 754 single-precision float
Double : 64 bit IEEE 754 double-precision float
Char : 16 bit unsigned Unicode character. Range from U+0000 to U+FFFF
String : A sequence of Chars
Boolean : Either the literal true or the literal false
Unit: Corresponds to no value : void
Null: null or empty reference
Nothing : The subtype of every other type; includes no values
Any: The supertype of any type; any object is of type Any : Java's Object class
AnyRef: The supertype of any reference type
How to Install
Setting up the development
Environment
• http://www.scala-lang.org/download/
• C:>scala -version
Scala code runner version 2.10.4 -- Copyright 2002-2013, LAMP/EPFL
• C:>scala
Welcome to Scala version 2.10.4 (Java HotSpot(TM) Client VM, Java
1.7.0_51).
Type in expressions to have them evaluated.
Type :help for more information.
• scala> println("Hello, Scala!");
Hello, Scala!
Compile and Run
• Compile
– scalac HelloWorld.scala
– C:> scalac HelloWorld.scala
• Run
– C:> scala HelloWorld
– Hello, World!
Sample Program
object Test {
def main(args: Array[String]){
println("hello world");
}
def Hello(args:Array[String]){
println("hello scala");
}
this.Hello(null);
}
Function
object <name> extends App {
def <function_name>(var_name: <var_type>, var_name: <var_type>):
<return_type>= {
}
}
object Sum extends App {
def sumInt(x: Int, y: Int): Int = {
x + y //return the sum of two values
}
println("Sum of 1 and 2: " + sumInt(1, 2))
}
Sum
object Sum extends App {
def sumInt(x: Int, y: Int): Int = {
x + y //return the sum of two values
}
println("Sum of 1 and 2: " + sumInt(1, 2))
}
Unit’s Example
object UnitTest extends App {
def greetMe(): Unit = {
println("Greetings !!!")
}
def greetMeByName(name: String): Unit = {
println("Hey " + name)
}
greetMe // print Greetings !!!
greetMeByName("John") // print Hey John
}
object & class
• class
– A class is a definition, a description. It defines a type in
terms of methods and composition of other types.
• Object
– An object is a singleton -- an instance of a class which is
guaranteed to be unique. For every object in the code, an
anonymous class is created, which inherits from whatever
classes you declared object to implement. This class
cannot be seen from Scala source code -- though you can
get at it through reflection.
• You can think of the "object" keyword creating a
Singleton object of a class, that is defined implicitly.
object & class
e.g.
• object A extends B with C
– This will declare an anonymous class which
extends B with the trait C and create a single
instance of this class named A.
• http://stackoverflow.com/questions/1755345/
scala-difference-between-object-and-class
Scala Keywords (Reserved)
• Can not be used as constant or variable or any other
identifier names.
abstract case catch class
def do else extends
false final finally for
forSome if implicit import
lazy match new null
object override package private
protected return sealed super
this throw trait try
true type val var
while with yield
- : = =>
<- <: <% >:
#@
Scala packages import
• import scala.xml._
– imports the contents of the scala.xml package
• import scala.collection.mutable.HashMap
– You can import a single class and object, for example,
HashMap from the scala.collection.mutable package
• import scala.collection.immutable.{TreeMap, TreeSet}
– You can import more than one class or object from a single
package, for example, TreeMap and TreeSet from the
scala.collection.immutable package:
Multi line Strings
• multi-line string literal is a sequence of
characters enclosed in triple quotes """ ... ""“
• For e.g. :
– """the present string
spans three
lines."""
var vs val
• var refers to a variable that can change value
– mutable variable
– var myVar : String = "Foo"
• val refers to a variable that can not change
value
– Immutable variable
– val myVal : String = "Foo“
– Equivalent to Java’s final
Scala’s Null
• null value is of type scala.Null
• compatible with every reference type.
• denotes a reference value which refers to a
special "null" object.
Scala vs Java
• All types are objects.
• Type inference.
• Nested Functions.
• Functions are objects.
• Domain specific language (DSL) support.
• Traits.
• Closures.
• Concurrency support inspired by Erlang.
Advanced Concepts
• Pattern matching
• Tail recursion
• Large library of list functions
• Functional dictionary class
• Automatic currying
• Concise way to compose functions
• Lazy lists
Questions ?
26
Thanks!
@rahuldausa on twitter and slideshare
http://www.linkedin.com/in/rahuldausa
Interested in Search/Information Retrieval ?
Join us @ http://www.meetup.com/Hyderabad-Apache-Solr-Lucene-Group/
27

Más contenido relacionado

La actualidad más candente

Introduction to Apache Spark
Introduction to Apache SparkIntroduction to Apache Spark
Introduction to Apache SparkRahul Jain
 
Apache Spark Fundamentals
Apache Spark FundamentalsApache Spark Fundamentals
Apache Spark FundamentalsZahra Eskandari
 
Introduction to ML with Apache Spark MLlib
Introduction to ML with Apache Spark MLlibIntroduction to ML with Apache Spark MLlib
Introduction to ML with Apache Spark MLlibTaras Matyashovsky
 
OSS NA 2019 - Demo Booth deck overview of Egeria
OSS NA 2019 - Demo Booth deck overview of EgeriaOSS NA 2019 - Demo Booth deck overview of Egeria
OSS NA 2019 - Demo Booth deck overview of EgeriaODPi
 
Extending Machine Learning Algorithms with PySpark
Extending Machine Learning Algorithms with PySparkExtending Machine Learning Algorithms with PySpark
Extending Machine Learning Algorithms with PySparkDatabricks
 
Spark streaming , Spark SQL
Spark streaming , Spark SQLSpark streaming , Spark SQL
Spark streaming , Spark SQLYousun Jeong
 
Spark introduction and architecture
Spark introduction and architectureSpark introduction and architecture
Spark introduction and architectureSohil Jain
 
Hibernate ppt
Hibernate pptHibernate ppt
Hibernate pptAneega
 
Introduction to spark
Introduction to sparkIntroduction to spark
Introduction to sparkHome
 
Elasticsearch Tutorial | Getting Started with Elasticsearch | ELK Stack Train...
Elasticsearch Tutorial | Getting Started with Elasticsearch | ELK Stack Train...Elasticsearch Tutorial | Getting Started with Elasticsearch | ELK Stack Train...
Elasticsearch Tutorial | Getting Started with Elasticsearch | ELK Stack Train...Edureka!
 
Kibana Tutorial | Kibana Dashboard Tutorial | Kibana Elasticsearch | ELK Stac...
Kibana Tutorial | Kibana Dashboard Tutorial | Kibana Elasticsearch | ELK Stac...Kibana Tutorial | Kibana Dashboard Tutorial | Kibana Elasticsearch | ELK Stac...
Kibana Tutorial | Kibana Dashboard Tutorial | Kibana Elasticsearch | ELK Stac...Edureka!
 
Introduction to Hadoop and Hadoop component
Introduction to Hadoop and Hadoop component Introduction to Hadoop and Hadoop component
Introduction to Hadoop and Hadoop component rebeccatho
 
Spark SQL Tutorial | Spark Tutorial for Beginners | Apache Spark Training | E...
Spark SQL Tutorial | Spark Tutorial for Beginners | Apache Spark Training | E...Spark SQL Tutorial | Spark Tutorial for Beginners | Apache Spark Training | E...
Spark SQL Tutorial | Spark Tutorial for Beginners | Apache Spark Training | E...Edureka!
 

La actualidad más candente (20)

Introduction to Apache Spark
Introduction to Apache SparkIntroduction to Apache Spark
Introduction to Apache Spark
 
Apache Spark Fundamentals
Apache Spark FundamentalsApache Spark Fundamentals
Apache Spark Fundamentals
 
ELK Stack
ELK StackELK Stack
ELK Stack
 
Introduction to ML with Apache Spark MLlib
Introduction to ML with Apache Spark MLlibIntroduction to ML with Apache Spark MLlib
Introduction to ML with Apache Spark MLlib
 
Hadoop and Spark
Hadoop and SparkHadoop and Spark
Hadoop and Spark
 
OSS NA 2019 - Demo Booth deck overview of Egeria
OSS NA 2019 - Demo Booth deck overview of EgeriaOSS NA 2019 - Demo Booth deck overview of Egeria
OSS NA 2019 - Demo Booth deck overview of Egeria
 
Intro to Apache Spark
Intro to Apache SparkIntro to Apache Spark
Intro to Apache Spark
 
Extending Machine Learning Algorithms with PySpark
Extending Machine Learning Algorithms with PySparkExtending Machine Learning Algorithms with PySpark
Extending Machine Learning Algorithms with PySpark
 
Apache Spark MLlib
Apache Spark MLlib Apache Spark MLlib
Apache Spark MLlib
 
Spark streaming , Spark SQL
Spark streaming , Spark SQLSpark streaming , Spark SQL
Spark streaming , Spark SQL
 
Spark introduction and architecture
Spark introduction and architectureSpark introduction and architecture
Spark introduction and architecture
 
Key-Value NoSQL Database
Key-Value NoSQL DatabaseKey-Value NoSQL Database
Key-Value NoSQL Database
 
Apache Spark Architecture
Apache Spark ArchitectureApache Spark Architecture
Apache Spark Architecture
 
Hibernate ppt
Hibernate pptHibernate ppt
Hibernate ppt
 
Introduction to spark
Introduction to sparkIntroduction to spark
Introduction to spark
 
Elasticsearch Tutorial | Getting Started with Elasticsearch | ELK Stack Train...
Elasticsearch Tutorial | Getting Started with Elasticsearch | ELK Stack Train...Elasticsearch Tutorial | Getting Started with Elasticsearch | ELK Stack Train...
Elasticsearch Tutorial | Getting Started with Elasticsearch | ELK Stack Train...
 
Kibana Tutorial | Kibana Dashboard Tutorial | Kibana Elasticsearch | ELK Stac...
Kibana Tutorial | Kibana Dashboard Tutorial | Kibana Elasticsearch | ELK Stac...Kibana Tutorial | Kibana Dashboard Tutorial | Kibana Elasticsearch | ELK Stac...
Kibana Tutorial | Kibana Dashboard Tutorial | Kibana Elasticsearch | ELK Stac...
 
Introduction to Hadoop and Hadoop component
Introduction to Hadoop and Hadoop component Introduction to Hadoop and Hadoop component
Introduction to Hadoop and Hadoop component
 
Spark SQL Tutorial | Spark Tutorial for Beginners | Apache Spark Training | E...
Spark SQL Tutorial | Spark Tutorial for Beginners | Apache Spark Training | E...Spark SQL Tutorial | Spark Tutorial for Beginners | Apache Spark Training | E...
Spark SQL Tutorial | Spark Tutorial for Beginners | Apache Spark Training | E...
 
Hadoop Ecosystem
Hadoop EcosystemHadoop Ecosystem
Hadoop Ecosystem
 

Destacado

Destacado (6)

Scala and spark
Scala and sparkScala and spark
Scala and spark
 
Spark workshop
Spark workshopSpark workshop
Spark workshop
 
Apache spark Intro
Apache spark IntroApache spark Intro
Apache spark Intro
 
Scala Intro
Scala IntroScala Intro
Scala Intro
 
Introduction to Functional Programming with Scala
Introduction to Functional Programming with ScalaIntroduction to Functional Programming with Scala
Introduction to Functional Programming with Scala
 
A Brief Intro to Scala
A Brief Intro to ScalaA Brief Intro to Scala
A Brief Intro to Scala
 

Similar a Introduction to Scala

Scala, Play 2.0 & Cloud Foundry
Scala, Play 2.0 & Cloud FoundryScala, Play 2.0 & Cloud Foundry
Scala, Play 2.0 & Cloud FoundryPray Desai
 
Introduction to Scala | Big Data Hadoop Spark Tutorial | CloudxLab
Introduction to Scala | Big Data Hadoop Spark Tutorial | CloudxLabIntroduction to Scala | Big Data Hadoop Spark Tutorial | CloudxLab
Introduction to Scala | Big Data Hadoop Spark Tutorial | CloudxLabCloudxLab
 
Java core - Detailed Overview
Java  core - Detailed OverviewJava  core - Detailed Overview
Java core - Detailed OverviewBuddha Tree
 
Learning core java
Learning core javaLearning core java
Learning core javaAbhay Bharti
 
Java-Intro.pptx
Java-Intro.pptxJava-Intro.pptx
Java-Intro.pptxVijalJain3
 
chapter 1-overview of java programming.pptx
chapter 1-overview of java programming.pptxchapter 1-overview of java programming.pptx
chapter 1-overview of java programming.pptxnafsigenet
 
java02.ppt
java02.pptjava02.ppt
java02.pptMENACE4
 
lecture-a-java-review.ppt
lecture-a-java-review.pptlecture-a-java-review.ppt
lecture-a-java-review.pptkavitamittal18
 
Java basics with datatypes, object oriented programming
Java basics with datatypes, object oriented programmingJava basics with datatypes, object oriented programming
Java basics with datatypes, object oriented programmingkalirajonline
 
lecture-a-java-review.ppt
lecture-a-java-review.pptlecture-a-java-review.ppt
lecture-a-java-review.pptNadiSarj2
 
lecture-a-java-review.ppt
lecture-a-java-review.pptlecture-a-java-review.ppt
lecture-a-java-review.pptJemarManatad1
 
lecture-a-java-review.ppt
lecture-a-java-review.pptlecture-a-java-review.ppt
lecture-a-java-review.pptSquidTurbo
 

Similar a Introduction to Scala (20)

Scala, Play 2.0 & Cloud Foundry
Scala, Play 2.0 & Cloud FoundryScala, Play 2.0 & Cloud Foundry
Scala, Play 2.0 & Cloud Foundry
 
Java
JavaJava
Java
 
ppt_on_java.pptx
ppt_on_java.pptxppt_on_java.pptx
ppt_on_java.pptx
 
Intro to Scala
 Intro to Scala Intro to Scala
Intro to Scala
 
Java
Java Java
Java
 
Java
JavaJava
Java
 
Introduction to Scala | Big Data Hadoop Spark Tutorial | CloudxLab
Introduction to Scala | Big Data Hadoop Spark Tutorial | CloudxLabIntroduction to Scala | Big Data Hadoop Spark Tutorial | CloudxLab
Introduction to Scala | Big Data Hadoop Spark Tutorial | CloudxLab
 
Java core - Detailed Overview
Java  core - Detailed OverviewJava  core - Detailed Overview
Java core - Detailed Overview
 
Scala-Ls1
Scala-Ls1Scala-Ls1
Scala-Ls1
 
Learning core java
Learning core javaLearning core java
Learning core java
 
Java-Intro.pptx
Java-Intro.pptxJava-Intro.pptx
Java-Intro.pptx
 
chapter 1-overview of java programming.pptx
chapter 1-overview of java programming.pptxchapter 1-overview of java programming.pptx
chapter 1-overview of java programming.pptx
 
java02.ppt
java02.pptjava02.ppt
java02.ppt
 
lecture-a-java-review.ppt
lecture-a-java-review.pptlecture-a-java-review.ppt
lecture-a-java-review.ppt
 
lecture-a-java-review.ppt
lecture-a-java-review.pptlecture-a-java-review.ppt
lecture-a-java-review.ppt
 
lecture-a-java-review.ppt
lecture-a-java-review.pptlecture-a-java-review.ppt
lecture-a-java-review.ppt
 
Java basics with datatypes, object oriented programming
Java basics with datatypes, object oriented programmingJava basics with datatypes, object oriented programming
Java basics with datatypes, object oriented programming
 
lecture-a-java-review.ppt
lecture-a-java-review.pptlecture-a-java-review.ppt
lecture-a-java-review.ppt
 
lecture-a-java-review.ppt
lecture-a-java-review.pptlecture-a-java-review.ppt
lecture-a-java-review.ppt
 
lecture-a-java-review.ppt
lecture-a-java-review.pptlecture-a-java-review.ppt
lecture-a-java-review.ppt
 

Más de Rahul Jain

Flipkart Strategy Analysis and Recommendation
Flipkart Strategy Analysis and RecommendationFlipkart Strategy Analysis and Recommendation
Flipkart Strategy Analysis and RecommendationRahul Jain
 
Emerging technologies /frameworks in Big Data
Emerging technologies /frameworks in Big DataEmerging technologies /frameworks in Big Data
Emerging technologies /frameworks in Big DataRahul Jain
 
Case study of Rujhaan.com (A social news app )
Case study of Rujhaan.com (A social news app )Case study of Rujhaan.com (A social news app )
Case study of Rujhaan.com (A social news app )Rahul Jain
 
Building a Large Scale SEO/SEM Application with Apache Solr
Building a Large Scale SEO/SEM Application with Apache SolrBuilding a Large Scale SEO/SEM Application with Apache Solr
Building a Large Scale SEO/SEM Application with Apache SolrRahul Jain
 
Real time Analytics with Apache Kafka and Apache Spark
Real time Analytics with Apache Kafka and Apache SparkReal time Analytics with Apache Kafka and Apache Spark
Real time Analytics with Apache Kafka and Apache SparkRahul Jain
 
Introduction to Machine Learning
Introduction to Machine LearningIntroduction to Machine Learning
Introduction to Machine LearningRahul Jain
 
What is NoSQL and CAP Theorem
What is NoSQL and CAP TheoremWhat is NoSQL and CAP Theorem
What is NoSQL and CAP TheoremRahul Jain
 
Introduction to Elasticsearch with basics of Lucene
Introduction to Elasticsearch with basics of LuceneIntroduction to Elasticsearch with basics of Lucene
Introduction to Elasticsearch with basics of LuceneRahul Jain
 
Introduction to Apache Lucene/Solr
Introduction to Apache Lucene/SolrIntroduction to Apache Lucene/Solr
Introduction to Apache Lucene/SolrRahul Jain
 
Introduction to Lucene & Solr and Usecases
Introduction to Lucene & Solr and UsecasesIntroduction to Lucene & Solr and Usecases
Introduction to Lucene & Solr and UsecasesRahul Jain
 
Introduction to Kafka and Zookeeper
Introduction to Kafka and ZookeeperIntroduction to Kafka and Zookeeper
Introduction to Kafka and ZookeeperRahul Jain
 
Hadoop & HDFS for Beginners
Hadoop & HDFS for BeginnersHadoop & HDFS for Beginners
Hadoop & HDFS for BeginnersRahul Jain
 
Hibernate tutorial for beginners
Hibernate tutorial for beginnersHibernate tutorial for beginners
Hibernate tutorial for beginnersRahul Jain
 

Más de Rahul Jain (14)

Flipkart Strategy Analysis and Recommendation
Flipkart Strategy Analysis and RecommendationFlipkart Strategy Analysis and Recommendation
Flipkart Strategy Analysis and Recommendation
 
Emerging technologies /frameworks in Big Data
Emerging technologies /frameworks in Big DataEmerging technologies /frameworks in Big Data
Emerging technologies /frameworks in Big Data
 
Case study of Rujhaan.com (A social news app )
Case study of Rujhaan.com (A social news app )Case study of Rujhaan.com (A social news app )
Case study of Rujhaan.com (A social news app )
 
Building a Large Scale SEO/SEM Application with Apache Solr
Building a Large Scale SEO/SEM Application with Apache SolrBuilding a Large Scale SEO/SEM Application with Apache Solr
Building a Large Scale SEO/SEM Application with Apache Solr
 
Real time Analytics with Apache Kafka and Apache Spark
Real time Analytics with Apache Kafka and Apache SparkReal time Analytics with Apache Kafka and Apache Spark
Real time Analytics with Apache Kafka and Apache Spark
 
Introduction to Machine Learning
Introduction to Machine LearningIntroduction to Machine Learning
Introduction to Machine Learning
 
What is NoSQL and CAP Theorem
What is NoSQL and CAP TheoremWhat is NoSQL and CAP Theorem
What is NoSQL and CAP Theorem
 
Introduction to Elasticsearch with basics of Lucene
Introduction to Elasticsearch with basics of LuceneIntroduction to Elasticsearch with basics of Lucene
Introduction to Elasticsearch with basics of Lucene
 
Introduction to Apache Lucene/Solr
Introduction to Apache Lucene/SolrIntroduction to Apache Lucene/Solr
Introduction to Apache Lucene/Solr
 
Introduction to Lucene & Solr and Usecases
Introduction to Lucene & Solr and UsecasesIntroduction to Lucene & Solr and Usecases
Introduction to Lucene & Solr and Usecases
 
Introduction to Kafka and Zookeeper
Introduction to Kafka and ZookeeperIntroduction to Kafka and Zookeeper
Introduction to Kafka and Zookeeper
 
Apache kafka
Apache kafkaApache kafka
Apache kafka
 
Hadoop & HDFS for Beginners
Hadoop & HDFS for BeginnersHadoop & HDFS for Beginners
Hadoop & HDFS for Beginners
 
Hibernate tutorial for beginners
Hibernate tutorial for beginnersHibernate tutorial for beginners
Hibernate tutorial for beginners
 

Último

Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 

Último (20)

Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 

Introduction to Scala

  • 1. Introduction to Scala August 2014 Meetup Rahul Jain @rahuldausa
  • 2. Agenda • Introduction to Functional Programming • Basics of Scala • Scala Use-casses • Examples • Code Samples/Walk-through 2
  • 3. Function Programming • programs are executed by evaluating expressions, in contrast with imperative programming where programs are composed of statements which change global state when executed. Functional programming typically avoids using mutable state. • Functional programming requires that functions are first-class, which means that they are treated like any other values and can be passed as arguments to other functions or be returned as a result of a function. • Being first-class also means that it is possible to define and manipulate functions from within other functions.
  • 4. About Scala • Scala, short for Scalable Language, is a hybrid functional programming language • created by Martin Odersky and it was first released in 2003. • features of object-oriented and functional languages • run on the Java Virtual Machine • Not a statically typed language • www.scala-lang.org
  • 5. Scala IDE • Eclipse: – http://scala-ide.org/ • IntelliJIdea : – http://www.jetbrains.com/idea/features/scala.ht ml
  • 6. Scala in the Enterprise • The Scala programming language is used by many companies to develop commercial software and production systems • For e.g. : – LinkedIn, EDFT,Twitter, Novell, the Guardian, Xebia, Xerox, FourSquare, Sony, Siemens, Th atcham, OPower, GridGain, AppJet, Reaktorand many others. • http://www.scala-lang.org/old/node/1658.html • http://www.quora.com/Startups/What-startups- or-tech-companies-are-using-Scala
  • 8. Popular Frameworks built on Scala • Akka • Play framework • Lift web • Apache Kafka • Scalding (from twitter) • Gizzard (from twitter) • Kestrel • and many more…
  • 9. Data Types Byte : 8 bit signed value. Range from -128 to 127 Short : 16 bit signed value. Range -32768 to 32767 Int : 32 bit signed value. Range -2147483648 to 2147483647 Long : 64 bit signed value. -9223372036854775808 to 9223372036854775807 Float : 32 bit IEEE 754 single-precision float Double : 64 bit IEEE 754 double-precision float Char : 16 bit unsigned Unicode character. Range from U+0000 to U+FFFF String : A sequence of Chars Boolean : Either the literal true or the literal false Unit: Corresponds to no value : void Null: null or empty reference Nothing : The subtype of every other type; includes no values Any: The supertype of any type; any object is of type Any : Java's Object class AnyRef: The supertype of any reference type
  • 11. Setting up the development Environment • http://www.scala-lang.org/download/ • C:>scala -version Scala code runner version 2.10.4 -- Copyright 2002-2013, LAMP/EPFL • C:>scala Welcome to Scala version 2.10.4 (Java HotSpot(TM) Client VM, Java 1.7.0_51). Type in expressions to have them evaluated. Type :help for more information. • scala> println("Hello, Scala!"); Hello, Scala!
  • 12. Compile and Run • Compile – scalac HelloWorld.scala – C:> scalac HelloWorld.scala • Run – C:> scala HelloWorld – Hello, World!
  • 13. Sample Program object Test { def main(args: Array[String]){ println("hello world"); } def Hello(args:Array[String]){ println("hello scala"); } this.Hello(null); }
  • 14. Function object <name> extends App { def <function_name>(var_name: <var_type>, var_name: <var_type>): <return_type>= { } } object Sum extends App { def sumInt(x: Int, y: Int): Int = { x + y //return the sum of two values } println("Sum of 1 and 2: " + sumInt(1, 2)) }
  • 15. Sum object Sum extends App { def sumInt(x: Int, y: Int): Int = { x + y //return the sum of two values } println("Sum of 1 and 2: " + sumInt(1, 2)) }
  • 16. Unit’s Example object UnitTest extends App { def greetMe(): Unit = { println("Greetings !!!") } def greetMeByName(name: String): Unit = { println("Hey " + name) } greetMe // print Greetings !!! greetMeByName("John") // print Hey John }
  • 17. object & class • class – A class is a definition, a description. It defines a type in terms of methods and composition of other types. • Object – An object is a singleton -- an instance of a class which is guaranteed to be unique. For every object in the code, an anonymous class is created, which inherits from whatever classes you declared object to implement. This class cannot be seen from Scala source code -- though you can get at it through reflection. • You can think of the "object" keyword creating a Singleton object of a class, that is defined implicitly.
  • 18. object & class e.g. • object A extends B with C – This will declare an anonymous class which extends B with the trait C and create a single instance of this class named A. • http://stackoverflow.com/questions/1755345/ scala-difference-between-object-and-class
  • 19. Scala Keywords (Reserved) • Can not be used as constant or variable or any other identifier names. abstract case catch class def do else extends false final finally for forSome if implicit import lazy match new null object override package private protected return sealed super this throw trait try true type val var while with yield - : = => <- <: <% >: #@
  • 20. Scala packages import • import scala.xml._ – imports the contents of the scala.xml package • import scala.collection.mutable.HashMap – You can import a single class and object, for example, HashMap from the scala.collection.mutable package • import scala.collection.immutable.{TreeMap, TreeSet} – You can import more than one class or object from a single package, for example, TreeMap and TreeSet from the scala.collection.immutable package:
  • 21. Multi line Strings • multi-line string literal is a sequence of characters enclosed in triple quotes """ ... ""“ • For e.g. : – """the present string spans three lines."""
  • 22. var vs val • var refers to a variable that can change value – mutable variable – var myVar : String = "Foo" • val refers to a variable that can not change value – Immutable variable – val myVal : String = "Foo“ – Equivalent to Java’s final
  • 23. Scala’s Null • null value is of type scala.Null • compatible with every reference type. • denotes a reference value which refers to a special "null" object.
  • 24. Scala vs Java • All types are objects. • Type inference. • Nested Functions. • Functions are objects. • Domain specific language (DSL) support. • Traits. • Closures. • Concurrency support inspired by Erlang.
  • 25. Advanced Concepts • Pattern matching • Tail recursion • Large library of list functions • Functional dictionary class • Automatic currying • Concise way to compose functions • Lazy lists
  • 27. Thanks! @rahuldausa on twitter and slideshare http://www.linkedin.com/in/rahuldausa Interested in Search/Information Retrieval ? Join us @ http://www.meetup.com/Hyderabad-Apache-Solr-Lucene-Group/ 27