SlideShare una empresa de Scribd logo
1 de 36
Descargar para leer sin conexión
Scala Frustrations
in Real Development
Naoki Takezoe
@takezoen

NTT-DATA INTELLILINK
Abstract
• Scala is pretty good for real development.
• However Scala has also some bad points.
• Please note for these points when you introduce
  Scala into real development.
Scala 300 Recipes from Shoeisha
• Includes 300 Practical Scala
  Recipes.
• from Basic Scala topics to
  frameworks and tools.

Covers Play2, Akka, sbt, scaladoc, ScalaIDE,
ScalaTest, Specs2, Scalatra, ScalaQuery,
Anorm, Casbah, spray, scala-io, scala-time,
sjson, util-eval, scalaxb, Dispatch and more.
Why we are using Scala?
• Decrease costs of system development.
• We felt the limit of Java several years ago.
• Scala might be a breakthrough?
About Our Project
• Porting Java based web application to Scala.
• Over 170 HTMLs and 40,000 lines.
• 5 members on 6 months.

Before                        After
 Seasar2                      Play2 (Customized)
 Apache Click                 ScalaQuery (Cuztomized)
 S2JDBC                       PostgreSQL
 PostgreSQL + Tsearch         Apache Solr
 Raw JavaScript               jQuery + jQuery UI
Benefits of Scala
• Decrease amount of source code
 ▫ 40%-50% OFF
 ▫ Better abstraction techniques
• Decrease bugs
 ▫ More type safe
 ▫ Immutable data types
• Java Interoperability
 ▫ Many Java based Frameworks and Libraries are
   available
 ▫ Easy to port existing Java software
Benefits of Scala
• Decrease amount of source code
 ▫ 40%-50% OFF
 ▫ Better abstraction techniques
 Flexibility and Safety
• Decrease bugs
 ▫ More type safe
 ▫ Immutable data types
• Java Interoperability
 ▫ Many Java based Frameworks and Libraries are
   available
 ▫ Easy to port existing Java software
Long compilation time
• Compilation is so much heavy.
• Painful for large application development.
Solution
 Buy high spec machines
 Asynchronous and automated build
ScalaIDE is heavy
• We meet a sandglass frequently.
Solution
 1. Turn off the incremental builder
 2. Turn off the code completion
 3. Try other IDE or text editor
sbt is NOT Simple Build Tool
• When we get a trouble, difficult to find a reason.
• Rapid version up causes compatibility problem
  of sbt plugins.
Solution
 We really need SBT in Action!
Long compilation time
• Many code generation and template compilation.
• Development mode is slow also.
Solution
 Buy high spec machines
 Divide large project
 play2-fastassets decreases request
Inflexible Validation
• Client-side validation is not provided.
• Error Message can’t be contained field name.
Solution
 Original client-side validation framework
 based on Play2’s form definition

 Original helper to display error messages
Anorm is too simple
•   We have to write all SQL.
•   Magic does not already exist.
•   SQL is not type safe.
•   No support for dynamic SQL.
Solution
 Use other ORMs such as ScalaQuery.
 We used a combination of scalaquery-magic
 scalagen and mirage-scala.
Function22 Problem in form definition
• a.k.a. Tuple22 Problem
• Form can not have over 18 properties.
 val userForm = Form(
   mapping(
    "firstName“      -> text,
    "lastName“       -> text,
    "mailAddress“    -> email,
    "password“       -> text,
    ...                               Max   18 properties
    "tel“            -> text,
    "mobile“         -> text,
    "company“        -> text,
    "department“     -> text
   )(UserInfo.apply)(UserInfo.unapply)
 )
Solution
 Nested definition, BUT it’s not expectable.
   val userForm = Form(
     mapping(
      "firstName"      -> text,
      "lastName"       -> text,
      "mailAddress"    -> email,
      "password"       -> text,
      "companyInfo" -> mapping(
       "company"       -> text,
       "department"    -> text
      )(CompanyInfo.apply)(CompanyInfo.unapply)
     )(UserInfo.apply)(UserInfo.unapply)
   )
No Servlet and HttpSession
• Hard to port existing Java based web apps.
• We want to run Play2 on the servlet container by
  un-technical reasons.
Solution
 play2-war-plugin packs Play2 apps to war.

 play2-httpsession provides HttpSession
 by using with play2-war-plugin.
solr-scala-client
https://github.com/takezoe/solr-scala-client

• Simple wrapper of SolrJ for Scala.
• Query converter using parser combinator.
import jp.sf.amateras.solr.scala._

