My response to Penn Jillette, Libertarians and compassion…

March 16, 2012

I happened to see a quote on Facebook from an article by Penn Jillette on CNN Opinion. In it he made the following statement:

It’s amazing to me how many people think that voting to have the government give poor people money is compassion. Helping poor and suffering people is compassion. Voting for our government to use guns to give money to help poor and suffering people is immoral self-righteous bullying laziness.
People need to be fed, medicated, educated, clothed, and sheltered, and if we’re compassionate we’ll help them, but you get no moral credit for forcing other people to do what you think is right. There is great joy in helping people, but no joy in doing it at gunpoint.

It resonated with me as something an Ayn Rand acolyte might say. So, here’s the response I left on my friend’s Facebook post (with edits and corrections):

Wow! Penn sounds like an Ayn Rand acolyte. I sure am glad these kinds of ideas are not mainstream, at least not today. Perhaps if enough people like Penn educate enough children who become adults and choose to take care of themselves and all those around them who are less “gifted” or explicitly disabled, then and ONLY then would what he (and Rand) is saying might work.

Contribution, either chosen, obligated or forced, has been the story of man since long and deep into is tribal ancestory. The idea that there is now enough excess capacity such that individualism is even possible to hold socially and psychologically is a testament to the previous systems’ ability to elevate homo-sapien’s survival.

Luckily, the very thing that psychologically drives Penn (and Rand) is the very thing that diminishes their ability to generate and sustain social cohesion to the point of their being politically irrelevant. There’s an equilibrium between socialism and individualism. Slide too much to either end of that spectrum and one becomes psychologically incongruent and dysfunctional. I don’t know about Penn, but Rand was clearly at the dysfunctional control-freak end of the individualism end of the spectrum.

Penn gets to say what he says only because so many people before him fought to survive so that he now floats in the excess resource capacity to say it without ever having to directly experience the full consequences of his assertions. I’m glad he’s an entertainer. It’s provides the most elegant ironic background to his “serious philosophical statement”. {smirk}

I find his “moral credit” and “joy” assertions are arrogant. He can assert those values for himself. However, who is he to claim they are universal values and then claim the “proper way to evaluate” both morally and joyfully. What a tool.

My evolutionary biology response to a copyright commentary…

March 1, 2012

I was reading a blog post titled “How You’re Breaking the Law Every Day (and What You Can Do About It)” and decided to post a comment. My comment hasn’t shown up over there yet. However, here’s what I ended up writing (with a couple of edits to correct spelling and grammar and better clarify points):

It’s so awesome to see so many commenters posting who have no skill to understand or even make the distinctions in the above article. And worse, the simpleminded auto-response zealots that incorrectly keep repeating the mantra “copyright infringement is theft”.

There’s are specific legal reasons the proper term is copyright “infringement” and not copyright “theft”. It’s because infringement doesn’t actually “harm” the owner by depriving him of the specific property. IT CANNOT as he still has his original as I walk away with a copy. Theft is defined to be when I take a physical thing from an owner and walk away with it. The owner no longer has the thing. Physical things are by nature scarce. Digital things are by nature abundant.

Or, try this on for size. We are rapidly getting close to the point where we will have matter replicators. We already have 3D printers (which is getting damn close). There will be a day where I can make a copy of your bike and then ride off on my copy. And you won’t be any the wiser as you will still have your original when you return to the bike stand to ride off on your copy. Now that’s physical goods abundance.

Or take one step further back. All of nature that is organic is based on profuse perfect copying with very slight modification over time (i.e. evolution). IT’S THE NATURE OF ALL ORGANISMS, OF ALL LIFE! It’s copy all the way down. So, big surprise that the emergent phenomena of the DNA replicators’ (that would be us humans) thoughts, i.e. memes, are entirely based upon profuse copying with very slight modification.

Attempting to stop humans from copying and modifying is to defy their basic biological and psychological nature. Doing so by government force violates a basic personal and psychological boundary of an individual. It also violates the basic boundary of a culture of such individuals. It’s what’s breaking the culture of the USA, TODAY!

