Contents

Scala, Rust

Exploration

Quick summary of recently reviewed concepts:

| Concept        | Scala 3                    | Rust                          |
|----------------+----------------------------+-------------------------------|
| Type classes   | given/using, derives       | Traits + blanket impls        |
| HKTs           | F[_] natively              | Not directly (GATs partial)   |
| Error handling | Either, Validated, EitherT | Result, ?, thiserror/anyhow   |
| Zero-cost types| opaque type                | newtypes, zero-sized types    |
| Closures       | Function1, SAM types       | Fn/FnMut/FnOnce               |

Other interesting observations:

  • cognitive load seems to be much higher when I look at Scala code compared to when I look at Rust’s (tbh I wasn’t expecting this)
  • Scala type system expressiveness is huge; I’m not sure I undestand where its depth ends

Scala tooling imporessions

Scala tooling sometimes seem a bit brittle:

  1. Code completion sometimes stops working (metals in Emacs/Vim).
  2. It is more stable on Intellij in general. Sometimes it has trouble resolving dependencies added to ``build.sbt` though.
  3. Intellij sometimes states with its curly underline that an expression is invalid whereas the problem is elsewhere completely (compared to very precise and dev-friendly compiler errors from Rust compiler, it is just not up to my expectations)

Libs impressions

  • cats is interesting to read, inspires my imagination for sure, but quite challenging if I want to apply those concepts
  • cats-effects and typelevel libs (eg HTTP4s) form an ecosystem that is even harder, something im my head just does not want this complexity
  • looking at ZIO and ZIO HTTP: I’m positively surprised with the quality of documentation; yesterday I was able to write a small http server and I had fun :)
  • Monix - compared to ZIO - is rather low-level; no Fibers as “first class citizens” (you need to Task.fork), there is CancellableFuture

New resource

I found one resource that is - I think - worth exproring: Software Patterns Lexicon (the link is for Scala, but other languages are there).