Saturday, August 25, 2007

The Mark of a Good Sitcom

I was doing my typical Saturday night activity of watching the Disney Channel when I was reminded of something that I had determined long ago: a good sitcom makes the half hour go by quickly. The sitcoms that led to the rediscovery of my tenet were Cory in the House and That's So Raven. It started with Cory in the House. I would watch seemingly 5 or so minutes at a time, get distracted by something, catch another 5 minutes, do something else...wow, is this show still on? Not that it was boring or anything, the episode just seemed lengthy. After it had ended, I felt as if I had devoted a lot of energy into watching that show--but not enough energy to keep me from watching more Disney Channel, of course. Next up was Raven. It was a good episode--the series finale, I think--but it wasn't one of those best-of or reflect-fondly-on-the-past episodes. In any case, it was over before I even realized that I had taken the time to start watching it, and watching it was effortless. Needless to say, That's So Raven is better than Cory in the House (that should be obvious to anyone even if they don't agree with my attestation of sitcom speediness).
  • By the way, you can watch Raven and Cory episodes on disneychannel.com.
  • Also, I've always felt that Family Guy episodes took a lot of time and energy to get through--becoming more depraved can be a chore sometimes, I suppose.
  • Although in the case of Arrested Development, becoming more depraved is a speedy process.
  • If I didn't have clocks to prove otherwise, I could swear The Office is only a 15 minute show, tops.

Wednesday, August 22, 2007

Are Java Generics Worth It?

Java 5 introduced a feature called Generics that was an attempt to duplicate, more or less, the Template feature of C++. The motivation behind it was to allow the compiler to provide more type safety--making sure you don't accidentally use the wrong type object. It was also touted as a way to prevent casting. So, for example, let's say I wanted to sum the contents of a Collection of Integers, I'd write this (before Java 5):