val client = new SolrClient("http://localhost:8983/solr")

val result = client.query("name: ?name?")
 .getResultAsMap(Map("name" -> "ThinkPad & X201s"))
  // => name:("ThinkPad" AND "X201s")

result.documents.foreach { doc: Map[String, Any] =>
  ...
}
scalagen
https://github.com/takezoe/scalagen

•   Code Generator from RDBMS.
•   Supports Anorm and ScalaQuery in the current version.
•   Easy to add support for other ORMs.
•   Work as CLI and sbt plugin.
seq(jp.sf.amateras.scalagen.ScalagenPlugin.scalagenSettings: _*)

scalagenConfiguration := jp.sf.amateras.scalagen.Settings(
  // for ScalaQuery
  generator = new jp.sf.amateras.scalagen.ScalaQueryGenerator(),
  // for Anorm
  //generator = new jp.sf.amateras.scalagen.ScalaQueryGenerator(),
  driver = "org.hsqldb.jdbcDriver",
  url = "jdbc:hsqldb:hsql://localhost/",
  username = "sa",
  password = ""
)
scalaquery-magic
https://github.com/shimamoto/scalaquery-magic

• Extends ScalaQuery.
• Make a Magic (like old Anorm’s Magic) by code
  generation using scalagen.
    val userInfoDao = new UserInfoDao()
    // SELECT by ID
    val userInfo = userInfoDao.selectById(1)
    // INSERT
    userInfoDao.insert(UserInfo(DEFAULT[Int], 'userName', 'password'))
    // UPDATE
    userInfoDao.update(userInfo.copy(userName = 'newName'))
    // DELETE by ID
    userInfoDao.deleteById(1)
mirage-scala
https://github.com/takezoe/mirage-scala

• SQL Centric ORM similar to Anorm.
• Executable SQL template called 2waySQL.
SLEECT USER_ID, USER_NAME, PASSWORD
FROM USER_INFO
/*BEGIN*/
WHERE
  /*IF userId != null*/
   USER_ID = /*userId*/1
  /*END*/
 /*IF userId != null*/
   USER_NAME = /*userName*/ 'takezoe'
  /*END*/
/*END*/
play2-httpsession
https://github.com/takezoe/play2-httpsession

• Provide HttpSession for Play2 applications.
• Work with play2-war-plugin.
import jp.sf.amateras.play2.httpsession.HttpSessionSupport._

def index = Action { implicit request =>
 // retrieve the object from HttpSession
 val value: Option[String] = HttpSession[String]("key")

    Ok(value).withHttpSession {
      // store objects into HttpSession
      "key" -> "value"
    }
}
play2-fastassets
https://github.com/takezoe/play2-fastassets

• Decrease amount of request to external CSS,
  JavaScript and images by browser cache.
@(title: String)(content: Html)
@import jp.sf.amateras.play2.fastassets.FastAssets
<!DOCTYPE html>
<html>
 <head>
  <title>@title</title>
  <link rel="stylesheet" media="screen" href="@FastAssets.at("stylesheets/main.css")">
  <link rel="shortcut icon" type="image/png" href="@FastAssets.at("images/favicon.png")">
  <script src="@FastAssets.at("javascripts/jquery-1.7.1.min.js")" type="text/javascript"></script>
 </head>
 <body>
  @content
 </body>
</html>
Scala is practical
• You are evangelists of Scala.
• Please introduce Scala in your work.
• But so carefully, especially in the large project.
Scala is now glowing up!
• This way along which Java passed.
• Time will solve these problems.
• We can contribute Scala glowing.
Scala Frustrations

Más contenido relacionado

La actualidad más candente

스프링 코어 강의 2부 - Java 구성을 활용한 스프링 코어 사용
스프링 코어 강의 2부 - Java 구성을 활용한 스프링 코어 사용스프링 코어 강의 2부 - Java 구성을 활용한 스프링 코어 사용
스프링 코어 강의 2부 - Java 구성을 활용한 스프링 코어 사용Sungchul Park
 
High Performance Django
High Performance DjangoHigh Performance Django
High Performance DjangoDjangoCon2008
 
The DOM is a Mess @ Yahoo
The DOM is a Mess @ YahooThe DOM is a Mess @ Yahoo
The DOM is a Mess @ Yahoojeresig
 
Using npm to Manage Your Projects for Fun and Profit - USEFUL INFO IN NOTES!
Using npm to Manage Your Projects for Fun and Profit - USEFUL INFO IN NOTES!Using npm to Manage Your Projects for Fun and Profit - USEFUL INFO IN NOTES!
Using npm to Manage Your Projects for Fun and Profit - USEFUL INFO IN NOTES!async_io
 
