Wednesday, September 16, 2015

Functional Java...

Functional Java...  In the bad old days before Java 1.8 (before lambdas, in other words), if you wanted to list the subdirectories of a given directory, you'd write something like this:
files = _node.listFiles( new FilenameFilter() {
    @Override    public boolean accept( final File node, final String name ) {
        return new File( node, name ).isDirectory();
    }
} );
That's an anonymous class declaration, complete with all the mess of Java wordiness that goes along with it.  Ugly, dense, and way too hard to understand.

Today I wrote one like this:
files = _node.listFiles( (node, name) -> { return new File( node, name ).isDirectory(); } );
That's a lambda in there: short, to the point, and easy to read.

I know it's a crazy simple example, and doesn't at all show off the power of lambdas or functional programming.  But anything that replaces the gobbledygook of the first example with the (relative) clarity of the second is a winner in my book.  Me like!

Dilbert...

Dilbert ... really cracked me up today :)


Pouring, it is...

Pouring, it is...  The skies just opened up here, with buckets of water sheeting down.  Up to this moment, the storm has dropped 1.8" on us – well ahead of the forecast.  The screen grab at right shows the radar image (if you look carefully, you can find the little ⊕ symbol that marks where Paradise is).  That red blob marks the intense rain, and the edge of it just hit us.  There's more to come.  North of us we see lots and lots of lightning.

At left is the scene outside our north-facing second floor windows.  You can see the choke cherries in the middle, just starting to turn color.  The rain isn't quite so obvious in the photo, but trust me on this: it's coming down cats and dogs.  Big ones!

We caught a break in the rain...

We caught a break in the rain ... late yesterday afternoon, so we piled all three dogs into the truck and headed up to “Tony Grove” Lake (in Logan Canyon) to see what we could see in the way of fall color.

Our route took us right past the Aggie's Creamery, so naturally we stopped in for an ice cream cone.  Debbie had a repeat: one scoop of chocolate, one scoop of espresso chip.  I tried something new: one scoop of maple walnut and one scoop of caramel cashew.  I couldn't get a comment from Debbie, other than “Mmmmmmmm” :)  Mine was outstanding – just the way I like it, with a subtle and not-too-sweet flavor of maple and caramel, and lots of nuts.  I did have one small problem, though: my server was on his first day at work, and didn't yet understand the physics of ice cream cone preparation.  It was all I could do to keep my ice cream situated on top of my cone.  He hadn't stuffed enough of it down into the cone to keep it stable.  I made it without dropping the ice cream, though.  That would have been tragic!

I also bought a half pound of “Aggiago” cheese, which I haven't tried yet.

The drive up Logan Canyon was full of fall color, mostly visible to us on the canyon's sides (as at right).  Mainly we saw the oranges and reds of maples, though there were also a few oaks, and up high, splashes of yellow from aspens (not quite in prime color yet). 
As we approached Tony Grove itself, though, things changed for the worse.  There are large areas of dead or half-dead aspen groves up there, and not a few dead firs.  We have no idea why that's the case.  Right around the lake itself we saw a bit of color, but truthfully nothing even close to the rather nice color further down in the canyon.  We walked the dogs up there (excited, they were!) and headed back home just before dark.  Where I walked the dogs, we saw this one lonely (and very late!) bloom on a plant I don't know.  Seems pretty weird to see this just a few weeks before there will be snow here...

To the readers who emailed me...

To the readers who emailed me ... about these floods.  We're not in any danger here in Paradise.  The floods are near the down of Hildale, Utah, which is 400 miles – a six hour drive – from Paradise.  That's about as far from us as you can get and still be in Utah :)

Many of the news reports on the flood neglect to add an interesting fact: Hildale is the Utah epicenter for Warren Jeff's polygamist version of the Latter Day Saints (Mormon) church...