Functional error handling in Scala alvin April 22, 2019 - 9:17am

Because functional programming is like algebra, there are no null values or exceptions. But of course you can still have exceptions when you try to access servers that are down or files that are missing, so what can you do? This lesson demonstrates the techniques of functional error handling in Scala.

One million Scala developers alvin November 16, 2018 - 8:10am

Yesterday I just churned the numbers from the surveys, but last night I started thinking how cool it is that there are one million Scala developers in the world.

I remember when I was wandering around Alaska in 2011 and first stumbled upon Programming in Scala, I found that very few people knew about Scala, maybe numbering in the thousands or tens of thousands at most. I hope Martin Odersky & Company are having a little celebration this year for their success. (And on to two million!)

Two good quotes about coaching and motivation from a Jon Gruden article alvin September 3, 2018 - 12:50pm

Here are two good quotes about coaching from this Jon Gruden article:

“He had a good demeanor about him, the way he got his point across. He always told me it was always about your demeanor and how you get your point across. He said, ‘You have to be a car salesman.’ If you want to sell plays, you can’t be short on energy. People want to be associated with people that have a lot of energy and love what they do and show enthusiasm, not someone who just walks in there and kind of goes through the motions.”

“I always tell people,‘You’ve gotta have a why.’ If you have a reason why, you’re most likely going to succeed. ... And those are the types of things as a coach, when you know those things, those are the buttons you can push. When you’re not hustling, when you’re not doing those things, it’s like, ‘Is that the type of example you’re trying to set for your little brothers?’ When you don’t know those things, you can’t use those things.”

If you could give one tip for reaching heights in tech today, what would it be? alvin July 19, 2018 - 10:38am

When asked, “If you could give one tip for reaching heights in tech today, what would it be?”, this was the initial response from Jonas Bonér, creator of Akka:

  • Work hard at minimizing your ego & attachment to identity
  • Learn deliberately, seek out weaknesses & work hard at them
  • Eliminate bad habits, replace them with good, one at a time
  • Read a lot, foundational stuff, not just latest hyped thing

If we think we want to get joy for ourselves ...

“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

What’s Important Now (WIN) alvin March 21, 2018 - 12:26pm

I know, it’s a little corny, but instead of writing out a “To-Do List” — which implies hard labor and/or something I force myself to do — these days I write “WIN” on the top of my index cards. WIN stands for, “What’s Important Now”, and I find that this change in wording changes my attitude towards the things that need to be done. Rather than thinking, “Ugh, okay, what do I have to do next,” I now think of these tasks as important to me, my future, and my success.

The beginning of a Scala “FileUtils” class alvin November 30, 2017 - 3:31pm

In production code I recommend that you use a good “Files” library like Apache Commons IO, but if you want to create your own Scala FileUtils class, here’s some source code that can help you get started.

First, here’s some code for the FileUtils class (an object, technically):

A look at how exceptions work with Scala Futures and the onComplete ‘Failure’ case alvin September 18, 2017 - 12:53pm

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:

A worthy struggle has its own rewards

Working with yoga is often interesting. You stretch and twist and focus, trying to be very conscious of your movements, and then one day in the middle of a twisting pose you see your left foot coming out from behind your right ear. At first that’s a real surprise, a shock. You think, “Well, that can’t be my foot over there,” and then you realize it is your foot, and with that comes a strong sense of accomplishment, and maybe a little smile.

Then you do the same pose in the opposition direction, but twist and stretch as you might, your right foot doesn’t come out from behind your left ear. You know you can’t push it any more, at least not while doing the pose properly, so you realize there’s a bit of an imbalance. You accept that there’s still more work to do, but it’s a good thing, so you push on.

I think life is like that too, or can be like that. If you enjoy the struggle, if it’s a worthy struggle — a path with heart — the effort comes willingly, and with its own rewards.