ニコニコ動画を検索可能にしてみよう
ニコニコ動画を検索可能にしてみようニコニコ動画を検索可能にしてみよう
ニコニコ動画を検索可能にしてみようgenta kaneyama
 
Angular 1 + es6
Angular 1 + es6Angular 1 + es6
Angular 1 + es6장현 한
 
Getting started with Elasticsearch and .NET
Getting started with Elasticsearch and .NETGetting started with Elasticsearch and .NET
Getting started with Elasticsearch and .NETTomas Jansson
 
JRuby @ Boulder Ruby
JRuby @ Boulder RubyJRuby @ Boulder Ruby
JRuby @ Boulder RubyNick Sieger
 
High Performance XQuery Processing in PHP with Zorba by Vikram Vaswani
High Performance XQuery Processing in PHP with Zorba by Vikram VaswaniHigh Performance XQuery Processing in PHP with Zorba by Vikram Vaswani
High Performance XQuery Processing in PHP with Zorba by Vikram Vaswanivvaswani
 
Going crazy with Node.JS and CakePHP
Going crazy with Node.JS and CakePHPGoing crazy with Node.JS and CakePHP
Going crazy with Node.JS and CakePHPMariano Iglesias
 
Java FX 2.0 - A Developer's Guide
Java FX 2.0 - A Developer's GuideJava FX 2.0 - A Developer's Guide
Java FX 2.0 - A Developer's GuideStephen Chin
 
React, Redux and es6/7
React, Redux and es6/7React, Redux and es6/7
React, Redux and es6/7Dongho Cho
 
연구자 및 교육자를 위한 계산 및 분석 플랫폼 설계 - PyCon KR 2015
연구자 및 교육자를 위한 계산 및 분석 플랫폼 설계 - PyCon KR 2015연구자 및 교육자를 위한 계산 및 분석 플랫폼 설계 - PyCon KR 2015
연구자 및 교육자를 위한 계산 및 분석 플랫폼 설계 - PyCon KR 2015Jeongkyu Shin
 
ゼロから始めるScalaプロジェクト
ゼロから始めるScalaプロジェクトゼロから始めるScalaプロジェクト
ゼロから始めるScalaプロジェクトRyuichi ITO
 
MongoDB: tips, trick and hacks
MongoDB: tips, trick and hacksMongoDB: tips, trick and hacks
MongoDB: tips, trick and hacksScott Hernandez
 
Building your first Node app with Connect & Express
Building your first Node app with Connect & ExpressBuilding your first Node app with Connect & Express
Building your first Node app with Connect & ExpressChristian Joudrey
 
No REST for the Wicked: REST and Catalyst
No REST for the Wicked: REST and CatalystNo REST for the Wicked: REST and Catalyst
No REST for the Wicked: REST and CatalystJay Shirley
 

La actualidad más candente (20)

스프링 코어 강의 2부 - Java 구성을 활용한 스프링 코어 사용
스프링 코어 강의 2부 - Java 구성을 활용한 스프링 코어 사용스프링 코어 강의 2부 - Java 구성을 활용한 스프링 코어 사용
스프링 코어 강의 2부 - Java 구성을 활용한 스프링 코어 사용
 
High Performance Django
High Performance DjangoHigh Performance Django
High Performance Django
 
The DOM is a Mess @ Yahoo
The DOM is a Mess @ YahooThe DOM is a Mess @ Yahoo
The DOM is a Mess @ Yahoo
 
Using npm to Manage Your Projects for Fun and Profit - USEFUL INFO IN NOTES!
Using npm to Manage Your Projects for Fun and Profit - USEFUL INFO IN NOTES!Using npm to Manage Your Projects for Fun and Profit - USEFUL INFO IN NOTES!
Using npm to Manage Your Projects for Fun and Profit - USEFUL INFO IN NOTES!
 
ニコニコ動画を検索可能にしてみよう
ニコニコ動画を検索可能にしてみようニコニコ動画を検索可能にしてみよう
ニコニコ動画を検索可能にしてみよう
 
Angular 1 + es6
Angular 1 + es6Angular 1 + es6
Angular 1 + es6
 
Getting started with Elasticsearch and .NET
Getting started with Elasticsearch and .NETGetting started with Elasticsearch and .NET
Getting started with Elasticsearch and .NET
 
JRuby @ Boulder Ruby
JRuby @ Boulder RubyJRuby @ Boulder Ruby
JRuby @ Boulder Ruby
 
