Blog Stats
  • Posts - 62
  • Articles - 11
  • Comments - 8
  • Trackbacks - 99

 

Hello World in XEN (my wish)

I will never understand the mind of a language designer.

Hello World Longhorn sample stolen from CodeProject:

// This is Avalon in Longhorn:
private void CreateWindow()
{
    //create main window
    MSAvalon.Windows.Window myWindow = new MSAvalon.Windows.Window();
    myWindow.Width = new Length(300);
    myWindow.Height = new Length(170);

    //Add a canvas to the window
    myCanvas = new MSAvalon.Windows.Controls.Canvas();

    myCanvas.Background =  MSAvalon.Windows.Media.Brushes.LightSteelBlue;
    myCanvas.Width = new Length(100,UnitType.Percent);
    myCanvas.Height = new Length(100,UnitType.Percent);
    myWindow.Children.Add(myCanvas);

    //Add a Text Box to the canvas
    myTextBox = new MSAvalon.Windows.Controls.TextBox();
    myTextBox.Width = new Length(200);
    myTextBox.Height = new Length(40);
    MSAvalon.Windows.Controls.Canvas.SetTop(myTextBox, new Length(30));
    MSAvalon.Windows.Controls.Canvas.SetLeft(myTextBox, new Length(50));

    myCanvas.Children.Add(myTextBox);

    //Add a button to the canvas
    myButton = new MSAvalon.Windows.Controls.Button();
    MSAvalon.Windows.Controls.Canvas.SetTop(myButton, new Length(100));
    MSAvalon.Windows.Controls.Canvas.SetLeft(myButton, new Length(110));
    myButton.Content = "Click Me";
    myCanvas.Children.Add(myButton);

    //Add a event handler for Click Event
    myButton.Click += new ClickEventHandler(OnClick);

    //show the window
    myWindow.Show();
}

Nice huh?

- - - - - - - - - - - - - - - - - - - - -

Now, look at this:

// This is XEN on steroids (well, my wish)
private UI myWindow : window
{
    //create main window
    Width = 300;
    Height = 170;

    //Add a canvas to the window
    myCanvas = Canvas
    {
        Background = LightSteelBlue;
        Width  = 100%;
        Height = 100%;

        //Add a Text Box to the canvas
        myTextBox = TextBox
        {
            Width  = 200;
            Height =  40;
            Top    =  30;
            Left   =  50;
        }

        //Add a button to the canvas
        myButton = Button
        {
            Top  = 100;
            Left = 110;
            Content = "Click Me";

            //Add a event handler for Click Event
            Click = OnClick;
        }
    }
}

And the winner is...

Remember guys, bring SQL and XML to the language, but don't forget about UI!


Feedback

# re: Hello World in XEN (my wish)

Gravatar Dude, looks like you just re-invented XAML and replaced the XML with curly braces.

My problems with the example code include:
- The need to instantiate Length objects: an overloaded function should instead take an Integer parameter.
- Constructors should take any set of public properties as optional parameters.
- C# is the wrong language for this anyway. A hierarchal property grid (with Excel-like navigation) is a more appropriate IDE design (C# or XAML should be under the covers). 3/8/2004 9:17 AM | Richard Tallent

# re: Hello World in XEN (my wish)

Gravatar Wait til you see the VB version of it.
Well, just remove all curlies and semi-colons and there you go. VBers would feel like in heaven.

But again, I don't know what's in the mind of a language designer.

;-) 3/8/2004 8:34 PM | RebelGeekz

# re: Hello World in XEN (my wish)

Gravatar check more info at http://www.dotnetspider.com 2/16/2005 4:11 AM | spam filter

Post a comment





 

Please add 5 and 7 and type the answer here:

 

 

Copyright © RebelGeekz