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?

27 comments:

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

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

    ReplyDelete
  3. 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!

    ReplyDelete
  4. Hey, I feel like I almost understood that! Excellent!

    ReplyDelete
  5. 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 :)

    ReplyDelete
  6. 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.

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

    ReplyDelete
  8. 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

    ReplyDelete
  9. Hi Kevin,
    I like and have in the past used a number of google technologies - including guice 2.0, google collections, closure, and jstemplate.

    However, when going to Google Code page and "browsing", none of these show up AFAIK.

    Why is that? Are they not being actively promoted? Is there some backdoor to be able to see "all" of google code technologies even if they're not listed explicitly there?

    I mean google's stuff is typically far more mature than many other open source things, so I'd like to get more of them!

    thanks,

    stephen b

    ReplyDelete
  10. Anonymous12:47 AM

    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.


    We look forward to this wonderful movie please oh.........link: Dell Latitude D600 battery|dell d830 ac adapter|dell d610 ac adapter|pa3468u 1aca ac adapter|dell latitude d520 ac adapter|5150 ac adapter|d400 ac adapter|d600 ac adapter|nadp 90kb|zd8000 battery|c1295 battery|pa3399u-1brs|pa3400u 1brs|HP 365485-001 Keyboard|HP/Compaq Laptop keyboard|Compaq M2000 Keyboard|HP Pavilion zv5000 Keyboard|HP Pavilion NX9100 Keyboard .........

    ReplyDelete
  11. Anonymous1:07 AM

    Latest film "Nightmare on Elm Street" Plot
    "The new Nightmare on Elm Street" played by the screenwriter Wesley Stricker, will follow the original director Wes Craven's

    Queen's routine, to stimulate a bloody killer scenes big screen again. According to reports, film the story will be a

    nightmare killer Freddy is how to burn the first incarnation of devils as the main history.

    We look forward to this wonderful movie please right..............................................
    New Nightmare on Elm Street "will be April 30, 2010 capture of the North American cinemas.

    ReplyDelete
  12. Other ways to unlock trapped cash thomas sabo is in the form of selling thomas sabo shop silverware, silver flatware, sterling silver thomas sabo jewellery and scrap silver. Each of these thomas sabo schmuck will fetch different values depending on charm club thomas sabo the product and purity factors. sabo charm club With the current economic condition, selling thomas sabo 2010 precious metals, either pure or scrap, has gained thomas sabo sales a lot of importance since it thomas sabo reduziert has great intrinsic value attached to it and selling the scrap is one of the smartest ways of making money.

    ReplyDelete
  13. For almost everybody, the solution will be no. You will find practically nothing incorrect using the hardware -- it is the limitations of the computer software and crucially the price that kill it. This is not your father's laptop computer -- you can't put in courses on it. No IM customer, no Spotify, no Photoshop, no Steam, no substitute browser. You've to undertake all the things by way of internet sites, Apple macbook a1181 Battery
    Apple macbook A1185 Battery
    Apple A1175 Battery MacBook
    Apple A1189 Battery MacBook
    Apple MA561 Battery
    Apple MacBook MA566 Battery
    HP Pavilion dv3t-2000 Battery
    HP G70 Laptop Battery
    Compaq Presario CQ32 Battery
    HP Presario CQ42 Battery
    HP Presario CQ62 Battery
    HP Presario CQ72 Battery
    432974-001 Battery
    HP Mini 110-3000 Battery
    HP Compaq 8510w Battery
    HP Compaq 8710w Battery
    HP Compaq 6720s Battery
    HP Compaq 6730S Battery
    HP Compaq 6735s Battery
    hp pavilion dv7 battery
    hp pavilion dv4 battery
    hp mini 110 batteryinternet apps and Google's online solutions. For nearly all the things other than actively playing again shots and films from the USB adhere, you want an internet link.

    ReplyDelete
  14. Anonymous4:46 AM



    Hey, Wow all the posts are very informative for the people who visit this site. Good work! We also have a Website. Please feel free to visit our site. Thank you for sharing.Well written article Thank You Sharing with Us pmp training Chennai | pmp training centers in Chenai | pmp training institutes in Chennai | pmp training and certification in Chennai | pmp training in velachery

    ReplyDelete
  15. Outstanding blog thanks for sharing such wonderful blog with us ,after long time came across such knowlegeble blog. keep sharing such informative blog with us. machine learning training in chennai
    machine learning projects in chennai
    machine learning tution in chennai
    artificial intelligence and machine learning course in chennai

    ReplyDelete
  16. great post .. thankx keep posting. you always motivate us..



    https://latestwhatsappstatus.com/love-quotes-status/

    ReplyDelete
  17. WOW!!! This is the most wonderful thing i have ever experience and i need to share this great testimony.



    https://techcrb.com/top-10-free-cricket-games-for-computers-2020/

    ReplyDelete
  18. great java tips At SynergisticIT we offer the best best java bootcamp

    ReplyDelete