The Artima Developer Community
Sponsored Link

Visualizing Complexity
A Conversation with James Gosling, Part III
by Bill Venners
November 10, 2003

<<  Page 2 of 3  >>

Advertisement

The Abstract Syntax Tree of Truth

Bill Venners: What kind of things would change if the abstract syntax tree is the truth, not text? Would my source be binary? Wouldn't comments need to become first class parts of the language? Right now, comments are just part of the text and they're thrown away.

James Gosling: Oddly enough, one of the most painful things inside our system right now is dealing with comments. Javadoc comments, which people use in very clearly stylized ways, are basically in the grammar. Because of that, Javadoc comments are completely straightforward to deal with. But general comments that people put in random places are an unbelievable pain.

Bill Venners: Because you don't know what to attach them to?

James Gosling: Yes. We do a pretty good job with comments, but some people do very bizarre things with comments. Currently, we don't even try to guarantee perfect fidelity for arbitrarily bizarre comment usage.

Also, we actually don't represent the programs as binary in their persistent form. We represent them as a Java source file. We actually use the Java source file as the way to represent the parse tree.

Bill Venners: If I also edited the Java source by hand, would it break your tool?

James Gosling: No, you can do arbitrary editing and we figure it out. It became clear that any parse tree representation that we would come up with would be almost certainly slower to parse and take more disk space than Java source code. We can derive almost everything we have as annotations from the source code directly. Certainly all the type information is generated by inferencing in the type system. So that's pretty straightforward. We can discover many other things by doing various kinds of pattern matching. And we have also been attaching attributes to methods.

Bill Venners: How do you add attributes?

James Gosling: We're about to start using the 1.5 metadata specification explicitly as our mechanism for attaching persistent information to source code. The traditional way to do that, used for example by Borland JBuilder, is to put the metadata in comments. Often people use Javadoc comments as the way to store their metadata, and that actually worked remarkably well. But now there's a real metadata facility in 1.5.

Bill Venners: What kinds of metadata would you be adding? If I'm visualizing a class in UML, and I click and drag it to a new position, it seems like the positions would need to be attached to the classes themselves.

James Gosling: Yes. Somebody doing a UML editor could certainly attach metadata about the location of the boxes on the screen. Also, in a UML diagram you often distinguish between the important concepts and the fluffy concepts. If you want to make the diagram small, you leave out the fluffy concepts and just represent the important ones. So you could, for example, certainly have a piece of metadata attached to each field that says whether it's fluffy or important.

<<  Page 2 of 3  >>


Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2014 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us