How we write and use Scala libraries not to cry

About me

M3,inc.

M3,inc.

We are using:
  • Java
  • Ruby
  • Scala

M3 & Scala

M3 & Scala

Lots of libraries

Three Problems in Scala

Theme 1

Binary Compatibility

In Java

<dependency>
  <groupId>org.mod4j.org.apache.commons</groupId>
  <artifactId>lang</artifactId>
  <version>2.1.0</version>
</dependency>
        

In Scala

<dependency>
  <groupId>com.github.seratch</groupId>
  <artifactId>scalikejdbc_2.9.1</artifactId>
  <version>1.4.3</version>
</dependency>
            
ArtifactId includes Scala version

Binary Compatibility

Prevents us from fast migration to newer version of Scala until all libraries our products depends on supports newer version.

Be careful!

Binary Compatibility

SBT

sbt

Cross Compiling

crossScalaVersions := Seq("2.9.1", "2.9.2", "2.10.0")
            
> + compile
> + publish
            
Compile and publish in multiple versions

Source Dependencies

import sbt._, sbt.Keys._
object ScalaProjectBuild extends Build {
  lazy val scalaProject = Project(
    id = "scala-project",
    base = file("."),
    settings = Project.defaultSettings ++ Seq(
      // add other settings here
    )
  ).dependsOn(
    uri("git://github.com/tototoshi/scala-csv.git#0.7.0")
  )
}
            

Scala Binary Version New!!

from SBT 0.12

ArtifactId now includes not Scala version but Scala binary version.

<dependency>
  <groupId>com.github.seratch</groupId>
  <artifactId>scalikejdbc_2.9.1</artifactId>
  <version>1.4.3</version>
</dependency>
            
<dependency>
  <groupId>com.github.seratch</groupId>
  <artifactId>scalikejdbc_2.10</artifactId>
  <version>1.4.3</version>
</dependency>
            

Scala version Scala binary version
2.10.0 2.10
2.10.1 2.10
2.10.2 2.10

Scala 2.10.x ensures their binary compatibility

During RC period

Scala version Scala binary version
2.10.0-RC1 2.10.0-RC1
2.10.0-RC2 2.10.0-RC2
2.10.0-RC3 2.10.0-RC3

Before 2.9.x

Scala version Scala binary version
2.9.1 2.9.1
2.9.2 2.9.2
2.8.2 2.8.2

Scala version == Scala binary version

Theme 2

Library Hosting

Library Hosting

Ruby RubyGems
Perl CPAN
Python PyPI
Java Maven Repository
Scala Maven Repository

One upon a time

There is a repository called scala-tools.org.... scala-tools down

Now, Sonatype

Why should we use sonatype?

Conclusion

Enjoy Scala!