Scala, Java, Unix, MacOS tutorials (page 50)

In an alternate life I became a baseball pitching coach after high school, and taught many pitchers how to throw a changeup, among other pitches. This photo shows Trevor Bauer’s changeup grip, which I originally saw related to this espn.com page.

Trevor Bauer changeup grip (baseball, pitching)

“...think of the universe as a vast electrical sea in which you are immersed and from which you are formed...”

~ from the book, The Artist’s Way

For a couple of weeks the song “This Beat Goes On/Switching to Glide” by The Kings has been in my brain, so in an effort to get it out of there, here it is:

“When engaged in noticing continuously both the dissolution of objects and the act of knowing, he (the meditator) reflects: ‘Even for the wink of an eye or a flash of lightning, nothing lasts. One did not realize this before. As things ceased and vanished in the past, so will they cease and vanish in the future.’ One must notice such a reflection.”

~ from the book, Practical Insight Meditation

As a quick note, objects created with object are final by default in Scala. I don’t think this is shown in Scala 2, but it’s made clear in the Scala 3 REPL:

scala> final object Foo
1 |final object Foo
  |^^^^^
  |final modifier is redundant for objects
// defined object Foo

Because the object keyword in Scala creates a singleton object, attempting to mark it as final is redundant. Putting this another way, as described in the Scala Tour, an object defines a class that has exactly one instance.

The best advice I’ve gotten for practicing mindfulness meditation while not sitting in meditation – i.e., in active meditation – is to make something of a game of it. When I wash the dishes it’s like, “How deep can I get while I wash these dishes?” Or when talking to another person, you both put down the cellphones and think, “Okay, we’re both here right now, how much can we focus only on each other and be here in this moment while we talk? How deep can we go?”

I was reminded of this when I read this line recently: “Finally, I got it! The menial tasks I had been assigned to around the temple were meant to be an exercise in meditation. Whatever I was doing, my job was to try to stay in samadhi.

(That quote comes from the book, The Science of Meditation.)

A little Iditarod humor in honor of the race starting on March 8, 2020, in Willow, Alaska. Photo from the Seavey family Ididaride website.

A flat tire in Alaska

If you haven’t seen the movie I.Q., it’s a cute love story. This line in particular reminds me of a couple of people I’ve known who have great minds, but don’t seem to trust that.

I.Q., I have a great brain, and I should trust that

When I have some free time I’d like to work with this image to make it look more like an oil painting. It’s not really mine to name, but I call it, Death of the Father.

Death of the Father

“Enlightenment is like a free fall. It’s like falling off a cliff that never ends, and you’ve acclimatized to it.”

~ Shinzen Young, in this video

At the 2013 Buddhist Geeks Conference, Shinzen Young gave a talk about The Meaning of Life. I just found this image on my phone, and apparently the meaning is in there somewhere. :) The graphic was created by Kelly Kingman.

The Meaning of Life, by Shinzen Young

The following quotes are from this article about how (and why) Peter Garbiel left Genesis and went out on his own:

“He (Gabriel) was a joy to work with, so smart and witty. It was just that sometimes he was a little overwhelmed by the speed and intensity of the sessions. A British interviewer came out to Toronto to meet him; then the headline declared: 'A Mumble-Free Gabriel!'

"With us he developed a new confidence and swagger. Prior to that he was a bit shy. He had to learn to shout to get through to us. There were just so many characters in their own right involved.”

Ezrin praises the contributions of guitarists Steve Hunter and Dick Wagner, bassist Tony Levin, synth player Larry Fast and other key players.

“We put a fantastic band together. They were like the Dirty Dozen – each of them was a psychopathic expert in their particular field of destruction. It felt like letting the crack criminals out of prison and putting them together in a gang for the Big Job.”

