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

Suzanne takes you down takes you down
To her place by the river

You can hear the boats go by
You can spend the night forever

And you know the girl’s half crazy
And that’s why you want to be there

And just when you want to tell her
That you have no love to give her

She gets you on her wavelength
And lets the river answer

That you’ve always been her lover

~ Some lyrics from “Suzanne,” written by Leonard Cohen in the 1960s. (In terms of a song I’d like to listen to, I prefer the Neil Diamond version.)

In my first “Hello, world” Scala.js tutorial I showed how to get started with Scala.js, including some necessary setup/configuration work. That tutorial ended by showing how to get the string “Hello, world” displayed in a browser.

In this tutorial I’ll take this a little further and show how to create an HTML button you can click that results in the string “Hello, world” being displayed in a JavaScript alert window. When the button is clicked, the alert window will be displayed by your Scala/Scala.js code.

July, 2020 Update: I don’t have time to update this page, but please see the end of this article for the latest, greatest source code. In short, several dependencies and versions have changed since I originally wrote this.

There is unrest in the forest
There is trouble with the trees
For the maples want more sunlight
And the oaks ignore their pleas.

The trouble with the maples
And they’re quite convinced they’re right
They say the oaks are just too lofty
And they grab up all the light.

But the oaks can’t help their feelings
If they like the way they’re made
And they wonder why the maples
Can’t be happy in their shade?

There is trouble in the forest
And the creatures all have fled
As the maples scream “Oppression!”
And the oaks just shake their heads.

~ from The Trees, by Rush

This is the first tutorial in a three-part series on getting started with Scala.js. This tutorial will demonstrate the proverbial “Hello, world” introduction. After this “Hello, world” tutorial, the next two tutorials will show some more powerful things you can do with Scala.js.

“I would rather have questions that can't be answered than answers that can't be questioned.”

~ Richard Feynman

I’m surprised that nobody I know knows the story Tiger Eyes, either the book by Judy Blume or the movie based on the book.

Probably the main theme of the book is about people who are afraid. Presumably they’re afraid of dying, and the result is that they’re afraid of living. Meanwhile, a teenage girl who has good reason to be afraid encounters these people who are afraid of life, and eventually realizes that a fear of life is no way to live. Despite a horrific thing that has happened in her recent past, she makes a conscious decision to live her life.

The Rocky Mountains this morning (June 16, 2019) when I was out looking for a new place to live in Colorado.

Rocky Mountains between two trees

True confession: My signature looks like my dad’s because I used to write my own notes to skip high school (and I did that a lot).

(Probably inspired by Juan Epstein.)

Two horses in Kentucky, June 1, 2019.

Two horses in Kentucky

“If you have contact with pure consciousness even for a moment, you are liberated.”

~ Sri Nisargadatta Maharaj

“To have never taken a solitary road trip across country? I mean, everybody’s got to take a road trip, at least once in their lives. Just you and some music.”

~ Claire in Elizabethtown

I’m so glad I listened to The Book Thief on my recent travels. The movie is okay, but the book is 100% better.

You’re not an official geek unless you’ve watched Firefly.

Firefly: Stop her from being cheerful, please

While traveling recently for a niece’s wedding, I saw that John Cusack will be at the Louisville Palace on August 1, 2019. I was tempted to buy a ticket (or two), but managed to control myself. :)

John Cusack at the Louisville Palace (August, 2019)

Ben Evans has an interesting article from 2015 titled, Mobile is not a neutral platform. Here’s a good quote:

“Of course, all this sort of stuff is a big reason why Google bought Android in the first place — Google was afraid that Microsoft (it was that long ago) would dominate mobile operating systems and shut it out. The obvious fear was around things like preloads, and the justice of that fear was proven right with Maps, where Apple Maps now has 2-3x more users on iOS than does Google Maps, despite being a weaker product — the ‘good enough’ default wins and the platform owner chooses what that is.”

I drove through St. Louis this past weekend, and made this 96-second video of the St. Louis Arch, more properly known as the Gateway Arch.

Scala problem: You want to define an equals method for your class so you can compare object instances to each other.

Solution

If you’re new to Scala, a first thing to know is that object instances are compared with ==:

"foo" == "foo"   // true
"foo" == "bar"   // false
"foo" == null    // false
null == "foo"    // false
1 == 1           // true
1 == 2           // false
1d == 1.0d       // true

case class Person(name: String)
Person("Jess") == Person("Jessie")   // false

This is different than Java, which uses == for primitive values and equals for object comparisons.

Right after I left Colorado ~3 weeks ago, I received a message that a package had arrived for me. I wasn’t expecting anything, so all I could think was that maybe the Nuts On Clark people had sent me a gift to apologize for a recent messed-up order.

I got back in Colorado last night, and when I walked to the front office today I found this “The Moose Is Back” t-shirt, which is an even better surprise than the free popcorn might have been. :)

The Moose Is Back t-shirt (Northern Exposure)

I don’t know who originally put together this image, but I’m a fan of this “None of us are getting out of here alive” quote. It puts things in the proper context, imho.

None of us are getting out of here alive - Richard Gere