High Performance XQuery Processing in PHP with Zorba by Vikram Vaswani
High Performance XQuery Processing in PHP with Zorba by Vikram VaswaniHigh Performance XQuery Processing in PHP with Zorba by Vikram Vaswani
High Performance XQuery Processing in PHP with Zorba by Vikram Vaswani
 
Going crazy with Node.JS and CakePHP
Going crazy with Node.JS and CakePHPGoing crazy with Node.JS and CakePHP
Going crazy with Node.JS and CakePHP
 
Java FX 2.0 - A Developer's Guide
Java FX 2.0 - A Developer's GuideJava FX 2.0 - A Developer's Guide
Java FX 2.0 - A Developer's Guide
 
React, Redux and es6/7
React, Redux and es6/7React, Redux and es6/7
React, Redux and es6/7
 
Oracle adapters for Ruby ORMs
Oracle adapters for Ruby ORMsOracle adapters for Ruby ORMs
Oracle adapters for Ruby ORMs
 
연구자 및 교육자를 위한 계산 및 분석 플랫폼 설계 - PyCon KR 2015
연구자 및 교육자를 위한 계산 및 분석 플랫폼 설계 - PyCon KR 2015연구자 및 교육자를 위한 계산 및 분석 플랫폼 설계 - PyCon KR 2015
연구자 및 교육자를 위한 계산 및 분석 플랫폼 설계 - PyCon KR 2015
 
Dropwizard
DropwizardDropwizard
Dropwizard
 
HTML,CSS Next
HTML,CSS NextHTML,CSS Next
HTML,CSS Next
 
ゼロから始めるScalaプロジェクト
ゼロから始めるScalaプロジェクトゼロから始めるScalaプロジェクト
ゼロから始めるScalaプロジェクト
 
MongoDB: tips, trick and hacks
MongoDB: tips, trick and hacksMongoDB: tips, trick and hacks
MongoDB: tips, trick and hacks
 
Building your first Node app with Connect & Express
Building your first Node app with Connect & ExpressBuilding your first Node app with Connect & Express
Building your first Node app with Connect & Express
 
No REST for the Wicked: REST and Catalyst
No REST for the Wicked: REST and CatalystNo REST for the Wicked: REST and Catalyst
No REST for the Wicked: REST and Catalyst
 

Similar a Scala Frustrations

Solid And Sustainable Development in Scala
Solid And Sustainable Development in ScalaSolid And Sustainable Development in Scala
Solid And Sustainable Development in ScalaKazuhiro Sera
 
Solid and Sustainable Development in Scala
Solid and Sustainable Development in ScalaSolid and Sustainable Development in Scala
Solid and Sustainable Development in Scalascalaconfjp
 
Scala in a wild enterprise
Scala in a wild enterpriseScala in a wild enterprise
Scala in a wild enterpriseRafael Bagmanov
 
Rafael Bagmanov «Scala in a wild enterprise»
Rafael Bagmanov «Scala in a wild enterprise»Rafael Bagmanov «Scala in a wild enterprise»
Rafael Bagmanov «Scala in a wild enterprise»e-Legion
 
Alberto Paro - Hands on Scala.js
Alberto Paro - Hands on Scala.jsAlberto Paro - Hands on Scala.js
Alberto Paro - Hands on Scala.jsScala Italy
 
Scala Italy 2015 - Hands On ScalaJS
Scala Italy 2015 - Hands On ScalaJSScala Italy 2015 - Hands On ScalaJS
Scala Italy 2015 - Hands On ScalaJSAlberto Paro
 
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...Codemotion
 
Top Ten Java Defense for Web Applications v2
Top Ten Java Defense for Web Applications v2Top Ten Java Defense for Web Applications v2
Top Ten Java Defense for Web Applications v2Jim Manico
 
Building Concurrent WebObjects applications with Scala
Building Concurrent WebObjects applications with ScalaBuilding Concurrent WebObjects applications with Scala
Building Concurrent WebObjects applications with ScalaWO Community
 
Typesafe stack - Scala, Akka and Play
Typesafe stack - Scala, Akka and PlayTypesafe stack - Scala, Akka and Play
Typesafe stack - Scala, Akka and PlayLuka Zakrajšek
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...Fabio Franzini
 
20151010 my sq-landjavav2a
20151010 my sq-landjavav2a20151010 my sq-landjavav2a
20151010 my sq-landjavav2aIvan Ma
 
