SlideShare ist ein Scribd-Unternehmen logo
1 von 18
Downloaden Sie, um offline zu lesen
5 Tips to build
long-lasting
Scala OSS
Kazuhiro Sera
@seratch
Scale By The Bay 2018
@seratch
• My name is Kaz (Kazuhiro Sera)
• Happy with Scala for 8 years
• Came from Tokyo, Japan !
• Come and join ScalaMatsuri in June next year! 🙌
• My 2nd talk at Scal(ae) By The Bay 🙏
• Love open source software projects 😍
• Started ScalikeJDBC, Skinny Framework, AWScala, etc
• Took over the maintenance of json4s, Scalate
🍶 🍣 🍱
What is ScalikeJDBC?
• My most long-lasting OSS (7 year history)
• A relational database client library in Scala
• Provide a “Scala-like” (Scala idiomatic) way
• Practical: easy-to-use APIs + less dependencies
• Brief history:
• Started as a simple lib similar to Twitter’s querulous
• Has more functionalities now
• Scala 2.10: String Interpolation, Macros 🎉
• SQL objects, one-to-x extraction, type-safe DSL
Basic usage of ScalikeJDBC
• Only 3 steps to issue a database query:
• 1) Build a SQL object
• 2) Define a function to extract values from ResultSet
• 3) Perform SQL execution with an implicitly passed
database session (which can be transaction-wired)
1)> val q: SQL[Nothing, NoExtractor] = sql"select id, name from members limit 2"
2)> val toTuple: (WrappedResultSet) => (Int, Option[String]) =
| (rs) => (rs.get[Int]("id"), rs.get[Option[String]]("name"))
3)> val rows: Seq[(Int, Option[String])] = q.map(toTuple).list.apply()
[SQL Execution] select id, name from members limit 2; (0 ms)
rows: Seq[(Int, Option[String])] = List((1,Some(Alice)), (2,Some(Bob)))
Other libraries?
• According to the number of stars,
• 1) Slick 2,124
• 2) Quill 1,311
• 3) Doobie 1,283
• 4) ScalikeJDBC 948
• ScalikeJDBC is ranked fourth (Not bad!)
• Try in-memory database example on scalikejdbc.org
• Any feedback? Reach out to me today 🤙
ScalikeJDBC turned 7 yrs old!
Happened during the time
• Scala binary versions: 5
• 2.9.1 ~ 2.9.2 ~ 2.10 ~ 2.11 ~ 2.12 ~ (2.13.0-M5 ~)
• (Prior to 2.10, every single patch version was bin-incompatible)
• JDK major versions: 5
• 7 ~ 8(LTS) ~ 9 ~ 10 ~ 11(LTS) ~
• JDBC API spec minor updates: 3
• 4.1 (JDK7) ~ 4.2 (JDK8) ~ 4.3 (JDK9)
• Added 4.2 APIs when dropping JDK7 support
• sbt migration: 0.13 to 1
• For the sbt plugin generating source code from database
5 tips to build long-lasting OSS
• 1) Find your lifework project
• 2) Be careful to add Scala dependencies
• 3) Stick with binary compatibility
• 4) Provide cross builds
• 5) Have effective CI builds
1) Find your lifework project
• Not specific to Scala OSS
• It’s all about the sustainability of voluntary works
• Two things to know 📝
• Focus on lifework projects
• Many projects terminated due to author’s social events
• e.g. Changing job, having a family, school graduation
• Can continue it regardless of those big changes?
• Difficulty to find successors
• Inconvenient truth; even if you have many users…
• Ideally, continue working on your project somehow
2) Be careful to add Scala deps
• It’s unfortunate that I have to say this but it’s critical
• Two things to know 📝
• "You’re in the same boat with many others”
• 🙅 Major upgrade: have to wait for all releases; it causes
significant delay of your release
• 🙅 Cross builds: can’t do if just one of them doesn’t
• Suggestion: Choose Java over Scala inside
• Not cool… but I have to say it’s a realistic trade-off
• 🙆 Pros: Can make upgrade/cross builds much easier
• 🙅 Cons: Handle null values inside
2’) Work with null in Scala
<<< Working with java.util.List >>>
scala> import scala.collection.JavaConverters._
import scala.collection.JavaConverters._
scala> val j = java.util.Arrays.asList("A", "B", "C")
j: java.util.List[String] = [A, B, C]
scala> val s = j.asScala
s: scala.collection.mutable.Buffer[String] = Buffer(A, B, C)
scala> null.asInstanceOf[java.util.List[String]].asScala // use Option!
res0: scala.collection.mutable.Buffer[String] = null
<<< Working with primitives >>>
scala> val j: java.lang.Integer = null
j: Integer = null
scala> val s: Int = j // auto boxing
s: Int = 0
scala> val s = Option(j).map(Int.unbox)
s: Option[Int] = None
java.util.List can be null.
null.asScala returns null.
A null value can be unexpectedly
converted to the type’s default value.
(0 : scala.Int’s default value)
3) Stick with bin-compatibility
• Bin-compatible?
• Normal situation; not see any runtime linkage errors
• If you break bin-compatibility:
• Painful runtime errors (NoSuchMethodError etc) 😿
• Scala compiler cannot detect runtime issues beforehand
• Two things to do 📝
• Define policies about bin-compatibility guarantee
• Once you released the first stable version
• Surely guarantee binary-compatibility
• Solution: Use MiMa
3’) Use MiMa to ensure that
• Use MiMa (Migration Manager for Scala)
• Can detect syntactic incompatibilities
• Developed and maintained by Lightbend devs
// project/plugins.sbt
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.3.0")
// build.sbt
project.settings(
MimaPlugin.mimaDefaultSettings ++ Seq(
mimaPreviousArtifacts := {
Set("0.1.0", "0.1.1").map { v =>
organization.value % s"${name.value}_${scalaBinaryVersion.value}" % v
}
},
test in Test := {
mimaReportBinaryIssues.value
(test in Test).value
}
)
)
4) Provide cross builds
• Cross builds = publish against multiple Scala bin versions
• Reality: We cannot always use the latest Scala
• Apache Spark took 2 years to support Scala 2.12
• Remember the tip 2) “be careful to add Scala deps”
• Two things to do 📝
• Support latest stable major & its previous major
• To be specific, Scala 2.12 and 2.11 at this moment
• Don’t have many files under src/main/scala-X.Y
• Testing a plenty of code there is hard+time-consuming
5) Have effective CI builds
• Why do we need it?
• To reduce review cost of pull requests
• To merge pull requests with confidence
• You need reliable evidences (regressions, bin-combat, code style, etc)
• Two things to do 📝
• Enable it anyway!
• You can use TravisCI/CircleCI for free
• Automate everything apart from code reviews
• Check bin-compatibility, consistency of code style, cross
builds, multiple JDKs, etc
• Configure matrix builds to cover all patterns
5’) TravisCI Build Example
language: scala
sudo: false
scala:
- 2.11.12
- 2.12.7
- 2.13.0-M5
jdk:
- oraclejdk8
- openjdk11
matrix:
include:
- scala: 2.12.7
jdk: oraclejdk9
script:
sbt ++$TRAVIS_SCALA_VERSION scalafmtCheck test # code formatter check + test
• Scala 2.11 + JDK 8, 11 = 2 builds
• Scala 2.12 + JDK 8, 9, 11 = 3 builds
• Scala 2.13.0-M5 + JDK 8, 11 = 2 builds
Additional 1 matrix build
3 Scala versions * 2 JDKs
= 6 patterns
7 patterns in total
Start with the sbt template!
• sbt project template (aka g8 template)
• Including all techniques in this talk
• Should be a good starting point for you 😎
mkdir my-awesome-library
cd my-awesome-library
sbt new seratch/long-lasting-scala.g8
sbt test
Recap
• You found out about ScalikeJDBC
• Contact me at any time during the conf 🤙
• If you like it, increment the stars (1K soon!)
• 5 tips to build long-lasting Scala OSS
• 1) Find what interests you for years
• 2) Be careful about adding Scala dependencies
• 3) Stick with binary compatibility
• 4) Provide cross builds
• 5) Have effective CI builds

