SlideShare a Scribd company logo
Rafael Bagmanov «Scala in a wild enterprise»
Rafael Bagmanov «Scala in a wild enterprise»
Scala in a wild
enterprise
Rafael Bagmanov
( Grid Dynamics )
the?
In what use cases (types of applications)
does Scala make the least sense?
"Database front end, CRUD apps.
Most of the boring apps that are built with
Struts and Spring"
David Pollak
"Barriers to scala adoption" Infoq.com
Rafael Bagmanov «Scala in a wild enterprise»
OpenGenesis
github.com/griddynamics/OpenGenesis
● open source - open-genesis.org
● 2 years of development
● > 50 KLOC of scala code
● successfully deployed to production in one
large american financial institution
● Buzzwords: continuous deployment, cloud,
chef, devops, aws, openstack
OpenGenesis
Deployment orchestration tool
● Integration with legacy apps and data (lots of
SOAP and xml)
● sophisticated security policies
● IT department separated from development
team
● J2EE Containers everywhere
● Risk averse
Enterprise characteristics
Typical "lightweight" j2ee stack
Web layer
Service layer
Data access layer
DB
Spring MVC
Spring
JPA
j2ee stack. Scala edition
Web layer
Service layer
Data access layer
DB
Spring MVC + scala magic
Spring + scala implicits
JPA Squeryl
j2ee stack. Scala edition
Web layer
Service layer
Data access layer
DB
Spring MVC
Spring
Squeryl
WAR
j2ee stack. Scala edition + scala
goodness
Web layer
Service layer
Data access layer
DB
Spring MVC
Spring
Squeryl
Workflow distributed
engine
Akka
WAR
Service layer: Spring
● DI fits almost nicely with scala
Spring with scala
● DI fits almost nicely with scala
class GenesisRestController {
@Autowired var genesisService: GenesisService = _
}
class GenesisRestController {
@BeanProperty var genesisService: GenesisService = _
}
class GenesisRestController (genesisService: GenesisService) {}
Spring with scala
● DI fits almost nicely with scala
○ "Everything is a trait" approach can't be done
Spring with scala
● DI fits almost nicely with scala
○ "Everything is a trait" approach can't be done
○ Be aware of type inference in @Configuration bean
trait Service
class ServiceImpl extends Service
@Configuration
class ServiceContext {
@Bean def service = new ServiceImpl
}
Spring with scala
● DI fits almost nicely with scala
○ "Everything is a trait" approach can't be done
○ Be aware of type inference in @Configuration bean
trait Service
class ServiceImpl extends Service
@Configuration
class ServiceContext {
@Bean def service: Service = new ServiceImpl
}
Spring with scala
● DI fits almost nicely with scala
● Rich spring templates libraries.
Spring with scala
● DI fits almost nicely with scala
● Rich spring templates libraries.
springLdapTemplate.authenticate("user", "*", "password", new
AuthenticationErrorCallback {
def execute(e: Exception) {log.error(e)}
})
Spring with scala
● DI fits almost nicely with scala
● Rich spring templates libraries.
springLdapTemplate.authenticate("user", "*", "password", new
AuthenticationErrorCallback {
def execute(e: Exception) {log.error(e)}
})
Spring with scala
● DI fits almost nicely with scala
● Rich spring templates libraries.
springLdapTemplate.authenticate("user", "*", "password", new
AuthenticationErrorCallback {
def execute(e: Exception) {log.error(e)}
})
springLdapTemplate.authenticate("user", "*", "password", log.error(_))
Spring with scala
● DI fits almost nicely with scala
● Rich spring templates libraries.
springLdapTemplate.authenticate("user", "*", "password", log.error(_))
implicit def authErrorCallbackWrapper(func:(Exception) => Any) = {
new AuthenticationErrorCallback {
def execute(exception: Exception): Unit = func(exception)
}
}
Spring with scala
● DI fits almost nicely with scala
● Rich spring templates libraries.
● AOP for free (almost)
Spring with scala
● DI fits almost nicely with scala
● Rich spring templates libraries.
● AOP for free (almost)
○ Be aware of naming in debug info
def findUsers(projectId: Int) {
dao.findUsers(projectId)
}
def findUsers2(projectId: Int) {
dao.allUsers().filter(_.projectId == projectId)
}
Spring with scala
● DI fits almost nicely with scala
● Rich spring templates libraries.
● AOP for free (almost)
○ Be aware of naming in debug info
def findUsers(projectId: Int) { // debugIfo: name "projectId"
dao.findUsers(projectId)
}
def findUsers2(projectId: Int) { // debugInfo: name "projectId$"
dao.allUsers().filter(_.projectId == projectId)
}
Spring with scala
● DI fits almost nicely with scala
● Rich spring templates libraries.
● AOP for free (almost)
● Spring security just works
Spring with scala
Persistence layer: Squeryl
● Lightweight ORM written in scala
Squeryl
● Lightweight ORM written in scala
Squeryl
class Workflow(override val id: Int) extends KeyedEntity[Int]
● Lightweight ORM written in scala
Squeryl
class Workflow(override val id: Int) extends KeyedEntity[Int]
object GS extends Schema {
val workflows = table[Workflow]
}
● Lightweight ORM written in scala
Squeryl
class Workflow(override val id: Int) extends KeyedEntity[Int]
object GS extends Schema {
val workflows = table[Workflow]
}
def find(workflowId: Int) = from(GS.workflows)(w =>
where(w.id === workflowId)
select (w)
orderBy(w.id desc)
)
● Lightweight ORM written in scala
○ First class support for scala collections, options, etc
Squeryl
● Lightweight ORM written in scala
○ First class support for scala collections, options, etc
○ Integrates with spring transaction management
(not out of the box)
Squeryl
● Lightweight ORM written in scala
○ First class support for scala collections, options, etc
○ Integrates with spring transaction management
(not out of the box)
Squeryl
@Transactional(propagation = REQUIRES_NEW)
def find(workflowId: Int) = from(GS.workflows)(w =>
where(w.id === workflowId)
select (w)
orderBy(w.id desc)
)
Squeryl
● Lightweight ORM written in scala
○ Likes heap in the same proportion as
Hibernate does
hibernate squeryl
● Lightweight ORM written in scala
○ Likes heap in the same proportion as
Hibernate does
○ Lot's of "black magic" in source code
Squeryl
● Lightweight ORM written in scala
● Internal scala DSL for writing queries
○ Type safe queries - compile time syntax check
Squeryl
● Lightweight ORM written in scala
● Internal scala DSL for writing queries
○ Lot's of "black magic" in source code
Squeryl
● Lightweight ORM written in scala
● Internal scala DSL for writing queries
○ Lot's of "black magic" in source code
○ Fallback on native sql is not easy
Squeryl
● Lightweight ORM written in scala
● Internal scala DSL for writing queries
○ Lot's of "black magic" in source code
○ Fallback on native sql is not easy
○ Lots of implicits drives IDE crazy and
increases compilation time
Squeryl
● Lightweight ORM written in scala
● Internal scala DSL for writing queries
○ Lot's of "black magic" in source code
○ Fallback on native sql is not easy
○ Lots of implicits drives IDE crazy and
increase compilation time
○ The approach is somewhat flawed (opinion)
Squeryl
Web layer: Spring MVC
lift-json
scala magic
● RESTfull web services
Web layer
case class User (
@NotBlank username: String,
@Email @Size(min = 1, max = 256) email: String,
password: Option[String]
)
@Controller
@RequestMapping(Array("/rest/users"))
class UsersController {
@RequestMapping(method = Array(RequestMethod.POST))
@ResponseBody
def create(@RequestBody @Valid request: User): User = userService.create(request)
}
● RESTfull web services
● Easy to make Hypermedia REST with
implicits
Web layer
@Controller
@RequestMapping(Array("/rest/users"))
class UsersController {
import com.griddynamics.genesis.rest.links.Hypermedia._
@RequestMapping(method = Array(RequestMethod.POST))
@ResponseBody
def create(@RequestBody @Valid request: User): Hypermedia[User] = {
userService.create(request).withLink("/rest/users", LinkType.SELF)
}
Couple of words about
AKKA
Ехал Акка через Акка
Смотрит Акка в Акка Акка
Сунул Акка Акка в Акка
Акка Акка Акка Акка *
* Ode to Akka in russian
Greatest challenge:
Greatest challenge:
People
● Hiring is hard
Challenges
● Hiring is hard
○ Scala is a talent attraction
Challenges
● Hiring is hard
○ Scala is a talent attraction
○ In avg: 0.5 interview per month
Challenges
● Hiring is hard
● Settling team standards and code
convention
Challenges
● Hiring is hard
● Settling team standards and code
convention
○ Tools are not there yet
Challenges
● Hiring is hard
● Settling team standards and code
convention
○ Tools are not there yet
○ Between "OCaml" and "Java" fires
Challenges
● Hiring is hard
● Settling team standards and code
convention
○ Tools are not there yet
○ Between "OCaml" and "Java" fires
○ "Effective scala" by Twitter and "Scala style guide"
might help (a bit)
Challenges
The greatest code-review mystery of
all times
if (option.isDefined) {
..
}
option.foreach { .. }
option match {
case Some(x) => ..
case None => ..
}
How to deal with scala.Option
?
The greatest code-review mystery of
all times
if (option.isDefined) {
..
}
option.foreach { .. }
option match {
case Some(x) => ..
case None => ..
}
How to deal with scala.Option
?
Recruiting java
developers
aka
5 stages of grief
1. Denial
2. Anger
3. Bargaining
4. Depression
5. Acceptance
5 stages of grief
1. Denial
2. Anger
3. Bargaining
4. Depression
5. Acceptance
5 stages of grief
1. Denial
2. Anger
3. Bargaining
4. Depression
5. Acceptance
5 stages of grief
1. Denial
2. Anger
3. Bargaining
4. Depression
5. Acceptance
5 stages of grief
1. Denial
2. Anger
3. Bargaining
4. Depression
5. Acceptance
5 stages of grief
1. Denial
2. Anger
3. Bargaining
4. Depression
5. Acceptance
5 stages of grief
Rafael Bagmanov «Scala in a wild enterprise»

More Related Content

PDF
Scala in a wild enterprise
PPTX
Alberto Paro - Hands on Scala.js
PDF
Scala Days NYC 2016
ODP
Introduction to Scala JS
PDF
Scala, Akka, and Play: An Introduction on Heroku
PDF
Solid And Sustainable Development in Scala
PDF
JavaOne 2017 - Choosing a NoSQL API and Database to Avoid Tombstones and Drag...
PDF
JavaOne 2017 - JNoSQL: The Definitive Solution for Java and NoSQL Database [C...
Scala in a wild enterprise
Alberto Paro - Hands on Scala.js
Scala Days NYC 2016
Introduction to Scala JS
Scala, Akka, and Play: An Introduction on Heroku
Solid And Sustainable Development in Scala
JavaOne 2017 - Choosing a NoSQL API and Database to Avoid Tombstones and Drag...
JavaOne 2017 - JNoSQL: The Definitive Solution for Java and NoSQL Database [C...

What's hot (20)

PDF
JavaOne 2017 - Collections.compare:JDK, Eclipse, Guava, Apache... [CON1754]
PDF
Martin Odersky - Evolution of Scala
PDF
Scarab: SAT-based Constraint Programming System in Scala / Scala上で実現された制約プログラ...
PDF
Introduction to Spark SQL and Catalyst / Spark SQLおよびCalalystの紹介
PDF
Introduction to Scala
PDF
Building Concurrent WebObjects applications with Scala
PPTX
Scala for C# Developers
PDF
Advanced Production Debugging
PDF
Type-safe front-end development with Scala
PDF
10 SQL Tricks that You Didn't Think Were Possible
PDF
Tomer Elmalem - GraphQL APIs: REST in Peace - Codemotion Milan 2017
PDF
Build Cloud Applications with Akka and Heroku
PPTX
Building a Unified Data Pipline in Spark / Apache Sparkを用いたBig Dataパイプラインの統一
PDF
Lightbend Lagom: Microservices Just Right (Scala Days 2016 Berlin)
PDF
The Evolution of Scala / Scala進化論
PPT
Scala Days San Francisco
PPTX
Collections.compare(JDK, Eclipse, Guava, Apache...);
ODP
Scal`a`ngular - Scala and Angular
PDF
Lightbend Lagom: Microservices Just Right
PPTX
Scala final ppt vinay
JavaOne 2017 - Collections.compare:JDK, Eclipse, Guava, Apache... [CON1754]
Martin Odersky - Evolution of Scala
Scarab: SAT-based Constraint Programming System in Scala / Scala上で実現された制約プログラ...
Introduction to Spark SQL and Catalyst / Spark SQLおよびCalalystの紹介
Introduction to Scala
Building Concurrent WebObjects applications with Scala
Scala for C# Developers
Advanced Production Debugging
Type-safe front-end development with Scala
10 SQL Tricks that You Didn't Think Were Possible
Tomer Elmalem - GraphQL APIs: REST in Peace - Codemotion Milan 2017
Build Cloud Applications with Akka and Heroku
Building a Unified Data Pipline in Spark / Apache Sparkを用いたBig Dataパイプラインの統一
Lightbend Lagom: Microservices Just Right (Scala Days 2016 Berlin)
The Evolution of Scala / Scala進化論
Scala Days San Francisco
Collections.compare(JDK, Eclipse, Guava, Apache...);
Scal`a`ngular - Scala and Angular
Lightbend Lagom: Microservices Just Right
Scala final ppt vinay
Ad

Similar to Rafael Bagmanov «Scala in a wild enterprise» (20)

PDF
Scala Frustrations
PDF
Scala and jvm_languages_praveen_technologist
PPTX
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
PPTX
Scala Italy 2015 - Hands On ScalaJS
PDF
Martin Odersky: What's next for Scala
PDF
Solid and Sustainable Development in Scala
PDF
Scala and Spring
PPTX
Spark - The Ultimate Scala Collections by Martin Odersky
PPT
PPTX
Scaling Up Machine Learning Experimentation at Tubi 5x and Beyond
PDF
Spring Day | Spring and Scala | Eberhard Wolff
PPTX
Big Data Processing with .NET and Spark (SQLBits 2020)
PDF
Scala - from "Hello, World" to "Heroku Scale"
PPTX
Scala,a practicle approach
PDF
Kabukiza.tech 1 LT - ScalikeJDBC-Async & Skinny Framework #kbkz_tech
PDF
Buildingsocialanalyticstoolwithmongodb
PDF
Schema on read is obsolete. Welcome metaprogramming..pdf
PDF
Java 23 and Beyond - A Roadmap Of Innovations
PDF
Scala active record
KEY
Cascalog at Strange Loop
Scala Frustrations
Scala and jvm_languages_praveen_technologist
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Scala Italy 2015 - Hands On ScalaJS
Martin Odersky: What's next for Scala
Solid and Sustainable Development in Scala
Scala and Spring
Spark - The Ultimate Scala Collections by Martin Odersky
Scaling Up Machine Learning Experimentation at Tubi 5x and Beyond
Spring Day | Spring and Scala | Eberhard Wolff
Big Data Processing with .NET and Spark (SQLBits 2020)
Scala - from "Hello, World" to "Heroku Scale"
Scala,a practicle approach
Kabukiza.tech 1 LT - ScalikeJDBC-Async & Skinny Framework #kbkz_tech
Buildingsocialanalyticstoolwithmongodb
Schema on read is obsolete. Welcome metaprogramming..pdf
Java 23 and Beyond - A Roadmap Of Innovations
Scala active record
Cascalog at Strange Loop
Ad

More from e-Legion (20)

PPTX
MBLT16: Elena Rydkina, Pure
PPTX
MBLT16: Alexander Lukin, AppMetrica
PPTX
MBLT16: Vincent Wu, Alibaba Mobile
PPTX
MBLT16: Dmitriy Geranin, Afisha Restorany
PPTX
MBLT16: Marvin Liao, 500Startups
PDF
MBLT16: Andrey Maslak, Aviasales
PDF
MBLT16: Andrey Bakalenko, Sberbank Online
PPTX
Rx Java architecture
PPTX
Rx java
PDF
MBLTDev15: Hector Zarate, Spotify
PDF
MBLTDev15: Cesar Valiente, Wunderlist
PDF
MBLTDev15: Brigit Lyons, Soundcloud
PDF
MBLTDev15: Egor Tolstoy, Rambler&Co
PDF
MBLTDev15: Alexander Orlov, Postforpost
PDF
MBLTDev15: Artemiy Sobolev, Parallels
PPTX
MBLTDev15: Alexander Dimchenko, DIT
PPTX
MBLTDev: Evgeny Lisovsky, Litres
PPTX
MBLTDev: Alexander Dimchenko, Bright Box
PPTX
MBLTDev15: Konstantin Goldshtein, Microsoft
PDF
MBLTDev15: Anna Mikhina, Maxim Evdokimov, Tinkoff Bank
MBLT16: Elena Rydkina, Pure
MBLT16: Alexander Lukin, AppMetrica
MBLT16: Vincent Wu, Alibaba Mobile
MBLT16: Dmitriy Geranin, Afisha Restorany
MBLT16: Marvin Liao, 500Startups
MBLT16: Andrey Maslak, Aviasales
MBLT16: Andrey Bakalenko, Sberbank Online
Rx Java architecture
Rx java
MBLTDev15: Hector Zarate, Spotify
MBLTDev15: Cesar Valiente, Wunderlist
MBLTDev15: Brigit Lyons, Soundcloud
MBLTDev15: Egor Tolstoy, Rambler&Co
MBLTDev15: Alexander Orlov, Postforpost
MBLTDev15: Artemiy Sobolev, Parallels
MBLTDev15: Alexander Dimchenko, DIT
MBLTDev: Evgeny Lisovsky, Litres
MBLTDev: Alexander Dimchenko, Bright Box
MBLTDev15: Konstantin Goldshtein, Microsoft
MBLTDev15: Anna Mikhina, Maxim Evdokimov, Tinkoff Bank

Recently uploaded (20)

PPT
Teaching material agriculture food technology
PDF
Machine learning based COVID-19 study performance prediction
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Modernizing your data center with Dell and AMD
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PPTX
Cloud computing and distributed systems.
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
NewMind AI Monthly Chronicles - July 2025
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Teaching material agriculture food technology
Machine learning based COVID-19 study performance prediction
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Modernizing your data center with Dell and AMD
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Cloud computing and distributed systems.
20250228 LYD VKU AI Blended-Learning.pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
Understanding_Digital_Forensics_Presentation.pptx
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
NewMind AI Monthly Chronicles - July 2025
Digital-Transformation-Roadmap-for-Companies.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...

Rafael Bagmanov «Scala in a wild enterprise»

  • 3. Scala in a wild enterprise Rafael Bagmanov ( Grid Dynamics ) the?
  • 4. In what use cases (types of applications) does Scala make the least sense?
  • 5. "Database front end, CRUD apps. Most of the boring apps that are built with Struts and Spring" David Pollak "Barriers to scala adoption" Infoq.com
  • 8. ● open source - open-genesis.org ● 2 years of development ● > 50 KLOC of scala code ● successfully deployed to production in one large american financial institution ● Buzzwords: continuous deployment, cloud, chef, devops, aws, openstack OpenGenesis Deployment orchestration tool
  • 9. ● Integration with legacy apps and data (lots of SOAP and xml) ● sophisticated security policies ● IT department separated from development team ● J2EE Containers everywhere ● Risk averse Enterprise characteristics
  • 10. Typical "lightweight" j2ee stack Web layer Service layer Data access layer DB Spring MVC Spring JPA
  • 11. j2ee stack. Scala edition Web layer Service layer Data access layer DB Spring MVC + scala magic Spring + scala implicits JPA Squeryl
  • 12. j2ee stack. Scala edition Web layer Service layer Data access layer DB Spring MVC Spring Squeryl WAR
  • 13. j2ee stack. Scala edition + scala goodness Web layer Service layer Data access layer DB Spring MVC Spring Squeryl Workflow distributed engine Akka WAR
  • 15. ● DI fits almost nicely with scala Spring with scala
  • 16. ● DI fits almost nicely with scala class GenesisRestController { @Autowired var genesisService: GenesisService = _ } class GenesisRestController { @BeanProperty var genesisService: GenesisService = _ } class GenesisRestController (genesisService: GenesisService) {} Spring with scala
  • 17. ● DI fits almost nicely with scala ○ "Everything is a trait" approach can't be done Spring with scala
  • 18. ● DI fits almost nicely with scala ○ "Everything is a trait" approach can't be done ○ Be aware of type inference in @Configuration bean trait Service class ServiceImpl extends Service @Configuration class ServiceContext { @Bean def service = new ServiceImpl } Spring with scala
  • 19. ● DI fits almost nicely with scala ○ "Everything is a trait" approach can't be done ○ Be aware of type inference in @Configuration bean trait Service class ServiceImpl extends Service @Configuration class ServiceContext { @Bean def service: Service = new ServiceImpl } Spring with scala
  • 20. ● DI fits almost nicely with scala ● Rich spring templates libraries. Spring with scala
  • 21. ● DI fits almost nicely with scala ● Rich spring templates libraries. springLdapTemplate.authenticate("user", "*", "password", new AuthenticationErrorCallback { def execute(e: Exception) {log.error(e)} }) Spring with scala
  • 22. ● DI fits almost nicely with scala ● Rich spring templates libraries. springLdapTemplate.authenticate("user", "*", "password", new AuthenticationErrorCallback { def execute(e: Exception) {log.error(e)} }) Spring with scala
  • 23. ● DI fits almost nicely with scala ● Rich spring templates libraries. springLdapTemplate.authenticate("user", "*", "password", new AuthenticationErrorCallback { def execute(e: Exception) {log.error(e)} }) springLdapTemplate.authenticate("user", "*", "password", log.error(_)) Spring with scala
  • 24. ● DI fits almost nicely with scala ● Rich spring templates libraries. springLdapTemplate.authenticate("user", "*", "password", log.error(_)) implicit def authErrorCallbackWrapper(func:(Exception) => Any) = { new AuthenticationErrorCallback { def execute(exception: Exception): Unit = func(exception) } } Spring with scala
  • 25. ● DI fits almost nicely with scala ● Rich spring templates libraries. ● AOP for free (almost) Spring with scala
  • 26. ● DI fits almost nicely with scala ● Rich spring templates libraries. ● AOP for free (almost) ○ Be aware of naming in debug info def findUsers(projectId: Int) { dao.findUsers(projectId) } def findUsers2(projectId: Int) { dao.allUsers().filter(_.projectId == projectId) } Spring with scala
  • 27. ● DI fits almost nicely with scala ● Rich spring templates libraries. ● AOP for free (almost) ○ Be aware of naming in debug info def findUsers(projectId: Int) { // debugIfo: name "projectId" dao.findUsers(projectId) } def findUsers2(projectId: Int) { // debugInfo: name "projectId$" dao.allUsers().filter(_.projectId == projectId) } Spring with scala
  • 28. ● DI fits almost nicely with scala ● Rich spring templates libraries. ● AOP for free (almost) ● Spring security just works Spring with scala
  • 30. ● Lightweight ORM written in scala Squeryl
  • 31. ● Lightweight ORM written in scala Squeryl class Workflow(override val id: Int) extends KeyedEntity[Int]
  • 32. ● Lightweight ORM written in scala Squeryl class Workflow(override val id: Int) extends KeyedEntity[Int] object GS extends Schema { val workflows = table[Workflow] }
  • 33. ● Lightweight ORM written in scala Squeryl class Workflow(override val id: Int) extends KeyedEntity[Int] object GS extends Schema { val workflows = table[Workflow] } def find(workflowId: Int) = from(GS.workflows)(w => where(w.id === workflowId) select (w) orderBy(w.id desc) )
  • 34. ● Lightweight ORM written in scala ○ First class support for scala collections, options, etc Squeryl
  • 35. ● Lightweight ORM written in scala ○ First class support for scala collections, options, etc ○ Integrates with spring transaction management (not out of the box) Squeryl
  • 36. ● Lightweight ORM written in scala ○ First class support for scala collections, options, etc ○ Integrates with spring transaction management (not out of the box) Squeryl @Transactional(propagation = REQUIRES_NEW) def find(workflowId: Int) = from(GS.workflows)(w => where(w.id === workflowId) select (w) orderBy(w.id desc) )
  • 37. Squeryl ● Lightweight ORM written in scala ○ Likes heap in the same proportion as Hibernate does hibernate squeryl
  • 38. ● Lightweight ORM written in scala ○ Likes heap in the same proportion as Hibernate does ○ Lot's of "black magic" in source code Squeryl
  • 39. ● Lightweight ORM written in scala ● Internal scala DSL for writing queries ○ Type safe queries - compile time syntax check Squeryl
  • 40. ● Lightweight ORM written in scala ● Internal scala DSL for writing queries ○ Lot's of "black magic" in source code Squeryl
  • 41. ● Lightweight ORM written in scala ● Internal scala DSL for writing queries ○ Lot's of "black magic" in source code ○ Fallback on native sql is not easy Squeryl
  • 42. ● Lightweight ORM written in scala ● Internal scala DSL for writing queries ○ Lot's of "black magic" in source code ○ Fallback on native sql is not easy ○ Lots of implicits drives IDE crazy and increases compilation time Squeryl
  • 43. ● Lightweight ORM written in scala ● Internal scala DSL for writing queries ○ Lot's of "black magic" in source code ○ Fallback on native sql is not easy ○ Lots of implicits drives IDE crazy and increase compilation time ○ The approach is somewhat flawed (opinion) Squeryl
  • 44. Web layer: Spring MVC lift-json scala magic
  • 45. ● RESTfull web services Web layer case class User ( @NotBlank username: String, @Email @Size(min = 1, max = 256) email: String, password: Option[String] ) @Controller @RequestMapping(Array("/rest/users")) class UsersController { @RequestMapping(method = Array(RequestMethod.POST)) @ResponseBody def create(@RequestBody @Valid request: User): User = userService.create(request) }
  • 46. ● RESTfull web services ● Easy to make Hypermedia REST with implicits Web layer @Controller @RequestMapping(Array("/rest/users")) class UsersController { import com.griddynamics.genesis.rest.links.Hypermedia._ @RequestMapping(method = Array(RequestMethod.POST)) @ResponseBody def create(@RequestBody @Valid request: User): Hypermedia[User] = { userService.create(request).withLink("/rest/users", LinkType.SELF) }
  • 47. Couple of words about AKKA
  • 48. Ехал Акка через Акка Смотрит Акка в Акка Акка Сунул Акка Акка в Акка Акка Акка Акка Акка * * Ode to Akka in russian
  • 51. ● Hiring is hard Challenges
  • 52. ● Hiring is hard ○ Scala is a talent attraction Challenges
  • 53. ● Hiring is hard ○ Scala is a talent attraction ○ In avg: 0.5 interview per month Challenges
  • 54. ● Hiring is hard ● Settling team standards and code convention Challenges
  • 55. ● Hiring is hard ● Settling team standards and code convention ○ Tools are not there yet Challenges
  • 56. ● Hiring is hard ● Settling team standards and code convention ○ Tools are not there yet ○ Between "OCaml" and "Java" fires Challenges
  • 57. ● Hiring is hard ● Settling team standards and code convention ○ Tools are not there yet ○ Between "OCaml" and "Java" fires ○ "Effective scala" by Twitter and "Scala style guide" might help (a bit) Challenges
  • 58. The greatest code-review mystery of all times if (option.isDefined) { .. } option.foreach { .. } option match { case Some(x) => .. case None => .. } How to deal with scala.Option ?
  • 59. The greatest code-review mystery of all times if (option.isDefined) { .. } option.foreach { .. } option match { case Some(x) => .. case None => .. } How to deal with scala.Option ?
  • 61. aka
  • 62. 5 stages of grief
  • 63. 1. Denial 2. Anger 3. Bargaining 4. Depression 5. Acceptance 5 stages of grief
  • 64. 1. Denial 2. Anger 3. Bargaining 4. Depression 5. Acceptance 5 stages of grief
  • 65. 1. Denial 2. Anger 3. Bargaining 4. Depression 5. Acceptance 5 stages of grief
  • 66. 1. Denial 2. Anger 3. Bargaining 4. Depression 5. Acceptance 5 stages of grief
  • 67. 1. Denial 2. Anger 3. Bargaining 4. Depression 5. Acceptance 5 stages of grief
  • 68. 1. Denial 2. Anger 3. Bargaining 4. Depression 5. Acceptance 5 stages of grief