Introducing the Seneca MVP framework for Node.js
Introducing the Seneca MVP framework for Node.jsIntroducing the Seneca MVP framework for Node.js
Introducing the Seneca MVP framework for Node.jsRichard Rodger
 
Spring Day | Spring and Scala | Eberhard Wolff
Spring Day | Spring and Scala | Eberhard WolffSpring Day | Spring and Scala | Eberhard Wolff
Spring Day | Spring and Scala | Eberhard WolffJAX London
 

Similar a Scala Frustrations (20)

Solid And Sustainable Development in Scala
Solid And Sustainable Development in ScalaSolid And Sustainable Development in Scala
Solid And Sustainable Development in Scala
 
Solid and Sustainable Development in Scala
Solid and Sustainable Development in ScalaSolid and Sustainable Development in Scala
Solid and Sustainable Development in Scala
 
Scala in a wild enterprise
Scala in a wild enterpriseScala in a wild enterprise
Scala in a wild enterprise
 
Rafael Bagmanov «Scala in a wild enterprise»
Rafael Bagmanov «Scala in a wild enterprise»Rafael Bagmanov «Scala in a wild enterprise»
Rafael Bagmanov «Scala in a wild enterprise»
 
Alberto Paro - Hands on Scala.js
Alberto Paro - Hands on Scala.jsAlberto Paro - Hands on Scala.js
Alberto Paro - Hands on Scala.js
 
Scala Italy 2015 - Hands On ScalaJS
Scala Italy 2015 - Hands On ScalaJSScala Italy 2015 - Hands On ScalaJS
Scala Italy 2015 - Hands On ScalaJS
 
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
 
Gradle
GradleGradle
Gradle
 
Top Ten Java Defense for Web Applications v2
Top Ten Java Defense for Web Applications v2Top Ten Java Defense for Web Applications v2
Top Ten Java Defense for Web Applications v2
 
Building Concurrent WebObjects applications with Scala
Building Concurrent WebObjects applications with ScalaBuilding Concurrent WebObjects applications with Scala
Building Concurrent WebObjects applications with Scala
 
Typesafe stack - Scala, Akka and Play
Typesafe stack - Scala, Akka and PlayTypesafe stack - Scala, Akka and Play
Typesafe stack - Scala, Akka and Play
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
Full Stack Scala
Full Stack ScalaFull Stack Scala
Full Stack Scala
 
Spring data requery
Spring data requerySpring data requery
Spring data requery
 
20151010 my sq-landjavav2a
20151010 my sq-landjavav2a20151010 my sq-landjavav2a
20151010 my sq-landjavav2a
 
Introducing the Seneca MVP framework for Node.js
Introducing the Seneca MVP framework for Node.jsIntroducing the Seneca MVP framework for Node.js
Introducing the Seneca MVP framework for Node.js
 
20120816 nodejsdublin
20120816 nodejsdublin20120816 nodejsdublin
20120816 nodejsdublin
 
Wider than rails
Wider than railsWider than rails
Wider than rails
 
Scala and Spring
Scala and SpringScala and Spring
Scala and Spring
 
Spring Day | Spring and Scala | Eberhard Wolff
Spring Day | Spring and Scala | Eberhard WolffSpring Day | Spring and Scala | Eberhard Wolff
Spring Day | Spring and Scala | Eberhard Wolff
 

Más de takezoe

Journey of Migrating Millions of Queries on The Cloud
Journey of Migrating Millions of Queries on The CloudJourney of Migrating Millions of Queries on The Cloud
Journey of Migrating Millions of Queries on The Cloudtakezoe
 
GitBucket: Open source self-hosting Git server built by Scala
GitBucket: Open source self-hosting Git server built by ScalaGitBucket: Open source self-hosting Git server built by Scala
GitBucket: Open source self-hosting Git server built by Scalatakezoe
 
Testing Distributed Query Engine as a Service
Testing Distributed Query Engine as a ServiceTesting Distributed Query Engine as a Service
Testing Distributed Query Engine as a Servicetakezoe
 
Revisit Dependency Injection in scala
Revisit Dependency Injection in scalaRevisit Dependency Injection in scala
Revisit Dependency Injection in scalatakezoe
 
How to keep maintainability of long life Scala applications
How to keep maintainability of long life Scala applicationsHow to keep maintainability of long life Scala applications
How to keep maintainability of long life Scala applicationstakezoe
 
頑張りすぎないScala
頑張りすぎないScala頑張りすぎないScala
頑張りすぎないScalatakezoe
 
