TouchDevelop is used to develop application programs for mobile devices, including smartphones and tablet computers. It can also be used on any computer which has a suitable web browser. In addition to its use as a tool for creating application programs, TouchDevelop has been used to teach programming and mobile device technology at schools, colleges and universities.
After being installed on a computer or a mobile device, TouchDevelop provides an interactive environment for developing, testing and running programs. The programs are coded in the TouchDevelop scripting language which is described below. A new program is entered onto the device via a syntax-directed editor which has been designed for use with the small touch-sensitive screen that is normally found on a smartphone. A user can also choose to download existing scripts, published on the TouchDevelop website by other users, and edit these scripts. The editor displays choices of actions (such as language elements to insert or code refactoring changes) which change according to context. A single tap, or mouse click, on a dynamically labeled key performs the action.
The development environment includes a facility for testing and debugging the program's user interface which avoids the need to restart the program from the beginning after each change. There is a debugger for analyzing and tracing program execution, as well as separate facility for running unit tests on components of the program.
The scripting language is designed to be terse in style, since code may need to be viewed on small screens. Symbols are used instead of keywords in many places to achieve that brevity. The language is imperative in nature, although some of the language syntax is similar to that used in object-oriented languages. The basic datatypes are numbers, strings and booleans. Compound datatypes include lists, arrays and other datatypes supported by the API library. The control flow constructs include if-then-else statements, for loops, while loops and function calls. (In TouchDevelop, a function is called an action.)
The language is both strongly typed and statically typed. Local variables are not explicitly declared, their types are instead inferred from their first use which must be an assignment statement that initializes the variable. The type system has value types where storage is allocated on the stack, and reference types where storage is allocated on the heap. The heap is garbage collected.
Scripts have a single thread of execution. Events, such as shaking the device or tapping the screen, can be associated with events in the script (provided that the device has the appropriate capabilities). An event will interrupt a running script to execute an associated action. However, an event action cannot interrupt another event but will be held until the action for that event has completed execution.
The TouchDevelop scripting language introduces a feature called "cloud types". A global variable with a cloud type has, or will have, its value synchronized with storage provided in the cloud. This feature enables scripts to interact safely and reliably with scripts running simultaneously on other devices.
The TouchDevelop API is a library which provides resources and extra datatypes, each with an appropriate set of associated actions. A partial list of the capabilities provided by the API is as follows.
- Graphics and screen drawing functions
- Touch input
- A physics engine (which is especially useful when programming interactive graphical games)
- User interface layout and controls
- Access to sensors provided by the device (such as accelerometer, GPS location, and compass)
- Read access to data stored on the device (such as music, photographs, and contact information)
- Cloud storage
- Sending messages via Short Message Service or an instant messaging service
- Interaction with social media such as Facebook
- "TouchDevelop". TouchDevelop. Retrieved 1 September 2013.
- Burckhardt, Sebastian; Fahndrich, Manuel; De Halleux, Peli; Kato, Jun; McDirmid, Sean; Moskal, Michal; Tillmann, Nikolai (June 2013). "It's Alive! Continuous Feedback in UI Programming". In PLDI. Microsoft Research. ACM SIGPLAN. Retrieved 24 June 2014.
- Nguyen, Tuan; Csallner, Christoph; Tillmann, Nikolai (May 2013). "GROPG: A graphical on-phone debugger". In Proc. 35th ACM/IEEE International Conference on Software Engineering (ICSE), New Ideas and Emerging Results (NIER) track. TouchDevelop. Retrieved 24 January 2014.
- Burckhardt, Sebastian; Fahndrich, Manuel; Leijen, Daan; Wood, Benjamin (15 June 2012). "Cloud Types for Eventual Consistency, in Proceedings of the 26th European Conference on Object-Oriented Programming (ECOOP)". In Proceedings of the 26th European Conference on Object-Oriented Programming (ECOOP). TouchDevelop. Springer. Retrieved 24 January 2014.
- Horspool, R. Nigel; Tillmann et, Nikolai (1 June 2013). TouchDevelop: Programming on the Go (3rd ed.). Apress Media LLC. ISBN 978-1-4302-6136-0.