SlideShare a Scribd company logo
1 of 48
Download to read offline
All I learned
while working on a Scala
OSS project
for over six years
Kazuhiro Sera
@seratch
1
Scala OSS project を 6 年以上続けるために必要なこと
というテーマで、瀬良 和弘 @seratch_ja がお話しします。
In 2011, I started a Scala open source project named ScalikeJDBC.
Thanks to many contributors, I am still working on the project after six
years.
In the meantime, the Scala community has been growing sharply, and
the trends have been continuously changing.
Despite the fact that the number of developers who work on OSS
projects has increased, there are not many developers
who have been working on a single Scala
project for several years.
In this talk, I will share my experiences and pieces of knowledge
through maintaining a single OSS project for more than six years.
2011 年から取り組んできた ScalikeJDBC をはじめとする
Scala OSS 開発から得た知見などをお話しします。 2
Agenda
Who Am I?
My “Hello World” in Scala (2009)
ScalikeJDBC, My Long-lived Scala Project
Tips for Continuation
Avoiding Depending on Scala Libraries
Cross-building Tips
Ensuring binary-compatibility (MiMa)
Building a Community of Friends
このような内容についてお話しします。上級者の方にはちょっ
と物足りない内容かもしれませんが、ご容赦を。 3
Who Am I?
まずは自己紹介から。 4
Kazuhiro Sera @seratch
Software Engineer, VPoE at SmartNews, Inc.
We’re a samurai sponsor 👏
Server-side software engineer (Scala, Java, Ruby)
Love coding, open-source community
A Scala enthusiast for 7+ years
Creator of ScalikeJDBC, Skinny Framework
One of the maintainers of Scalate, json4s, Scalatra
SmartNews で働いています。サーバサイドエンジニア、
ScalikeJDBC、Skinny などの Scala OSS をやっています。5
Star as an endorsement
Increment the number of stargazers 🙇
好きなライブラリのスター数を increment しましょう。
スターが増えるの、かなり励みになるのです.. 🙇  6
My “Hello World” in Scala
(2009)
私の OSS について話す前に、私の Scala との出会いから
Scala のこれまでの変遷についてお話ししたいと思います。 7
Scala 2.7.3 (9 yrs ago)
Scala 2.7.3 は 2009 年頭にリリースされています。
何ともう 9 年も前ですね!
2009-01-14
8
My “Hello World” in Scala
In 2009, I was a Java developer at the time
Looking for a new one / unsatisfied with Groovy
At the beginning, I tried with Scala 2.7.3
My first impression of Scala
“IDE integration was still very poor. It’s a bit early to
seriously use it at work.”
Excited with hybrid paradigms, actors, concise syntax
I started learning it seriously in the following year
初めて使ったのは 2.7.3 で当時は Java エンジニアでした。
仕事にはまだ使えないけど面白い言語だなと思いました。 9
Let’s try Scala 2.7.3
Scala 2.7.3 を試してみましょう。.. と、Java 8 で.. 動きませ
んね。sbt から REPL の起動ができません。
$ java -version
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
$ sbt ++2.7.3 console
[info] 'compiler-interface' not yet compiled for Scala 2.7.3.final. Compiling...
error: error while loading Consumer, class file '/Library/Java/JavaVirtualMachines/
jdk1.8.0_151.jdk/Contents/Home/jre/lib/rt.jar(java/util/function/Consumer.class)'
is broken
(bad constant pool tag 18 at byte 15)
one error found