GitBucket: Git Centric Software Development Platform by Scala
GitBucket:  Git Centric Software Development Platform by ScalaGitBucket:  Git Centric Software Development Platform by Scala
GitBucket: Git Centric Software Development Platform by Scalatakezoe
 
Non-Functional Programming in Scala
Non-Functional Programming in ScalaNon-Functional Programming in Scala
Non-Functional Programming in Scalatakezoe
 
Scala警察のすすめ
Scala警察のすすめScala警察のすすめ
Scala警察のすすめtakezoe
 
Scala製機械学習サーバ「Apache PredictionIO」
Scala製機械学習サーバ「Apache PredictionIO」Scala製機械学習サーバ「Apache PredictionIO」
Scala製機械学習サーバ「Apache PredictionIO」takezoe
 
The best of AltJava is Xtend
The best of AltJava is XtendThe best of AltJava is Xtend
The best of AltJava is Xtendtakezoe
 
Scala Warrior and type-safe front-end development with Scala.js
Scala Warrior and type-safe front-end development with Scala.jsScala Warrior and type-safe front-end development with Scala.js
Scala Warrior and type-safe front-end development with Scala.jstakezoe
 
Tracing Microservices with Zipkin
Tracing Microservices with ZipkinTracing Microservices with Zipkin
Tracing Microservices with Zipkintakezoe
 
Type-safe front-end development with Scala
Type-safe front-end development with ScalaType-safe front-end development with Scala
Type-safe front-end development with Scalatakezoe
 
Scala Frameworks for Web Application 2016
Scala Frameworks for Web Application 2016Scala Frameworks for Web Application 2016
Scala Frameworks for Web Application 2016takezoe
 
Macro in Scala
Macro in ScalaMacro in Scala
Macro in Scalatakezoe
 
Java9 and Project Jigsaw
Java9 and Project JigsawJava9 and Project Jigsaw
Java9 and Project Jigsawtakezoe
 
Reactive database access with Slick3
Reactive database access with Slick3Reactive database access with Slick3
Reactive database access with Slick3takezoe
 
markedj: The best of markdown processor on JVM
markedj: The best of markdown processor on JVMmarkedj: The best of markdown processor on JVM
markedj: The best of markdown processor on JVMtakezoe
 
ネタじゃないScala.js
ネタじゃないScala.jsネタじゃないScala.js
ネタじゃないScala.jstakezoe
 

Más de takezoe (20)

Journey of Migrating Millions of Queries on The Cloud
Journey of Migrating Millions of Queries on The CloudJourney of Migrating Millions of Queries on The Cloud
Journey of Migrating Millions of Queries on The Cloud
 
GitBucket: Open source self-hosting Git server built by Scala
GitBucket: Open source self-hosting Git server built by ScalaGitBucket: Open source self-hosting Git server built by Scala
GitBucket: Open source self-hosting Git server built by Scala
 
Testing Distributed Query Engine as a Service
Testing Distributed Query Engine as a ServiceTesting Distributed Query Engine as a Service
Testing Distributed Query Engine as a Service
 
Revisit Dependency Injection in scala
Revisit Dependency Injection in scalaRevisit Dependency Injection in scala
Revisit Dependency Injection in scala
 
How to keep maintainability of long life Scala applications
How to keep maintainability of long life Scala applicationsHow to keep maintainability of long life Scala applications
How to keep maintainability of long life Scala applications
 
頑張りすぎないScala
頑張りすぎないScala頑張りすぎないScala
頑張りすぎないScala
 
GitBucket: Git Centric Software Development Platform by Scala
GitBucket:  Git Centric Software Development Platform by ScalaGitBucket:  Git Centric Software Development Platform by Scala
GitBucket: Git Centric Software Development Platform by Scala
 
Non-Functional Programming in Scala
Non-Functional Programming in ScalaNon-Functional Programming in Scala
Non-Functional Programming in Scala
 
Scala警察のすすめ
Scala警察のすすめScala警察のすすめ
Scala警察のすすめ
 
Scala製機械学習サーバ「Apache PredictionIO」
Scala製機械学習サーバ「Apache PredictionIO」Scala製機械学習サーバ「Apache PredictionIO」
Scala製機械学習サーバ「Apache PredictionIO」
 
The best of AltJava is Xtend
The best of AltJava is XtendThe best of AltJava is Xtend
The best of AltJava is Xtend
 
Scala Warrior and type-safe front-end development with Scala.js
Scala Warrior and type-safe front-end development with Scala.jsScala Warrior and type-safe front-end development with Scala.js
Scala Warrior and type-safe front-end development with Scala.js
 