Weitere ähnliche Inhalte

Mehr von Kazuhiro Sera

マイクロサービス運用の所感 #m3dev
マイクロサービス運用の所感 #m3devマイクロサービス運用の所感 #m3dev
マイクロサービス運用の所感 #m3devKazuhiro Sera
 
Scala が支える医療系ウェブサービス #jissenscala
Scala が支える医療系ウェブサービス #jissenscalaScala が支える医療系ウェブサービス #jissenscala
Scala が支える医療系ウェブサービス #jissenscalaKazuhiro Sera
 
Scala on Rails #rakutentech
Scala on Rails #rakutentechScala on Rails #rakutentech
Scala on Rails #rakutentechKazuhiro Sera
 
Solid And Sustainable Development in Scala
Solid And Sustainable Development in ScalaSolid And Sustainable Development in Scala
Solid And Sustainable Development in ScalaKazuhiro Sera
 
Beginning Scala with Skinny Framework #jjug_ccc
Beginning Scala with Skinny Framework #jjug_cccBeginning Scala with Skinny Framework #jjug_ccc
Beginning Scala with Skinny Framework #jjug_cccKazuhiro Sera
 
[Japanese] Skinny Framework で始める Scala #jjug_ccc #ccc_r24
[Japanese] Skinny Framework で始める Scala #jjug_ccc #ccc_r24[Japanese] Skinny Framework で始める Scala #jjug_ccc #ccc_r24
[Japanese] Skinny Framework で始める Scala #jjug_ccc #ccc_r24Kazuhiro Sera
 