int sum = 0; for (Iterator it = coll.iterator(); it.hasNext(); ) sum += ((Integer)it.next()).intValue();
(Note that before Java 5, I could also add a String to my collection, which would have caused a runtime error in my summation code.) In Java 5, I write this:
int sum = 0; for (Integer i : coll) sum += i;
(I'm also taking advantage of another new Java 5 feature called autoboxing, but I digress...) If I tried adding a String to my collection, the compiler wouldn't let me, thus preventing the runtime error.
This is all wonderful, you may think, but there are downsides I've discovered:

  • Extra Keystrokes: I may avoid casting and its associated keystrokes with Generics, but I have to type a lot more just to declare that I'm using Generics. Compare the two Collection instantiations below.
    Collection coll = new ArrayList(); // pre-Java 5 Collection<Integer> coll = new ArrayList<Integer>(); // Java 5
    Hmm...Java 5 is a little bit wordier. But it can easily get worse, like if I wanted, say, a Map of Strings to a Collection of Integers:
    Map map = new HashMap(); // pre-Java 5 Map<String,Collection<Integer>> map = new HashMap<String,Collection<Integer>>(); // Java 5
    Java 5 doesn't require you to explicitly specify Generic types, but it will give you a warning if you're not.
  • Type "Interference": For lack of a better way of describing this, sometimes in an attempt to use Genericized code, you can find yourself struggling to placate the compiler so that it lets you do what you want to do. I think the issue is partially related to backwards compatability, wildcards, and covariance-- which is a fancy way of saying that subtypes and supertypes aren't interchangable. This article does a good job of explaining the quirks. It'll suffice to say that nuances and subtleties with Generics sometimes hinders your ability to program more than the type safety provided helps you program.
  • Compiler Errors: I stick with the Sun compilers, so it could be their problem, but I depending on the version of the compiler I use, sometimes my complex Generics code compiles, sometimes it doesn't. We used to have problems with JDK 1.5.0_08 but had those problems resovled by _09. Now we're getting a new compiler errors after switching to 1.6.0_02. You really need to execise more caution with JDK upgrades when your code relies on Generics.
  • Unreadable Code: This is the most troubling of the problems I have with Generics. A mark of a good programmer, in my opinion, is working code that is readable and therefore understandable. But sometimes if there's some code that is Genericized using other Genericized code, you get this snowball effect and before you know it your code is littered with so many angle brackets you'd think you were writing XML. Check out this class declaration from some code written for my latest work project:
    public abstract class FooDAG<F extends Foo,     B extends Bar<F, F, B>,     E extends FooDAG.Edge<F, B, E>>   extends FooGraph<F, B, E, FooDAG.Node<F, B, E>>   implements Iterable<FooDAG.Node<F, B, E>>
    Even though I helped write this class, I honestly don't fully understand at this time what it does or why it needs to be that way, at least without a good 15 minutes reading the class over.

In any case, I'm beginning to conclude that the extra type safety offered by Generics isn't worth it, especially nowadays with with popularity of loosely-typed dynamic languages and dependency injection frameworks like Spring, which let you retrieve objects from a Factory which you need to explicitly cast into the object of your choice. I do enjoy using the Generics built in to the JavaSE API, namely the java.util package, but as far as using Generics in your own private APIs, I don't think it's worth it.

Monday, August 20, 2007

LDS Wedding

A coworker invited me to his wedding reception at a Latter-Day Saints Church this past weekend. The wedding itself was in the Temple adjacent to the church, which we could not attend because we weren't of the "restored sainthood" (plus you need an official LDS card affirming your worthiness). However, on our way to the church we made a wrong turn into the temple parking lot and managed to get a fairly up-close view of the outside of the place.

I noticed some architectural similarities between the temple and some Masonic buildings I've seen, specifically the Masonic Temple in Alexandria and a lodge a couple miles from where we live.
  1. No Windows - although the Masonic Temple appears to have windows, the lodge and the Mormon Temple were void of any inlet for natural light. It's a little odd that something touted as "a light to the world" shields the outside world from any light originating from within it.

  2. Near Symmetrical Design - all the buildings are symmetrical, or as the Masons seem to refer to it "geometrical." The only non-symmetrical feature of the temple is the spire holding the statue of Moroni. Note that the remaining five spires form a slightly elliptical inverted pentagram behind him. (OK, so maybe that's a little bit of a stretch, but some Mormon temples do have pentagrams on them.)

  3. Out-of-place -both the temples sort of show up out of nowhere. You're driving down the beltway towards the Wilson Bridge, noticing the large commercial buildings and then all of sudden you say "What's that?" as the Masonic Temple comes into view. Likewise, the spectacle of the gigantic, marble white Mormon Temple nested within a quiet, lush, wooded area elicits even more of an exclamation.
  4. Creepy - the creepiness is probably results from a combination of the out-of-place nature, unusual architecture, and the enigmatic nature of Mormonism and Masonry. It was uncomfortable to be there.

Some claim Mormonism has no relation to Freemasonry, other than that Joseph Smith himself was a 32nd-level Mason, the highest level to which any non-US President can attain to (Smith also possessed +12 Charisma and +5 Accuracy with the long bow...I kid). But apparently there's a lot of material out there linking the two more deeply, architecturally and ceremonially. I'm not going to tread those waters right now.

I would like to offer my congratulations to my coworker, though. He and his wife are a great fit and make a cute couple.

Friday, August 17, 2007

Debt & Debtor

I've been reading a lot of stock market news along with doom and gloom stories about the economy. I think the gist is that long-term loans became so cheap, people were enticed to buy things with borrowed money. With all this money (rather, credit) circulating, houses became a lot more expensive--not because they were actually increasing in value, but because people had more and more credit to spend. So people borrowed even more money to buy these homes. Long story short, more money has been loaned out than actually exists, and that's causing problems; you can't pay back loans with non-existent money: Nicholas Andre: (looking at peices of paper in a suticase) Where's all the money? Lloyd Christmas: That's as good as money sir, those are IOUs. Go ahead and add it up every cents accounted for. Look, see this that's a car, 275 thou--might want to hang on to that one. Being able to compare US consumers with Lloyd Christmas from Dumb & Dumber makes me nervous. So here's the rundown as I've gathered:
  • People borrow more money than they're able to pay back.
  • Banks lose money on the loans given to these people.
  • Banks can't give out more loans since they don't have as much money to loan out.
  • People can't get the loans they need to buy things, so they have to stop spending.
  • Companies profiting from people buying their stuff lose sales.
  • Investors used to steady, rising company profits get upset and cash out their investments.
  • Stock prices fall, companies lose capital they need to do business, people lose jobs, the economy goes south.

Hey, doesn't this sound familiar? Anyways, the difference between now and 1929 is that we have federal groups that are supposed pull strings to try to keep the economy going. Good luck with that. To be fair, the latest move by the Fed--lowering the interest rate for loans they give to banks--did help the market rebound today, but that just adds more borrowed money into the mix.

Eventually the US is going to have to generate money, maybe some lucrative new energy source, perhaps? Until then, I'm not sure what to do. If this scenario causes the value of the dollar to increase (as a result of credit being harder to obtain and prices decreasing), I'll want to hold onto cash. On the other hand, if the US economy tanks and the dollar loses its value, then my cash will be worthess, so maybe I'll want to buy gold or something to protect my dollars.

Thursday, August 16, 2007

What is Technology?

"Technology" gets thrown around to describe lots of different things, some of which are truly technology while others are just boring "stuff." I listen to WTOP during my commute and a fair number of ads seem to be companies offering technology "solutions" that meet "critical requirements." My hunch is that the majority of these "solutions" are just attempts at using some newer boring stuff to replace older boring stuff clients already use. The newer stuff will hopefully be an improvement over the older stuff, but that's assuming the contractor is able get the newer boring stuff in place within time and budget constraints--a surprisingly difficult feat (and a whole other topic). Here are some examples of boring stuff passed off as technology:
  1. Standards (CSS, EJB): A standard is nothing more than an agreed way of doing things that people implement in partially incompatable ways. Nothing that can be done using one standard that can't be done with a different standard.
  2. Programming Languages (.NET, Java, Ruby): New languages allow people to do the same things they've always been able to do with a different syntax. Ultimately, though, all languages end up as a bunch of zeros and ones pumping through a processor. And that's boring.
  3. XML (XSLT, Schema, XForms, XML-RPC): XML is a standard (and a yucky programming language), but it deserves it's own bullet because it's the parent of dozens of derivative standards that are all equally boring.
  4. Web-enabling: This is the process of moving applications from one OS (Windows/Unix/Mac) to another, more limited OS (Internet Explorer/Firefox/Safari).

Things that are really technology require scientific research to discover and implement, in my opinion--things that are produced by engineering not marketing.

Outlet

I started this blog to externalize my thoughts in order to make room for other thoughts or good ideas...ideas like how to start a successful business or getting free lunches. To avoid random rants, I will try to focus postings into four categories corresponding to the prominent areas of my life (which are sadly not always in this order): Christ, Family, Money, Technology.

I used to have a pre-Google Blogger blog in college that I neglected and now is forever lost among the Google server farms. Then I posted some things on my myspace blog...but myspace is lame (sorry, Rupert). We'll see how it goes this time around.