Scala the-good-parts

Fuqiang Wang
Fuqiang WangCEO at keevol.com
Scala
The Good Parts
@
http://afoo.me
also the SimpleParts
The
Good
Parts
Of
The
Language
–the guys who came from Java to Scala said
“
(I will never turn back to Java
any more)”
farewell, semi-colon
Type Inference
类型后置+类型推导的时代
Scala
Go
Swift
u name it…
expression everywhere
var retVal = for{
a <- numList if a != 3; if a < 8
}yield a
for( a <- retVal){
println( "Value of a: " + a );
}
val delimiter = if(defaultDelimiter)’;’ else ‘-’;
Noreturn any more!
Combinator
&
Composition
Flexible Parameters
But not friendly to Javaers
case class
How you do it in Java Way?
IDEs can help
Library can help
Commons Lang
Google Guava
Lombok
Let’s do it in Scala Way!
tuples
static Companion object
special `apply` in companion object
match
everything and everywhere
Pattern Matching Takes Them All
extractor object
unapply : Input => Optional[Output]
case class is lucky
monad and container objects
monad and container objects
you have met Option, right?
But it’s more than Some or None!
Monad is too academic,
let’s know it in an easy way
import scala.collection._Go
and Explore…
function Rocks
Function literals A=>B
Partial Applied functions
Are NOT
Partial Functions
Partial Applied Functions
Partial
Functions
Partial Function Tip
scala> val m = Map(1->2, 2->3)
m: scala.collection.immutable.Map[Int,Int] = Map(1 -> 2, 2 -> 3)
scala> m.collect({case (k, v) if k % 2 ==0 => (k,v) })
res7: scala.collection.immutable.Map[Int,Int] = Map(2 -> 3)
scala> m collect {case (k, v) if k % 2 ==0 => (k,v) }
res7: scala.collection.immutable.Map[Int,Int] = Map(2 -> 3)
Curried Functions
Caution!
Dark Magic
high-order Functions
Try Function
as return value
How about Java8?
Both Cool~
as long as you like
The
Good
Parts
Of
The
Ecosystem
REPL
快速验证你的疑惑和想法
The JVMFamily
What comes into your mind
when u hear the Java word?
Inter-communication
Libraries
Frameworks
Tools
SBTmakes build-life easier.
Triggered
Execution
Wonderful Plugins
SBT Native Packager
Plugin
sbt-assembly
sbt-dependency-graph
you favoured IDEs’ Plugins
Concurrency in another way
SIP14 Rocks - Futures and Promises
Composable !
SIP14 Rocks - Futures and Promises
Actor Model
Don’t be silly
A Best Practice Of
Message Passing Concurrency
Hello Actor
Gravity

