Review: Core Java Volume I

Core Java Volume I-Fundamentals Book Cover Core Java Volume I-Fundamentals
Cay S. Horstmann; Gary Cornell
Prentice Hall

One measure of a great novel is whether it's worth reading a second time.  Similarly, the measure of a great technical book is whether it's worth reading cover to cover when you are already familiar with the topic.  As a Java programmer, I might have assumed that reading an entire book on the Java language would not be a worthwhile way to pick up the handful of tidbits that I'd managed never to have acquired.  But I would have been wrong.

While this text could be used for someone with a programming background but new to Java, it's structured well enough to solidify and enhance the understanding of someone who's already done this a few years.  Specifically, the authors' experience shows when they explain various options for using a feature of the language, explain the comparisons, and then unabashedly advise "do it this way; don't do it the other way".  For example, the section on multithreading gives clear and concise explanations as to how create threads and locks and use the "synchronized" keyword, and compelling explains why you'd want to use each of the various options, including the "never" do this cases.

It would have been easy to gloss over "type erasure", as the phrase doesn't imply what it is or why we would care.  By including clear opinions and warnings from their own experience, I now understand that generic types in Java are a compile-time construct rather than a full enhancement to the underpinnings of the runtime.  The authors explain every consequence of the fact that Java containers actually lose some of their type information after compilation, and therefore why there are arbitrary-seeming limitations and otherwise inexplicable compile-time errors.

While this book is titled as if it would be a solid reference book to let collect dust on your shelf, I found it much better suited for enhancing my mental framework about what Java can and can not do by simply reading it.

Comparing Data Storage Costs

Comparing a pay-per-use data storage service like Amazon AWS’s S3 against a service with maximum reserved storage is a bit of an apples-to-oranges comparison.  If you have, say, 100 gigabytes available through a Sugarsync account, your unused capacity will always be greater than zero.  You will always pay for some amount of unused capacity, making your actual gigabyte-month costs higher than they would be if you were only charged for actual usage.  That said, here are some current costs by gigabyte-month:

ServiceOptionAdvertised rateEffective rate at 50GBEffective rate at 100GB
Sugarsync$7.49/month 100 GB$.0749$.1498$.075
AWS S3less than 1TB$.0300$.03
$.030
AWS Glacierless than 1TB$0.007 per GB$.007$.007
Dropbox1TB $9.99$.01$.199$.099
Amazon CloudDrive$69.99/year$.1166
$.058

 

CentOS v AWS Linux

This post got me thinking about which version of Linux to run for my AWS EC2 instances.  At first, I found the AWS Linux perfectly suitable: it’s endorsed by Amazon, and obviously runs well.  All of the appropriate interactions between the operating system and the virtualization system obviously work, where it isn’t immediately obvious that other version would do the same.

An investigation was inspired by the idea that AWS Linux can not (reasonably) be taken out of the AWS to do investigation, reproduce problems, or develop offline.  Similarly, you can’t build an AWS instance on a local (screaming fast) machine and then push an image back to EC2.

I chose CentOS to be that much more agnostic to the hosting virtualization service, though I’m an AWS fan.

Here are some of the pleasant side effects I found of using CentOS as bonuses:

  • SELinux — more security if you want it (and if you don’t)
  • Clearer documentation – examples from the world
  • CentOS free just like AWS Linux
  • fresher repositories
  • simulate environment locally
  • can’t pull AWS Linux
  • Build your own kernel

 

Fast WordPress Hosting

Since I’ve switched all my web sites  providing only content to WordPress, I’m necessarily obsessed with performance and trying to find the most cost-effective way to flexibly run a site and get screamingly fast performance.  I say “flexibly” because I’ve gotten used to installing a variety of software directly from the command line.  This may be unnecessary as I trust the available set of WordPress modules more and more, but I still like the flexibility of managing my own Linux server.

So what’s fast enough?

An Amazon t2.micro instance provides 1.016s average total round trip on repeated viewings.

Dreamhost shared hosting averages 2.530.

But this wonderful post has me thinking that trying to draw averages may not be particularly helpful, and also implies that “max response time” values make real user experience not something that can be terribly well controlled.

Ignorance of IP Name Resolution

An ideal blog post probably provides answers to others who may be searching.  This one doesn’t.  This is the accounting of the mysteries of “localhost” on CentOS linux instances.  I’ll post updates as I actually start to understand the answers.

Fetching a web page from localhost is slower than fetching from 127.0.0.1

127.0.0.1: average response .015s

localhost: average response .166s

So an entire end-to-end fetch is ten times as slow using localhost, and the IP address is apparently not cached, as it doesn’t get any faster with repeated runs.

Yes, “localhost” is an alias to 127.0.0.1 in my hosts file, so I expect that an actual DNS request on the wire should not be necessary.

WordPress won’t find my database on host “localhost”, but it will find it at 127.0.0.1

Okay?

AWS IAM Roles

One of the limitations of Amazon AWS’s EC2 IAMs is the instance role MUST be assigned at “launch” time.  This is distinct from the “Start” action on an instance that was running as has been stopped.  In order to associate a current instance with a new or existing IAM profile, you must create a new instance.  This can be done by creating an image from the current instance and launching that.

Once an IAM role has been assigned, you may alter it.  This suggests that best practice is to always launch an instance with SOME IAM role.

Are the command line tools related to IAM roles?  YES, although it’s not specified, AWS command line  tools will find the role of the instance it’s on,  even if it’s not AWS Linux.

Assuming a role

http://docs.aws.amazon.com/cli/latest/userguide/cli-roles.html

First Impressions of iOS 9

  1. The virtual keyboard shows lower case letters when you’re entering in lowercase.  Yay!
  2. Low power mode: the OS turns off or tones down some of the expense battery consuming functionality.  Don’t know yet how effective this is, but anything is an improvement over involuntarily burning through battery charge until the phone arbitrarily quits.
  3. We still can’t get rid of built in apps.  I’m not buying an Apple watch, Apple!  I don’t need your mandatory app.

Business Book Reading List

I appreciated this article on which books are worth reading.  The premise is that nobody should be reading “business card books” which tout the author’s credibility, books that aren’t long enough to be worth a book, and actually good books.

I don’t agree that even most business books fall neatly into one of these categories, but I do appreciate the list of “good books”:

“MASTERY” by Robert Greene
“BOLD” by Peter Diamondis and Steven Kotler
“OUTLIERS” by Malcolm Gladwell
“WHERE GOOD IDEAS COME FROM” by Steven Johnson
“MAN’S SEARCH FOR MEANING” by Victor Frankl
“BORN STANDING UP” by Steve Martin
“ZERO TO ONE” by Peter Thiel
“QUIET” by Susan Cain
“ANTIFRAGILE” by Nassim Taleb
“MINDSET” by Carol Dweck

I’m starting with Nassim Taleb’s book: he seems to have dozens of quotable reference in every book he’s written.

Getting Mac Yosemite to Sleep

I’ve had numerous issues with convincing my Mac Pro 1,1 to sleep, and almost equal problems keeping it from sleeping when it’s in the middle of doing work I actually want done.

Apple’s site is quite helpful here, when I tried everything on the list.  I suspect that Bluetooth and/or network waking is the issue.

https://support.apple.com/kb/PH18596?locale=en_US