I recently bought the second edition of Mastering the Core Teachings of the Buddha: An Unusually Hardcore Dharma Book (I already read the first edition), and it occurred to me as I was reading the introductory pages why I like this book so much: As the author (Daniel Ingram) writes, “... it is a very strange thing to have such a completely different language, set of experiences, and perspectives from most of the people around me. I can often feel like an alien wearing a trench coat of normalcy ... If you go way into this stuff, you will discover this same loneliness.” I know that feeling well.

If you’re debating about whether this book might be right for you, my recommendation is that if that description applies to you, this book is probably right for you.

Also, you don’t have to be a Buddhist to read the book. Mr. Ingram often explains mindfulness and meditation techniques in great detail, and without archaic language.

In fact, I think one of the prime reasons to buy the book might be the thought, “I had some sort of unusual experience that I find hard to talk to other people about, but I’m courageous enough to want to learn more about it, and understand it.” As Mr. Ingram explains, sometimes experiences that happen to some people while meditating happen to other people who have never meditated a moment before in their life.

I suspect that some of my early experiences happened because I was a pitcher on baseball teams in my high school years, and I took that very seriously and concentrated hard while pitching. While other players had more talent, I had great concentration (and control). These days when I meditate I sometimes think, “Yep, this feels just like the concentration required while pitching.”

If you want a truly hardcore book with no-nonsense language from someone who is willing to talk about these things, this book is for you.

This is an excerpt from my much longer blog post, How to Use By-Name Parameters in Scala.

“By-name” parameters — also known as call-by-name parameters — are quite different than by-value parameters. Rob Norris, (aka, “tpolecat”) makes the observation that you can think about the two types of parameters like this:

Today I spent some time going down the road of “What is a thunk in Scala?” Here’s some relevant text from this Wikipedia page. Note that I have deleted some lines, and modified others:

In computer programming, a thunk is a subroutine used to inject an additional calculation into another subroutine. Thunks are primarily used to delay a calculation until its result is needed, or to insert operations at the beginning or end of the other subroutine.

The term originated as a humorous, incorrect, past participle of “think.” That is, a “thunk value” becomes available after its calculation routine is thought through, or executed.

Sometimes I get away from writing Scala for a while, and when I come back to it I see a piece of code that looks like this following example and I wonder, “What is Foo, and how does this code work?”:

val f1 = Foo {
    println("hello from the `f1` instance")
    "this is the result of the block of code"
}

Well, one way it can work is that Foo can be a class that accepts a function parameter, and so everything inside those curly braces is the argument to Foo. For example, this code shows how a Foo class can be defined to accept a function as a constructor parameter:

case class Foo[A, B](f: A => B) {
    // more code here ...
}

That code says that Foo is a Scala case class that takes one constructor parameter, which is a function that transforms a generic type A into a resulting generic type B.

Going back to the first code I showed, everything inside the curly braces is that first argument to Foo:

Scala anonymous class example - passing a block of code

Informally speaking, everything inside a set of curly braces in Scala can be thought of as “a block of code,” and typically that block of code has some return value, such as "hello" in this example.

Facebook tells me that I found this quote by Janis Ian back in 2014. Still seems like a good idea. :)

Janis Ian - Buy a book instead of a drink

“My father always used to say, ‘Don’t raise your voice; improve your argument.’ Good sense does not always lie with the loudest shouters, nor can we say that a large, unruly crowd is always the best arbiter of what is right.”

~ Archbishop Desmond Tutu

“If we think we want to get joy for ourselves, we realize that it’s very shortsighted, short-lived. Joy is the reward, really, of seeking to give joy to others. When you show compassion, when you show caring, when you show love to others, do things for others, in a wonderful way you have a deep joy that you can get in no other way.”

“You can’t buy it with money. You can be the richest person on Earth, but if you care only about yourself, I can bet my bottom dollar you will not be happy and joyful. But when you are caring, compassionate, more concerned about the welfare of others than about your own, wonderfully, wonderfully, you suddenly feel a warm glow in your heart, because you have, in fact, wiped the tears from the eyes of another.”

~ Archbishop Desmond Tutu, in The Book of Joy