Tag Archives: project siena

Figuring out Project Siena: a Windows 8 app to build Windows 8 apps

A couple of weeks back I took a look at Project Siena, a preview of a new tool for building Windows 8 apps. Project Siena features a simplified user interface builder, an Excel-like expression language, and data-bound controls. It generates Windows 8 JavaScript apps. Project Siena is itself a Windows Store app, and runs fine on Windows RT (the ARM version). I have been using it successfully on Surface 2, on which it runs sweetly.

When I first looked at Project Siena I tried to build the same first app that I have used for numerous simple tests of development tools over the years: a to-do list. I was impressed by how easy it was to create the user interface, but unable to work out the code to complete it. Unless I missed it, the key information is not included in any of the initial documentation. I found this disappointing, since it has been easy to work out the code in every other programming environment I have tried.

I gradually worked it out. Here is the app:

image

The idea is that you have a listbox, an input box, and two buttons. One button takes the contents of the input box and adds it to the list. The other button removes the selected item in the list. All the functionality you need for a to-do list (actually a simple memo control would do, but that would be a bit too simple).

In Siena, data is stored in Collection objects, and you can bind a listbox to a collection. By default, a new listbox is bound to an object called ListboxSample, but you cannot use it for this; if you try, you get a squiggly line error with the message that ListboxSample is not a collection.

image

Instead, you have to create your own collection object. In Siena, you declare a variable by using it and its type is inferred. Enter this for the OnSelect property of the Add button:

Collect(mycollection,{Value: InputText1!Text})

This is the code that took me so long to work out. The Collect function adds an item to a collection. If the collection does not already exist, it creates it. The first argument to Collect is a collection object, and the second, an item. What is an item? In effect, a record or row in a table. The syntax for an item in Siena is:

{Fieldname1: fieldvalue1,Fieldname2: fieldvalue2,…}

where the dots represent additional fields as required. Therefore, the code I entered for the Add button creates or appends an item with a single field, called Value, to a collection called mycollection.

Now you can select the listbox and tap Data and then Items. The collection called mycollection magically appears for selection. Select it. In the case of multi-field collections, you can also choose which field appears in the list. Only one field it seems; yes, Siena needs a grid control.

Then you can run the app, tap Add, and see the content of the input box added to the list.

The Remove button is easy:

Remove(mycollection, Listbox1!Selected)

However, our app has a flaw. The data does not persist. Next time you run the app, the list will be empty. This is easy to fix too. Go back to the OnSelect property of the Add button. Type a semicolon after the existing line of code, and then:

SaveData(mycollection,"mycollection")

This saves the collection to isolated storage on your PC. Alternatively, you could call a web service and save to the cloud, but I am not sure of the code for that yet.

Next, we have to load the data when the app starts. You can use the OnVisible property of the screen for this. Type:

Clear(mycollection);Collect(mycollection,LoadData("mycollection"))

Note that since Collect appends to the collection, we have to clear it first, to avoid duplicate items.

Now the app is complete.

What do I think of Siena after doing this? It certainly has its frustrations, but I like it. I do think that the designers have gone too far in pretending that code is unimportant; it is silly that you have to type into a single line editor. It would also have saved me time if Microsoft had provided a syntax guide and programming guide, rather than concentrating on how to show pretty pictures.

Who is going to use Siena, if anyone? That is the harder question.

Microsoft Project Siena: another go at the spirit of Visual Basic

Remember Visual Basic? By which I mean, not the current language that is a case-insensitive alternative to C# that does much the same thing, but the original rapid app development tool that democratised Windows development back in 1991. At the time, Windows development was a sought-after skill but rather difficult. VB meant anyone could create an application; pros could build excellent ones, amateurs something ugly and unmaintainable, but nevertheless something that worked. The transition to .NET brought many benefits, but also more complexity. The latest evolution of the Windows client, the Windows Runtime, is also challenging to get right (I am currently writing a simple C# game on the platform).

Microsoft has been looking for a new “VB” for years. 2007: Popfly (now abandoned). 2011: Lightswitch. Now we have Project Siena.

image

Siena is an app for building apps. An app is a Siena document with a .siena extension. Here is what Microsoft’s Bryan Group says:

Microsoft Project Siena (code name) is the beta release of a new technology for business experts, business analysts, consultants, and other app imagineers. Now, without any programming, you can create powerful apps for the device-first and cloud-connected world, with the potential to transform today’s business processes.

Building Siena apps is as easy as editing a document. Place some visuals on a canvas. Hook them up to your data. Customize how your app looks and works. Then, if you need special logic and intelligence, write Excel-like expressions. You can use your app immediately, or share it with colleagues or the world.

This sounds great to me. I installed it and set about building an app. I decided to create the same app I have used to try out dozens of programming tools over the years: a to-do list with the ability to add and remove tasks

image

Building the user interface went OK, but how do I add and remove items from the list? I have got as far as figuring out that I need to type the right magic into the OnSelect property of a button:

image

I will let you know when I have worked out what to do next. I will observe that the environment is geared towards data binding, rather than directly updating the user interface, and remote data, such as binding to tables in Azure Mobile Services, a REST API, an RSS feed or a SharePoint list. However you can also bind to an Excel spreadsheet for local data.

Unfortunately there is no “Run” button. You can preview your Siena app by pressing F5 or tapping the Run button in the top app bar.

To deploy your Siena app, you hit Publish:

image 

This creates a package of files, including InstallApp.exe. Siena generates HTML and JavaScript so you can learn a lot about the environment by poking around in the generated files.

image

Run InstallApp.exe and the app installs into your local PC. Mine runs fine, it just does not work yet.

Siena, as is usual for this type of release, suffers from lack of documentation. There is a function reference and a few sketchy help topics. There are also some sample apps. Here is what the Personnel Manager has in the OnSelect of its Add button; perhaps this is a clue:

UpdateIf(Assoc,ID = ThisItem!ID,{AssignedTo:SelectedDepartment, Time:Now()}); RemoveIf(SelectedAssociates, ID = ThisItem!ID)

While it is great to have a genuinely easy visual interface builder, the development features of Visual Studio are greatly missed; the code editor as far as I can tell is limited to a single line in a text input field, though you do get a squiggly underline if you do it wrong, and a bit of code completion.

How is the average “business expert, business analyst, consultant, and other app imagineer” going to get on with Project Siena? That is the question; and in the current preview I’d guess they will be flummoxed and go straight back to Excel or Access, though I would love to be proved wrong.

It looks like a lot of work has gone into this though, and no doubt better documentation and enhanced features are on the way.