📜 ⬆️ ⬇️

TouchDevelop - creating applications on touch devices directly from the browser

Microsoft Research has launched a web version of TouchDevelop - a shell for creating applications for Windows 8 and Windows Phone, sharpened by a touch-device. The environment allows you to create applications very quickly, and works on iPad, iPhone, Android, PC, Mac, and Windows Phone. Directly from the browser!



Programming on touch devices disrupts familiar notions: in just a couple of dozen screen touches, you can create a full-fledged application. To get acquainted with this IDE, let's create together with the iPad a simple spell checker.
')
To check the spelling, we use the Yandex.Speler API. An application should read input, send a request to the API via HTTP, parse the result, and display words written with errors. Create a new script. This is what Hello, Habr looks like!

We can add an expression before or after the selected block. Under the code is a list of actions sorted by importance. Depending on where the cursor is, there will be different logic in this list. Now the cursor is on a line: we can edit it, concatenate it with another string, or call it on one of the string methods. Let's say hello to Habr and look for an input request in the console methods. The system prompts if the expression in the current form does not make sense and offers solutions:



Click "ask string", set the query text, click the magic "store in var". Creating a request is no more difficult: touching “web”, then “create request”, enter the address of the spelcheker's API, and the request parameter text = is concatenated with the received string s. Sending request.



On a new line, the editor suggests using the newly created variable, or inserting an if, foreach, while, etc. block. So do. Touching the response variable, touch on “content as json”, then on “store in var” - a new line is ready. Click "foreach" to process the resulting array of errors that we have already parsed from json. We go through the array - the system prompts that “e” is a JSON Object, and something must be done with it (for example, output).



Extract the json field of the object, form lines for output. If you touch the parent block, it is highlighted entirely, and you can insert an expression before or after it.



The script is ready. It can be run directly from here, on top of the button run. Boom, mistake. "Show stack trace" throws immediately to the line where the exception has flown. One of the significant drawbacks of TouchDevelop is that I did not find a way to debug via breakpoints. This is a concept editor, but not yet a full IDE.



But some simple smart chips are still in stock. For example, you can wrap a dedicated block in an if, or put it into a separate function. The application lacked http: // in the address of the API and the index of the correction option (the field at (0) method), since "S" turned out to be an array. The script works:



Calculate the minimum number of touches of the screen, which is required to create a script. Let's throw out the intermediate variable errors, let's not consider Habr's greeting and text input:

wall -> ask string -> text input -> store in var -> new line -> web -> create request -> input api -> concatenation -> s -> send -> store in var -> new line -> foreach -> response -> content as json -> focus in the block do -> e -> field -> name -> concatenation -> 123 -> string -> input of the string "->" -> concatenation -> e -> field - > name -> at -> store in var -> new line -> variable -> post to wall

Less than 30 screen touches (plus text input) were required to create a program. This is not yet a tool for daily use, but the future is near. Very soon, programming on a tablet will be as easy as on ordinary computers. We will follow the development of the project.
image

Source: https://habr.com/ru/post/161083/


All Articles