No, my opinions as expressed in this blog are not those of my employer. They're mine alone. That's why they're called "my opinions." Helloooo.

Monday, March 12, 2007

by the way, what does 'extraordinarily typesafe' mean?

I was feeling pretty proud about Guice. It went 1.0 last week and has been making the rounds in the blogosphere the last few days; it seems to make a positive first impression on most people.

I showed my wife an announcement that I sent to some mailing list or other about the release. This was like a few days ago. And just now she says to me, "by the way, what does 'extraordinarily typesafe' mean?"

I said,

"In the software world we really like to think in terms of objects, and our favorite programming languages are built to support this object-centric view. An object might be the name 'Caryn', or it might be Kevin's Discover card or the font that I like to post my blog in.

"When things are not 'typesafe', someone can walk up to you and ask for your credit card and you can hand him a font, and he'll say, '30 seconds.' And he'll walk away, many kilograms away and only later will he gleefully try to charge your credit card and explode cosmically. You know, like what was supposed to happen in Ghostbusters when they crossed the streams.

"Java has always been typesafe at some level, because you can't just pass a font to a credit-card processor. But there was a huge, yawning chasm in the type-safety landscape that an entire Stay-Puft man could fit in comfortably: collections of things. See, you might have a roster full of names, or a wallet full of credit cards, or a drop-down box full of font choices, and as soon as you put something into any of these, it would immediately forget what the hell kind of a thing you just put in. And when you'd take something out, you'd say, 'take this thingamabob out, and by the way, that's a credit card I'm taking out.' Yeah. Only it might not actually be.

"What this is, is it's not typesafe. So anyway, what this guy Josh I work with, who I'm always telling you about, helped to mastermind was this huge change in Java a few years ago, that finally plugged this leak, so that you can now say 'this is a bag of credit cards' or 'this is a bag of employees' and you're only allowed to do things with these bags that make sense. Now Java is finally very typesafe.

"So then there's this thing called Dependency Injection that our framework supports, and other things like Spring also support it, except Spring doesn't support all the latest advancements in Java, and it wants you to configure things outside your Java code, in a bloody text file. So you can go to that text file and say 'use this font renderer to process credit card payments' and it will think that's okay, until you try to run everything and then the asploding.

"But Bob and I made this framework where you get to only write Java code, and so as soon as you try to do this bogus thing, it's just like that example of the bag of employees above. The words turn red on your screen and you know something's wrong right away.

But java's type system is not great, let's not kid ourselves. It is far better than most but erasure generics makes it difficult to do really "extremely typesafe" and cool things. Also erasure means that you dont really know that you have a bag of credit cards, you just have a gatekeeper that lets you into the shopping mall if you have a bag of credit cards. If, after you get in, you slip in some strawberries, you're screwed (and have to resort to things like checkedCollections).

I would have loved it if we followed something like C++ type system where you can declare arbitrary type parameters like:

Given a choice between extreme type safety and dynamic type safety, and assuming good test coverage for both, I'll take dynamic type safety almost every time. The contortions people submit themselves (and other) to in the name of extreme type safety can be appalling.

Kevin, I would drop 2 or 3 large each month to read your diatribes. You could be "Kevin on Injection!" Seriously, my wife and I talk tech at the local pub, and people look at us like we should be in the circus. One night she started railing about injection schemes and the bartender asked us to clean up the language!

Anyways, love your stuff and once I'm finished writing this damn Struts2 book, I plan to roll up into your Guice grove to have a look around.

Latest film "007: license to kill" the story Sanchez learned that King of drug trafficking in Latin America, the message stays near the Bahamas, the British spy James Bond 007 to get there with Wright and Sharkey, tried to Sanchez arrested. But Sanchez is not only escaped, but also Wright dropped into a shark pool. Although Wright saved a life, has become disabled. Mr. Bond boss M issued a warning, but Bond is to continue the pursuit, then was relieved of his duties, was also confiscated the license to kill. Sanchez in Panama City, Isthmus has a bank of a nightclub, he was there and a group of drug traffickers from the East to meet a big deal to co-operate. Bent on revenge for the Wright Bond inquired into the news after posing as a speculator who arrived there. Just looking for a chance Bond, Hong Kong agents seized him in a wide, this "escape the spies" taken to a secret location, to the British spy agencies. The secret location was subsequently Sanchez armed men blew up, cleaning up debris, they found a Bond has survived an accident. Bond Sanchez defrauded the trust and taken to an underground drugs factory, a men being recognized Sanchez, the Bond pre-emptive fire to Sanchez. Finally, Bond lit a cigarette lighter with Wright Sanchez clothes soaked in gasoline, burned alive to Sanchez.

The author has written an excellent article. You have made your point and there is not much to argue about. It is like the following universal truth that you can not argue with: No truth is universal, everything has its exception. Thanks for the info http://www.bestpenisproducts.comhttp://www.buypenisproducts.com

The christian louboutin store was designed for the ladies. Since the louboutin heelswas born, the ladies life become colorful.The elegant pattern, the delicate style all mold the ladies perfect leg profile. The christian louboutin evening pumps are the god's masterwork. Who invited the christian louboutin pumps? Seldom people knew, but I think every lady would be grateful for him. Among the countless pumps, the christian louboutin peep toe is the most outstanding ones. Flowers in the spring of 2011 creeping, up from hair to clothes continue to footwear, have had a brilliant up. In such a glamor, spring and summer flowers now here. Romance is a woman's mood, exquisite flowers just right of expression in our gestures, the woman, how can we not love the romantic temperament so that they distributed the flowers do? 2011 flowers bloom will enjoy different poses! The Christian Louboutin 2011 Sandals also can adds the hright of the ladies, it bring surprise to the short lady. Especially the red sole of the louboutin heels, magic and sexy, many ladies are crazy. The red sole, the first feature of the Christian Louboutin heels.