Skip to content

Michael Latta on Declarative vs. Imperative

March 29, 2007

Micheal Latta has an iteresting post "Declarative vs. Imperative".  In it he compares the approach of Xaml for UI and Ruby for Rails for UI.

In the end, it seems like the thing he enjoys with Ruby is the ability to stay in one language:

You can make [treeviews] you anticipated in the XAML visible, but not create new ones. For that you need imperative code. In WPF this is C#. You need to change to a different language. In Ruby you stay in the same language for all cases, and you can place any of those operations in the system at any time. The program is not cast in stone the minute the class is loaded into the AppDomain as in the CLR. You do not need to use some arcane code generation API to create run-time dynamic logic.

If you spend time working with people on WPF, you’ll often hear the "how can I do this in Xaml" question.  Perhaps it is the draw to one language?

Xaml has shown strength in tooling…we already have many tools (designers and file format converters) for Xaml for UI.  I’m not sure how this compares to imperative approaches.  I understand how it compares to Windows Forms, but not Ruby.  How does programming in teams, using visual designers, etc… affect this picture?

Very interesting…


From → XAML (non-UI)

  1. Marc permalink

    Hmm, you have to swap between HTML and Ruby in RoR, so you can\’t stay entirely in Ruby (well – there are some libraries to assist with that, but realistically you\’ll need to do some plain old HTML).
    This isn\’t that different to XAML over C# but the experiences are clearly more divergent which is probably where complexity for developers becomes a factor.
    I think that this nets to two key things:
    – Programming in dynamic languages is typically quicker and more flexible but requires greater discipline than statically typed languages. An ideal language would by dynamic to code, but \’typed in the end\’ meaning that the compiler could rinse out the \’not-required\’ flexibility to improve performance.
    – Embedded Ruby and HTML is just like coding in \’classic\’ ASP with VBScript (sorta…). I\’ve always thought of ASP and latterly RoR as much more natural ways of web programming even though I\’m aware of the big benefits that ASP.NETs declarative model gives me. Now – what if XAML had been designed like classic ASP with <% %> tags to embed bits of dynamic code? Probably very cool indeed…  XAML is just HTML powered by C#. Like HTML powered by Ruby (or ASP, or PHP). What remains is the use of a static language. So then I\’d really like to use XAML powered by Ruby, or Python.

  2. Jacky permalink

    "Now – what if XAML had been designed like classic ASP with <% %> tags to embed bits of dynamic code?"You can use <x:Code><![CDATA[ …. ]]></x:Code>Not quite as easy to type as <% %> admittedly 🙂

  3. Marc permalink

    Good point, but that doesn\’t allow me to do actual dynamic XAML creation – you know, like:
    <BUTTON x:Name="<%=myVar%>"/>

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: