The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Latent Types

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
Latent Types Posted: Mar 13, 2004 6:18 PM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: Latent Types
Feed Title: Avi Bryant
Feed URL: http://smallthought.com/avi/?feed=rss2
Feed Description: HREF Considered Harmful
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Avi Bryant

Advertisement
There's been some interesting discussion in the Ruby community about "lazy" or "latent" typing - the key idea being that rather than putting type annotations for variables into the code, you extract the information from a running program. You can then use this information for web service introspection, or autocompletion in an IDE, etc. I think this is an excellent answer to statements I commonly hear like "dynamic language environments can never have real Intellisense" - just cause the type information isn't written into the source code doesn't mean it's not accessible. And it's a lot easier to implement for us simple object folk than ML or Haskell style Hindley-Milner type inference.

This approach seems a natural fit for Smalltalk, because image-based development means you've always got running code and live instances easily available for inspection by the IDE. Unlike the Ruby solutions that require doing a special run of your program to collect the information, a Smalltalk environment could just incrementally collect type information in the background as you run test cases and so on (JITted VMs already do this, in fact, but for optimization purposes). Then, say, when you hover your mouse over a variable name, it can pop up a tooltip with its best guess as to type, if it has one (the one time it definitely wouldn't know anything yet is when you're writing a new method, but that's also when you least need the information).

The only thing like this I know about for Squeak is the very cool Instance based Class Diagram tool. This will automatically build a UML-like diagram of the relationships between a set of classes based on examining any instances it can find. But instance variable types aren't enough - to really convince a manifest typing nut, we'd want parameter types and temporary variable types too. There are a couple of ways I would approach this. The first would be to have a background process that worked much like the statistical profiler that comes with Squeak: every once in a while it would wake up and scan the stack of the active process. Instead of recording the call graph, however, it would record type information. The problem with this is that it would miss short or infrequently called methods. So I'd also want to do something like wrapping a method whenever it's compiled, recording type info the first time (or first N times) the method is invoked, and then unwrapping it so it runs at full speed thereafter.

So I'm curious to hear from those in the OO manifest typing camp that are scared about the readability of dynamic languages - would this address your concerns at all? Or do you only feel secure when a human programmer has specified each and every type in the system by hand? (I know the functional language people won't like it, but that's a whole different standard of type safety).

Read: Latent Types

Topic: Spreading the meme Previous Topic   Next Topic Topic: PR in the blogosphere

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use