Visage Compiler Preview 1

6 views
Skip to first unread message

Stephen Chin

unread,
Oct 18, 2010, 1:20:51 AM10/18/10
to visag...@googlegroups.com, visage...@googlegroups.com
I finished the implementation of default properties, and have posted a preview release of the compiler to get some feedback:
http://code.google.com/p/visage/downloads/list
Instructions on overlaying this on top of a JavaFX 1.3.1 install are here:
http://code.google.com/p/visage/wiki/InstallingPreviewBuilds

So why do default properties matter?  It makes the trivial case for a lot of objects much simpler, and greatly increases the readability of your Visage code.
For example, the following JavaFX code:
Stage {
  scene: Scene {
    contents: Rectangle {
      width: 100
      height: 100
    }
  }
}

Simplifies to the following in Visage:
Stage {
  Scene {
    Rectangle {
      width: 100
      height: 100
    }
  }
}

Note: The JavaFX libraries lack default property declarations so you would get some friendly compiler errors.  However, if you created some simple subclasses of the built-in classes and override the variables declaring them as "default", then you could do this.

Please give this feature a try and let me know what you think.  Also, if you find any bugs or run into issues, please discuss them on the mailing list or file an issue:
http://code.google.com/p/visage/issues/list

Just in case you are wondering, this particular change is binary compatible with old JavaFX releases, and the generated class files will work on the stock JavaFX 1.3.1 libraries so you are not introducing any dependencies on Visage (yet).  The only source incompatibility will be if you use the keywords "default" or "cascade" in your program, which have been added to the reserved words.

For more details about the exact syntax and semantics of this feature, please see the wiki entry on default properties:
http://code.google.com/p/visage/wiki/DefaultProperties

Cheers,
--
--Steve
blog: http://steveonjava.com/

James Weaver

unread,
Oct 18, 2010, 1:22:39 AM10/18/10
to visag...@googlegroups.com, visage...@googlegroups.com
Nice!  Thanks Stephen,

Jim Weaver

William Antônio Siqueira

unread,
Oct 18, 2010, 4:15:08 AM10/18/10
to visag...@googlegroups.com
That's great! Thank you Stephen, let's test.

Regards,

William Antônio Siqueira
Colaborador JavaFree
Analista Programador ABAP/Java


2010/10/18 James Weaver <james.l...@gmail.com>

James Weaver

unread,
Oct 18, 2010, 11:35:55 AM10/18/10
to visag...@googlegroups.com
Visagers,

Here is a blog post that highlights Visage Compiler Preview #1 and the new logo:

Regards,
Jim Weaver

On Mon, Oct 18, 2010 at 1:20 AM, Stephen Chin <st...@widgetfx.org> wrote:

Hans-Henry Sandbaek

unread,
Oct 18, 2010, 1:56:48 PM10/18/10
to visag...@googlegroups.com
Hello Jim,

seems like there is a minor typo in there - "contents" instead of "content", which you inherated for your blog.  Sorry, I did not recognize this in Steve's earlier email.

I really like this improvement, though.  Easy, but significant impact on readability.

Cheers,
Hans-Henry
 

James Weaver

unread,
Oct 18, 2010, 2:05:50 PM10/18/10
to visag...@googlegroups.com
Thanks Hans-Henry!

Jim Weaver

Robert Casey

unread,
Oct 18, 2010, 6:54:11 PM10/18/10
to visag...@googlegroups.com

This is a great concept to introduce to the language.

-Rob

Josh Marinacci

unread,
Oct 18, 2010, 12:01:00 PM10/18/10
to visage...@googlegroups.com, visag...@googlegroups.com
wow, that's very exciting. How difficult was this to add?

-j
Blasting forth in three part harmony!

Hans-Henry Sandbaek

unread,
Oct 19, 2010, 6:39:09 AM10/19/10
to visag...@googlegroups.com
Hi Steve,

The new default statement triggered some throughts ...

I understand this would not be a high priority issue.  But, because we all want Visage to be superiour, I guess any new and sensible idea is
worth consideration.

I was thinking of the benefits of extending the new default keyword to also be used for object-instantiation.  With the default statement
we could define default-values for properties which are not explicitly provided for instantiation.  This would allow for a certain level of
individual interface-abstraction without the need of sub-classing. And, it could help us to decrease the lines of code, as well as increase
readability.

Classes some times offer a lot of properties, which again require objects with lots of properties and so forth.  Sometimes we end up with
rather verbose statements.  The definition of the Rectangle below is an example of this.  It makes it harder than it has to be to keep the
overview of the source and it triggers a lot of scrolling. 
 
Therefore, maybe we could think of a default-statement like this:
   
    default Text24 = Text { font: Font {size:24 name:name} }

    default RectangleWvlg = Rectangle {    //Rectangle with a vertical linear gradient.
            width:  w
            height: h
            arcWidth: 20 
            arcHeight: 20
            fill: LinearGradient {
                      startX: 0
                      startY: 0
                      endX: 0
                      endY: 1
                      proportional: true
                      stops: [
                            Stop { offset: 0.0 color: stopColor1 },
                            Stop { offset: 1.0 color: stopColor2 },
                      ]
                 }
    } 

    Stage {
       Scene {

          Text24 { "this is my text" },

          RectangleWvlg { x:10 y:10  w:100  h:100  stopColor1:Color.BLUE  stopColor2: Color.GREY },    

          Text24 { "this is another text" name:"Times Roman" },

          RectangleWvlg { x:110 y:10 w:100  h:100  stopColor1:Color.WHITE  stopColor2: Color.GREY }    
       }
    }

Of course, we could achieve basically the same abstraction through sub-classing etc.  But, I think this
concept would be more elegant, and requires less code.  This concept does not need to have any impact on the generated byte-code. 
All use of the defaults could be transformed by the parser, before the code-generation starts.


Cheers,
Hans-Henry
 

JH

unread,
Oct 19, 2010, 6:43:21 PM10/19/10
to Visage Developers
Hi Hans-Henry,

your idea for default values is certainly worth consideration. There
is however a different proposed feature that will achieve your
example: cascading properties. This way you could define 'default' or
cascading properties for all of your Rectangles with a linear
gradient.

We haven't worked out the details yet, but if you're interested, take
a look at the issue on cascading properties: http://code.google.com/p/visage/issues/detail?id=12

Cheers!

--JH

On Oct 19, 12:39 pm, Hans-Henry Sandbaek <hhsandb...@googlemail.com>
wrote:
>   Am 18.10.2010 07:20, schrieb Stephen Chin:
>
>
>
>
>
>
>
>
>
> > I finished the implementation of default properties
> > <http://code.google.com/p/visage/issues/detail?id=6>, and have posted
Reply all
Reply to author
Forward
0 new messages