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.

"And that's why we say we're 'extraordinarily typesafe'."

Do you buy it?

19 comments:

Hendrik said...

Excellent writing style. Way to go! Hope this wasn't the last post.

Charles said...

awesome. guice+intellij, making java even more type safe.

Dhanji said...

this is a nice post, I was entertained reading it!

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:

class List<CreditCard, Strawberry> { }

and I could put in only credit cards OR strawberries.

still guice is awesome, rock on kevin!

Jemaleddin said...

Hey, I feel like I almost understood that! Excellent!

Kelly said...

Re: dhanji's comment

There's a bit of an effort afoot to erase erasure in JDK 1.7:

http://gafter.blogspot.com/2006/11/reified-generics-for-java.html

https://openjdk.dev.java.net/servlets/ReadMsg?list=compiler-dev&msgNo=265

Also, excellent wife-speak explanation Kevin :)

Dave Smith said...

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.

malcolmsparks said...

Nice post, and congratulations on Guice. Bugs are bad, type-safety means fewer bugs.

Scott said...

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.

Scott

nasha said...

Why was there no follow on bankruptcy then? The bailout of AIG FP went to (wow power leveling) hedge funds that bound credit swaps on Lehman failing or others betting on rating (wow power leveling) declines. AIG has drained over 100 billion from the government. Which had to go to (wow power leveling) those who bet on failures and downgrades. Many of whom (power leveling)were hedge funds. I-banks that had offsetting swaps needed the money from the AIG bailout or they would have been caught. Its an (wow powerleveling) insiders game and it takes just a little bit too much time for most people to think (wow gold) through where the AIG 100 billion bailout money went to, hedge funds and players, many of whom hire from the top ranks of DOJ, Fed, Treasury, etc. ZHANG XIAO CHEN

Affordable Luxurious Wedding Dress Blog said...

cheap wedding gowns,
discount bridal gowns,
China wedding dresses,
discount designer wedding dresses,
China wedding online store,
plus size wedding dresses,
cheap informal wedding dresses,
junior bridesmaid dresses,
cheap bridesmaid dresses,
maternity bridesmaid dresses,
discount flower girl gowns,
cheap prom dresses,
party dresses,
evening dresses,
mother of the bride dresses,
special occasion dresses,
cheap quinceanera dresses,
hot red wedding dresses

srggy said...

new polos men poloswomen polosdiscount polos
summer polospolo shirts whosalepolo fashionembroodered polos
tennis racketsclothing poloclothingedhardyshirt
edhardyclothingsummer ed hardy clothingcheap shirtsed hardy brand
cheap ed hardypolo shirts cheapcheap tennis racketsdiscount tennis rackets
ralphlaurenpoloshirtscheappolospolo fashionpolo logo
polo shirts in voguepolo women clothinged-hardy shirtsed-hardy sunglasses
ed-hardy logopolofashioncheaptennisracquetsed-hardy sunglasses
ed-hardy sunglassesed-hardy clothingdiscount polo shirtswholesale ed hardhy shirts
clothingfashionpolos summertennisrackets discountpolos clothes
wilson k sixedhardyclotheswholesale-polo-shirts

srggy said...

Andy Roddick's signature babolat pure drive, Pure Drive Roddick Babolat wilson k six, features GT Technology combined with head microgel and prince-o3-tour, versatile and accurate cheap tennis racquets with unparalleled performance and incredible feel with less vibrations.

srggy said...

Look !The shirt for men's clothing,ed hardy clothing, The ed hardy clothes on each piece were created ed hardy shirts and is recognized globally for his technical brilliance and mesmerizing imagery.Short sleeves ed hardy mens and ed hardy womens , remember to check out ed hardy t-shirts because they are very popular in demand too!Combination with ed hardy sunglasses,very handsome.

srggy said...

The button to break the conventional design of polo shirts, the depth of clear lines of wholesale polo shirts from the Department of V on the first gives the impression of a unique, tailor-made with dark-green Lacoste polo shirts with the color scheme of Red and the casual cheap lacoste polos, stressed a summer of non-traditional use of color, so that the overall shape ofralph lauren polo shirts is full of flavor. The classic black-and-white cheap ralph lauren polos with matching black-and-white striped discount ralph lauren polos elegant leaves the impression that the import of polo clothing and black shoes brighten even more people.

srggy said...

polo ralph lauren integrates two types of luxury and leisure style, now more and more popular men’s “thin” burberry polos, most designers have sought to perfect the cut with “cutting” a bag of bones of the body ralph lauren polo shirts. It is amazing that a tight lacoste polo shirts with pencil pants, full of retro style with a European aristocratic culture of leisure cheappolos.

j said...

Burberry polo shirt the steady, solid, so many young girls also love it. Speaking of people of a ralph lauren polo, think it a sign of nobility elegant waving in the horse club.spyder jacket in the cold in your winter activities can be easily.columbia jacket it is expensive, but here you do not need to consider the price of it. the north face jacket one of my favorite money, I do not know how many in this world of its fans.
ed hardy clothing
ed hardy clothes
ed hardy shirts
ed hardy t-shirts
ed hardy sunglasses
ed hardy mens
ed hardy womens
Wholesale Handbags
Cheap Handbags

j said...

In preparation for the purchase of a tennis racquetbefore, we must consider your financial ability to bear; On this basis, a further comparison, as far as possible, choose your tennis racket. Now a lot of cheap tennis racquet and more mixed materials, the proportion of mixed-use to control the stiffness of the tennis racquet discount and the shock-absorbing capacity, the more rigid cheap tennis racket, the swing more powerful force; but the relative resilience of the shock-absorbing capacity and discount tennis racket performance of talks on the easier it is for the wrist and elbow injury.
head junior tennis racket
wilson tennis racquet
wilson tennis racket
head tennis racket
babolat tennis racket
Womens Handbags
Cheap Purses
Designer Handbags

j said...

http://2009tennis.blogspot.com/
http://www.free-blog-site.com/tennis
http://o3.indiatimes.com/racquet/
http://cid-8c8a918b06ff68fd.spaces.live.com/?lc=2052
http://2009tennis.cocolog-nifty.com/

http://2009tennis.blog.drecom.jp/
http://2009tennis.blog.shinobi.jp/
http://www.actiblog.com/slary/
http://pshirts.blog126.fc2.com/
http://www.free-blog-site.com/shirts

asdfsadf said...

nike shoes, jordan shoes, nike dunks, nike air force 1, nike shox, nike shoes, nike shox, nike dunks, nike air force 1, nike shox, nike shoes, nike shox oz, nike shox nz, nike shox r3, nike shox r4, nike shox r5, nike shox tl
nike air force 1










nike Air Force 1, nike shoes, Jordan shoes, nike sb dunks, cheap nike Air Force 1, cheap nike shoes, cheap Jordan shoes, cheap nike sb dunks, discount nike Air Force 1, discount nike shoes, discount Jordan shoes, discount nike sb dunks, nike shoes, nike shox, nike dunks, nike air force 1, jordan shoes, nike shoes, nike shox, nike dunks, nike air force 1, jordan shoes












nike shoes, nike shox, jordan shoes, puma shoes, nike dunks, nike air max, nike air force one, timberland boots, ugg boots, nike shoes, nike shox, nike air force 1, nike sb dunks, puma shoes, nike air max, jordan shoes, ugg boot, jordan sneakers, timberland shoes, bape shoes, nike shoes, nike shox, nike dunks, nike air force 1, jordan shoes