Skinny Framework 1.0.0
Skinny Framework 1.0.0Skinny Framework 1.0.0
Skinny Framework 1.0.0Kazuhiro Sera
 
Skinny Framework Progress Situation
Skinny Framework Progress SituationSkinny Framework Progress Situation
Skinny Framework Progress SituationKazuhiro Sera
 
Skinny Framework 進捗どうですか? #fud_scala
Skinny Framework 進捗どうですか? #fud_scalaSkinny Framework 進捗どうですか? #fud_scala
Skinny Framework 進捗どうですか? #fud_scalaKazuhiro Sera
 
テストの運用について #m3dev
テストの運用について #m3devテストの運用について #m3dev
テストの運用について #m3devKazuhiro Sera
 
めんどくさくない Scala #kwkni_scala
めんどくさくない Scala #kwkni_scalaめんどくさくない Scala #kwkni_scala
めんどくさくない Scala #kwkni_scalaKazuhiro Sera
 
歌舞伎座.tech 1 LT - ScalikeJDBC Async & Skinny Framework #kbkz_tech
歌舞伎座.tech 1 LT - ScalikeJDBC Async & Skinny Framework #kbkz_tech歌舞伎座.tech 1 LT - ScalikeJDBC Async & Skinny Framework #kbkz_tech
歌舞伎座.tech 1 LT - ScalikeJDBC Async & Skinny Framework #kbkz_techKazuhiro Sera
 
Kabukiza.tech 1 LT - ScalikeJDBC-Async & Skinny Framework #kbkz_tech
Kabukiza.tech 1 LT - ScalikeJDBC-Async & Skinny Framework #kbkz_techKabukiza.tech 1 LT - ScalikeJDBC-Async & Skinny Framework #kbkz_tech
Kabukiza.tech 1 LT - ScalikeJDBC-Async & Skinny Framework #kbkz_techKazuhiro Sera
 
テストを書くのが嫌いな君へ #m3dev
テストを書くのが嫌いな君へ #m3devテストを書くのが嫌いな君へ #m3dev
テストを書くのが嫌いな君へ #m3devKazuhiro Sera
 
Skinny Controllers, Skinny Models
Skinny Controllers, Skinny ModelsSkinny Controllers, Skinny Models
Skinny Controllers, Skinny ModelsKazuhiro Sera
 
ScalikeJDBC Tutorial for Beginners
ScalikeJDBC Tutorial for BeginnersScalikeJDBC Tutorial for Beginners
ScalikeJDBC Tutorial for BeginnersKazuhiro Sera
 
A Test Code Generator for RSpec Users
A Test Code Generator for RSpec UsersA Test Code Generator for RSpec Users
A Test Code Generator for RSpec UsersKazuhiro Sera
 