And THAT is why, at the most fundamental level, the government enforced monopolies of copyright and patent are ultimately undermined and will never be successfully fully regulated. It requires all the participants to willing deny their basic “copyism” nature, something they cannot and will not do.

It’s hard to put more simply than this. I AM COPY! WE ARE COPY!

Learning Scala and Functional Programming is a psychological challenge…

February 20, 2012

I just finished reading an interesting article which describes the author’s “Aha!” moment around how he is seeing adoption of Functional Programming in general and Scala in particular is occurring with “code density is too high”. Here’s the comment I left which describes more accurately what is actually occurring for me as I attempt to move from Java imperative programming to Scala functional programming:

Very nicely put.

From what I can tell, the fundamental issue has to do with misplaced optimization (i.e. efficiency) combined with a psychologically undermining fear based self-suggestion of “what if this next abstraction I’ve yet to learn is the one that is just beyond my limit of capability”. At least that is what I am currently facing as I attempt to learn Scala and Functional Programming after having _invested_ two decades into OOP (Eiffel, Delphi and Java).

Do I spend the time attempting to make the leap to understand Functional Programming with all it’s weird foreign and non-OO way of doing things? Example: the term monad has kept me up with nightmares of non-grokking now for almost a year, and that’s after reading article after article attempting to explain it. Or, do I leverage what I already know and for what the market is already paying top dollar, or take the risk and time to invest in something that is foreign, it will be years before I am at an expert level again and during that time, I will suffer internal confusion and a confidence crisis as I continue to do OOP in my day job and attempt to do OOP + FP in my spare time?

At this point, I am making the investment to learn Scala and Functional Programming. And I am framing it as an intellectual challenge knowing I might not ever get to leverage either in any real financial way like I have been able to with Java and OOP. And the cost, psychologically to me, has been pretty expensive. I figure I have another year, at least, of being uncomfortably ego-challenging confronted before I finally feel a sufficient level of Scala and FP confidence. So, that’s two years I am pushing myself to invest.

So, given that, I can see how many will choose to wait until Scala and FP are much more mainstream before taking their own investment risks, both psychologically and intellectually.

 

 

Apple’s hypocritical crying of patent-abuse…

February 9, 2012

I enjoyed seeing this blog post about Apple not liking how the patent game is turning out for them. And here’s the comment I left there:

Very well said!

Apple wanted it one way while it was obvious it was to their advantage. Now that Apple has felt some pain (lost battles, bad press, and an injunction or two) and realizes the absolute gargantuan number of companies aligned with Android who are now repositioning to be against Apple which will include an onslaught of new patent infringement litigation from this mass of entities, Apple realizes that regardless of their huge cache of cash, they can be litigated right out of that entire pile of money.

And thanks to Apple’s legal stupidity, they have enabled Microsoft to gain some power such as to become a threat to Apple’s smartphone and tablet markets, too, both through direct Win8 competitors (small) and Microsoft receiving Android royalties (large). And if B&N are able to get Microsoft pushed back into the anti-trust corner again using the Nokia collusion, and in time time lopping of Microsoft’s patent head with the US Feds back in an oversight role, the freed value will enable Android to become that much more powerful an IOS foe.

Apple made a strategic mistake. And now the multi-national megacorporation retaliation genie is out of the bottle. Apple’s just set themselves up to be the “this is what happens when you attempt to be legally aggressive and abusive with patents”. And honestly, from a Karma perspective, it couldn’t happen to a more deserving company.

Job’s unbelievably immature and irrational anti-Android ranting is coming back to haunt his precious Apple. Too bad he’s not here to see and experience the undesirable consequences of his legal temper tantrums.

Isn’t this a very nice example of what goes around comes around?! {smirk}

11 Year Old Java Method’s subtle multi-threading issue…

December 4, 2011

Summary:

Problem:

Thinking about multi-threaded code on a slow single core processor (from 2000) is subtly different than thinking about mutli-threaded code on a multi-core processor (from 2011), especially when using the following line of code:

int salt = Math.abs(new Random().nextInt());

Solution:

A) Create a private static field:

private static final Random RANDOM = new Random(); //created once when the class is loaded

B) Change all the code to use the static instance, RANDOM, ensuring two threads are MUCH less likely to receive the same value:

