sbt 1.6.0-RC1

Hi everyone. On behalf of the sbt project, I am happy to announce sbt 1.6.0-RC1. This is the sixth feature release of sbt 1.x, a binary compatible release focusing on new features. sbt 1.x is released under Semantic Versioning, and the plugins are expected to work throughout the 1.x series. Please try it out, and report any issues you might come across.

  • If no serious issues are found by Saturday, December 11th 2021, 1.6.0-RC1 will become 1.6.0 final.

The headline features of sbt 1.6.0 are:

  • Improved JDK 17 support
  • BSP improvements
  • Zinc improvements
  • Remote caching improvements
  • Tab completion of global keys

sudori part 3

I’m hacking on a small project called sudori, an experimental sbt. The initial goal is to port the macro to Scala 3. It’s an exercise to take the macro apart and see if we can build it from the ground up. This an advanced area of Scala 2 and 3, and I’m finding my way around by trial and error. This is part 3. It’s been a while since I wrote part 2, but in between I’ve written intro to Scala 3 macros, which is sort of a sudori prequel.

Starlark 4.2.1

Starlark is a dialect of Python, originally designed as a configuration language for the Bazel build tool. Currently there are implementations in Go, Java, and Rust. As far as I know, the main Java implementation of Starlark has only been available as Bazel’s source repo on GitHub. Since it would be convenient to have a binary distribution, I’ve forked the repo, and published it as "com.eed3si9n.starlark" % "starlark" % "4.2.1" (com.

JDK 17 on GitHub Actions

Here’s a quick tutorial of how to test your project on JDK 17 using Ólaf’s olafurpg/setup-scala. As the starting point we’ll use the following setup, which is documented in Setting up GitHub Actions with sbt: name: CI on: pull_request: push: jobs: test: strategy: fail-fast: false matrix: include: - os: ubuntu-latest java: 11 jobtype: 1 - os: ubuntu-latest java: 11 jobtype: 2 - os: ubuntu-latest java: 11 jobtype: 3 runs-on: ${{ matrix.

intro to Scala 3 macros

Introduction Macro is a fun and powerful tool, but overuse of the macro could cause harm as well. Please enjoy macros responsibly. What is macro? A common explanation given is that a macro is a program that is able to take code as an input and output code. While it’s true, it might not immediately make sense since Scala programmers are often familiar with higher-order functions like (map {...}) and by-name parameter, which on the surface it might seem like it is passing a block of code around.

Jar Jar Abrams 1.8.0 and sbt-assembly 1.1.0

Jar Jar Abrams 1.8.0 and sbt-assembly 1.1.0 are released. Jar Jar Abrams is an experimental extension to Jar Jar Links, intended to shade Scala libraries. Thus far we have been using Pants team’s fork of Jar Jar Links, but now that it’s been abandaned, Eric Peters has in-sourced it to jarjar-abrams repo so we can patch it. Our jarjar fork is released under com.eed3si9n.jarjar organization name and package name. bug fixes Eric has fixed a bug around ShadeRules.

sudori part 2

I’m hacking on a small project called sudori, an experimental sbt. The initial goal is to port the macro to Scala 3. It’s an exercise to take the macro apart and see if we can build it from the ground up. This an advanced area of Scala 2 and 3, and I’m finding my way around by trial and error. This is part 2. Reference: Scala 3 Reference: Metaprogramming sudori part 1 Instance When we think of the build.

sudori part 1

I’m hacking on a small project called sudori, an experimental sbt. The initial goal is to port the macro to Scala 3. It’s an exercise to take the macro apart and see if we can build it from the ground up. This an advanced area of Scala 2 and 3, and I’m finding my way around by trial and error. Reference: Scala 3 Reference: Metaprogramming Convert I think I’ve identified a basic part called Convert, which doesn’t really depend on anything.

sbt 1.5.5

I’m happy to announce sbt 1.5.5 patch release is available. Full release note is here - https://github.com/sbt/sbt/releases/tag/v1.5.5

Highlights

sbt 1.5.4

I’m happy to announce sbt 1.5.4 patch release is available. Full release note is here - https://github.com/sbt/sbt/releases/tag/v1.5.4 How to upgrade Download the official sbt runner + launcher from SDKMAN or download from https://github.com/sbt/sbt/releases/. In addition, the sbt version used for your build is upgraded by putting the following in project/build.properties: sbt.version=1.5.4 This mechanism allows that sbt 1.5.4 is used only for the builds that you want. Highlights Fixes compiler ClassLoader list to use compilerJars.

sbt-assembly 1.0.0

In June of 2011, I started working on sbt-assembly for sbt 0.10, based on Coda Hale’s assembly-sbt from sbt 0.7, which in turn was probably inspired by maven-assembly-plugin. After ten years, I’m going to call this one 1.0.0. sbt-assembly 1.0.0 is published to Maven Central.

sbt 1.5.3

I’m happy to announce sbt 1.5.3 patch release is available. Full release note is here - https://github.com/sbt/sbt/releases/tag/v1.5.3 How to upgrade Download the official sbt runner + launcher from SDKMAN or download from https://github.com/sbt/sbt/releases/. In addition, the sbt version used for your build is upgraded by putting the following in project/build.properties: sbt.version=1.5.3 This mechanism allows that sbt 1.5.3 is used only for the builds that you want. Highlights Fixes scalacOptions not getting forwarded to ScalaDoc in Scala 3 #6499 by @pikinier20 Fixes undercompilation of sealed traits that extends other seal traits zinc#979 by @dwijnand Fixes version parsing not recognizing dots in a prerelease tag lm#377 by @Nirvikalpa108 Fixes inputFile resolving to incorrect files when file specific globs are used io#319 by @eatkins Updates to Scala 2.

Scala, Python quick reference

syntax Scala Python immutable variable val x = 1 Starlark: REV = "1.1.0" lazy variable lazy val x = 1 n/a mutable variable var x = 1 in function: x = 1 if expression if (x > 1) "a" else "b" "a" if x > 1 else "b" ———————- —————————- —————————- function def add3(x: Int): Int =

POM consistency for sbt plugins

There’s a long-standing bug that sbt maintainers have known for a while, which is that when sbt plugin is published to a Maven repository, the POM file sbt generates is not valid. From a mailing list thread titled [0.12] plan for instance, Mark McBride reported it in 2012: On the maven note, the poms generated for plugins aren’t actually valid. Trying to upload them to artifactory without disabling pom consistency checks fails :/

sbt 1.5.2

I’m happy to announce sbt 1.5.2 patch release is available. Full release note is here - https://github.com/sbt/sbt/releases/tag/v1.5.2 How to upgrade Download the official sbt runner + launcher from SDKMAN or download from https://github.com/sbt/sbt/releases/. In addition, the sbt version used for your build is upgraded by putting the following in project/build.properties: sbt.version=1.5.2 This mechanism allows that sbt 1.5.2 is used only for the builds that you want. Highlights Fixes sbt new leaving behind target directory #6488 by @eed3si9n Fixes ConcurrentModificationException while compiling Scala 2.

Bintray to JFrog Artifactory migration status and sbt 1.5.1

I’m happy to announce sbt 1.5.1 patch release is available. Full release note is here - https://github.com/sbt/sbt/releases/tag/v1.5.1. This post will also report the Bintray to JFrog Artifactory migration. Bintray to JFrog Artifactory migration status First and foremost, I would like to thank JFrog for their continued support of sbt project and the Scala ecosystem. As sbt was taking off in the number of contributors and plugins, we had a Bintray-shaped problem.

herding cats: day 19

Wrote herding cats: day 19 featuring FunctionK, or Rúnar’s encoding of rank-2 polymorphic function, and Resource datatype, which he envisioned rank-N polymorphism would unlock back in 2010.

sbt 1.5.0

Hi everyone. On behalf of the sbt project, I am happy to announce sbt 1.5.0. This is the fifth feature release of sbt 1.x, a binary compatible release focusing on new features. sbt 1.x is released under Semantic Versioning, and the plugins are expected to work throughout the 1.x series. The headline features of sbt 1.5.0 are: Scala 3 support Eviction error Deprecation of sbt 0.13 syntax Coursier-based launcher How to upgrade Download the official sbt launcher from SDKMAN or download from https://github.

sbt 1.5.0-RC2

Hi everyone. On behalf of the sbt project, I am happy to announce sbt 1.5.0-RC2. This is the fifth feature release of sbt 1.x, a binary compatible release focusing on new features. sbt 1.x is released under Semantic Versioning, and the plugins are expected to work throughout the 1.x series. If no serious issues are found by Saturday, April 3rd 2021, 1.5.0-RC2 will become 1.5.0 final. If no serious issues are found by Saturday, March 27th 2021, 1.

sbt 1.4.9

I’m happy to announce sbt 1.4.9 patch release is available. Full release note is here - https://github.com/sbt/sbt/releases/tag/v1.4.9 How to upgrade Download the official sbt launcher from SDKMAN or download from https://github.com/sbt/sbt/releases/. In addition, the sbt version used for your build is upgraded by putting the following in project/build.properties: sbt.version=1.4.9 This mechanism allows that sbt 1.4.9 is used only for the builds that you want. Highlights sbt 1.4.9 fixes JLine 2 fork + JAnsi version to match that of JLine 3.

sbt 1.4.8

I’m happy to announce sbt 1.4.8 patch release is available. Full release note is here - https://github.com/sbt/sbt/releases/tag/v1.4.8 How to upgrade Download the official sbt launcher from SDKMAN or download from https://github.com/sbt/sbt/releases/. In addition, the sbt version used for your build is upgraded by putting the following in project/build.properties: sbt.version=1.4.8 This mechanism allows that sbt 1.4.8 is used only for the builds that you want. Highlights sbt 1.4.8 is a maintenance patch.

syntactic Scalafix rule for unified slash syntax

In sbt 1.1.0 I implemented unified slash syntax for sbt. Today I sent a pull request to deprecate the old sbt 0.13 shell syntax #6309. Naturally, the topic of deprecating old syntax for build.sbt also came up. will you also deprecate `scalacOptions in (Compile, console)` in *.sbt and *.scala files? I hope so — Seth Tisue (@SethTisue) February 16, 2021 This is because “unified” slash syntax is called so because it unifies the shell syntax and the build syntax together.

git bisecting scala/scala

git bisecting is a useful technique to locate the source of a bug. For scala/scala in particular, bisect.sh can save a lot of time by using the pre-build compiler artifacts on the Scala CI Artifactory.

sbt 1.4.7

I’m happy to announce sbt 1.4.7 patch release is available. Full release note is here - https://github.com/sbt/sbt/releases/tag/v1.4.7 How to upgrade Download the official sbt launcher from SDKMAN or download from https://github.com/sbt/sbt/releases/. In addition, the sbt version used for your build is upgraded by putting the following in project/build.properties: sbt.version=1.4.7 This mechanism allows that sbt 1.4.7 is used only for the builds that you want. Highlights Updates to Coursier 2.0.9, fixing authentication with Sonatype Nexus #6278 / [coursier#1948] by @cchepelov Fixes Ctrl-C printing out stack trace #6213 by @eatkins GNU Emacs support for sbtn and sbt --client #6276 by @fommil Participation sbt 1.

sbt 1.4.6

I’m happy to announce sbt 1.4.6 patch release is available. Full release note is here - https://github.com/sbt/sbt/releases/tag/v1.4.6 How to upgrade Download the official sbt launcher from SDKMAN or download from https://github.com/sbt/sbt/releases/. In addition, the sbt version used for your build is upgraded by putting the following in project/build.properties: sbt.version=1.4.6 This mechanism allows that sbt 1.4.6 is used only for the builds that you want. Highlights Updates to Coursier 2.0.8, which fixes the cache directory setting on Windows (Fix contributed by Frank Thomas) Fixes performance regression in shell tab completion #6214 by @eed3si9n Fixes match error when using withDottyCompat lm#352 by @eed3si9n Fixes thread-safety in AnalysisCallback handler zinc#957 by @dotta Participation sbt 1.

enforcing Semantic Versioning with sbt-strict-update

Rob wrote: I want to tell sbt “this specific version breaks binary compatibility, so don’t resolve it via eviction, fail the build instead.” How do I do this? Complete answers only, I’m done trying to figure it out by following clues. I wrote a small sbt plugin sbt-strict-update to do this. Add this to project/plugins.sbt: addSbtPlugin("com.eed3si9n" % "sbt-strict-update" % "0.1.0") and then add this to build.sbt: ThisBuild / libraryDependencySchemes += "org.

sbt 1.4.5

I’m happy to announce sbt 1.4.5 patch release is available. Full release note is here - https://github.com/sbt/sbt/releases/tag/v1.4.5 How to upgrade Download the official sbt launcher from SDKMAN or download from https://github.com/sbt/sbt/releases/. In addition, the sbt version used for your build is upgraded by putting the following in project/build.properties: sbt.version=1.4.5 This mechanism allows that sbt 1.4.5 is used only for the builds that you want. Highlights sbt 1.4.5 adds support for Apple silicon (AArch64 also called ARM64) #6162/#6169 by @eatkins Updates to Coursier 2.

auto publish sbt plugin from GitHub Actions

This is a GitHub Actions version of auto publish sbt plugin from Travis CI. In this post, we’ll try to automate the release of an sbt plugin using Ólaf’s olafurpg/sbt-ci-release. The README of sbt-ci-release covers the use case for a library published to Sonatype OSS. Read it thoroughly since this post will skip over the details that do not change for publishing sbt plugins. Automated release in general is a best practice, but there’s one benefit specifically for sbt plugin releases.

scopt 4

This post was first published in December 2018 together with 4.0.0-RC2. It’s updated to reflect the changes made in November 2020 for 4.0.0. You can skip to the readme, if you’re in a hurry. To try new scopt 4.0.0: libraryDependencies += "com.github.scopt" %% "scopt" % "4.0.0" scopt 4.0.0 is cross published for the following build matrix: Scala JVM JS (1.x) JS (0.6.x) Native (0.4.0-M2) Native (0.

Weehawken-Lang1

about Weehawken-Lang It’s a strange time we live in. We can’t just meet up and catch up and talk about coding. This also opens an opportunity to think more virtually about the idea of meetups. I want to start Weehawken-Lang, a virtual meetup group about programming languages and tooling design (compilers, interpreters, build tools etc). It aims to be a casual place where people with different language backgrounds can exchange ideas about programming languages.

sbt 1.4.4

I’m happy to announce sbt 1.4.4 patch release is available. Full release note is here - https://github.com/sbt/sbt/releases/tag/v1.4.4 How to upgrade Download the official sbt launcher from SDKMAN or download from https://github.com/sbt/sbt/releases/. In addition, the sbt version used for your build is upgraded by putting the following in project/build.properties: sbt.version=1.4.4 This mechanism allows that sbt 1.4.4 is used only for the builds that you want. Highlights Updates SemanticDB to 4.4.0 to support Scala 2.

sbt 1.4.3

I’m happy to announce sbt 1.4.3 patch release is available. Full release note is here - https://github.com/sbt/sbt/releases/tag/v1.4.3 How to upgrade Download the official sbt launcher from SDKMAN or download from https://github.com/sbt/sbt/releases/. This installer includes the sbtn binary. In addition, the sbt version used for your build is upgraded by putting the following in project/build.properties: sbt.version=1.4.3 This mechanism allows that sbt 1.4.3 is used only for the builds that you want.

sbt 1.4.2

I’m happy to announce sbt 1.4.2 patch release is available. Full release note is here - https://github.com/sbt/sbt/releases/tag/v1.4.2 How to upgrade Download the official sbt launcher from SDKMAN or download from https://github.com/sbt/sbt/releases/. This installer includes the sbtn binary. In addition, the sbt version used for your build is upgraded by putting the following in project/build.properties: sbt.version=1.4.2 This mechanism allows that sbt 1.4.2 is used only for the builds that you want.

remote caching sbt builds with Bintray

The feature in sbt and Zinc 1.4.x that I spent most amount of time and energy probably is the virtualization of file, and lifting out timestamps. Combined together, we can liberate the Zinc state from machine-specificity and time, and become the foundation we lay towards building incremental remote caching for Scala. I blogged about this in cached compilation for sbt. This is part 2. Now that sbt 1.4.x is out, there is a growing interest in this feature among people who want to try this out.

sbt 1.4.1

I’m happy to announce sbt 1.4.1 patch release is available. Full release note is here - https://github.com/sbt/sbt/releases/tag/v1.4.1 How to upgrade Download the official sbt launcher from SDKMAN or download from https://www.scala-sbt.org/download.html. This installer includes the sbtn binary. In addition, the sbt version used for your build is upgraded by putting the following in project/build.properties: sbt.version=1.4.1 This mechanism allows that sbt 1.4.1 is used only for the builds that you want.

virtualizing a hackathon at ScalaMatsuri 2020

Here’s a report of running a virtual hackathon at ScalaMatsuri Day 2 Unconference. Someone proposed it for the Unconference, and I volunteered to be a facilitator on the day, so I went in without preparation. I booked the time originally for 4h (noon - 4pm JST, 11pm - 3am EDT) but it was successful so it got extended after some coffee break. One thing I emphasize is The Law of Two Feet:

sbt 1.4.0

Hi everyone. On behalf of the sbt project, I am happy to announce sbt 1.4.0. This is the fourth feature release of sbt 1.x, a binary compatible release focusing on new features. sbt 1.x is released under Semantic Versioning, and the plugins are expected to work throughout the 1.x series.

The headline features of sbt 1.4.0 are:

  • build server protocol (BSP) support
  • sbtn: a native thin client for sbt
  • build caching
  • ThisBuild / versionScheme to take the guessing out of eviction warning

sbt 1.4.0-RC2

Hi everyone. On behalf of the sbt project, I am happy to announce sbt 1.4.0-RC2. This is the fourth feature release of sbt 1.x, a binary compatible release focusing on new features. sbt 1.x is released under Semantic Versioning, and the plugins are expected to work throughout the 1.x series.

  • If no serious issues are found by Saturday, October 3rd 2020, 1.4.0-RC2 will become 1.4.0 final.
  • If no serious issues are found by Saturday, September 19th 2020, 1.4.0-RC1 will become 1.4.0 final.

The headline features of sbt 1.4.0 are:

  • build server protocol (BSP) support
  • sbtn: a native thin client for sbt
  • build caching
  • ThisBuild / versionScheme to take the guessing out of eviction warning

parallel cross building sandwich

This is part 4 of the post about sbt-projectmatrix, an experimental plugin that I’ve been working to improve the cross building in sbt. Here’s part 1, part 2, and part 3. I’ve just released 0.6.0. recap: building against multiple Scala versions After adding sbt-projectmatrix to your build, here’s how you can set up a matrix with two Scala versions. ThisBuild / organization := "com.example" ThisBuild / scalaVersion := "2.12.12" ThisBuild / version := "0.

joining Twitter

I’m excited to announce that I’m joining Twitter’s Build Team to work on the next generation of efficient build systems supporting thousands of Twitter developers worldwide. Today’s my first day. This is the team that developed monorepo build tool Pants, and is transitioning to migrate the flock to Bazel. This presented a unique opportunity for me to work with a team of people passionate about developer experience and productivity, and I’m looking forward to getting to know the team, and learning the new challenges.

sbt-buildinfo 0.10.0

I’m happy to announce sbt-buildinfo 0.10.0. sbt-buildinfo is a small sbt plugin to generate BuildInfo object from your build definitions.

Since the last feature release was in 2018, there have been some pending contributions. I think the important thing is that it compiles with -Xlint and -Xfatal-warnings on both Scala 2.13.3 and 2.12.12.

auto publish sbt plugin from Travis CI

In this post, we’ll try to automate the release of an sbt plugin using Ólafur’s olafurpg/sbt-ci-release. The README of sbt-ci-release covers the use case for a library published to Sonatype OSS. Read it thoroughly since this post will skip over the details that do not change for publishing sbt plugins. Automated release in general is a best practice, but there’s one benefit specifically for sbt plugin releases. Using this setup allows multiple people to share the authorization to release an sbt plugin without adding them to Bintray sbt organization.

sbt 1.3.13

I’m happy to announce sbt 1.3.13 patch release. Full release note is here - https://github.com/sbt/sbt/releases/tag/v1.3.13.

Special thanks to Scala Center. It takes time to review bug reports, pull requests, make sure contributions land to the right places, and Scala Center sponsored me to do maintainer tasks for sbt during June.

sbt 1.3.12

I’m happy to announce sbt 1.3.12 patch release. Full release note is here - https://github.com/sbt/sbt/releases/tag/v1.3.12. Special thanks to Scala Center. It takes time to review bug reports, pull requests, make sure contributions land to the right places, and Scala Center sponsored me to do maintainer tasks for sbt during May. Darja + whole Scala Center crew have been chill to work with. Change since sbt 1.3.11 There was a regression in sbt 1.

sbt 1.3.11

I’m happy to announce sbt 1.3.11 patch release. Full release note is here - https://github.com/sbt/sbt/releases/tag/v1.3.11. Special thanks to Scala Center. It takes time to review bug reports, pull requests, make sure contributions land to the right places, and Scala Center sponsored me to do maintainer tasks for sbt during May. Darja + whole Scala Center crew have been chill to work with. How to upgrade Normally changing the project/build.properties to

Jar Jar Abrams

Jar Jar Abrams is an experimental Scala extension of Jar Jar Links, a utility to shade Java libraries. For library authors, the idea of other library is a double-edged sword. On one hand, using other libraries avoids unnecessary duplication of work, not using other libraries is almost hypocritical. On the other hand, each library you add would add a transitive dependency to your users, increasing the possibility of conflict. This is partly due to the fact that within a single running program you can one have one version of a library.

Selective functor in sbt

In sbt core concepts talks I’ve been calling sbt a casually functional build tool. Two hallmarks of functional programming are that it uses immutable data structure instead of mutation, and that it gives attention to when and how effects are handled. settings and tasks From this perspective, we can think of setting expressions and tasks to be those two things: Settings form an immutable graph in a build. Tasks represent effects.

keeping promise in sbt

build.sbt is a DSL for defining a task graph to be used for automatic parallel processing. The message passing among the tasks are expressed using something.value macro, which encodes Applicative composition (task1, task2) mapN { case (t1, t2) => .... }. One mechanism I’ve been thinking about is allowing some long-running task1 to communicate with task2 midway. Normally, we would break down task1 into two subtasks. But it might not be as straight-forward to implement such thing.

cached compilation for sbt

The notion of cached compilation or remote cache has been around for a while now, but often it required the setup has not been easy. If we can bake build-as-function feature into basic tool chain such as Zinc and sbt, Scala community in general can benefit from it to speed up the build. Even for open source projects, if Travis CI publishes into Bintray or something, the contributors might be able to resume compilation off of the last build. The PR for sbt change is sbt/sbt#5534, and the virtualization change in Zinc is sbt/zinc#712.

about me

I am Eugene Yokota (@eed3si9n on Twitter and GitHub), a software engineer with years of experience working on Scala tooling. I’ve been lead sbt maintainer since 2014, former Tech Lead of the Lightbend Tooling Team, and Principal Engineer on the Scala (Compiler) Team (See 6 years at Lightbend for details). I’m passionate about improving developer experience on and off the work, and like to tinker with ideas both through coding and this blog http://eed3si9n.

sbt 1.3.10

I’m happy to announce sbt 1.3.10 patch release. Full release note is here - https://github.com/sbt/sbt/releases/tag/v1.3.10 How to upgrade Normally changing the project/build.properties to sbt.version=1.3.10 would be ok. However, given that the release may contain fixes to scripts and also because your initial resolution would be faster with *.(zip|tgz|msi) that contains all the JAR files, we recommend you use the installer distribution. They will be available from SDKMAN etc. Notes about Homebrew Homebrew maintainers have added a dependency to JDK 13 because they want to use more brew dependencies brew#50649.

Zinc 1.4.0-M1

I’ve just released Zinc 1.4.0-M1. Note this is a beta release and it won’t be compatible with future 1.4.x, but I chose a commit fairly close to 1.3.x so it should be usable. Cross builds Zinc to Scala 2.12 and 2.13 zinc#754 by @eed3si9n Upgrades ScalaPB to 0.9.3 zinc#713 by @slandelle Replaces ZipUtils usage of deprecated java.util.Date with java.time zinc#714 by @slandelle Zinc is an incremental compiler for Scala.

parallel cross building, part 3

This is part 3 of the post about sbt-projectmatrix, an experimental plugin that I’ve been working to improve the cross building in sbt. Here’s part 1 and part 2. I’ve just released 0.5.0. recap: building against multiple Scala versions After adding sbt-projectmatrix to your build, here’s how you can set up a matrix with two Scala versions. ThisBuild / organization := "com.example" ThisBuild / scalaVersion := "2.12.10" ThisBuild / version := "0.

6 years at Lightbend

I joined Lightbend (then Typesafe) in March, 2014. After six incredible years April 7, 2020 was my last day. I am grateful that I got the opportunity to work with an amazing group of people at Lightbend, partners, customers, and various people I got to meet at conferences. Looking back, before COVID-19 times, it’s almost surreal that I was flying to Europe, Asia, and North America every few months to attend conferences and tech meetings.

user-land compiler warnings in Scala, part 2

Last week I wrote about #8820, my proposal to add user-land compiler warnings in Scala. The example I had was implementing ApiMayChange annotation. package foo import scala.annotation.apiStatus, apiStatus._ @apiStatus( "should DSL is incubating, and future compatibility is not guaranteed", category = Category.ApiMayChange, since = "foo-lib 1.0", defaultAction = Action.Warning, ) implicit class ShouldDSL(s: String) { def should(o: String): Unit = () } This was ok as a start, but a bit verbose.

bianlu plant-based hotpot

serves 4? ingredients 1 head of napa cabbage 100 ml of semame oil 5 dried shiitake some dried kombu kelp 160g vermicelli bean thread frozen meatless meatballs kosher salt chili oil, chili oil with fried garlic, or chili powder (optional) cooked white rice steps put cold water in a large dutch oven with 5 dried shiitake and similar amount of dried kombu kelp. let it sit for a few hours covered.

user-land compiler warnings in Scala

As a library author, I’ve been wanting to tag methods in Scala that can trigger custom warnings or compiler errors. Why would I want to intentionally cause a compiler error? One potential use case is displaying a migration message for a removed API. Restligeist macro: n. A macro that fails immediately to display migration message after implementation has been removed from the API. — ∃ugene yokot∀ (@eed3si9n) August 30, 2016 For example, if you try to use <<= in sbt 1.

equal protection under Eq law

The relationship given to Int and Long should be exactly the same as the relationship third-party library like Spire can write UInt or Rational with the first-class numeric types.

  • We should make 1 == 1L an error under strictEquality
  • We should allow custom types to participate in constant expression conversion using FromDigits

liberty, equality, and boxed primitive types

I want to understand how equality works in Scala. It’s a complicated topic that’s been going on for ten years. Major concerns are: null Unboxed number types Boxed number types Reference types Collections (especially of F[+A]) Understanding equality means knowing how these combinations are compared. Scala Language Specification The language spec provides some hints, although it does not have the full information. Chapter 12 contains the definition of Any as follows:

Giter8 0.12.0

giter8.version

I added a small app called giter8-launcher for Giter8 0.12.0. The purpose of the app is to make the behavior of the Giter8 template more predictable. Today, template authors may create a template for some version of Giter8 X, but the users might use some other version of Giter8 Y that ships with “sbt new.”

One of the neat ideas about sbt is that no matter what version of sbt script users might have it installed, the core sbt version is specified by the build author using project/build.properties file. This significantly reduces the it-only-works-on-my-machine problem. giter8-launcher is analogous to sbt’s sbt-launcher. giter8-launcher clones the template and reads project/build.properties file to determine the Giter8 version to render the template.

Template authors can now specify the Giter8 version in project/build.properties file as:

giter8.version=0.12.0

parallel cross building with VirtualAxis

This is part 2 of the post about sbt-projectmatrix, an experimental plugin that I’ve been working to improve the cross building in sbt. Here’s part 1. I’ve just released 0.4.0. recap: building against multiple Scala versions After adding sbt-projectmatrix to your build, here’s how you can set up a matrix with two Scala versions. ThisBuild / organization := "com.example" ThisBuild / scalaVersion := "2.12.10" ThisBuild / version := "0.1.0-SNAPSHOT" lazy val core = (projectMatrix in file("core")) .

Pamflet 0.8.2

Pamflet is a publishing application for short texts, particularly user documentation of open-source software.

Pamflet 0.8.2 updates its monospace typeface to SFMono, and undoes the incidental pink color that got introduced when I migrated from Blueprint to Bootstrap.

semantics of dependency resolvers

The semantics of a dependency resolver determine the concrete classpath based on the user-specified dependency constraints. Typically the differences in the details manifest as different way the version conflicts are resolved.

  • Maven uses nearest-wins strategy, which could downgrade transitive dependencies
  • Ivy uses latest-wins strategy
  • Coursier generally uses latest-wins strategy, but it’s tries to enforce version range strictly
  • Ivy’s version range handling goes to the Internet, which makes the build non-repeatable
  • Coursier orders version string completely differently from Ivy

parallel cross building using sbt-projectmatrix

Last year I wrote an experimental sbt plugin called sbt-projectmatrix to improve the cross building in sbt. I’ve just released 0.2.0. building against multiple Scala versions After adding sbt-projectmatrix to your build, here’s how you can set up a matrix with two Scala versions. ThisBuild / organization := "com.example" ThisBuild / scalaVersion := "2.12.8" ThisBuild / version := "0.1.0-SNAPSHOT" lazy val core = (projectMatrix in file("core")) .settings( name := "core" ) .

splitting git repo

split a subdirectory into a new repo (simple case) git clone --no-hardlinks --branch master originalRepoURL childRepo cd childRepo git filter-branch --prune-empty --subdirectory-filter path/to/keep master git remote remove origin git prune git gc --aggressive Change originalRepoURL, master, and path/to/keep to appropriate values. Use -- --all to handle all branches. split a subdirectory into a new repo (complex case) In case you have multiple paths you want to filter, you need to use --index-filter together with GNU xargs and GNU sed available via brew install gnu-sed findutils.

all your JDKs on Travis CI using SDKMAN!

This is a second post on installing your own JDKs on Travis CI. Previously I’ve written about jabba. Today, let’s look at SDKMAN!, an environment manager written by Marco Vermeulen (@marc0der) for JDKs and various tools on JVM, including Groovy, Spark, sbt, etc. AdoptOpenJDK 11 and 8 Update 2020-09-23: Updated the regex of version number. Update 2019-11-06: Added sdkman_auto_selfupdate to workaround the update prompt blocking the CI. Also it adds || true on the sdk install line.

'Ancillary Justice' by Ann Leckie

Ancillary Justice by Ann Leckie My rating: 4 of 5 stars ‘Ancillary Justice’ is written in a first-person narrative as the AI of thousands of years old starship Justice of Toren of The Radchaai Empire. Another interesting part is since the Radchaai language is genderless, the narrator constantly describes everyone as “she,” but later you might discover that some character might be he. There are other small details here and there that narrator might say, but you start to question it as the story develops.

Pamflet 0.8.0

Over the holiday break I’ve implemented left TOC for Pamflet, and released it as Pamflet 0.8.0.

Pamflet is a publishing application for short texts, particularly user documentation of open-source software.

masking scala.Seq

As of Scala 2.13.0-M5, it’s planned that scala.Seq will change from scala.collection.Seq to scala.collection.immutable.Seq. Scala 2.13 collections rework explains a bit about why it’s been non-immutable historically. Between the lines, I think it’s saying that we should celebrate that scala.Seq will now be immutable out of the box. Defaulting to immutable sequence would be good for apps and fresh code. The situation is a bit more complicated for library authors.

making conference a safer space for women

We need to change the culture around tech conferences to improve the inclusion of women (and people from other backgrounds too!). For that, there needs to be clear signaling and communication about two basic issues

  1. No, it’s not ok to hit on women at a conference.
  2. Assume technical competence, and treat women as professional peers. These points should be communicated over and over at each conference before the keynote takes place, and before socializing hours.

'Red Mars' by Kim Stanley Robinson

Red Mars (Mars Trilogy, #1)Red Mars by Kim Stanley Robinson
My rating: 4 of 5 stars

Red Mars is a science fiction classic written in 1992. This book is everything I wanted and more, starting with first hundred astronauts and cosmonauts migrating to Mars to build the infrastructure such that more people can migrate. By the middle of the book, thousands of people migrate to Mars. The book explores various dimensions the epic project, not just technological challenges, but psychological effects, personality differences, and political interests by superpowers. The geography of Mars is written in vivid, majestic details.

super shell for sbt

I’ve implemented “super shell” feature for sbt over the weekend. The idea is to take over the bottom n lines of the termnial, and display the current tasks in progress. the limitation of using log as status report Logs are useful in many situations, and sometimes it’s the only viable tool to find out what’s going on. But on a console app like sbt, using logs to tell the build user what’s going on doesn’t always work.

stricter Scala with -Xlint, -Xfatal-warnings, and Scalafix

Compile, or compile not. There’s no warning. Two of my favorite Scala compiler flags lately are "-Xlint" and "-Xfatal-warnings". Here is an example setting that can be used with subprojects: ThisBuild / organization := "com.example" ThisBuild / version := "0.1.0-SNAPSHOT" ThisBuild / scalaVersion := "2.12.6" lazy val commonSettings = List( scalacOptions ++= Seq( "-encoding", "utf8", "-deprecation", "-unchecked", "-Xlint", "-feature", "-language:existentials", "-language:experimental.macros", "-language:higherKinds", "-language:implicitConversions", "-Ypartial-unification", "-Yrangepos", ), scalacOptions ++= (scalaVersion.value match { case VersionNumber(Seq(2, 12, _*), _, _) => List("-Xfatal-warnings") case _ => Nil }), Compile / console / scalacOptions --= Seq("-deprecation", "-Xfatal-warnings", "-Xlint") ) lazy val foo = (project in file("foo")) .

git gone: cleaning stale local branches

Working with GitHub and pull requests a lot, I end up accumulating stale branches that are no longer needed. In this post, we will look at how to clean the stale local branches. There are mainly two strategies: Pick a “master” branch, and delete what’s merged to it Assuming branches are deleted first on GitHub, delete local branches that no longer exists on remote “origin” Erik Aybar’s Git Tip: Deleting Old Local Branches takes the second approach.

console games in Scala

I’ve been thinking about rich console applications, the kind of apps that can display things graphically, not just appending lines at the end. Here are some info, enough parts to be able to write Tetris. ANSI X3.64 control sequences To display some text at an arbitrary location on a termial screen, we first need to understand what a terminal actually is. In the middle of 1960s, companies started selling minicomputers such as PDP-8, and later PDP-11 and VAX-11.

all your JDKs on Travis CI using jabba

Whether you want to try using OpenJDK 11-ea, GraalVM, Eclipse OpenJ9, or you are stuck needing to build using OpenJDK 6, jabba has got it all. jabba is a cross-platform Java version manager written by Stanley Shyiko (@shyiko). AdoptOpenJDK 8 and 11 Here’s how we can use jabba on Travis CI to cross build using AdoptOpenJDK 8 and 11: sudo: false dist: trusty group: stable language: scala scala: - 2.12.7 env: global: - JABBA_HOME=/home/travis/.

bringing back power assert with Expecty

Last week I wrote about using source dependencies with sbt-sriracha for testing purpose. This week we’ll look into using Expecty to do power assert. Power assert (or power assertion) is a variant of assert(...) function that that prints out detailed error message automatically. It was originally implemented by Peter Niederwieser (@pniederw) for Spock, and in 2009 it was merged into Groovy 1.7. Power assert has spread to Ruby, JavaScript, Rust, etc.

hot source dependencies using sbt-sriracha

Source dependencies is one of features that existed in sbt since ever, but hasn’t been documented well. immutable source dependency Here’s how to declare source dependency to the latest commit for scopt commandline option parsing library. lazy val scoptJVMRef = ProjectRef(uri("git://github.com/scopt/scopt.git#c744bc48393e21092795059aa925fe50729fe62b"), "scoptJVM") ThisBuild / organization := "com.example" ThisBuild / scalaVersion := "2.12.2" lazy val root = (project in file(".")) .dependsOn(scoptJVMRef) .settings( name := "Hello world" ) When you start sbt and run compile, sbt will automatically clone scopt/scopt under the staging directory, and link the builds together.

detecting Java version from Bash

Yesterday I wrote about cross JVM testing using Travis CI. testing Scala apps on macOS using Travis CI Here’s how we can test Scala apps on macOS using Travis CI. This is adapted from Lars and Muuki’s method: Testing Scala programs with Travis CI on OS X dist: trusty language: scala matrix: include: ## build using JDK 8, test using JDK 8 - script: - sbt universal:packageBin - cd citest && .

cross JVM testing using Travis CI

Oracle is moving to ship non-LTS JDK every 6 months, and LTS JDK every 3 years. Also it’s converging to OpenJDK. In this scheme, JDK 9 will be EOL in March 2018; JDK 10 will come out in March 2018, and EOL in September 2018; and LTS JDK 11 that replaces JDK 8 in September 2018 will stay with us until 2021. As we will see quick succession of JDKs in the upcoming months, here’s a how-to on testing your app on JDK 8, JDK 9, and JDK 10 Early Access using Travis CI.

removing commas with sbt-nocomma

August, 2016 During the SIP-27 trailing commas discussion, one of the thoughts that came to my mind was unifiying some of the commas with semicolons, and take advantage of the semicolon inference. Aug 10 2016 20:46: This doesn’t actually work. @Ichoran kindly pointed out an example: Seq( a b c ) This is interpreted to be Seq(a.b(c)) in Scala today. January, 2018 Recently @swachter opened a thread called Comma inference that reminded me of this topic:

Coursera machine learning memo

This holiday break, I somehow got into binge watching Coursera’s Stanford Machine Learning course taught by Andrew Ng. I remember machine learning to be really math heavy, but I found this one more accessible. Here are some notes for my own use. (I am removing all the fun examples, and making it dry, so if you’re interested in machine learning, you should check out the course or its official notes.)

encoding file path as URI reference

In this post I am going to discuss an old new problem of encoding file path as Uniform Resource Identifier (URI) reference. As of 2017, the authoritative source of information is RFC 8089 - The “file” URI Scheme written by Matthew Kerwin. RFC 8089 The "file" URI Scheme https://tools.ietf.org/html/rfc8089 Wow, it actually happened. — Matthew Kerwin (@phluid61) February 18, 2017 Future readers might also want to search for “file URI scheme RFC”, and find the latest version.

sbt server with Sublime Text 3

On Tech Hub blog I demonstrated how to use sbt server from VS Code to display compiler errors from a running sbt session. In this post, I’ll show how to do that for Sublime Text 3 in this post. setting up Sublime Text 3 with sbt server First, add tomv564/LSP plugin to Sublime Text 3. cd ~/Library/Application\ Support/Sublime\ Text\ 3/Packages git clone https://github.com/tomv564/LSP.git Run ‘Preferences > Package Control > Satisfy Dependencies’ Next, download sbt-server-stdio.

Ergodox

Over the weekend I assembled an Ergodox.

  • Infinity ErgoDox Ergonomic Keyboard Kit via massdrop
  • Cherry MX Brown switches
  • Datamancer Infinity Ergodox Hardwood Case (Black Walnut / Original) via massdrop
  • Plum Blossom PBT Dye-Subbed Keycap Set (OEM, Blank) via massdrop

Scala language server using sbt

It’s been a month since sbt 1.0 shipped, and I can finally sit back and think about sbt server again. Using my weekends time, I started hacking on an implementation of Scala language server on top of sbt server. what is a language server? A language server is a program that can provide language service to editors like Visual Studio Code, Eclipse Che, and Sublime Text 3 via Language Server Protocol.

Persistent Versioning

In this post, I’d like to introduce a version scheme that I call Persistent Versioning. Most of the ideas presented in this post are not new or my own. Let me know if there’s already a name for it. In 2015, Jake Wharton (@JakeWharton) wrote a blog post titled Java Interoperability Policy for Major Version Updates: A new policy from @jessewilson and I for the libraries we work on to ensure major version updates are interoperable: https://t.

auto publish (a website) from Travis-CI

GitHub Pages is a convenient place to host OSS project docs. This post explains how to use Travis CI to deploy your docs automatically on a pull request merge. 1. Generate a fresh RSA key in some directory Make a directory outside of your project first. Pick a key name deploy_yourproject_rsa, so you can distinguish it from other keys. $ mkdir keys $ cd keys $ ssh-keygen -t rsa -b 4096 -C "yours@example.

tray for Atreus

In the last post that I wrote about Atreus build, I noted that there’s an issue of keyboard positioning: Even if I can overcome the layout and memorize the various symbol locations, there’s the issue of the placement. If I place the keyboard in between me and the laptop the screen becomes too far. I solved this issue by making a tray for Atreus that I can position it on top of the MacBook Pro keyboard.

Atreus

Last night I finished making my Atreus keyboard from a DYI kit that I got a while back. Here are some of the details: I chose Matias Quiet Click switch option (gray slider). There’s no clicking. The modifiers use Matias Quiet Linear switches (red slider). There are 42 keys in split ortholinear layout. Mahogany ply case. The materials The kit comes with almost everything you need to assemble the Arteus keyboard.

Gigahorse 0.3.0

Gigahorse 0.3.0 is now released. See documentation on what it is.

OkHttp support

0.3.0 adds Square OkHttp support. Gigahorse-OkHttp is availble for Scala 2.10, 2.11, and 2.12.

According to the JavaDoc you actually don’t have to close the OkHttpClient instance.

scala> import gigahorse._, support.okhttp.Gigahorse
import gigahorse._
import support.okhttp.Gigahorse

scala> import scala.concurrent._, duration._
import scala.concurrent._
import duration._

scala> val http = Gigahorse.http(Gigahorse.config) // don't have to close
http: gigahorse.HttpClient = gigahorse.support.okhttp.OkhClient@23b48158

downloading and running app on the side with sbt-sidedish

I’ve been asked by a few people on downloading JARs, and then running them from an sbt plugin. Most recently, Shane Delmore (@shanedelmore) asked me about this at nescala in Brooklyn. During an unconference session I hacked together a demo, and I continued some more after I came home. sbt-sidedish sbt-sidedish is a toolkit for plugin authors to download and run an app on the side from a plugin. It on its own does not define any plugins.

Contraband, an alternative to case class

Here are a few questions I’ve been thinking about: How should I express data or API? How should the data be represented in Java or Scala? How do I convert the data into wire formats such as JSON? How do I evolve the data without breaking binary compatibility? limitation of case class The sealed trait and case class is the idiomatic way to represent datatypes in Scala, but it’s impossible to add fields in binary compatible way.

Gigahorse 0.2.0

Gigahorse 0.2.0 is now released. The new change is that it abstracts over two backends. @alexdupre contributed migration from AHC 1.9 to AHC 2.0, which is based on Netty 4 in #12.

In addition, there’s now an experimental Akka HTTP support that I added. #15

Please see Gigahorse docs for the details.

Gigahorse 0.1.0

Update: please use Gigahorse 0.1.1

Gigahorse 0.1.0 is now released. It is an HTTP client for Scala with Async Http Client underneath. Please see Gigahorse docs for the details. Here’s an example snippet to get the feel of the library.

scala> import gigahorse._
scala> import scala.concurrent._, duration._
scala> Gigahorse.withHttp(Gigahorse.config) { http =>
         val r = Gigahorse.url("http://api.duckduckgo.com").get.
           addQueryString(
             "q" -> "1 + 1",
             "format" -> "json"
           )
         val f = http.run(r, Gigahorse.asString andThen {_.take(60)})
         Await.result(f, 120.seconds)
       }

registry and reference pattern

There’s a “pattern” that I’ve been thinking about, which arises in some situation while persisting/serializing objects. To motivate this, consider the following case class: scala> case class User(name: String, parents: List[User]) defined class User scala> val alice = User("Alice", Nil) alice: User = User(Alice,List()) scala> val bob = User("Bob", alice :: Nil) bob: User = User(Bob,List(User(Alice,List()))) scala> val charles = User("Charles", bob :: Nil) charles: User = User(Charles,List(User(Bob,List(User(Alice,List()))))) scala> val users = List(alice, bob, charles) users: List[User] = List(User(Alice,List()), User(Bob,List(User(Alice,List()))), User(Charles,List(User(Bob,List(User(Alice,List())))))) The important part is that it contains parents field, which contains a list of other users.

sjson-new and the prisoner of Azkaban

This is part 3 on the topic of sjson-new. See also part 1 and part 2.

Within the sbt code base there are a few places where the persisted data is in the order of hundreds of megabytes that I suspect it becomes a performance bottleneck, especially on machines without an SSD drive. Naturally, my first instinct was to start reading up on the encoding of Google Protocol Buffers to implement my own custom binary format.

sjson-new and custom codecs using LList

Two months ago, I wrote about sjson-new. I was working on that again over the weekend, so here’s the update. In the earlier post, I’ve introduced the family tree of JSON libraries in Scala ecosystem, the notion of backend independent, typeclass based JSON codec library. I concluded that we need some easy way of defining a custom codec for it to be usable. roll your own shapeless In between the April post and the last weekend, there were flatMap(Oslo) 2016 and Scala Days New York 2016.

sjson-new

background One of the fun way of thinking about software projects is literary analysis. Instead of the actual source code, think of who wrote it when and why (what problem does it solve), and how it’s written (what influenced it). Within the Scala ecosystem, not too many genre are as rich as the JSON libraries. In December 2008, the first edition of Programming in Scala came out, which used JSON as an example in the context of parser combinator, and showed that JSON parser can be written in 10 lines of code:

sbt server reboot

This is a continuation from the sbt 1.0 roadmap that I wrote recently. In this post, I’m going to introduce a new implementation of sbt server. Please post on sbt-dev mailing list for feedback.

The motivation for sbt server is better IDE integration.

A build is a giant, mutable, shared, state, device. It’s called disk! The build works with disk. You cannot get away from disk.

– Josh Suereth in The road to sbt 1.0 is paved with server

The disk on your machine is fundamentally a stateful thing, and sbt can execute the tasks in parallel only because it has the full control of the effects. Any time you are running both sbt and an IDE, or you’re running multiple instances of sbt against the same build, sbt cannot guarantee the state of the build.

sbt 1.0 roadmap

There’s been some discussions around sbt 1.0 lately, so here is a writeup to discuss it. This document is intended to be a mid-term mission statement. A refocus to get something out. Please post on sbt-dev mailing list for feedback. Timing I don’t have a good idea on the timing of when sbt 1.0 will ship. The biggest feature of sbt 1.0 is code reorganization, which is is already in progress: http://www.

ScalaMatsuri as a lifestyle

For me (and for many of the 27 organizers, I imagine) ScalaMatsuri is a lifestyle. It’s true that there was a successful two-day conference in Tokyo with 550 participants. But for us the organizers, the preparation has been going on since February 28th, for 11 months. Despite the fact that my contribution was small, planning ScalaMatsuri 2016 was by far the most amount of involvement I’ve committed to. Through the course of planning months, there were many discussions over Slack, Hangouts, and occasionally even face-to-face.

stricter Scala with -Yno-lub

For a flexible language like Scala, it’s useful to think of subset of the programming language, like your own personal Good Parts, and opinionated style guides. setup To try -Yno-lub, you can drop in the following sbt plugin to project/ynolub.sbt: addSbtPlugin("com.eed3si9n" % "sbt-ynolub" % "0.2.0") lub When Scala’s type inferencer finds type A and type B to unify, it tries to calculate the lub (least upper bounds) of two types with regards to <:<.

herding cats: day 1

Check out my new series herding cats. (I’m writing it using Pamflet from the get go)

This is a log of me going through Cats, a functional programming library for Scala that is currently experimental and under active development.

switching Java version

I’ve been switching between Mac and Ubuntu, and between Java 6 and 7 lately. This is a memo of how to switch Java versions on both Mac and Ubuntu. Update: Yoshida-san told me about this thing called jEnv, which does all this. Zshrc Here’s one way of loading different shell files depending on the OS: ## basic [ -f $HOME/dotfiles/zshrc.basic ] && source $HOME/dotfiles/zshrc.basic ## aliases [ -f $HOME/dotfiles/zshrc.alias ] && source $HOME/dotfiles/zshrc.

monads are fractals

On my way back from Uppsala, my mind wandered to a conversation I had with a collegue about the intuition of monads, which I pretty much butchered at the time. As I was mulling this over, it dawned on me.

Sierpinski triangle

monads are fractals

The above is a fractal called Sierpinski triangle, the only fractal I can remember to draw. Fractals are self-similar structure like the above triangle, in which the parts are similar to the whole (in this case exactly half the scale as parent triangle).

Monads are fractals. Given a monadic data structure, its values can be composed to form another value of the data structure. This is why it’s useful to programming, and this is why it occurrs in many situations.

Let’s look at some examples:

scala> List(List(1), List(2, 3), List(4))
res0: List[List[Int]] = List(List(1), List(2, 3), List(4))

towards universal access at a conference

Two days of #ScalaMatsuri ended as a huge success. But for the next year, I’m leaving ourselves a few homeworks to work on. As the title suggests, the next goal that we should aim for is universal access. In Scala language, universal access principle indicates the fact that both methods and fields can be accessed interchangeably from outside. For a conference, I mean universal access to mean being more inclusive to various groups of people:

ScalaMatsuri day1

This year was the second Scala conference in Japan. We’ve changed the name to ScalaMatsuri, which means Scala festival in Japanese. 300 tickets sold out. With invited guests and free tickets for sponsors, there may have been even more people. The venue was at CyberAgent, which runs blog service and online ad services. Day 1 kicked off with Martin’s (@ordersky) ‘Evolution of Scala.’ Many people were looking forward to see Martin, so I think it was full house from the get go.

IRC memo

register your nick /msg NickServ REGISTER %password% youremail@example.com What is the recommended way to set up my IRC nickname? make new channel To check whether a channel has already been registered, use the command: /msg ChanServ info ##channelname /join ##channelname The command to register your channel (once you’ve joined it and you have op status) is as follows: /msg ChanServ register ##channelname Registering a channel on freenode

Vim memo

Personally, I don’t mind using SublimeText, which is my editor of choice for a while. But I’m also curious about commandline editors since many people taut their ability to code over the network. You could forward X or remote in using some other way and still use Sublime, but let’s see how if goes. I started working on this Vim setup when I got a new MBP recently. Figured, I can try something new.

scripting with Scala

The need for regular expressions is real. Whenver I need to transform a set of text files it usually ends up with fumbling through the documentation of find command, zsh, and StackOverflow Perl questions. I would rather use Scala instead of muddling through Perl. It’s really the matter of my familiarity than anything else. For example, I now have over a hundred reStructuredText files that I want to convert into markdown.

constraining class linearization (mixin order) in Scala

Woke up early yesterday, so I started skimming @xuwei_k’s override blog post. The topic was so intriguing, I got out of the bed and started translating it as the curious case of putting override modifier when overriding an abstract method in Scala. In there he describes the conundrum of providing the default instances to typeclasses by using Scalaz codebase as an example. Here’s a simplified representation of the problem: trait Functor { def map: String } trait Traverse extends Functor { override def map: String = "meh" } sealed trait OneOrFunctor extends Functor { override def map: String = "better" } sealed trait OneOrTraverse extends OneOrFunctor with Traverse { } object OneOr { def OneOrFunctor: Functor = new OneOrFunctor {} def OneOrTraverse: Traverse = new OneOrTraverse {} } To test this you can run:

curious case of putting override modifier when overriding an abstract method in Scala

This is a translation of Scalaで抽象メソッドをoverrideする際にoverride修飾子を付けるべきかどうかの是非 by Kenji Yoshida (@xuwei_k), a Scalaz committer. First, a quote from Programming in Scala, 2nd ed. p. 192: Scala requires [override] modifier for all members that override a concrete member in a parent class. The modifier is optional if a member implements an abstract member with the same name. In this post, we’ll discuss this “The modififier is optional.” Since overriding an existing method with implementation requires override modifier, and failure to do so would result to a compiler error, there’s not much to talk about for that case.

sequencing tasks with sbt-sequential

In this post, I will discuss the execution semantics and task sequencing in sbt 0.13. First we will cover the background, and then I will introduce a new experimental plugin sbt-sequential that adds sequential tasks. background Mark said: The sbt model is to have your side effects be local to your task so that as long as dependencies are satisfied, the task can be executed whenever. The win is parallel by default and enabling faster builds in practice.

traveling through the 4th dimension with sbt 0.13

Warning: This is a memo about sbt for intermediate users. setting system At the heart of sbt 0.13 is the setting system, just like sbt 0.12. Let’s look at Settings.scala: trait Init[Scope] { ... final case class ScopedKey[T]( scope: Scope, key: AttributeKey[T]) extends KeyedInitialize[T] { ... } sealed trait Initialize[T] { def dependencies: Seq[ScopedKey[_]] def evaluate(map: Settings[Scope]): T ... } sealed class Setting[T] private[Init]( val key: ScopedKey[T], val init: Initialize[T], val pos: SourcePosition) extends SettingsDefinition { .

what is object-oriented programming?

How do you define oop?

purely object-oriented programming

Purely object-oriented programming is defined to be:

programming with objects.

What’s an object?

It is an atom that can hold references to other objects, receive predefined list of messages, and send messages to other objects and itself; and nothing else. A message consists of a name and a list of reference to objects.

This is it. The wording is mine, but the idea is from Alan Kay (2003), the guy who coined the term object-oriented programming. Anything else is either not directly tied to oop or an implementation detail.

sbt-logo proposal

See sbt-logo proposals thread on sbt-dev and the original thread on sbt. The source is at eed3si9n/sbt-logo. Edit: Changed the tail of ’t'. See github for the original. .main-black { background-color: rgb(0, 0, 0); /* color: rgb(239, 110, 37); */ color: white; font-family: Exo, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 21px; padding: 10px 20px; } .main { background-image: url('http://www.scala-sbt.org/release/docs/_static/dark-blue-bg.png'); color: white; font-family: Exo, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 21px; padding: 10px 20px; } .

Scala: the flying sandwich parts

JavaScript existed since 1995 long before ‘JavaScript: The Good Parts’ (2008), jQuery (2006), and V8 (2008) happened. The interesting thing about Douglas Crockford’s ‘The Good Parts’ is that unlike the other additive work, it’s a book about subtracting features from the language.

I’ve been thinking about exploring a subset of Scala in a wonderland setting without the “real world” constraints such as Java familiarity and interoperability. If using Scala as an alternative Java is acceptable, why not try using it as an alternative functional programming language? Another point of this thought experiment is to see some of the duplicate constructs can be reduced. In this article, I’m not interested in finding out the idiomatic way, or calling something good or bad. I’m calling this The Flying Sandwich Parts (TFSP).

scopt 3.0

scopt is a little command line options parsing library. Today, I’m releasing scopt 3.0. If you’re not interested in the implementation details, skip to the readme. Around March 4th, 2010, I became a committer to scopt, a fork of Aaron Harnly’s scala-options that was written in 2008. I think I wanted to make a few changes around the usage text, key=value options, and argument list. Since then I’ve been fielding all the bug reports, including the request to publish the jar on scala-tools.

how to write a Dispatch plugin

Dispatch has been the de facto library to get to the Internet from Scala. To keep in step with the recent move towards non-blocking IO, @n8han rewrote the library as Reboot based on Async Http Client. This became Dispatch 0.9. Then Dispatch 0.10 came out to replace its own Promise type with the standarized SIP-14 Future.

As with Dispatch Classic, Reboot lets you write plugins to wrap around web APIs. In this post we’ll port a plugin from Classic to explore how it works.

working on your own twitter bot?

Notes on 'Monads Are Not Metaphors'

This is a translation of 「モナドはメタファーではない」に関する補足 by Kenji Yoshida (@xuwei_k), one of the most active Scala bloggers in Japan covering wide range of topics from Play to Scalaz. Daniel Spiewak’s Monads Are Not Metaphors was written about two and a half years ago, but seeing how its Japanese translation is still being tweeted and being bookmarked by 250 users on Hantena, its popularity doesn’t seem to cease. I just remembered something to note about the example code used in the post, which could be an unstylish critique, but I’m going to jot it down here.

translating a conference

It’s been a month now, but on March 1, 2013 I flew to Japan to attend “Scala Conference in Japan 2013.” That’s the name of the conference. from a podcast One day (June 2, 2012), I was listening to Scala Types recorded at Scala Days 2012, and someone (turns out it’s @timperrett) said “I would love to see Scala Days in Asia. We had two in Europe now. It would be wicked to have it in China or Japan, or somewhere like that.

sudoku using Func

This is the 5th entry of Scalaz Advent Calendar 2012. During the months of December, tech-savvy geeks in Japan take turns to post themed blog articles, known as the “Advent Calendar”. For last year’s Scala Advent Calendar 2011 I translated Eric Torreborre’s post covering The Essence of Iterator Pattern. It was somewhat of a calculated move, knowing Japanese fondness for functional programming articles. Another selfish motive was that some of the concept would seep in to my thickness as I was translating the post word by word.

Scalaz cheat sheet

### Equal[A] ```scala def equal(a1: A, a2: A): Boolean (1 === 2) assert_=== false (2 =/= 1) assert_=== true ``` ### Order[A] ```scala def order(x: A, y: A): Ordering 1.0 ?|? 2.0 assert_=== Ordering.LT 1.0 lt 2.0 assert_=== true 1.0 gt 2.0 assert_=== false 1.0 lte 2.0 assert_=== true 1.0 gte 2.0 assert_=== false 1.0 max 2.0 assert_=== 2.0 1.0 min 2.0 assert_=== 1.0 ``` ### Show[A] ```scala def show(f: A): Cord 1.

C# LINQ for Scala heads

This is a memo of C# Linq features for Scala programmers. Or vice versa. Type inference C# has type inference. I try to use var when I can for local variables. var x = 1; Scala also has var, but the preferred way is to use immutable val if possible. val x = 1 Creating a new List or an Array C# can create collections in-line. using System.

sbt plugins roundup

Unlike XML-based build tools sbt’s build definitions are written in Scala (for both .sbt and .scala). This means that once one gets over the hurdle of learning sbt’s concepts and operators, it doesn’t take much for build users to start writing sbt plugins. I’ve ported a few from sbt 0.7 before, but I’ve also been writing some original ones recently that I’d like to share. sbt-dirty-money sbt-dirty-money is a plugin to clean Ivy cache somewhat selectively (anything that includes organization and name under ~/.

treehugger.scala pamflet

treehugger is a library to write Scala source code programmatically. It’s also an implementation of Scala AST based on Reflection API, now available from github eed3si9n/treehugger. Edit: I’ve expanded this into a complete guide using awesome n8han/pamflet. See treehugger’s pamflet

implicit parameter precedence again

Scala the language is one of the most elegant, expressive, consistent, and pragmatic languages. From pattern matching to the uniform access principle, it got so many things right. And Scala the ecosystem and Scala the community only makes it better. In Scala 2.9.1, locally declared implicits are preferred over imported ones. The problem is that the spec does not cover such behavior. My original hypothesis was that either I did not understand the spec correctly, or the spec was wrong.

an unofficial guide to sbt 0.10 v2.0

version 2.0 When the original version was published on 06/19/2011, the motive for writing this guide was to aid the effort of moving people over to sbt 0.10 from 0.7, inspired by Mark’s sbt 0.10 demos that I was able to see live (first at northeast scala, and second at scala days 2011). At the time, the plugins were considered to be a major roadblock to the migration, since build users can’t move to 0.

testing sbt plugins

NOTE: Official docs: http://www.scala-sbt.org/1.x/docs/Testing-sbt-plugins.html Let’s talk about testing. Once you write a plugin, it turns into a long-term thing. To keep adding new features (or to keep fixing bugs), writing tests makes sense. But how does one go about testing a plugin to a build tool? We fly, of course. scripted test framework sbt comes with scripted test framework, which let’s you script a build scenario. It was written to test sbt itself on complex scenarios such as change detection and partial compilation:

sff4s: simple future facade for Scala

I wish there was a common super trait for various future implementations in the standard library, so I can express the concept without tying the code to a specific platform stack. I am not sure if there are others who feel the same, but I think it would be useful for library authors. That’s my motivation of writing sff4s. what is future? You’ve probably come across the notion before but let’s go over it quickly.

beginning sbt 0.10

On 7/13/2011 I hosted a ny-scala meetup on sbt 0.10 migration with doug tangren and rose toomey. Here is the slides. beginning sbt 0.10 picture show

Twilight for IntelliJ IDEA

I’ve tried other IDEs for Scala, but always ended up going back to TextMate. As I am getting on the IntelliJ IDEA wagon, I’ve made a Twilight theme to make the ride smoother.

typeclass-based XML data binding

Ultimately, the users of scalaxb are interested the real problems that the entity objects express, not how they persist into XML. That’s why I knew I eventually had to vacate the singleton/companion object of the case class to implement the data binding. Until recently it has been generating the data binding implementation as follows: object Address extends rt.ElemNameParser[Address] { val targetNamespace = "http://www.example.com/IPO" def parser(node: scala.xml.Node): Parser[Address] = ... def toXML(__obj: Address, __namespace: String, __elementLabel: String, __scope: scala.

Scala and OSGi using NetBeans

For some reason, I can’t keep OSGi in my head. Everything I read about it slips away in a few weeks, and I have re-read the guides and tutorials. Here’s a memo of setting up OSGi bundle written in Scala using NetBeans, following Neil Barlett’s OSGi in Practice, except the book uses Eclipse. Installing Scala on Mac Skip this section if you use non-Mac. Install MacPorts. Run the following from Terminal:

Scala and Evaluation Strategy

Once you use any technology to a significant extent, you understand its strength and shortcomings. I’ve probably written tens of thousands of lines of code in Delphi or C++, Java and C# too to some extent. I’ve depended on those languages, but gripe about them too. The new language obviously has the advantage of just being new. Since I haven’t written anything significant in Scala besides Tetris, I haven’t hit the shortcomings yet.