u can’t escape
IoCWisely
Taming Actor
Throttling
Hibernating
Journaling
Clustering
web another way
URL-Oriented design
route - the central hub
what a route looks like
[Http Method] [path] [controller method]
GET / controllers.Application.main
POST / controllers.Application.index
# Map static resources from the /public folder to the /assets URL path
GET /assets/*file controllers.Assets.at(path="/public", file)
GET /webjars/*file controllers.WebJarAssets.at(file)
Perfect For Web APIScenarios
Breakingout of Web Containers
make a killing with big data
do you know
DryadLINQ
Microsoftdoes NOT always
suck
from single framework to family
Memory Computing
enhanced with
neat DSL
You know Scala Collections well, you
play with Spark well ;)
val textFile = spark.textFile("hdfs://...")
val errors = textFile.filter(line => line.contains("ERROR"))
errors.count()
errors.filter(line => line.contains("MySQL")).count()
errors.filter(line => line.contains("MySQL")).collect()
Micro-batching
is not sorealtime
ImmediatelyVS. Wait a moment
– who said that?!
“Where the fucking awesome
type system of scala?”
Scala
wisely
扶墙老师はpuristない
Find your own toolbox
not ONLY a
Hammer
海纳百Lang
有容乃大
Java Scala ^_-
string interpolation wisely
@see also org.slf4j.helpers.MessageFormatter
About Implicit
1. 如果有普遍的共识
和约定的, 可以使用;
2. 否则,不建议使用!
Annotation wisely
No Perfect Annotation Solution
UglyThing
macross
enumeration wisely
or sealed trait?
scala
the
endpoints
instead of
the
Dependencies.
Standalone
http://afoo.me/posts/2015-03-24-java-scala-project-type-choice-principle.html
Questions?
over
1 of 77

Recommended

Continuations in scala (incomplete version) by
Continuations in scala (incomplete version)Continuations in scala (incomplete version)
Continuations in scala (incomplete version)Fuqiang Wang
1.2K views21 slides
Scala - the good, the bad and the very ugly by
Scala - the good, the bad and the very uglyScala - the good, the bad and the very ugly
Scala - the good, the bad and the very uglyBozhidar Bozhanov
57.5K views30 slides
“Insulin” for Scala’s Syntactic Diabetes by
“Insulin” for Scala’s Syntactic Diabetes“Insulin” for Scala’s Syntactic Diabetes
“Insulin” for Scala’s Syntactic DiabetesTzach Zohar
873 views47 slides
Scala the good and bad parts by
Scala the good and bad partsScala the good and bad parts
Scala the good and bad partsbenewu
3K views27 slides
Scala by
ScalaScala
Scalaguest8996422d
8.2K views31 slides
10 Things I Hate About Scala by
10 Things I Hate About Scala10 Things I Hate About Scala
10 Things I Hate About ScalaMeir Maor
3K views36 slides

More Related Content

What's hot

Kotlin L → ∞ by
Kotlin L → ∞Kotlin L → ∞
Kotlin L → ∞Abdellah SELASSI
156 views24 slides
Model with actors and implement with Akka by
Model with actors and implement with AkkaModel with actors and implement with Akka
Model with actors and implement with AkkaNgoc Dao
2.5K views25 slides
Metaprogramming with javascript by
Metaprogramming with javascriptMetaprogramming with javascript
Metaprogramming with javascriptAhmad Rizqi Meydiarso
693 views27 slides
A quick and fast intro to Kotlin by
A quick and fast intro to Kotlin A quick and fast intro to Kotlin
A quick and fast intro to Kotlin XPeppers
1.7K views32 slides
Kotlin presentation by
Kotlin presentation Kotlin presentation
Kotlin presentation MobileAcademy
7.7K views17 slides
Java Intro by
Java IntroJava Intro
Java Introbackdoor
4.4K views30 slides

What's hot(20)

Model with actors and implement with Akka by Ngoc Dao
Model with actors and implement with AkkaModel with actors and implement with Akka
Model with actors and implement with Akka
Ngoc Dao2.5K views
A quick and fast intro to Kotlin by XPeppers
A quick and fast intro to Kotlin A quick and fast intro to Kotlin
A quick and fast intro to Kotlin
XPeppers1.7K views
Kotlin presentation by MobileAcademy
Kotlin presentation Kotlin presentation
Kotlin presentation
MobileAcademy7.7K views
Java Intro by backdoor
Java IntroJava Intro
Java Intro
backdoor4.4K views
Grooming with Groovy by Dhaval Dalal
Grooming with GroovyGrooming with Groovy
Grooming with Groovy
Dhaval Dalal4.1K views
Introduction to Kotlin Language and its application to Android platform by EastBanc Tachnologies
Introduction to Kotlin Language and its application to Android platformIntroduction to Kotlin Language and its application to Android platform
Introduction to Kotlin Language and its application to Android platform
JS Fest 2018. Douglas Crockford. The Better Parts by JSFestUA
JS Fest 2018. Douglas Crockford. The Better PartsJS Fest 2018. Douglas Crockford. The Better Parts
JS Fest 2018. Douglas Crockford. The Better Parts
JSFestUA1.4K views
Polyglot Programming @ Jax.de 2010 by Andres Almiray
Polyglot Programming @ Jax.de 2010Polyglot Programming @ Jax.de 2010
Polyglot Programming @ Jax.de 2010
Andres Almiray682 views
How to start using Scala by Ngoc Dao
How to start using ScalaHow to start using Scala
How to start using Scala
Ngoc Dao2.2K views

Viewers also liked

挖财的互联网金融技术实践与探索@upyun opentalk by
挖财的互联网金融技术实践与探索@upyun opentalk挖财的互联网金融技术实践与探索@upyun opentalk
挖财的互联网金融技术实践与探索@upyun opentalkFuqiang Wang
1.6K views42 slides
Kafka简介 by
Kafka简介Kafka简介
Kafka简介Fuqiang Wang
899 views38 slides
Scala funbyexample by
Scala funbyexampleScala funbyexample
Scala funbyexampleFuqiang Wang
525 views36 slides
Gold investment types introduction by
Gold investment types introductionGold investment types introduction
Gold investment types introductionFuqiang Wang
969 views11 slides
Architecture patterns and practices by
Architecture patterns and practicesArchitecture patterns and practices
Architecture patterns and practicesFuqiang Wang
2.3K views178 slides
SBT Made Simple by
SBT Made SimpleSBT Made Simple
SBT Made SimpleFuqiang Wang
1.4K views20 slides

Viewers also liked(17)

挖财的互联网金融技术实践与探索@upyun opentalk by Fuqiang Wang
挖财的互联网金融技术实践与探索@upyun opentalk挖财的互联网金融技术实践与探索@upyun opentalk
挖财的互联网金融技术实践与探索@upyun opentalk
Fuqiang Wang1.6K views
Gold investment types introduction by Fuqiang Wang
Gold investment types introductionGold investment types introduction
Gold investment types introduction
Fuqiang Wang969 views
Architecture patterns and practices by Fuqiang Wang
Architecture patterns and practicesArchitecture patterns and practices
Architecture patterns and practices
Fuqiang Wang2.3K views
JVMLS 2016. Coroutines in Kotlin by Andrey Breslav
JVMLS 2016. Coroutines in KotlinJVMLS 2016. Coroutines in Kotlin
JVMLS 2016. Coroutines in Kotlin
Andrey Breslav3K views
More Than Java Concurrency by Fuqiang Wang
More Than Java ConcurrencyMore Than Java Concurrency
More Than Java Concurrency
Fuqiang Wang1.6K views
Seed2016 - 개미수열 한주영 (annotated) by Jooyung Han
Seed2016 - 개미수열 한주영 (annotated)Seed2016 - 개미수열 한주영 (annotated)
Seed2016 - 개미수열 한주영 (annotated)
Jooyung Han1.9K views
Proof and Emacs by dico_leque
Proof and EmacsProof and Emacs
Proof and Emacs
dico_leque1.1K views
モナドをつくろう by dico_leque
モナドをつくろうモナドをつくろう
モナドをつくろう
dico_leque5.1K views
Flexible Types in Kotlin - JVMLS 2015 by Andrey Breslav
Flexible Types in Kotlin - JVMLS 2015Flexible Types in Kotlin - JVMLS 2015
Flexible Types in Kotlin - JVMLS 2015
Andrey Breslav1.2K views
Introduction to Kotlin: Brief and clear by Andrey Breslav
Introduction to Kotlin: Brief and clearIntroduction to Kotlin: Brief and clear
Introduction to Kotlin: Brief and clear
Andrey Breslav4.3K views
Zookeeper In Simple Words by Fuqiang Wang
Zookeeper In Simple WordsZookeeper In Simple Words
Zookeeper In Simple Words
Fuqiang Wang4.7K views
A Brief Intro to Scala by Tim Underwood
A Brief Intro to ScalaA Brief Intro to Scala
A Brief Intro to Scala
Tim Underwood23.1K views

Similar to Scala the-good-parts

Scala by
ScalaScala
ScalaAndreas Enbohm
785 views11 slides
The things we don't see – stories of Software, Scala and Akka by
The things we don't see – stories of Software, Scala and AkkaThe things we don't see – stories of Software, Scala and Akka
The things we don't see – stories of Software, Scala and AkkaKonrad Malawski
4K views119 slides
Solid And Sustainable Development in Scala by
Solid And Sustainable Development in ScalaSolid And Sustainable Development in Scala
Solid And Sustainable Development in ScalaKazuhiro Sera
10.4K views48 slides
Solid and Sustainable Development in Scala by
Solid and Sustainable Development in ScalaSolid and Sustainable Development in Scala
Solid and Sustainable Development in Scalascalaconfjp
539 views48 slides
Introduction to Scala language by
Introduction to Scala languageIntroduction to Scala language
Introduction to Scala languageAaqib Pervaiz
119 views21 slides
Clojure made-simple - John Stevenson by
Clojure made-simple - John StevensonClojure made-simple - John Stevenson
Clojure made-simple - John StevensonJAX London
2.7K views78 slides

Similar to Scala the-good-parts(20)

The things we don't see – stories of Software, Scala and Akka by Konrad Malawski
The things we don't see – stories of Software, Scala and AkkaThe things we don't see – stories of Software, Scala and Akka
The things we don't see – stories of Software, Scala and Akka
Konrad Malawski4K views
Solid And Sustainable Development in Scala by Kazuhiro Sera
Solid And Sustainable Development in ScalaSolid And Sustainable Development in Scala
Solid And Sustainable Development in Scala
Kazuhiro Sera10.4K views
Solid and Sustainable Development in Scala by scalaconfjp
Solid and Sustainable Development in ScalaSolid and Sustainable Development in Scala
Solid and Sustainable Development in Scala
scalaconfjp539 views
Introduction to Scala language by Aaqib Pervaiz
Introduction to Scala languageIntroduction to Scala language
Introduction to Scala language
Aaqib Pervaiz119 views
Clojure made-simple - John Stevenson by JAX London
Clojure made-simple - John StevensonClojure made-simple - John Stevenson
Clojure made-simple - John Stevenson
JAX London2.7K views
Scala overview by Steve Min
Scala overviewScala overview
Scala overview
Steve Min3.7K views
Scala final ppt vinay by Viplav Jain
Scala final ppt vinayScala final ppt vinay
Scala final ppt vinay
Viplav Jain227 views
Scala : language of the future by AnsviaLab
Scala : language of the futureScala : language of the future
Scala : language of the future
AnsviaLab854 views
Scala and jvm_languages_praveen_technologist by pmanvi
Scala and jvm_languages_praveen_technologistScala and jvm_languages_praveen_technologist
Scala and jvm_languages_praveen_technologist
pmanvi644 views
Intro to scala by Joe Zulli
Intro to scalaIntro to scala
Intro to scala
Joe Zulli330 views
Sparklife - Life In The Trenches With Spark by Ian Pointer
Sparklife - Life In The Trenches With SparkSparklife - Life In The Trenches With Spark
Sparklife - Life In The Trenches With Spark
Ian Pointer595 views
Scala Programming for Semantic Web Developers ESWC Semdev2015 by Jean-Paul Calbimonte
Scala Programming for Semantic Web Developers ESWC Semdev2015Scala Programming for Semantic Web Developers ESWC Semdev2015
Scala Programming for Semantic Web Developers ESWC Semdev2015
whats new in java 8 by Dori Waldman
whats new in java 8 whats new in java 8
whats new in java 8
Dori Waldman535 views
Effective Scala (JavaDay Riga 2013) by mircodotta
Effective Scala (JavaDay Riga 2013)Effective Scala (JavaDay Riga 2013)
Effective Scala (JavaDay Riga 2013)
mircodotta2K views

Recently uploaded

Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue by
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlueElevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlueShapeBlue
96 views7 slides
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue by
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlueMigrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlueShapeBlue
96 views20 slides
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT by
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBITUpdates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBITShapeBlue
91 views8 slides
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha... by
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...ShapeBlue
74 views18 slides
Business Analyst Series 2023 - Week 4 Session 7 by
Business Analyst Series 2023 -  Week 4 Session 7Business Analyst Series 2023 -  Week 4 Session 7
Business Analyst Series 2023 - Week 4 Session 7DianaGray10
80 views31 slides
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... by
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...Bernd Ruecker
50 views69 slides

Recently uploaded(20)

Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue by ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlueElevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
ShapeBlue96 views
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue by ShapeBlue
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlueMigrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue
ShapeBlue96 views
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT by ShapeBlue
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBITUpdates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT
ShapeBlue91 views
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha... by ShapeBlue
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
ShapeBlue74 views
Business Analyst Series 2023 - Week 4 Session 7 by DianaGray10
Business Analyst Series 2023 -  Week 4 Session 7Business Analyst Series 2023 -  Week 4 Session 7
Business Analyst Series 2023 - Week 4 Session 7
DianaGray1080 views
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... by Bernd Ruecker
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
Bernd Ruecker50 views
Data Integrity for Banking and Financial Services by Precisely
Data Integrity for Banking and Financial ServicesData Integrity for Banking and Financial Services
Data Integrity for Banking and Financial Services
Precisely56 views
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue by ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlueCloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
ShapeBlue46 views
DRBD Deep Dive - Philipp Reisner - LINBIT by ShapeBlue
DRBD Deep Dive - Philipp Reisner - LINBITDRBD Deep Dive - Philipp Reisner - LINBIT
DRBD Deep Dive - Philipp Reisner - LINBIT
ShapeBlue62 views
"Surviving highload with Node.js", Andrii Shumada by Fwdays
"Surviving highload with Node.js", Andrii Shumada "Surviving highload with Node.js", Andrii Shumada
"Surviving highload with Node.js", Andrii Shumada
Fwdays40 views
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ... by ShapeBlue
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...
ShapeBlue83 views
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ... by ShapeBlue
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...
ShapeBlue65 views
PharoJS - Zürich Smalltalk Group Meetup November 2023 by Noury Bouraqadi
PharoJS - Zürich Smalltalk Group Meetup November 2023PharoJS - Zürich Smalltalk Group Meetup November 2023
PharoJS - Zürich Smalltalk Group Meetup November 2023
Noury Bouraqadi141 views
NTGapps NTG LowCode Platform by Mustafa Kuğu
NTGapps NTG LowCode Platform NTGapps NTG LowCode Platform
NTGapps NTG LowCode Platform
Mustafa Kuğu141 views
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava... by ShapeBlue
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...
ShapeBlue48 views
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... by James Anderson
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
James Anderson133 views
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ... by ShapeBlue
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
ShapeBlue77 views
Keynote Talk: Open Source is Not Dead - Charles Schulz - Vates by ShapeBlue
Keynote Talk: Open Source is Not Dead - Charles Schulz - VatesKeynote Talk: Open Source is Not Dead - Charles Schulz - Vates
Keynote Talk: Open Source is Not Dead - Charles Schulz - Vates
ShapeBlue119 views
State of the Union - Rohit Yadav - Apache CloudStack by ShapeBlue
State of the Union - Rohit Yadav - Apache CloudStackState of the Union - Rohit Yadav - Apache CloudStack
State of the Union - Rohit Yadav - Apache CloudStack
ShapeBlue145 views

Scala the-good-parts