int salt = Math.abs(RANDOM.nextInt());

Details:

So, there I was looking through the server logs of the most recent release of my team’s Java server application. And every other day or so, a weird SQL insert error would show up indicating the values of the primary key had already been inserted. Given the file based code in this area had been working for the past 11 years (in writes to the file system), the code in the new release had added pushing the records into to the SQL DB. And additional new IOException error (“is a directory”) started showing up occasionally claiming a file operation was attempted on a folder…except that I was not working with a folder, I was working with a file. Huh?!

For deeper context, let’s step back in time. The primary application was started in 1999/Nov. It’s a simple HTTP servlet application which accepts a small set of parameters (URI or post) and responds with XML (mime type text/xml). In order to debug system interactions, a copy of the XML is stored in local file system. The folder path consists of “servlet_name/year/month/day” (ex: AddressResponse/2011/12/04). And the file is named “hh_nn_ss-mmm(salt).xml” (ex: 04_58_37-987(2043482311).xml). To avoid possible collisions in case the four separate servers generating these files were to end up with the same time stamp to the millisecond for the file, a small salt value was added to the end of the file, the value in parenthesis, to reduce the possible collisions as much as possible. Implicit in this was the thinking that if two threads in the same server (process) happened to generate the same time stamp, the salt would eliminate to very small probability the two files would collide. The value is generated using java.util.Random. And the line of code which generates it is:

int salt = Math.abs(new Random().nextInt());
 Ah, the folly of insufficiently thought out problems based on implicitly defaulted parameters. Sigh. I am sure some, and perhaps many, of you can already see where this is headed. Please remember, this was code written over 11 years ago which had long been forgotten about and “just worked”.

So back to the present and the errors/exceptions – a failed insertion into the SQL DB and a claim that attempting to open a new file to write results in an exception with the message text simply saying “is a directory”. I ran through the new DB code over and over again assuming I had made some “global context via Java statics” error even though I had been diligent to avoid statics and make EVERYTHING immutable (tysvm Joshua Bloch). Finally, I happened to notice that non-primary key data was slightly different between the data already existing in the DB and the data dumped into the exception log. This implied that two separate requests were ending up with an identical file name INCLUDING THE SALT. Statistically, that seemed impossible. The servers don’t receive enough requests to actually come near the 1 in +2.1 billion chance that the same salt value would be generated.

After carefully reading the code and checking for any sort of bleed of the text value between threads (hundreds of lines of code between a number of files), I pulled all my hair out. And barely slept that night. When I got to work the next day, I almost didn’t open Eclipse as I didn’t want to get stuck chasing this. I had way too many other things I had to work. However, since I didn’t understand what the problem was, I couldn’t be sure it was just contained to this one area. There might be some sort of data loss occurring which was silent and remained hidden. And it was occurring in production. So, ignoring it was not the right or responsible thing to do.

I opened Eclipse anyway and my focus shifted to where the salt value was being generated. It seemed it was the only point where the conflict could occur. Double checked to verify there was no static bleed. I went and looked at multi-threading issues around java.util.Random. There had been some prior to 1.5. However, the servers were both now on 1.6. And I didn’t have the problem back when they were using 1.3. Then, I looked at the line again:

int salt = Math.abs(new Random().nextInt());
Then, my subconscious finally indicated that maybe I ought to make explicit what is implicitly default about this line. Instantiating java.util.Random with an empty constructor (no seed) causes Random to use System.currentTimeMillis() as the default for the seed. So, the line really reads:
int salt = Math.abs(new Random(System.currentTimeMillis()).nextInt());

And walla, there’s the problem. How? First you must understand how java.util.Random works. It’s a pseudo random number generator. What it means is that it’s not really random. Given the same starting seed value, the nextInt() method will return exactly the same sequence of values. So, new Random(0).nextInt() will always return exactly the same value every time. Almost all of the time for almost all uses of Random, using the clock (i.e. System.currentTimeMillis()) is a great way to generate a random sequence. The problem here is that two separate servlet threads happen to make the call at exactly the same time which results in exactly the same value being generated as the default for the empty Random constructor. This results in the salt value in both threads being precisely the same. And this results in both threads having identical file names. So, the thread that is successful in getting the file stored to the file system “loses” in that the second thread automatically deletes it and then saves it’s own copy. However, the DB allows the first thread’s record to be inserted and then the DB rejects the second thread’s record. And as a result, the two errors above occur.