プラガブル Play20 Scala
プラガブル Play20 Scalaプラガブル Play20 Scala
プラガブル Play20 ScalaKazuhiro Sera
 
Learning from "Effective Scala"
Learning from "Effective Scala"Learning from "Effective Scala"
Learning from "Effective Scala"Kazuhiro Sera
 

Mehr von Kazuhiro Sera (20)

マイクロサービス運用の所感 #m3dev
マイクロサービス運用の所感 #m3devマイクロサービス運用の所感 #m3dev
マイクロサービス運用の所感 #m3dev
 
Scala が支える医療系ウェブサービス #jissenscala
Scala が支える医療系ウェブサービス #jissenscalaScala が支える医療系ウェブサービス #jissenscala
Scala が支える医療系ウェブサービス #jissenscala
 
Scala on Rails #rakutentech
Scala on Rails #rakutentechScala on Rails #rakutentech
Scala on Rails #rakutentech
 
Solid And Sustainable Development in Scala
Solid And Sustainable Development in ScalaSolid And Sustainable Development in Scala
Solid And Sustainable Development in Scala
 
Beginning Scala with Skinny Framework #jjug_ccc
Beginning Scala with Skinny Framework #jjug_cccBeginning Scala with Skinny Framework #jjug_ccc
Beginning Scala with Skinny Framework #jjug_ccc
 
[Japanese] Skinny Framework で始める Scala #jjug_ccc #ccc_r24
[Japanese] Skinny Framework で始める Scala #jjug_ccc #ccc_r24[Japanese] Skinny Framework で始める Scala #jjug_ccc #ccc_r24
[Japanese] Skinny Framework で始める Scala #jjug_ccc #ccc_r24
 
Skinny Framework 1.0.0
Skinny Framework 1.0.0Skinny Framework 1.0.0
Skinny Framework 1.0.0
 
Skinny Framework Progress Situation
Skinny Framework Progress SituationSkinny Framework Progress Situation
Skinny Framework Progress Situation
 
Skinny Framework 進捗どうですか? #fud_scala
Skinny Framework 進捗どうですか? #fud_scalaSkinny Framework 進捗どうですか? #fud_scala
Skinny Framework 進捗どうですか? #fud_scala
 
テストの運用について #m3dev
テストの運用について #m3devテストの運用について #m3dev
テストの運用について #m3dev
 
めんどくさくない Scala #kwkni_scala
めんどくさくない Scala #kwkni_scalaめんどくさくない Scala #kwkni_scala
めんどくさくない Scala #kwkni_scala
 
歌舞伎座.tech 1 LT - ScalikeJDBC Async & Skinny Framework #kbkz_tech
歌舞伎座.tech 1 LT - ScalikeJDBC Async & Skinny Framework #kbkz_tech歌舞伎座.tech 1 LT - ScalikeJDBC Async & Skinny Framework #kbkz_tech
歌舞伎座.tech 1 LT - ScalikeJDBC Async & Skinny Framework #kbkz_tech
 
Kabukiza.tech 1 LT - ScalikeJDBC-Async & Skinny Framework #kbkz_tech
Kabukiza.tech 1 LT - ScalikeJDBC-Async & Skinny Framework #kbkz_techKabukiza.tech 1 LT - ScalikeJDBC-Async & Skinny Framework #kbkz_tech
Kabukiza.tech 1 LT - ScalikeJDBC-Async & Skinny Framework #kbkz_tech
 
テストを書くのが嫌いな君へ #m3dev
テストを書くのが嫌いな君へ #m3devテストを書くのが嫌いな君へ #m3dev
テストを書くのが嫌いな君へ #m3dev
 
Skinny Controllers, Skinny Models
Skinny Controllers, Skinny ModelsSkinny Controllers, Skinny Models
Skinny Controllers, Skinny Models
 
ScalikeJDBC Tutorial for Beginners
ScalikeJDBC Tutorial for BeginnersScalikeJDBC Tutorial for Beginners
ScalikeJDBC Tutorial for Beginners
 
A Test Code Generator for RSpec Users
A Test Code Generator for RSpec UsersA Test Code Generator for RSpec Users
A Test Code Generator for RSpec Users
 
Crucible @ M3, Inc.
Crucible @ M3, Inc.Crucible @ M3, Inc.
Crucible @ M3, Inc.
 
