Computer latency: 1977-2017 alvin February 10, 2019 - 6:24pm

A friend sent me this link about computer latency.

A note about Scala/Java startup time alvin January 15, 2019 - 4:04pm

I was reading this post by Martin Odersky (Make the Scala runtime independent of the standard library) and came across this comment by Li Haoyi: “This would also make it more feasible to use Scala for tiny bootstrap scripts; current Mill’s launcher is written in Java because the added classloading needed to use scala.Predef (even just println) easily adds a 200-400ms of initialization overhead.” I haven’t written anything where the startup time of a Scala application was a huge problem, but that was interesting to read.

(Though I should say that I wish all Scala/Java command-line apps started faster. It’s one reason I occasionally think about using Haskell for small scripts, so I can compile them to an executable.)

Processing large files in Java alvin January 13, 2019 - 10:37am

I haven’t read the article I’ve linked to yet, I’m just saving it here for future reading.

Looking at what makes a baseball move alvin November 29, 2018 - 7:33am

Back in my day, aerospace engineering undergrad students had very little time to work in the wind tunnels at Texas A&M, but in the limited time I had I tried to look at what makes a knuckleball move erratically. Barton Smith at Utah State University did the same thing (presumably with much more wind tunnel time) looking at a baseball’s spin rate, spin axis, and orientation of the ball.

How to speed up Scala compilation times with scalac-profiling alvin June 5, 2018 - 11:49am

scala-lang.org has an article titled Speeding Up Compilation Time with `scalac-profiling` where they demonstrate how they reduced a project’s compilation time from 32.5 seconds down to 4 seconds. In addition to all of the scalac and profiling details, it demonstrates a nice use of flamegraphs.

Scala 2.12.5 compiler flag to let the backend run in parallel alvin May 14, 2018 - 6:19pm

I haven’t tried it yet, but as a note to self, Scala 2.12.5 introduced a new -Ybackend-parallelism N compiler flag with which “the backend can now run in parallel on N threads.”

“Every person in your company is a vector”

“Every person in your company is a vector. Your progress is determined by the sum of all vectors.”

That’s a quote from Elon Musk. In this context a vector is what I know about from my engineering background, a company of both a speed and a direction, something like this:

case class Vector(speed: Double, direction: String)

The correct thing about that quote is that the worst employees I ever had pulled in a direction that was somewhere around 180 degrees opposite of the direction we were aiming for. For example, if nine out of ten employees are rowing a boat that’s headed east, an employee that’s rowing towards the west is going to slow everyone else down.

Unfortunately I never had much success turning those people around, so they were always fired or encouraged to find other work. Over the years we had everything from people whose work had to be completely re-done to people who had agendas during the 8-5 work hours that had nothing to do with the company’s agenda.

A Scala method to run any block of code slowly

The book, Advanced Scala with Cats, has a nice little function you can use to run a block of code “slowly”:

def slowly[A](body: => A) = try body finally Thread.sleep(100)

I’d never seen a try/finally block written like that (without a catch clause), so it was something new for the brain.

In the book they run a factorial method slowly, like this:

slowly(factorial(n - 1).map(_ * n))

FWIW, you can modify slowly to pass in the length of time to sleep, like this:

def slowly[A](body: => A, sleepTime: Long) = try body finally Thread.sleep(sleepTime)
Galaxies can (and do) move apart at faster than light speed alvin December 4, 2017 - 2:53pm

Another good tweet from Brian Greene: “Special Relativity tells us that nothing can travel through space faster than the speed of light, but this does not constrain the speed at which space itself expands. Galaxies can — and do — move apart at faster than light speed.”