The first error, the one claiming that opening the file to write it to the file system (message of “is a directory”) was when one thread was still in the middle of writing the file (owned the system file lock) causing the second thread to receive the exception. And the second exception, the SQL DB insert error, was when either thread finally wrote it’s record to the DB successfully causing the lagging thread to “lose” when the DBs primary key (unique index) restricted the attempted duplicate insertion.

Now that I understood the problem, some XML responses were not being logged in the file system and the SQL DB, I could conclude the problem was non-critical and didn’t require an immediate fix. The fix could go into the next release which ought to occur within the next 2-4 months. It also meant that the problem has likely existed ever since this code was generated back in 2000 and has been silently occurring, albeit very infrequently, because the file saving mechanism was always deleting the first thread’s file write with the second thread’s file write (silent file delete needs to be elevated to a log output so this could have been caught sooner).

This issue actually showed there were several problems with the code design beyond just the java.util.Random default value issue. However, the fix for this particular part of the issue (with a minimum of redesign) is to change the class where the salt is generated by moving the creation of the Random to a private static value. This will ensure the Random is generated once when the class is loaded. And then the salt related code will call nextInt() on that instance of Random (and nextInt() is thread safe, I checked).

There is still the very remote possibility that two threads could both have an identical date/time stamp and nextInt() return the same (Math.abs()) value, twice in a row. However, we are now back at the 1 in +2.1 billion chance, a risk I’d easily take…for now. I will eventually revisit the code generating the file name to eliminate file name duplication in that rare event.

It is possible to design the logic more effectively to handle file name conflicts and just regenerate the full name for the file. The probability that the time stamp and the salt will be the same on the regenerate is so very small, it would rarely occur (like maybe once every 10 years given the current server loads). And even if it happened to occur, the expense for the recalculation would be close to negligible. And given the exception, just causing the thread with the collision to sleep for a couple of milliseconds before attempting the regenerate would noise up the results, especially of the chosen sleep time happened to be a random value between 1 and 20 and retrieved from the same instance of RANDOM.

After working through all of this, I then realized I might have used this particular Random pattern in other places in the code base. A quick use of Eclipse to search the code base turned up a use in a different area, and it was using the same basic implementation. The impact there was not large enough to even worry about it as there was already a mechanism for retrying around conflicts. Still, I will update it with the same solution (moving to a private static instance initialized at class load time) and virtually eliminate conflicts.

As servers continue to increase in speed, number of processors and number of cores, conflicts which were virtually impossible 10 years ago, are much more possible now. It does make me wonder what other kinds of assumptions I have made in my code from back then which will show up as odd server log exceptions. Whatever the case, I’m sure Murphy is working hard to enlighten me as soon as possible. Whoohoo!

 

Interesting piece on personal health and western medicine…

December 3, 2011

I really liked how this guy so completely identifies how modern western medicine has a very reactive “wait until they get sick” mentality over an “ounce of prevention is worth a pound of tests and pharmaceutical products”:

http://www.aquatic-ape-diet.com/blog/2011/12/02/critiquing-the-lesswrong-mineral-supplementation-5000-contest/

Here’s a copy of the comment I left on his blog  just now (third from the top):

Tyvm for writing about your experiments and observations with a skeptical and critical tone of science and medicine status-quo. I appreciate your candor and assertiveness, although they have a slight ring of defensive superiority (which I don’t entirely understand).

That said, ultimately there are very few who are trained effectively in the scientific method, much less deeply understand it. Secondly, and to your point, you cannot really use those methods effectively when researching specific causes and causal chains in dynamic complex systems (i.e. chaotic systems) such as human biology (which is an attempted “subset” of the much larger organisms picture).

And since people have to make decisions today with limited information (not evidence…most people never get close to evidence…they read other peoples supposed interactions and observations and second hand elevate those via the labels “facts” and “evidence”), they want to do so with confidence and with deferred responsibility. That sets up the general mentality of avoiding self-experimentation and replying on “science” and “medical” experts to give them the confidence while the experts also take on implicitly the responsibility for all negative outcomes.

