Facebook engineers shared this post about how they switched from InnoDB to MyRocks and successfully cut their storage usage in half.
Scala, Java, Unix, MacOS tutorials (page 153)
This past week I started working on the index for my book on Scala and functional programming. In retrospect I wish I had written the book using LaTeX (or some other technology) rather than Markdown; I would have started this process long ago.
I’d been thinking about buying a large cellphone (phablet) recently, and every time I mentioned it to a woman, they immediately asked, “Do you know how small the pockets are in women’s pants?” That makes me think there’s a market for women’s pants with larger pockets.
With Twitter being Twitter, I saw this image there, and now I can’t find it again. But it shows that the new iPhone 8 is significantly faster at rendering a cnn.com page.
Actually, since I can’t find the original source, I don’t know if they both rendered mobile web pages, or whether they tried several times to make sure it wasn’t just a hiccup. But seeing that the architecture in a little phone can come anywhere near the performance of a desktop/laptop processor that’s still being sold makes one wonder about the future.
Update: I think this was the original source of the image.
“To produce a mighty book, you must choose a mighty theme.”
~ Herman Melville
“Designing APIs is a subtle blend of craft and engineering. It is the one area we should carefully refine our design skills for.”
This is a nice, smart, compassionate response from the owner of the Miami Dolphins, to the president of the United States, who continues to embarrass himself and everyone that lives here.
Here’s a little note on pure functions, black holes, and miracles. From my book, Learning Functional Programming in Scala.
“Praying is talking to the universe, meditation is listening to it.”
(I’m sorry, I don’t know the original source of this image or this quote, but I like it.)
[1st day working at the Hotel California]
Guest: I’d like to check out.
Me: Sure. You’re all set. Have a great day!
Guest: Thanks!
[Guest leaves]
Boss: Can I see you in my office?
*printer won’t print black text because yellow ink is low*
*Al throws printer off balcony*
I was just reminded of the time a recruiter told me to “play dumb” when a particular person interviewed me, because that person didn’t like to be challenged, and had to feel like he was the smartest person in the room. I couldn’t bring myself to do that; I figured if that was the way it was going to be, I didn’t want to work there.
“Monad transformers are not too intuitive, especially in Scala, and are known to produce hard to understand code structure.”
~ Debasish Ghosh, Functional and Reactive Domain Modeling
Every once in a while someone asks what writing a book is like. For me, it usually looks like this. I hate to waste paper (and I recycle almost everything), but I think much better on paper.
deelay.me looks like a good website to use if you’re writing network-access code and want to simulate accessing a slow web server.
Back in April when I was 2,000 miles from home, my iPhone began crashing and I had to learn the “hard reboot” technique. Then right before my surgery last month it quit working for cell calls, and I learned more iPhone restoration techniques. After that, the Bluetooth failed. I bought a cheap Moto E so I could make calls.
Over the weekend I dropped a phone for the first time in my life, and I ended up with some iPhone 5s Gorilla Glass in my fingers. But still, it works for music and messages.
Here’s a little example of how exceptions work with Scala Futures, specifically looking at the onComplete ‘Failure’ case.
In this example I start three Futures that run for different lengths of time, and the shortest-running Future throws an exception:
import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global
import scala.util.{Failure, Success}
object ScalaFuturesAndExceptions extends App {
val startTime = currentTime
val f1 = Future {
sleep(2000)
1
}
val f2 = Future {
sleep(550)
throw new Exception("Ka-boom!")
2
}
val f3 = Future {
sleep(1000)
3
}
val result = for {
r1 <- f1
r2 <- f2
r3 <- f3
} yield (r1 + r2 + r3)
result.onComplete {
case Success(x) => {
// the code won't come here
println(s"\nresult = $x")
}
case Failure(e) => {
// the code comes here because of the intentional exception
val finishTime = currentTime
val delta = finishTime - startTime
System.err.println(s"delta = $delta")
System.err.println("Failure happened!")
// just a short message; i don't care about the full exception
System.err.println(e.getMessage)
}
}
// important for a little parallel demo: keep the main
// thread of the jvm alive
sleep(4000)
def sleep(time: Long) = Thread.sleep(time)
def currentTime = System.currentTimeMillis()
}
When I run this App, the Failure case isn’t reached for 2008 ms, just a bit longer than the run time of the longest-running Future, f1. Here’s the output:
delta = 2008
Failure happened!
Ka-boom!
This tells me that the exception in f2 causes the code to go to the Failure case of onComplete, but, it doesn’t get there until f1 finishes running. More specifically, the exception thrown by f2 doesn’t cause any part of the process to short-circuit after 550 ms. You can adjust the sleep times in the futures to demonstrate this for yourself.
I was just working on a Scala application to combine a few Futures and then work with the result using onComplete, and needed to see the effect that exceptions have on the process. So I created this example, and thought I’d share the results here so it might help someone else.
Update: the order matters
I didn’t think to test this initially, but if I change the order of the Futures in the for-expression, putting f2 first:
val result = for {
r2 <- f2 //the exception-throwing future, runs 550ms
r1 <- f1
r3 <- f3
} yield (r1 + r2 + r3)
the output is different:
delta= 558 Failure happened! Ka-boom!
In this example, the for-expression short-circuits immediately after f2 throws its exception after 550 ms.
In the real world there may be no way for you to know which Future will return (or throw an exception) first, but this hard-coded example shows that the order is important. (Note that if you remove the exception from f2, the code runs in just over 2000 ms, which confirms that the three futures run in parallel in the success case.)
Went to hear Bach last night. Very disappointing. It was just some cover band.
(originally from someone on twitter, i think)
“I don’t have talent. I have tenacity. I have discipline. There was no choice for me but to work really hard.”
~ Henry Rollins
Denali, as seen from the rivers in Talkeetna, Alaska, in September, 2007.