Tracing Microservices with Zipkin
Tracing Microservices with ZipkinTracing Microservices with Zipkin
Tracing Microservices with Zipkin
 
Type-safe front-end development with Scala
Type-safe front-end development with ScalaType-safe front-end development with Scala
Type-safe front-end development with Scala
 
Scala Frameworks for Web Application 2016
Scala Frameworks for Web Application 2016Scala Frameworks for Web Application 2016
Scala Frameworks for Web Application 2016
 
Macro in Scala
Macro in ScalaMacro in Scala
Macro in Scala
 
Java9 and Project Jigsaw
Java9 and Project JigsawJava9 and Project Jigsaw
Java9 and Project Jigsaw
 
Reactive database access with Slick3
Reactive database access with Slick3Reactive database access with Slick3
Reactive database access with Slick3
 
markedj: The best of markdown processor on JVM
markedj: The best of markdown processor on JVMmarkedj: The best of markdown processor on JVM
markedj: The best of markdown processor on JVM
 
ネタじゃないScala.js
ネタじゃないScala.jsネタじゃないScala.js
ネタじゃないScala.js
 

Último

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
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
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
 
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
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
"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
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
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
 
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
 
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
 
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
 
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
 
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
 

Último (20)

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
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
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
 
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...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
"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 ...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
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, ...
 
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
 
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
 
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​
 
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
 
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
 