This simple psychological self-referential loop is what has caused so much of the “wait until they get sick” mentality of most of western medicine. And given the profit motive is so strong in the scientists and medical researchers and practicianers, and given the government force of the major agencies combined with the government encouraged and enforced monopolies of patent, copyright and trademarks, it’s a self sustaining self-deluding self-denial cycle that has no foreseeable resolution.

I feel very grateful that I have been able to see this and step away from it. And then re-enter on my own terms and with my taking complete and total responsibility for my health. My doctor does not prescribe, he consults with me. I make the choice to submit to the tests, to fill and take the prescription, to return if/when I decide. I don’t know of very many people who choose this balance. Most either completely submit to the “expert system” of scientists and physicians, or completely avoid the system all together. For me, both are extreme and result in avoidable undesirable outcomes.

Again, thank you for sharing from your own N=1 experimental perspective. I value your sharing very deeply.

The GOP’s Palin Chains…

January 28, 2011

I find it radical to watch an irresistible force hit an immovable object:

Democrats just have to be smart enough to have brought simple wire clips

The reality of the GOP's position for the 2012 POTUS election

This image originated elsewhere. The added text parody (or travesty depending upon your point of view) just leaped into my mind.

iPhone 4, IOS built-in PDF reader versus my new favorite app…

January 25, 2011

I upgraded my iPhone 3G to an iPhone 4 the week after Christmas. I wasn’t planning to do that. My hand was kind of forced. You see, I had upgraded my 3G to IOS4 about a month after IOS 4 shipped. OMG, was that a mistake! My phone when from useful (with 3.1.3) to damn near unusable, no exaggeration. The IOS 4.1.0 update which arrived two months later made the phone just barely useful again…as long as I restarted my phone every 24 hours. Any longer than that, and opening simple apps would take minutes. Again, no exaggeration.

Here’s a real life example. It’s the day after Christmas and I am taking my girlfriend to the nearby James Avery (special jewelry) store. However, I don’t really know where the closest one is. I unlock my 3G, click on the Map app (the killer app for the iPhone as far as I am concerned – it’s the app I use at least 50% of the time) and select the search bar to type in my search string of “James Avery”.

It takes +10 seconds to open the Map app. The screen appears and then it takes close to a minute before my touching the search bar selects it. Another 15 seconds of tapping on the small “x” to the right to clear the text box results in the text clearing, the cursor appearing at the beginning. And then it freezes. For over 45 seconds. My girlfriend is treated to my exhibiting class A violent ape behavior. My speech patterns are slurred from the vitriol busting out of my completely enraged head.

And then the cursor starts blinking. I started this activity as we got into the car. It is now close to 5 minutes later, and a good +5 miles down the road. For all I know, we have FREAKIN PASSED THE BLOODY STORE! At least the cursor is blinking indicating I can type. So, I quickly type “james”. However, I am treated to a single click sound and the letter “J” popping up and freezing in the popped up position. I wait. And wait. At this point, my girlfriend and I just choose to stop using the iPhone. We drive to the only James Avery store we know nearby (15 miles away). I happened to note the time on my car clock when the J froze on the screen.

SEVEN MINUTES LATER I heard a click on my iPhone. I looked down, but the frozen J remains hovering on the screen. I look away. I hear another click. Then a series of 3 more click sounds. I looked down. The J has disappeared and the A has lept up and is now frozen on the screen…for about 3 seconds before the other three letters finally animate the completion of the word.

Seven minutes the phone sat there completely and utterly useless. And with three months remaining on my AT&T contract, I was very annoyed as I felt stuck. I was now very committed to obtaining an Android device with 4G. I was now VERY motivated to get as far away from the iPhone and AT&T as possible. I was NOT going to reward Apple’s atrocious misuse of my perfectly fine phone (prior to their craptastic IOS 4.x upgrades).

A day later, my girlfriend and I were spending time with another couple who both happen to have iPhone 4s. They heard my story. When they heard I was going to be enduring another 3-6 months of 3G agony, they said “Do the math. Get an iPhone 4. And then break the contract and sell the iPhone 4. The most it would cost me was another $100 a month for a couple of months. That sounded like heaven compared to my day-to-day trauma of using the 3G.

