|
|
Dynamic Runtime Type-Object-Class Inference
written by Peter William Lount version 1, 20050914 In furtherance to Exploring Type Safety in Smalltalk".
"we have type information that was not explicit in the source code - we have information that we don't have about the "dynamically typed program"
- Isaac Gouy Not the case! Yes, we have information that wasn't present explicitly in the dynamic program's source code. However we can retrieve and we do have within our grasp the runtime "type" information of running dyamic programs. No doubt about it. Run time type inference is a technique that has long been applied to dynamic programs to recover the type information while the program is running. It was experimented with at Xerox Parc. It is known that Dynamic Type Inference "recovers" type information - well recovers is not really the most accurate term, maybe "discovers" is better - and that the information may have additional uses. For example, the Self system uses this runtime "type/class" information of the prototypical objects to customize and recompile methods under the covers and on the fly which enables some performance optimizations. Other uses are certainly possible such as using the information for Refactoring. What's nice about the way that the Self system uses the information is that it's out of the view of the application programmer so that they don't need to concern themselves with the low level details. Of course systems programmers, such as the programmers of Self, must be aware of these details but then the bulk of programmers work on applications not low level systems deails. This is done for business reasons of efficiency of getting work done on time on budget. By some measures high level languages are only as valuable as the results produced with them. With programmers of typed systems being concerned with low level details of bytes, pointers and types of variables the programmers spend less time being concerned with what the business needs to get done. Hiding these details is crucial towards growing the future value of software systems to businesses. Dynamic runtime type inference (maybe runtime class inference or runtime object class-type inference is a better name) is but one tool in providing access to programs. There are others such as trace analysis and interactive debuggers that enable rewind and playback. Potent concepts. I think that type inference in dynamic systems is much more powerful than simple "compile time" type inference in that it provides additional meta data to a running program while it's actually running! This form of live reflection is very powerful and enables a class of applications that static and typed languages and systems simply can't deliver. Why? A static program is just that, static and frozen in time. Sure you can perform certain analysis upon it at compile time however that's only a frozen snapshot of the program and before it ran one line of code at that! With a fully dynamic program it is possible to build an application that is being altered by the users in real time so that essentially the program is being modified while it's running - and that's definitely not a static program at that point! To illustrate, the "valid set of" classes (types) that are running through particular instance variables, parameters and return values could be designed to dramatically change as such a program is running! This can't be done in any current static or typed language, it's simply not what they are designed for. Dynamic type inference is a useful adjunct for dynamic systems as a form of meta data that can assist a certain class of dynamic applications, most notably the Integrated Development Environment. Let's embrace this adjunct meta data as appropriate. Let's also end the nonsense from those that support typed systems that they are the sole owners of the notions of type inference. That's just silly. Self proves beyond any doubt that dynamic systems have used types for a long time. Often these typed promoters think that type inference is only valid in the pervue of funcational programs. Haskell's style of type inference, for example, is a compile time analysis tool used in its "functional programming" system, and is therefor a different beastie. As we all know functional programming is a completly different paradigm from imperative object oriented programming (such as implemented by Smalltalk). As such while it might be instructive to compare technologies it's not always very pragmaticly useful due to the "paradigm mismatch" problem. I often wonder if those that espouse that the functional paradigm type arguments be applied to the imperative paradigm don't take the large paradigm delta into account. Let's clarify that that's their limitation in thinking not ours. Dynamic systems rock and we should use any technology that makes them better without losing their most essential aspects that enable pure dynamic capabilities. Otherwise, we might just as well bow down and jump back in to the stone age and use C, Java, C++, C#, and ... . The future is dynamic. Let's make it happen. Copyright 1 9 9 9 - 2 0 1 0 b y S m a l l t a l k . o r g "! , A l l R i g h t s R e s e r v e d . |
|