Scala Frustrations

  • 1. Scala Frustrations in Real Development Naoki Takezoe @takezoen NTT-DATA INTELLILINK
  • 2. Abstract • Scala is pretty good for real development. • However Scala has also some bad points. • Please note for these points when you introduce Scala into real development.
  • 3. Scala 300 Recipes from Shoeisha • Includes 300 Practical Scala Recipes. • from Basic Scala topics to frameworks and tools. Covers Play2, Akka, sbt, scaladoc, ScalaIDE, ScalaTest, Specs2, Scalatra, ScalaQuery, Anorm, Casbah, spray, scala-io, scala-time, sjson, util-eval, scalaxb, Dispatch and more.
  • 4. Why we are using Scala? • Decrease costs of system development. • We felt the limit of Java several years ago. • Scala might be a breakthrough?
  • 5. About Our Project • Porting Java based web application to Scala. • Over 170 HTMLs and 40,000 lines. • 5 members on 6 months. Before After  Seasar2  Play2 (Customized)  Apache Click  ScalaQuery (Cuztomized)  S2JDBC  PostgreSQL  PostgreSQL + Tsearch  Apache Solr  Raw JavaScript  jQuery + jQuery UI
  • 6. Benefits of Scala • Decrease amount of source code ▫ 40%-50% OFF ▫ Better abstraction techniques • Decrease bugs ▫ More type safe ▫ Immutable data types • Java Interoperability ▫ Many Java based Frameworks and Libraries are available ▫ Easy to port existing Java software
  • 7. Benefits of Scala • Decrease amount of source code ▫ 40%-50% OFF ▫ Better abstraction techniques Flexibility and Safety • Decrease bugs ▫ More type safe ▫ Immutable data types • Java Interoperability ▫ Many Java based Frameworks and Libraries are available ▫ Easy to port existing Java software
  • 8.
  • 9. Long compilation time • Compilation is so much heavy. • Painful for large application development.
  • 10. Solution Buy high spec machines Asynchronous and automated build
  • 11. ScalaIDE is heavy • We meet a sandglass frequently.
  • 12. Solution 1. Turn off the incremental builder 2. Turn off the code completion 3. Try other IDE or text editor
  • 13. sbt is NOT Simple Build Tool • When we get a trouble, difficult to find a reason. • Rapid version up causes compatibility problem of sbt plugins.
  • 14. Solution We really need SBT in Action!
  • 15.
  • 16. Long compilation time • Many code generation and template compilation. • Development mode is slow also.
  • 17. Solution Buy high spec machines Divide large project play2-fastassets decreases request
  • 18. Inflexible Validation • Client-side validation is not provided. • Error Message can’t be contained field name.
  • 19. Solution Original client-side validation framework based on Play2’s form definition Original helper to display error messages
  • 20. Anorm is too simple • We have to write all SQL. • Magic does not already exist. • SQL is not type safe. • No support for dynamic SQL.
  • 21. Solution Use other ORMs such as ScalaQuery. We used a combination of scalaquery-magic scalagen and mirage-scala.
  • 22. Function22 Problem in form definition • a.k.a. Tuple22 Problem • Form can not have over 18 properties. val userForm = Form( mapping( "firstName“ -> text, "lastName“ -> text, "mailAddress“ -> email, "password“ -> text, ... Max 18 properties "tel“ -> text, "mobile“ -> text, "company“ -> text, "department“ -> text )(UserInfo.apply)(UserInfo.unapply) )
  • 23. Solution Nested definition, BUT it’s not expectable. val userForm = Form( mapping( "firstName" -> text, "lastName" -> text, "mailAddress" -> email, "password" -> text, "companyInfo" -> mapping( "company" -> text, "department" -> text )(CompanyInfo.apply)(CompanyInfo.unapply) )(UserInfo.apply)(UserInfo.unapply) )
  • 24. No Servlet and HttpSession • Hard to port existing Java based web apps. • We want to run Play2 on the servlet container by un-technical reasons.
  • 25. Solution play2-war-plugin packs Play2 apps to war. play2-httpsession provides HttpSession by using with play2-war-plugin.
  • 26.
  • 27. solr-scala-client https://github.com/takezoe/solr-scala-client • Simple wrapper of SolrJ for Scala. • Query converter using parser combinator. import jp.sf.amateras.solr.scala._ val client = new SolrClient("http://localhost:8983/solr") val result = client.query("name: ?name?") .getResultAsMap(Map("name" -> "ThinkPad & X201s")) // => name:("ThinkPad" AND "X201s") result.documents.foreach { doc: Map[String, Any] => ... }
  • 28. scalagen https://github.com/takezoe/scalagen • Code Generator from RDBMS. • Supports Anorm and ScalaQuery in the current version. • Easy to add support for other ORMs. • Work as CLI and sbt plugin. seq(jp.sf.amateras.scalagen.ScalagenPlugin.scalagenSettings: _*) scalagenConfiguration := jp.sf.amateras.scalagen.Settings( // for ScalaQuery generator = new jp.sf.amateras.scalagen.ScalaQueryGenerator(), // for Anorm //generator = new jp.sf.amateras.scalagen.ScalaQueryGenerator(), driver = "org.hsqldb.jdbcDriver", url = "jdbc:hsqldb:hsql://localhost/", username = "sa", password = "" )
  • 29. scalaquery-magic https://github.com/shimamoto/scalaquery-magic • Extends ScalaQuery. • Make a Magic (like old Anorm’s Magic) by code generation using scalagen. val userInfoDao = new UserInfoDao() // SELECT by ID val userInfo = userInfoDao.selectById(1) // INSERT userInfoDao.insert(UserInfo(DEFAULT[Int], 'userName', 'password')) // UPDATE userInfoDao.update(userInfo.copy(userName = 'newName')) // DELETE by ID userInfoDao.deleteById(1)
  • 30. mirage-scala https://github.com/takezoe/mirage-scala • SQL Centric ORM similar to Anorm. • Executable SQL template called 2waySQL. SLEECT USER_ID, USER_NAME, PASSWORD FROM USER_INFO /*BEGIN*/ WHERE /*IF userId != null*/ USER_ID = /*userId*/1 /*END*/ /*IF userId != null*/ USER_NAME = /*userName*/ 'takezoe' /*END*/ /*END*/
  • 31. play2-httpsession https://github.com/takezoe/play2-httpsession • Provide HttpSession for Play2 applications. • Work with play2-war-plugin. import jp.sf.amateras.play2.httpsession.HttpSessionSupport._ def index = Action { implicit request => // retrieve the object from HttpSession val value: Option[String] = HttpSession[String]("key") Ok(value).withHttpSession { // store objects into HttpSession "key" -> "value" } }
  • 32. play2-fastassets https://github.com/takezoe/play2-fastassets • Decrease amount of request to external CSS, JavaScript and images by browser cache. @(title: String)(content: Html) @import jp.sf.amateras.play2.fastassets.FastAssets <!DOCTYPE html> <html> <head> <title>@title</title> <link rel="stylesheet" media="screen" href="@FastAssets.at("stylesheets/main.css")"> <link rel="shortcut icon" type="image/png" href="@FastAssets.at("images/favicon.png")"> <script src="@FastAssets.at("javascripts/jquery-1.7.1.min.js")" type="text/javascript"></script> </head> <body> @content </body> </html>
  • 33.
  • 34. Scala is practical • You are evangelists of Scala. • Please introduce Scala in your work. • But so carefully, especially in the large project.
  • 35. Scala is now glowing up! • This way along which Java passed. • Time will solve these problems. • We can contribute Scala glowing.