I went home, verified the math and the next day, I was upgraded to the iPhone 4. And it was awesome. The apps all became useful once again. I then spent another 12 hours reversing the 3G to 3.1.3 so my girlfriend could “try it out”. It was completely useful once I had it back to 3.1.3. She was coming off of a Blackberry…and loved the 3G. She’s all aglow now that she has her mega-useful iPhone.

Now that I have been using my iPhone 4 for the last month, I had an e-book in .pdf format I had purchased. I loaded it onto my Dropbox, brought up the iPhone Dropbox app and was able to read it. Dropbox appears to use the built in PDF reader in IOS. Well, while that reader is great for short documents. It was not great for my +800 page technical book. In fact, I was +300 pages into the book when I made the mistake of wanting to review the table of contents. I tried to find a “goto page” function. No where to be found. At least no where intuitive. Turns out, there isn’t one. ARGH!

That lead me to start researching other options for viewing an ebook as a PDF. After reviewing several, I found the PERFECT (not just best) PDF viewer. It’s called “GoodReader“. I jemmed and hawed for a couple of minutes about it costing $3 before realizing that just the ability to jump to a page was worth WAY more than that (having had to,by this time, hand scroll hundreds of pages of my technical book). So, I purchased it. And it’s pure heaven. I can SO tell they use it themselves. It has so many nice features and touches. And reading my ebook is now a such a joy! Awesome!

BTW, I’m not in any way affiliated with this app other than I was lucky enough to discover it.

ERROR: Failure to be consistent in commitment to blog once a week…

January 22, 2011

ARGH! I failed to post here once a week like I had committed to back in October. I don’t like failing. So, I am reluctant to make a new commitment. However, it’s strange how making a public commitment generates a form of accountability that isn’t the same when I just make the commitment to myself (especially internally and unspoken).

So much has happened on so many fronts in the last 3 months. The biggest was the holidays, of course. And then my recent move. Anyway, excuses aside and uncommitment commitments aside, I will write here as the fancy strikes.

The riff stuck in my head and soul…

November 13, 2010

Summary:

I finally found the full song to the bit that was going through my head over and over again.

Details:

Sometime last night, while out on the town and probably while eating dinner, a song played in the background. And a bit of it stuck in my head. And played over and over again. I went to sleep with it circling. I awakened this morning and the song bit reappeared in my head as I was showering. ARGH! I couldn’t get it out of head. And all I had were some notes. No lyrics. And no recall of the group who played and sang it. It was maddening. And I had no way to “search” for it.

Until I remembered that somewhere I had heard you could hum a couple of bars into some iPhone app and it would find songs that might match. After doing some basic things for the morning, I finally had a couple of seconds to hunt down the app. It was called Shazam. And it was useless. Apparently, it wanted to hear the original song. I didn’t have that. And if I did, I would just look the song up by its lyrics on Google. ARGH! I then found another app called SoundHound. It, too, was useless. It kept on finding artists in other countries and songs in other languages. I knew this was a pretty popular rock group with a male lead singer. And that the song itself was relatively popular, and recent (in the last decade). I deleted both free apps and gave up looking for awhile.

And the freakin bit of the tune just kept playing over and over in my head. And I kept whistling it. And I kept asking my girlfriend if she knew it. She recognized the riff. But she, too, was not able to quite put her finger on who or what it might be.

I then got home and googled around for apps on my laptop that would let me hum the riff and try to find a matching song. After a couple of false starts, I landed on midomi. And I then hummed the riff in. After reconfiguring the advanced search to only look for songs in English and in the Rock genre, up the song popped as the 2nd entry (behind Brittany Spears) – Coldplay’s “Talk”. The snippet was the wrong part of the song, but I instantly knew the lead vocal’s voice was an exact voiceprint match to my memory. I then went to YouTube and searched for “coldplay talk lyrics” and played the first entry. And there were the riffs, right there at the very start of the song. I was in heaven.

And I have been playing the song over and over again now for awhile. Kind of obsessed with it. Weird.