On JDK 8+,
it fails to run the REPL…
10
Let’s try 2.8.0.. 👀
Scala 2.8.0 ならどうか.. エラー内容違いますが
こちらも残念から動作しないようです。
$ sbt ++2.8.0 console
[info] 'compiler-interface' not yet compiled for Scala 2.8.0.final. Compiling...
error: error while loading CharSequence, class file '/Library/Java/JavaVirtualMachines/
jdk1.8.0_151.jdk/Contents/Home/jre/lib/rt.jar(java/lang/CharSequence.class)' is broken
(bad constant pool tag 18 at byte 10)
error: error while loading AnnotatedElement, class file '/Library/Java/JavaVirtualMachines/
jdk1.8.0_151.jdk/Contents/Home/jre/lib/rt.jar(java/lang/reflect/AnnotatedElement.class)' is
broken
(bad constant pool tag 18 at byte 76)
error: error while loading Arrays, class file '/Library/Java/JavaVirtualMachines/
jdk1.8.0_151.jdk/Contents/Home/jre/lib/rt.jar(java/util/Arrays.class)' is broken
(bad constant pool tag 18 at byte 765)
error: error while loading Comparator, class file '/Library/Java/JavaVirtualMachines/
jdk1.8.0_151.jdk/Contents/Home/jre/lib/rt.jar(java/util/Comparator.class)' is broken
(bad constant pool tag 18 at byte 20)
/var/folders/vl/bxx80tvs2gd8tzrtyd_b0p9r0000gp/T/sbt_6e129fa2/xsbt/ExtractAPI.scala:549:
error: java.util.Comparator does not take type parameters
private[this] val sortClasses = new Comparator[Symbol] {
^
5 errors found
11
On JDK 8+,
it fails to run the REPL…
Let’s try 2.9.0.. 👀
2.9.0 も.. 動かない.. .. だと.. ..
$ sbt ++2.9.0 console
[info] 'compiler-interface' not yet compiled for Scala 2.9.0.final. Compiling...
error: error while loading CharSequence, class file '/Library/Java/JavaVirtualMachines/
jdk1.8.0_151.jdk/Contents/Home/jre/lib/rt.jar(java/lang/CharSequence.class)' is broken
(bad constant pool tag 18 at byte 10)
error: error while loading AnnotatedElement, class file '/Library/Java/JavaVirtualMachines/
jdk1.8.0_151.jdk/Contents/Home/jre/lib/rt.jar(java/lang/reflect/AnnotatedElement.class)' is
broken
(bad constant pool tag 18 at byte 76)
error: error while loading Arrays, class file '/Library/Java/JavaVirtualMachines/
jdk1.8.0_151.jdk/Contents/Home/jre/lib/rt.jar(java/util/Arrays.class)' is broken
(bad constant pool tag 18 at byte 765)
error: error while loading Comparator, class file '/Library/Java/JavaVirtualMachines/
jdk1.8.0_151.jdk/Contents/Home/jre/lib/rt.jar(java/util/Comparator.class)' is broken
(bad constant pool tag 18 at byte 20)
/var/folders/vl/bxx80tvs2gd8tzrtyd_b0p9r0000gp/T/sbt_a0025195/xsbt/ExtractAPI.scala:549:
error: java.util.Comparator does not take type parameters
private[this] val sortClasses = new Comparator[Symbol] {
^
5 errors found
12
On JDK 8+,
it fails to run the REPL…
2.10.2+ runs on JDK 8 ☺
2.10.2 から Java 8 で動くようになり、それまでのバージョ
ンは動きませんでした。今後も似たようなことは起きるかも。
$ sbt ++2.10.2 console
[info] 'compiler-interface' not yet compiled for Scala 2.10.2. Compiling...
[info] Compilation completed in 7.522 s
[info] Starting scala interpreter...
[info]
Welcome to Scala version 2.10.2 (Java HotSpot(TM) 64-Bit Server VM, Java
1.8.0_151).
Type in expressions to have them evaluated.
Type :help for more information.
scala>
13
Scala 2.10.2+ works on Java 8 ☺
2.7.3 on JDK7.. 👀
ということで 2.7.3 を試したければ Java 7 を使わないと.. ..
おや、これも動かないのでしょうか??
$ export JAVA_HOME=`/usr/libexec/java_home -v 1.7`
$ java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
$ sbt ++2.7.3 console
[info] 'compiler-interface' not yet compiled for Scala 2.7.3.final. Compiling...
/var/folders/vl/bxx80tvs2gd8tzrtyd_b0p9r0000gp/T/sbt_7f1250db/
CompilerInterface.scala:9: error: value interactive is not a member of package
scala.tools.nsc
import scala.tools.nsc.interactive.RangePositions
^
(omitted)
42 errors found
[error] (run-main) Error compiling sbt component 'compiler-interface'


14
Somehow, it fails to boot on
Java7 .. 😢
2.7.3 without sbt ☺
実は現行 sbt で当時の Scala を動かすことができません。
sbt を使わずに起動すれば Java 7 で当然動作します。
$ export JAVA_HOME=`/usr/libexec/java_home -v 1.7`
$ java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
$ bin/scala
Welcome to Scala version 2.7.3.final (Java HotSpot(TM) 64-Bit Server VM, Java
1.7.0_80).
Type in expressions to have them evaluated.
Type :help for more information.
15
“sbt console” supports only Scala 2.9.0+.
You have to use the scala script instead.
Scala 2.7 and beyond
9 年経って Scala はどれくらい変わったのでしょうか?
これは以降のメジャーバージョンリリースの年表です。
Scala 2.8 2010-07-15
Scala 2.9 2011-05-12
Scala 2.10 2012-12-20
Scala 2.11 2014-05-20
Scala 2.12 2016-10-29
Scala 2.13.0-M3 2018-01-31
Scala 3.0 (with Dotty) ???
16
Missing parts (2.8, 2.9)
Named and default arguments (2.8+)
Package objects (2.8+)
The App trait (2.9+)
JavaConverters/JavaConversions (2.9+)
2.8 と 2.9 ではこれらの機能が追加されました。
当時は 2.x.0 と 2.x.1 に互換性がありませんでした。 17
Missing parts (2.10)
2.x binary compatibility (2.10+)
Value classes (2.10+)
Implicit classes (2.10+)
String Interpolation (2.10+)
Futures and Promises (2.10+)
Dynamic (2.10+)
Macros (2.10+)
2.10 はターニングポイントとなるリリースでした。
バイナリ互換性の改善 + 多くの機能が追加されました。 18
Missing parts (2.11, 2.12)
Blackbox/whitebox macros (2.11+)
Quasiquotes (2.11+)
Java 8 SAM types compatibility (2.12.+)
Using invokeDynamic for lambda (2.12+)
2.11, 2.12 はマクロの改善と内部的な最適化が主でした。
言語の利用者としては新しい機能はあまりありません。 19
Moderate changes recently
このように 2.10 以降の言語の変更はあまり多くありません。
OSS を始めるタイミングとしてはよいかもしれませんね。
Scala 2.8 2010-07-15
Scala 2.9 2011-05-12
Scala 2.10 2012-12-20
Scala 2.11 2014-05-20
Scala 2.12 2016-10-29
Scala 2.13.0-M3 2018-01-31
Scala 3.0 (with Dotty) ???
20
ScalikeJDBC,
My Long-lived Scala Project
では、そろそろ本題、まず私の Scala OSS について開発に
至った背景や大事にしている思想など、簡単に説明します。21
Why I Started My Project
I needed a practical DB library in 2011
I was going to start using Scala for real projects
Twitter’s querulous looked reasonable, but it
supported MySQL only
ScalaQuery looked hard to master for me
For Fun / To learn new things
At the time, I was new to both Scala and OSS
I wanted to try something exciting by myself 😎
2011 年当時、実用的な DB library を必要としていたのと、
新しいことをやってみたいという気持ちから始めました。 22
History of DB Libraries
Scala の RDB access library の変遷です。
今はメンテされていないものもいくつかあります。 23
Non-practical Libraries
In return for fancy APIs
Not designed to solve real-world business problems
New team members need long time to catch up
Troubleshooting can be bothersome
Insufficient information for debugging
Frequently breaking API compatibilities
Author suddenly stopped maintaining the library..
カッコいい API だが現実の問題に対応できない・学習コスト
高い。デバッグしにくい 。互換性をよく崩す。メンテが突然止
まる。これらに該当しないことが私の「実用的」の基準です。24
Philosophy of ScalikeJDBC
“Just write SQL and get things done!”
Easy-to-understand
Requires only Scala basics + JDBC basics
No steep learning curve! (except for Scala 😜)
Well-considered flexibility to deal with edge cases
No breaking API changes as much as possible
ScalikeJDBC が大事にしていること:すぐに理解し使える、
特殊ケースに対応できる、互換性を極力崩さない 25
Tips for Continuation
次に長く続けるために必要だった考え方や工夫
についてお話ししたいと思います。 26
More than 6 Years
6 年以上特定の library の開発を継続してきました。
これは Scala community の中でも長い方でしょう。
I’ve been working on it for more than 6 years
Scala 2.9 ~ 2.10 ~ 2.11 ~ 2.12 ~ 2.13
27
Tips for Continuation
KISS (Keep It Simple, Stupid) Principle
Keep it Contributors Friendly
Avoiding Depending on Scala Libraries
Knowledge on Important Factors
Cross-building
Binary-compatibilities
Building a Community of Friends
You’re not alone! 🙌
継続で大事なこと:シンプルに保つこと、重要な要素(えwク
ロスビルド / バイナリ互換)の理解、コミュニティの形成 28
Avoiding Depending on
Scala Libraries
Scala library への依存を避けるべき:残念なことですが
library を長くメンテするには大事なことです。 29
Common reasons to do that
Await their releases every Scala major upgrade
If you depend on short-lived libraries..
When becoming unmaintained, you’ll have to fork
and maintain them by yourself
May bring binary compatibility issues
Scala major upgrade の度に release 待ち、短命 library を
最悪 fork する羽目、バイナリ互換性の問題などありえます。30
Fetters for Cross-building
So difficult to do cross-building while depending on
other Scala libraries
All depending Scala libraries must do the exactly
same cross-building (unrealistic..)
If you give cross-building high priority, you should
consider to depend on not Scala libraries but Java
libraries (or no dependencies..)
クロスビルドで他の Scala library への依存は相当な足かせで
す。全ての依存がクロスビルドをしなければ成立しません。31
Depending on Java libraries
Depending on well-maintained Java libraries is a
reasonable way to reduce your efforts
No extra efforts when Scala major upgrade
Stability (well-tested by large number of users)
Downside of using Java libraries?
Have to understand Java interoperability tips
Have to completely encapsulate Java world which
brings you lots of null 😢
Java library 依存は悪くない選択肢で色々楽になりますが
Java な世界観を隠蔽するなどのケアは必要になるでしょう。32
Cross-building Tips
特に ScalikeJDBC は古い Scala を使うユーザにも配慮してき
ました。そのために必要な工夫について説明します。 33
Supported Versions
ScalikeJDBC は @xuwei-k の尽力のおかげもあり
クロスビルドをかなり頑張っているライブラリです。
ScalikeJDBC Release date Scala binary versions sbt versions
1.0 2012-05
2.9.0
2.9.1
2.9.2
-
2.0 2014-05
2.10
2.11
0.13.x
3.0 2017-06
2.10
2.11
2.12
0.13.x
3.2 2018-01
2.10
2.11
2.12
0.13.x
1.x
34
CI Build Configuration
Properly configuring CI builds
is the most important practice
for cross-building
If you don’t configure CI to
check cross-building
automatically, it’ll be very
annoying to manually check
the validity of pull requests
CI ビルドを適切に設定して運用することが最も大事です。クロ
スビルドを気にしながら PR を受け付けるには必須です。 35
src/main/scala-2.x
Dealing with deprecated APIs between Scala major
versions / 3rd party libraries’ upgrades
src/main/scala-{Scala binary version}
非推奨となった API を使い分ける場合 src/main の配下に
binary version 毎に違うソースコードを置いて対処します。36
Ensuring binary-compatibility
(MiMa)
次にバイナリ互換性を守る方法について紹介します。Scala で
はバイナリ互換性を仕組みによって守ることができます。 37
Are Java Libraries Safe?
Java language itself is binary compatible between
major versions
Great efforts for backward compatibilities 🙂
However, it’s not true for 3rd party Java libraries
Even famous libraries sometimes break their binary
compatibilities between releases
(e.g) Jackson 2.x are basically binary incompatible
Java ライブラリでバイナリ互換性を気にしたことがないあな
たは幸運な人です。非互換はしばしば発生しているのです。38
How to Ensure It
Use “MiMa”
MiMa = Migration Manager
lightbend/migration-manager
Using it via the sbt plugin is convenient
MiMa(ミーマ)というツールがバイナリ非互換を検知してく
れるのでこれを sbt プラグイン経由で使うのが一般的です。39
When to Be Strict About It
Up to the type of your library
If you provide a low-level library that other libraries
may depend on it
you should be very careful
As for directly used libraries / in-house libraries
you don’t need to be so strict
社内や他の library が依存する library を提供しないなら、必
ずしもバイナリ互換性に厳密に取り組む必要性はありません。40
ScalikeJDBC’s Policy
Bump major/minor version when introducing some
binary incompatibilities
All patch version releases are bin-compatible
GitHub branch strategies
Having a corresponding git branch for each bin-
compatible minor version (e.g. 3.2.x, 3.1.x, .. )
master branch: the latest (3.3.x as of March 2018)
ポリシー:バイナリ非互換は major/minor ver、patch ver 間
はバイナリ互換を保証、git branch を minor 単位で運用 41
MiMa Configuration
ScalikeJDBC の設定例:クロスビルドで stable major のみを
チェック、すべての patch versions との突き合わせ
Skipping unstable Scala versions
such as 2.13.0-M3
42
Building a Community of
Friends 🙌
OSS を続けることは一人でできることではありません。
コミュニティの中で仲間を見つけ、一緒に歩みましょう。 43
Scala Ninja @xuwei-k
Kenji Yoshida さんは「文字通り Scala 忍者」として知られて
いる、まさに日本を代表するコミュニティ貢献者です。 44
Not only the “Scala Ninja”
私の OSS は Yoshida さんの尽力はもちろんですが、多くの
方々の貢献のおかげで継続することができています。 45
OSS Open/Closed Principle
Open/Closed Principle
Open for extension, but closed for modification
OSS Open/Closed Principle
Open for contribution,
Friendly for new contributors; easy-to-..
but closed for confusion (to be long-lived)
CI / test suites which detect common mistakes
Clearly stipulated rules (CONTRIBUTING.md)
貢献に開いているプロジェクトの条件:動かしやすさ、理解し
やすさ、安全な変更、テストコード、明記されたルール 46
Just Keep Working on It
Library maintainers must overcome upgrades
Scala major upgrades / Cross-building
sbt build settings upgrades
I’m still taking time to adapt sbt 1.x ..
It’s like a battle of patience..
Keep it simple, avoid hacky code/configuration
Keep working on it at your own pace
Library メンテナは Scala や sbt の更新に対応し続けなけれ
ばいけません。凝ったことはせず、コツコツ持久戦で.. 47
Let’s build our long-lived
Scala community

together! 😀
みんなで長く続く Scala コミュニティを作っていきましょう!
この発表でご紹介したことがそのお役に立てば幸いです。 48

More Related Content

Similar to All I learned while working on a Scala OSS project for over six years #ScalaMatsuri

Scalaでのプログラム開発
Scalaでのプログラム開発Scalaでのプログラム開発
Scalaでのプログラム開発Kota Mizushima
 
The state of sbt 0.13, sbt server, and sbt 1.0 (ScalaMatsuri ver)
The state of sbt 0.13, sbt server, and sbt 1.0 (ScalaMatsuri ver)The state of sbt 0.13, sbt server, and sbt 1.0 (ScalaMatsuri ver)
The state of sbt 0.13, sbt server, and sbt 1.0 (ScalaMatsuri ver)Eugene Yokota
 
Ruby on Rails3 Tutorial Chapter2
Ruby on Rails3 Tutorial Chapter2Ruby on Rails3 Tutorial Chapter2
Ruby on Rails3 Tutorial Chapter2Sea Mountain
 
Scalaの現状と課題
Scalaの現状と課題Scalaの現状と課題
Scalaの現状と課題Kota Mizushima
 
Dev love関西 forslideshare
Dev love関西 forslideshareDev love関西 forslideshare
Dev love関西 forslideshareDaisuke Kasuya
 
JavaScript Tips 2015(PDF 版)
JavaScript Tips 2015(PDF 版)JavaScript Tips 2015(PDF 版)
JavaScript Tips 2015(PDF 版)taskie
 
9/14にリリースされたばかりの新LTS版Java 17、ここ3年間のJavaの変化を知ろう!(Open Source Conference 2021 O...
9/14にリリースされたばかりの新LTS版Java 17、ここ3年間のJavaの変化を知ろう!(Open Source Conference 2021 O...9/14にリリースされたばかりの新LTS版Java 17、ここ3年間のJavaの変化を知ろう!(Open Source Conference 2021 O...
9/14にリリースされたばかりの新LTS版Java 17、ここ3年間のJavaの変化を知ろう!(Open Source Conference 2021 O...NTT DATA Technology & Innovation
 
Beginners Scala in FAN 20121009
Beginners Scala in FAN 20121009Beginners Scala in FAN 20121009
Beginners Scala in FAN 20121009Taisuke Shiratori
 
Beginning Java EE 6 勉強会(1) #bje_study
Beginning Java EE 6 勉強会(1) #bje_studyBeginning Java EE 6 勉強会(1) #bje_study
Beginning Java EE 6 勉強会(1) #bje_studyToshiaki Maki
 
Skinny Framework 進捗どうですか? #fud_scala
Skinny Framework 進捗どうですか? #fud_scalaSkinny Framework 進捗どうですか? #fud_scala
Skinny Framework 進捗どうですか? #fud_scalaKazuhiro Sera
 
Java on Kubernetes on Azure
Java on Kubernetes on AzureJava on Kubernetes on Azure
Java on Kubernetes on AzureYoshio Terada
 
Ruby on Rails を用いたWEBアプリケーションの開発
Ruby on Rails を用いたWEBアプリケーションの開発Ruby on Rails を用いたWEBアプリケーションの開発
Ruby on Rails を用いたWEBアプリケーションの開発Koichi Shimozono
 
これからのJDK/JVM 何を選ぶ?どう選ぶ?
これからのJDK/JVM 何を選ぶ?どう選ぶ?これからのJDK/JVM 何を選ぶ?どう選ぶ?
これからのJDK/JVM 何を選ぶ?どう選ぶ?Takahiro YAMADA
 
SDLoader SeasarCon 2009 Whire
SDLoader SeasarCon 2009 WhireSDLoader SeasarCon 2009 Whire
SDLoader SeasarCon 2009 WhireAkio Katayama
 
ScalaでAndroidアプリ開発
ScalaでAndroidアプリ開発ScalaでAndroidアプリ開発
ScalaでAndroidアプリ開発papamitra
 
[JavaOne Tokyo 2012] JavaFX and Web Integration
[JavaOne Tokyo 2012] JavaFX and Web Integration[JavaOne Tokyo 2012] JavaFX and Web Integration
[JavaOne Tokyo 2012] JavaFX and Web IntegrationKazuchika Sekiya
 
2011年javaの旅
2011年javaの旅2011年javaの旅
2011年javaの旅torutk
 

Similar to All I learned while working on a Scala OSS project for over six years #ScalaMatsuri (20)

scala-kaigi1-sbt
scala-kaigi1-sbtscala-kaigi1-sbt
scala-kaigi1-sbt
 
Scalaでのプログラム開発
Scalaでのプログラム開発Scalaでのプログラム開発
Scalaでのプログラム開発
 
The state of sbt 0.13, sbt server, and sbt 1.0 (ScalaMatsuri ver)
The state of sbt 0.13, sbt server, and sbt 1.0 (ScalaMatsuri ver)The state of sbt 0.13, sbt server, and sbt 1.0 (ScalaMatsuri ver)
The state of sbt 0.13, sbt server, and sbt 1.0 (ScalaMatsuri ver)
 
Ruby on Rails3 Tutorial Chapter2
Ruby on Rails3 Tutorial Chapter2Ruby on Rails3 Tutorial Chapter2
Ruby on Rails3 Tutorial Chapter2
 
Scalaの現状と課題
Scalaの現状と課題Scalaの現状と課題
Scalaの現状と課題
 
Dev love関西 forslideshare
Dev love関西 forslideshareDev love関西 forslideshare
Dev love関西 forslideshare
 
Play勉強会 第3回
Play勉強会 第3回Play勉強会 第3回
Play勉強会 第3回
 
JavaScript Tips 2015(PDF 版)
JavaScript Tips 2015(PDF 版)JavaScript Tips 2015(PDF 版)
JavaScript Tips 2015(PDF 版)
 
9/14にリリースされたばかりの新LTS版Java 17、ここ3年間のJavaの変化を知ろう!(Open Source Conference 2021 O...
9/14にリリースされたばかりの新LTS版Java 17、ここ3年間のJavaの変化を知ろう!(Open Source Conference 2021 O...9/14にリリースされたばかりの新LTS版Java 17、ここ3年間のJavaの変化を知ろう!(Open Source Conference 2021 O...
9/14にリリースされたばかりの新LTS版Java 17、ここ3年間のJavaの変化を知ろう!(Open Source Conference 2021 O...
 
Beginners Scala in FAN 20121009
Beginners Scala in FAN 20121009Beginners Scala in FAN 20121009
Beginners Scala in FAN 20121009
 
Beginning Java EE 6 勉強会(1) #bje_study
Beginning Java EE 6 勉強会(1) #bje_studyBeginning Java EE 6 勉強会(1) #bje_study
Beginning Java EE 6 勉強会(1) #bje_study
 
Skinny Framework 進捗どうですか? #fud_scala
Skinny Framework 進捗どうですか? #fud_scalaSkinny Framework 進捗どうですか? #fud_scala
Skinny Framework 進捗どうですか? #fud_scala
 
Java on Kubernetes on Azure
Java on Kubernetes on AzureJava on Kubernetes on Azure
Java on Kubernetes on Azure
 
Ruby on Rails を用いたWEBアプリケーションの開発
Ruby on Rails を用いたWEBアプリケーションの開発Ruby on Rails を用いたWEBアプリケーションの開発
Ruby on Rails を用いたWEBアプリケーションの開発
 
Play jjug2012spring
Play jjug2012springPlay jjug2012spring
Play jjug2012spring
 
これからのJDK/JVM 何を選ぶ?どう選ぶ?
これからのJDK/JVM 何を選ぶ?どう選ぶ?これからのJDK/JVM 何を選ぶ?どう選ぶ?
これからのJDK/JVM 何を選ぶ?どう選ぶ?
 
SDLoader SeasarCon 2009 Whire
SDLoader SeasarCon 2009 WhireSDLoader SeasarCon 2009 Whire
SDLoader SeasarCon 2009 Whire
 
ScalaでAndroidアプリ開発
ScalaでAndroidアプリ開発ScalaでAndroidアプリ開発
ScalaでAndroidアプリ開発
 
[JavaOne Tokyo 2012] JavaFX and Web Integration
[JavaOne Tokyo 2012] JavaFX and Web Integration[JavaOne Tokyo 2012] JavaFX and Web Integration
[JavaOne Tokyo 2012] JavaFX and Web Integration
 
2011年javaの旅
2011年javaの旅2011年javaの旅
2011年javaの旅
 

More from Kazuhiro Sera

Contributing to Scala OSS from East Asia #ScalaMatsuri
 Contributing to Scala OSS from East Asia #ScalaMatsuri Contributing to Scala OSS from East Asia #ScalaMatsuri
Contributing to Scala OSS from East Asia #ScalaMatsuriKazuhiro Sera
 
Skinny Meetup Tokyo 2 日本語スライド
Skinny Meetup Tokyo 2 日本語スライドSkinny Meetup Tokyo 2 日本語スライド
Skinny Meetup Tokyo 2 日本語スライドKazuhiro Sera
 
Seasar ユーザだったプログラマが目指す OSS の世界展開 #seasarcon
Seasar ユーザだったプログラマが目指す OSS の世界展開 #seasarconSeasar ユーザだったプログラマが目指す OSS の世界展開 #seasarcon
Seasar ユーザだったプログラマが目指す OSS の世界展開 #seasarconKazuhiro Sera
 
Java エンジニアチームが始めやすい Scala コーディングスタイル #ichigayageek
Java エンジニアチームが始めやすい Scala コーディングスタイル #ichigayageekJava エンジニアチームが始めやすい Scala コーディングスタイル #ichigayageek
Java エンジニアチームが始めやすい Scala コーディングスタイル #ichigayageekKazuhiro Sera
 
Future on Servlet #scala_ks
Future on Servlet #scala_ksFuture on Servlet #scala_ks
Future on Servlet #scala_ksKazuhiro Sera
 
Servlet と Future の関わり方 #scala_ks
Servlet と Future の関わり方 #scala_ksServlet と Future の関わり方 #scala_ks
Servlet と Future の関わり方 #scala_ksKazuhiro 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
 
テストの運用について #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
 

More from Kazuhiro Sera (20)

Contributing to Scala OSS from East Asia #ScalaMatsuri
 Contributing to Scala OSS from East Asia #ScalaMatsuri Contributing to Scala OSS from East Asia #ScalaMatsuri
Contributing to Scala OSS from East Asia #ScalaMatsuri
 
Skinny Meetup Tokyo 2 日本語スライド
Skinny Meetup Tokyo 2 日本語スライドSkinny Meetup Tokyo 2 日本語スライド
Skinny Meetup Tokyo 2 日本語スライド
 
Skinny 2 Update
Skinny 2 UpdateSkinny 2 Update
Skinny 2 Update
 
Seasar ユーザだったプログラマが目指す OSS の世界展開 #seasarcon
Seasar ユーザだったプログラマが目指す OSS の世界展開 #seasarconSeasar ユーザだったプログラマが目指す OSS の世界展開 #seasarcon
Seasar ユーザだったプログラマが目指す OSS の世界展開 #seasarcon
 
Java エンジニアチームが始めやすい Scala コーディングスタイル #ichigayageek
Java エンジニアチームが始めやすい Scala コーディングスタイル #ichigayageekJava エンジニアチームが始めやすい Scala コーディングスタイル #ichigayageek
Java エンジニアチームが始めやすい Scala コーディングスタイル #ichigayageek
 
Future on Servlet #scala_ks
Future on Servlet #scala_ksFuture on Servlet #scala_ks
Future on Servlet #scala_ks
 
Servlet と Future の関わり方 #scala_ks
Servlet と Future の関わり方 #scala_ksServlet と Future の関わり方 #scala_ks
Servlet と Future の関わり方 #scala_ks
 
マイクロサービス運用の所感 #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
 
テストの運用について #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
 

All I learned while working on a Scala OSS project for over six years #ScalaMatsuri

  • 1. All I learned while working on a Scala OSS project for over six years Kazuhiro Sera @seratch 1 Scala OSS project を 6 年以上続けるために必要なこと というテーマで、瀬良 和弘 @seratch_ja がお話しします。
  • 2. In 2011, I started a Scala open source project named ScalikeJDBC. Thanks to many contributors, I am still working on the project after six years. In the meantime, the Scala community has been growing sharply, and the trends have been continuously changing. Despite the fact that the number of developers who work on OSS projects has increased, there are not many developers who have been working on a single Scala project for several years. In this talk, I will share my experiences and pieces of knowledge through maintaining a single OSS project for more than six years. 2011 年から取り組んできた ScalikeJDBC をはじめとする Scala OSS 開発から得た知見などをお話しします。 2
  • 3. Agenda Who Am I? My “Hello World” in Scala (2009) ScalikeJDBC, My Long-lived Scala Project Tips for Continuation Avoiding Depending on Scala Libraries Cross-building Tips Ensuring binary-compatibility (MiMa) Building a Community of Friends このような内容についてお話しします。上級者の方にはちょっ と物足りない内容かもしれませんが、ご容赦を。 3
  • 5. Kazuhiro Sera @seratch Software Engineer, VPoE at SmartNews, Inc. We’re a samurai sponsor 👏 Server-side software engineer (Scala, Java, Ruby) Love coding, open-source community A Scala enthusiast for 7+ years Creator of ScalikeJDBC, Skinny Framework One of the maintainers of Scalate, json4s, Scalatra SmartNews で働いています。サーバサイドエンジニア、 ScalikeJDBC、Skinny などの Scala OSS をやっています。5
  • 6. Star as an endorsement Increment the number of stargazers 🙇 好きなライブラリのスター数を increment しましょう。 スターが増えるの、かなり励みになるのです.. 🙇  6
  • 7. My “Hello World” in Scala (2009) 私の OSS について話す前に、私の Scala との出会いから Scala のこれまでの変遷についてお話ししたいと思います。 7
  • 8. Scala 2.7.3 (9 yrs ago) Scala 2.7.3 は 2009 年頭にリリースされています。 何ともう 9 年も前ですね! 2009-01-14 8
  • 9. My “Hello World” in Scala In 2009, I was a Java developer at the time Looking for a new one / unsatisfied with Groovy At the beginning, I tried with Scala 2.7.3 My first impression of Scala “IDE integration was still very poor. It’s a bit early to seriously use it at work.” Excited with hybrid paradigms, actors, concise syntax I started learning it seriously in the following year 初めて使ったのは 2.7.3 で当時は Java エンジニアでした。 仕事にはまだ使えないけど面白い言語だなと思いました。 9
  • 10. Let’s try Scala 2.7.3 Scala 2.7.3 を試してみましょう。.. と、Java 8 で.. 動きませ んね。sbt から REPL の起動ができません。 $ java -version java version "1.8.0_151" Java(TM) SE Runtime Environment (build 1.8.0_151-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode) $ sbt ++2.7.3 console [info] 'compiler-interface' not yet compiled for Scala 2.7.3.final. Compiling... error: error while loading Consumer, class file '/Library/Java/JavaVirtualMachines/ jdk1.8.0_151.jdk/Contents/Home/jre/lib/rt.jar(java/util/function/Consumer.class)' is broken (bad constant pool tag 18 at byte 15) one error found 
 On JDK 8+, it fails to run the REPL… 10
  • 11. Let’s try 2.8.0.. 👀 Scala 2.8.0 ならどうか.. エラー内容違いますが こちらも残念から動作しないようです。 $ sbt ++2.8.0 console [info] 'compiler-interface' not yet compiled for Scala 2.8.0.final. Compiling... error: error while loading CharSequence, class file '/Library/Java/JavaVirtualMachines/ jdk1.8.0_151.jdk/Contents/Home/jre/lib/rt.jar(java/lang/CharSequence.class)' is broken (bad constant pool tag 18 at byte 10) error: error while loading AnnotatedElement, class file '/Library/Java/JavaVirtualMachines/ jdk1.8.0_151.jdk/Contents/Home/jre/lib/rt.jar(java/lang/reflect/AnnotatedElement.class)' is broken (bad constant pool tag 18 at byte 76) error: error while loading Arrays, class file '/Library/Java/JavaVirtualMachines/ jdk1.8.0_151.jdk/Contents/Home/jre/lib/rt.jar(java/util/Arrays.class)' is broken (bad constant pool tag 18 at byte 765) error: error while loading Comparator, class file '/Library/Java/JavaVirtualMachines/ jdk1.8.0_151.jdk/Contents/Home/jre/lib/rt.jar(java/util/Comparator.class)' is broken (bad constant pool tag 18 at byte 20) /var/folders/vl/bxx80tvs2gd8tzrtyd_b0p9r0000gp/T/sbt_6e129fa2/xsbt/ExtractAPI.scala:549: error: java.util.Comparator does not take type parameters private[this] val sortClasses = new Comparator[Symbol] { ^ 5 errors found 11 On JDK 8+, it fails to run the REPL…
  • 12. Let’s try 2.9.0.. 👀 2.9.0 も.. 動かない.. .. だと.. .. $ sbt ++2.9.0 console [info] 'compiler-interface' not yet compiled for Scala 2.9.0.final. Compiling... error: error while loading CharSequence, class file '/Library/Java/JavaVirtualMachines/ jdk1.8.0_151.jdk/Contents/Home/jre/lib/rt.jar(java/lang/CharSequence.class)' is broken (bad constant pool tag 18 at byte 10) error: error while loading AnnotatedElement, class file '/Library/Java/JavaVirtualMachines/ jdk1.8.0_151.jdk/Contents/Home/jre/lib/rt.jar(java/lang/reflect/AnnotatedElement.class)' is broken (bad constant pool tag 18 at byte 76) error: error while loading Arrays, class file '/Library/Java/JavaVirtualMachines/ jdk1.8.0_151.jdk/Contents/Home/jre/lib/rt.jar(java/util/Arrays.class)' is broken (bad constant pool tag 18 at byte 765) error: error while loading Comparator, class file '/Library/Java/JavaVirtualMachines/ jdk1.8.0_151.jdk/Contents/Home/jre/lib/rt.jar(java/util/Comparator.class)' is broken (bad constant pool tag 18 at byte 20) /var/folders/vl/bxx80tvs2gd8tzrtyd_b0p9r0000gp/T/sbt_a0025195/xsbt/ExtractAPI.scala:549: error: java.util.Comparator does not take type parameters private[this] val sortClasses = new Comparator[Symbol] { ^ 5 errors found 12 On JDK 8+, it fails to run the REPL…
  • 13. 2.10.2+ runs on JDK 8 ☺ 2.10.2 から Java 8 で動くようになり、それまでのバージョ ンは動きませんでした。今後も似たようなことは起きるかも。 $ sbt ++2.10.2 console [info] 'compiler-interface' not yet compiled for Scala 2.10.2. Compiling... [info] Compilation completed in 7.522 s [info] Starting scala interpreter... [info] Welcome to Scala version 2.10.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_151). Type in expressions to have them evaluated. Type :help for more information. scala> 13 Scala 2.10.2+ works on Java 8 ☺
  • 14. 2.7.3 on JDK7.. 👀 ということで 2.7.3 を試したければ Java 7 を使わないと.. .. おや、これも動かないのでしょうか?? $ export JAVA_HOME=`/usr/libexec/java_home -v 1.7` $ java -version java version "1.7.0_80" Java(TM) SE Runtime Environment (build 1.7.0_80-b15) Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode) $ sbt ++2.7.3 console [info] 'compiler-interface' not yet compiled for Scala 2.7.3.final. Compiling... /var/folders/vl/bxx80tvs2gd8tzrtyd_b0p9r0000gp/T/sbt_7f1250db/ CompilerInterface.scala:9: error: value interactive is not a member of package scala.tools.nsc import scala.tools.nsc.interactive.RangePositions ^ (omitted) 42 errors found [error] (run-main) Error compiling sbt component 'compiler-interface' 
 14 Somehow, it fails to boot on Java7 .. 😢
  • 15. 2.7.3 without sbt ☺ 実は現行 sbt で当時の Scala を動かすことができません。 sbt を使わずに起動すれば Java 7 で当然動作します。 $ export JAVA_HOME=`/usr/libexec/java_home -v 1.7` $ java -version java version "1.7.0_80" Java(TM) SE Runtime Environment (build 1.7.0_80-b15) Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode) $ bin/scala Welcome to Scala version 2.7.3.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_80). Type in expressions to have them evaluated. Type :help for more information. 15 “sbt console” supports only Scala 2.9.0+. You have to use the scala script instead.
  • 16. Scala 2.7 and beyond 9 年経って Scala はどれくらい変わったのでしょうか? これは以降のメジャーバージョンリリースの年表です。 Scala 2.8 2010-07-15 Scala 2.9 2011-05-12 Scala 2.10 2012-12-20 Scala 2.11 2014-05-20 Scala 2.12 2016-10-29 Scala 2.13.0-M3 2018-01-31 Scala 3.0 (with Dotty) ??? 16
  • 17. Missing parts (2.8, 2.9) Named and default arguments (2.8+) Package objects (2.8+) The App trait (2.9+) JavaConverters/JavaConversions (2.9+) 2.8 と 2.9 ではこれらの機能が追加されました。 当時は 2.x.0 と 2.x.1 に互換性がありませんでした。 17
  • 18. Missing parts (2.10) 2.x binary compatibility (2.10+) Value classes (2.10+) Implicit classes (2.10+) String Interpolation (2.10+) Futures and Promises (2.10+) Dynamic (2.10+) Macros (2.10+) 2.10 はターニングポイントとなるリリースでした。 バイナリ互換性の改善 + 多くの機能が追加されました。 18
  • 19. Missing parts (2.11, 2.12) Blackbox/whitebox macros (2.11+) Quasiquotes (2.11+) Java 8 SAM types compatibility (2.12.+) Using invokeDynamic for lambda (2.12+) 2.11, 2.12 はマクロの改善と内部的な最適化が主でした。 言語の利用者としては新しい機能はあまりありません。 19
  • 20. Moderate changes recently このように 2.10 以降の言語の変更はあまり多くありません。 OSS を始めるタイミングとしてはよいかもしれませんね。 Scala 2.8 2010-07-15 Scala 2.9 2011-05-12 Scala 2.10 2012-12-20 Scala 2.11 2014-05-20 Scala 2.12 2016-10-29 Scala 2.13.0-M3 2018-01-31 Scala 3.0 (with Dotty) ??? 20
  • 21. ScalikeJDBC, My Long-lived Scala Project では、そろそろ本題、まず私の Scala OSS について開発に 至った背景や大事にしている思想など、簡単に説明します。21
  • 22. Why I Started My Project I needed a practical DB library in 2011 I was going to start using Scala for real projects Twitter’s querulous looked reasonable, but it supported MySQL only ScalaQuery looked hard to master for me For Fun / To learn new things At the time, I was new to both Scala and OSS I wanted to try something exciting by myself 😎 2011 年当時、実用的な DB library を必要としていたのと、 新しいことをやってみたいという気持ちから始めました。 22
  • 23. History of DB Libraries Scala の RDB access library の変遷です。 今はメンテされていないものもいくつかあります。 23
  • 24. Non-practical Libraries In return for fancy APIs Not designed to solve real-world business problems New team members need long time to catch up Troubleshooting can be bothersome Insufficient information for debugging Frequently breaking API compatibilities Author suddenly stopped maintaining the library.. カッコいい API だが現実の問題に対応できない・学習コスト 高い。デバッグしにくい 。互換性をよく崩す。メンテが突然止 まる。これらに該当しないことが私の「実用的」の基準です。24
  • 25. Philosophy of ScalikeJDBC “Just write SQL and get things done!” Easy-to-understand Requires only Scala basics + JDBC basics No steep learning curve! (except for Scala 😜) Well-considered flexibility to deal with edge cases No breaking API changes as much as possible ScalikeJDBC が大事にしていること:すぐに理解し使える、 特殊ケースに対応できる、互換性を極力崩さない 25
  • 27. More than 6 Years 6 年以上特定の library の開発を継続してきました。 これは Scala community の中でも長い方でしょう。 I’ve been working on it for more than 6 years Scala 2.9 ~ 2.10 ~ 2.11 ~ 2.12 ~ 2.13 27
  • 28. Tips for Continuation KISS (Keep It Simple, Stupid) Principle Keep it Contributors Friendly Avoiding Depending on Scala Libraries Knowledge on Important Factors Cross-building Binary-compatibilities Building a Community of Friends You’re not alone! 🙌 継続で大事なこと:シンプルに保つこと、重要な要素(えwク ロスビルド / バイナリ互換)の理解、コミュニティの形成 28
  • 29. Avoiding Depending on Scala Libraries Scala library への依存を避けるべき:残念なことですが library を長くメンテするには大事なことです。 29
  • 30. Common reasons to do that Await their releases every Scala major upgrade If you depend on short-lived libraries.. When becoming unmaintained, you’ll have to fork and maintain them by yourself May bring binary compatibility issues Scala major upgrade の度に release 待ち、短命 library を 最悪 fork する羽目、バイナリ互換性の問題などありえます。30
  • 31. Fetters for Cross-building So difficult to do cross-building while depending on other Scala libraries All depending Scala libraries must do the exactly same cross-building (unrealistic..) If you give cross-building high priority, you should consider to depend on not Scala libraries but Java libraries (or no dependencies..) クロスビルドで他の Scala library への依存は相当な足かせで す。全ての依存がクロスビルドをしなければ成立しません。31
  • 32. Depending on Java libraries Depending on well-maintained Java libraries is a reasonable way to reduce your efforts No extra efforts when Scala major upgrade Stability (well-tested by large number of users) Downside of using Java libraries? Have to understand Java interoperability tips Have to completely encapsulate Java world which brings you lots of null 😢 Java library 依存は悪くない選択肢で色々楽になりますが Java な世界観を隠蔽するなどのケアは必要になるでしょう。32
  • 33. Cross-building Tips 特に ScalikeJDBC は古い Scala を使うユーザにも配慮してき ました。そのために必要な工夫について説明します。 33
  • 34. Supported Versions ScalikeJDBC は @xuwei-k の尽力のおかげもあり クロスビルドをかなり頑張っているライブラリです。 ScalikeJDBC Release date Scala binary versions sbt versions 1.0 2012-05 2.9.0 2.9.1 2.9.2 - 2.0 2014-05 2.10 2.11 0.13.x 3.0 2017-06 2.10 2.11 2.12 0.13.x 3.2 2018-01 2.10 2.11 2.12 0.13.x 1.x 34
  • 35. CI Build Configuration Properly configuring CI builds is the most important practice for cross-building If you don’t configure CI to check cross-building automatically, it’ll be very annoying to manually check the validity of pull requests CI ビルドを適切に設定して運用することが最も大事です。クロ スビルドを気にしながら PR を受け付けるには必須です。 35
  • 36. src/main/scala-2.x Dealing with deprecated APIs between Scala major versions / 3rd party libraries’ upgrades src/main/scala-{Scala binary version} 非推奨となった API を使い分ける場合 src/main の配下に binary version 毎に違うソースコードを置いて対処します。36
  • 38. Are Java Libraries Safe? Java language itself is binary compatible between major versions Great efforts for backward compatibilities 🙂 However, it’s not true for 3rd party Java libraries Even famous libraries sometimes break their binary compatibilities between releases (e.g) Jackson 2.x are basically binary incompatible Java ライブラリでバイナリ互換性を気にしたことがないあな たは幸運な人です。非互換はしばしば発生しているのです。38
  • 39. How to Ensure It Use “MiMa” MiMa = Migration Manager lightbend/migration-manager Using it via the sbt plugin is convenient MiMa(ミーマ)というツールがバイナリ非互換を検知してく れるのでこれを sbt プラグイン経由で使うのが一般的です。39
  • 40. When to Be Strict About It Up to the type of your library If you provide a low-level library that other libraries may depend on it you should be very careful As for directly used libraries / in-house libraries you don’t need to be so strict 社内や他の library が依存する library を提供しないなら、必 ずしもバイナリ互換性に厳密に取り組む必要性はありません。40
  • 41. ScalikeJDBC’s Policy Bump major/minor version when introducing some binary incompatibilities All patch version releases are bin-compatible GitHub branch strategies Having a corresponding git branch for each bin- compatible minor version (e.g. 3.2.x, 3.1.x, .. ) master branch: the latest (3.3.x as of March 2018) ポリシー:バイナリ非互換は major/minor ver、patch ver 間 はバイナリ互換を保証、git branch を minor 単位で運用 41
  • 42. MiMa Configuration ScalikeJDBC の設定例:クロスビルドで stable major のみを チェック、すべての patch versions との突き合わせ Skipping unstable Scala versions such as 2.13.0-M3 42
  • 43. Building a Community of Friends 🙌 OSS を続けることは一人でできることではありません。 コミュニティの中で仲間を見つけ、一緒に歩みましょう。 43
  • 44. Scala Ninja @xuwei-k Kenji Yoshida さんは「文字通り Scala 忍者」として知られて いる、まさに日本を代表するコミュニティ貢献者です。 44
  • 45. Not only the “Scala Ninja” 私の OSS は Yoshida さんの尽力はもちろんですが、多くの 方々の貢献のおかげで継続することができています。 45
  • 46. OSS Open/Closed Principle Open/Closed Principle Open for extension, but closed for modification OSS Open/Closed Principle Open for contribution, Friendly for new contributors; easy-to-.. but closed for confusion (to be long-lived) CI / test suites which detect common mistakes Clearly stipulated rules (CONTRIBUTING.md) 貢献に開いているプロジェクトの条件:動かしやすさ、理解し やすさ、安全な変更、テストコード、明記されたルール 46
  • 47. Just Keep Working on It Library maintainers must overcome upgrades Scala major upgrades / Cross-building sbt build settings upgrades I’m still taking time to adapt sbt 1.x .. It’s like a battle of patience.. Keep it simple, avoid hacky code/configuration Keep working on it at your own pace Library メンテナは Scala や sbt の更新に対応し続けなけれ ばいけません。凝ったことはせず、コツコツ持久戦で.. 47
  • 48. Let’s build our long-lived Scala community
 together! 😀 みんなで長く続く Scala コミュニティを作っていきましょう! この発表でご紹介したことがそのお役に立てば幸いです。 48