プラガブル Play20 Scala
プラガブル Play20 Scalaプラガブル Play20 Scala
プラガブル Play20 Scala
 
Learning from "Effective Scala"
Learning from "Effective Scala"Learning from "Effective Scala"
Learning from "Effective Scala"
 

Kürzlich hochgeladen

SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 

Kürzlich hochgeladen (20)

SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 

5 tips to build long-lasting Scala OSS

  • 1. 5 Tips to build long-lasting Scala OSS Kazuhiro Sera @seratch Scale By The Bay 2018
  • 2. @seratch • My name is Kaz (Kazuhiro Sera) • Happy with Scala for 8 years • Came from Tokyo, Japan ! • Come and join ScalaMatsuri in June next year! 🙌 • My 2nd talk at Scal(ae) By The Bay 🙏 • Love open source software projects 😍 • Started ScalikeJDBC, Skinny Framework, AWScala, etc • Took over the maintenance of json4s, Scalate 🍶 🍣 🍱
  • 3. What is ScalikeJDBC? • My most long-lasting OSS (7 year history) • A relational database client library in Scala • Provide a “Scala-like” (Scala idiomatic) way • Practical: easy-to-use APIs + less dependencies • Brief history: • Started as a simple lib similar to Twitter’s querulous • Has more functionalities now • Scala 2.10: String Interpolation, Macros 🎉 • SQL objects, one-to-x extraction, type-safe DSL
  • 4. Basic usage of ScalikeJDBC • Only 3 steps to issue a database query: • 1) Build a SQL object • 2) Define a function to extract values from ResultSet • 3) Perform SQL execution with an implicitly passed database session (which can be transaction-wired) 1)> val q: SQL[Nothing, NoExtractor] = sql"select id, name from members limit 2" 2)> val toTuple: (WrappedResultSet) => (Int, Option[String]) = | (rs) => (rs.get[Int]("id"), rs.get[Option[String]]("name")) 3)> val rows: Seq[(Int, Option[String])] = q.map(toTuple).list.apply() [SQL Execution] select id, name from members limit 2; (0 ms) rows: Seq[(Int, Option[String])] = List((1,Some(Alice)), (2,Some(Bob)))
  • 5. Other libraries? • According to the number of stars, • 1) Slick 2,124 • 2) Quill 1,311 • 3) Doobie 1,283 • 4) ScalikeJDBC 948 • ScalikeJDBC is ranked fourth (Not bad!) • Try in-memory database example on scalikejdbc.org • Any feedback? Reach out to me today 🤙
  • 7. Happened during the time • Scala binary versions: 5 • 2.9.1 ~ 2.9.2 ~ 2.10 ~ 2.11 ~ 2.12 ~ (2.13.0-M5 ~) • (Prior to 2.10, every single patch version was bin-incompatible) • JDK major versions: 5 • 7 ~ 8(LTS) ~ 9 ~ 10 ~ 11(LTS) ~ • JDBC API spec minor updates: 3 • 4.1 (JDK7) ~ 4.2 (JDK8) ~ 4.3 (JDK9) • Added 4.2 APIs when dropping JDK7 support • sbt migration: 0.13 to 1 • For the sbt plugin generating source code from database
  • 8. 5 tips to build long-lasting OSS • 1) Find your lifework project • 2) Be careful to add Scala dependencies • 3) Stick with binary compatibility • 4) Provide cross builds • 5) Have effective CI builds
  • 9. 1) Find your lifework project • Not specific to Scala OSS • It’s all about the sustainability of voluntary works • Two things to know 📝 • Focus on lifework projects • Many projects terminated due to author’s social events • e.g. Changing job, having a family, school graduation • Can continue it regardless of those big changes? • Difficulty to find successors • Inconvenient truth; even if you have many users… • Ideally, continue working on your project somehow
  • 10. 2) Be careful to add Scala deps • It’s unfortunate that I have to say this but it’s critical • Two things to know 📝 • "You’re in the same boat with many others” • 🙅 Major upgrade: have to wait for all releases; it causes significant delay of your release • 🙅 Cross builds: can’t do if just one of them doesn’t • Suggestion: Choose Java over Scala inside • Not cool… but I have to say it’s a realistic trade-off • 🙆 Pros: Can make upgrade/cross builds much easier • 🙅 Cons: Handle null values inside
  • 11. 2’) Work with null in Scala <<< Working with java.util.List >>> scala> import scala.collection.JavaConverters._ import scala.collection.JavaConverters._ scala> val j = java.util.Arrays.asList("A", "B", "C") j: java.util.List[String] = [A, B, C] scala> val s = j.asScala s: scala.collection.mutable.Buffer[String] = Buffer(A, B, C) scala> null.asInstanceOf[java.util.List[String]].asScala // use Option! res0: scala.collection.mutable.Buffer[String] = null <<< Working with primitives >>> scala> val j: java.lang.Integer = null j: Integer = null scala> val s: Int = j // auto boxing s: Int = 0 scala> val s = Option(j).map(Int.unbox) s: Option[Int] = None java.util.List can be null. null.asScala returns null. A null value can be unexpectedly converted to the type’s default value. (0 : scala.Int’s default value)
  • 12. 3) Stick with bin-compatibility • Bin-compatible? • Normal situation; not see any runtime linkage errors • If you break bin-compatibility: • Painful runtime errors (NoSuchMethodError etc) 😿 • Scala compiler cannot detect runtime issues beforehand • Two things to do 📝 • Define policies about bin-compatibility guarantee • Once you released the first stable version • Surely guarantee binary-compatibility • Solution: Use MiMa
  • 13. 3’) Use MiMa to ensure that • Use MiMa (Migration Manager for Scala) • Can detect syntactic incompatibilities • Developed and maintained by Lightbend devs // project/plugins.sbt addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.3.0") // build.sbt project.settings( MimaPlugin.mimaDefaultSettings ++ Seq( mimaPreviousArtifacts := { Set("0.1.0", "0.1.1").map { v => organization.value % s"${name.value}_${scalaBinaryVersion.value}" % v } }, test in Test := { mimaReportBinaryIssues.value (test in Test).value } ) )
  • 14. 4) Provide cross builds • Cross builds = publish against multiple Scala bin versions • Reality: We cannot always use the latest Scala • Apache Spark took 2 years to support Scala 2.12 • Remember the tip 2) “be careful to add Scala deps” • Two things to do 📝 • Support latest stable major & its previous major • To be specific, Scala 2.12 and 2.11 at this moment • Don’t have many files under src/main/scala-X.Y • Testing a plenty of code there is hard+time-consuming
  • 15. 5) Have effective CI builds • Why do we need it? • To reduce review cost of pull requests • To merge pull requests with confidence • You need reliable evidences (regressions, bin-combat, code style, etc) • Two things to do 📝 • Enable it anyway! • You can use TravisCI/CircleCI for free • Automate everything apart from code reviews • Check bin-compatibility, consistency of code style, cross builds, multiple JDKs, etc • Configure matrix builds to cover all patterns
  • 16. 5’) TravisCI Build Example language: scala sudo: false scala: - 2.11.12 - 2.12.7 - 2.13.0-M5 jdk: - oraclejdk8 - openjdk11 matrix: include: - scala: 2.12.7 jdk: oraclejdk9 script: sbt ++$TRAVIS_SCALA_VERSION scalafmtCheck test # code formatter check + test • Scala 2.11 + JDK 8, 11 = 2 builds • Scala 2.12 + JDK 8, 9, 11 = 3 builds • Scala 2.13.0-M5 + JDK 8, 11 = 2 builds Additional 1 matrix build 3 Scala versions * 2 JDKs = 6 patterns 7 patterns in total
  • 17. Start with the sbt template! • sbt project template (aka g8 template) • Including all techniques in this talk • Should be a good starting point for you 😎 mkdir my-awesome-library cd my-awesome-library sbt new seratch/long-lasting-scala.g8 sbt test
  • 18. Recap • You found out about ScalikeJDBC • Contact me at any time during the conf 🤙 • If you like it, increment the stars (1K soon!) • 5 tips to build long-lasting Scala OSS • 1) Find what interests you for years • 2) Be careful about adding Scala dependencies • 3) Stick with binary compatibility • 4) Provide cross builds • 5) Have effective CI builds