cloud data for TouchDevelop released today
What makes some of the best mobile apps great is the ability to share data, game progress, or to play or work together with your friends or other people at the same time.
Today is a big day for TouchDevelop: We are releasing cloud data, a super easy, integrated way to create apps with distributed program state. All you have to do is mark some of your tables or indices as cloud, and the TouchDevelop runtime system does the rest to upload the data to the cloud, and download it to all relevant clients. The feature is now available in the TouchDevelop Web App on touchdevelop.com and in the TouchDevelop app for Windows Phone 8.
Check out the sample scripts below, or create a new script with the blank cloud app template to get going.
Like TouchDevelop on Facebook to stay up to date.
what is the challenge?
What does it take to create an app that uses data shared between many devices and many people?
Well, you would typically need to subscribe to some cloud service that stores, manages and distributes the data; you need to somehow glue the cloud together with your mobile app, and deal with conflicts in the data; while mobile devices tend to be connected to the internet most of the time, you also have to deal with scenarios where the internet connection is lost, for example when you enter a tunnel or an airplane. You would want your app to keep working, and gracefully resume cloud-connected operations once the internet connection is re-established.
There are many powerful approaches that make all of this possible day. For example, you can create a Windows Azure account to get access to a cloud service, and you can use the Mobile Services package that comes with code templates to use in languages such as C# and JavaScript to glue your mobile app to the cloud. Such an approach might involve writing or adapting code in multiple languages, for example SQL for transactions and queries, JavaScript for business logic that runs on the server, and C# for your Windows Phone client code.
Can it be even simpler?
just tag it as cloud!
With TouchDevelop cloud data, you don’t have to set up your own cloud service, and you don’t have to learn new programming languages. Cloud data is fully integrated as a language feature in TouchDevelop, and there is only a tiny tweak needed to bring cloud data to your program: Go to the definition of one of your tables or indices (in the records section), and change the record kind from “table” to “cloud table”, or from “index” to “cloud index”.
By default, cloud data is shared between all your devices where you have signed in with the same credentials. There are many ways to enable sharing with other people; the easiest is to add the following line of code:
cloud data → switch to session(cloud data → everyone session)
how it works
All cloud data is first of all stored locally on the device where you are working. That's why everything works offline as well. If your device has a working internet connection, data changes you make locally get sent to a TouchDevelop cloud service, and any new changes available in the cloud from other devices are downloaded to your device. As a result, the cloud and any other connected device maintains a full copy of the relevant data. When you connect with a new device, it will automatically download all the data from the cloud.
You can manage your cloud data in the app: go to your user page, tap on private, cloud sessions. You can see and delete your cloud data stored on your device or in the cloud.
We’ll impose limitations on the size of each individual session, and on the combined size of the data stored in all of your cloud session. In future, we are planning to give you an option to export your cloud data to your own Windows Azure account, where no such limitations would apply.
sample scripts
Take a look at the following sample scripts to see cloud data in action.
Sample scripts written by the TouchDevelop team:
- cloud list - a simple list using cloud data
- quick vote - very simple voting app
- cloud paper scissors - real time matchmaking and gameplay of the classic game
- Cloud Square - age old game for keeping kids occupied at restaurants
- Cloud Checkers - thanks to lycan.999 for the initial version!
- instant poll - quickly polling an audience and displaying the responses as a grid of colors
- bird log - Log your bird sightings and share them with other people!
- contest voting - we'll keep this app around even after the voting period will have closed
- guess multi-player demo - demo of Cloud Game Selector library
Useful libraries created by the TouchDevelop team:
- Barrier user round - helps synchronize multiple players in a game with rounds
- Cloud Game Selector - join multi-player games in cloud sessions
Cool scripts written by TouchDevelop users:
the research behind cloud data
We had been planning to add a cloud data feature since the first released version of TouchDevelop. It turned out to be quite a challenge to hide all the complexity of cloud data so that you don’t have to deal with it. One researcher in our group, Sebastian Burckhardt, studied the problem in depth and developed cloud state as we are releasing it today. If you are interested in the theoretical underpinnings, check out the following research papers:
Cloud Types for Eventual Consistency, Eventually Consistent Transactions
If you are attending the SPLASH conference this week in Indianapolis, come to his talk on Wednesday to hear all about it!
documentation
Read more about how to use cloud session in your scripts on the TouchDevelop documentation page.