30 July 2014
The team behind the Scratch programming language has released ScratchJr for the iPad, following a successful Kickstarter campaign which I was pleased to support with a small donation. ScratchJr is aimed at younger children, aged 5 to 7 years old, and has a simplified interface and set of blocks for making scripts. It has some great looking graphics, and the blocks can be used to create some surprisingly sophisticated effects. The app can be used to make stories with different scenes (a new feature in ScratchJr), and simple games too.
Our nieces and nephews are already experienced iPad users, so I'm confident that the interface will present no challenge at all to young children. They quickly learn what the icons mean and happily explore what they do.
Here are three scripts you can use to make an arcade game in ScratchJr:
The Alien Shooter game
To understand how that program works, and get an overview of the new app, see my review of ScratchJr on the iPad, including how to make an arcade game. If you're a fan of ScratchJr's older cousin Scratch, check out the bonus resources from my book Scratch Programming in Easy Steps.
Permanent link for this post | Blog Home | Website Home
28 July 2014
At this month's Londroid Meetup at Skills Matter, there was a chance for developers to learn more about how to create successful apps for Google Glass. It presented an opportunity to see the devices, but most importantly, a chance to hear from Google representatives about what Google has learned about making Glass apps through trial and error. Senior developer advocates Hoi Lam and Timothy Jordan gave talks, sharing their favourite apps and best practice using Google Glass.
(You can read my article about the UK launch of Google Glass in London, including a review of how it works, here).
A Google Glass device in use. More photos here.
Here are the key takeaways I noted:
- Know your techs. There are three ways you can develop Glass apps. You will be able to use the upcoming Android Wear notifications, which will push notifications from your Android phone to your Google Glass. You can use the Google Mirror API if you have a web service to deliver that into Google Glass with minimal changes. Or you can use the Google GDK (Glass Development Kit), which adds some Glass-specific features to Android, including voice triggers and gestures. The Mirror API can enable you to implement your app more quickly, but it means output is pulled from the cloud. It's best used when it will feel intuitive to the user if there is a delay in getting information, such as in a searching application. The GDK is suitable when you need an app to work offline, need a real-time response, or need deeper hardware integration.
- Design around user intent. Although I'm talking about applications here, Glassware, as they call it, isn't like a phone or a tablet app. Users won't expect to open an app and then do something. Instead, you should design around their intent and cut the time from their expression of that to you delivering a result. For example, a tablet user might open a mapping app and then search for directions. A Google Glass user would just ask for directions.
- Design for Glass. App developers are experienced at porting from "one rectangle to another", but Google Glass isn't just a smaller rectangle. It's so different to existing mobile platforms, that you need to rethink the experience you provide. Jordan suggested thinking about what it is you always wanted to do with your services that you can now do with Google Glass, and then focus on that one feature. Wordlens, for example, provides hands-free translation of signs using the camera, leaving your hands free for maps and baggage. Augmedix enables doctors to look up medical information without turning away from the patient, and enables them to build stronger rapport and better study the patient's condition.
- Don't get in the way. Google's vision for Glass is that it should not interrupt the user and take them out of the moment. Lam had a great example of how he's been using Google Glass to photograph his daughter while playing with her. He can look at her all the time and use both hands to guide her on the climbing frame, but can capture that moment using Google Glass. Google's aim is that the device should enhance living in the moment, rather than pulling people out of it. As a result, users should be able to ignore your Glassware without any penalty, and it shouldn't require them to take action.
- Be relevant. Google Glass isn't designed to provide all the information, all the time, just what's most relevant now. Think about how you can use contexts like the time of day and the location to provide relevant information to the user when they need it. For example, it would be great if a shopping list app presented a reminder just as you're passing the shop, Jordan suggested. Because of the need to focus on what's relevant now, you can't just port your mobile apps across and expect to end up with something usable.
- Avoid the unexpected. One of Google's guidelines is that you shouldn't surprise the user in a way they don't want. This probably applies to every platform, but it's especially important for Glass, because the nature of the device means that unpleasant surprises would feel particularly intrusive. Nobody wants to see cabbage adverts in their glasses at 3.30am. Jordan presented CNN as a good example of managing expectations. When the software is configured, it makes it clear to the user how many alerts they will see and when they're likely to see them.
- Build for users. Jordan said that Google had tried building some applications that didn't work, and advised against building something just because it seems cool and takes advantage of the technology. Instead, you should focus on a problem that people have and help them to solve it. Again, this might seem like something that applies to every platform, but it's still a good filter to put your idea through before developing it. The idea of a facial recognition app came up that would tell you who somebody was when you met them again, having forgotten their name from your previous encounter. That seems like a cool idea, but it would get in the way of the real social interaction. In practice, I think it would be pretty hard to use without somebody knowing it was being used on them, which would be a particularly graceless way to socialise. (Facial recognition apps are currently not allowed on Google Glass in any case).
- Be wary of head gestures. They can be a cool way to control Google Glass, but people lack fine motor movements, so they're not good where precision is required, including in scrolling.
- Make it glanceable. Jordan presented two different designs of a running app, both of which showed the steps taken and the percentage of the run completed. One of the pics had a photographic backdrop showing some running shoes. When the room was polled on which design they preferred, it was evenly split. The screen with the shoes in, though, took longer to glance at, eye-tracking studies had shown. The eye is distracted by irrelevant information and graphics, and when you're running, you can't take in information as quickly. Keep the design simple, and think about what the user really needs. During the run, they need coaching support, not a complete data set.
- Expect design delay. Plan to spend time iterating on the user experience. Until you've tried it, you won't know what works effectively, so allocate plenty of time to experiment with this new interface.
It's early days for Google Glass, and there was a lot of excitement in the room just seeing the devices and trying them out. There's clearly a lot of potential for innovative new applications, particularly for platform-based services, which will be better able to build a business model on a device that is not conducive to advertising, and that does not yet support monetisation. What are your thoughts on Google Glass?
Permanent link for this post | Blog Home | Website Home
03 July 2014
When I discovered Scratch, I was fascinated to see that the language enables you to put scripts on different sprites, or multiple scripts on the same sprite, that appear to execute at the same time. This is a bit like threading, an advanced programming technique that enables you (in very basic terms) to have different bits of a program executing in parallel (at the same time).
There is a special class of bug that emerges when you're dealing with parallel code, which is the race condition. This happens when two different bits of the program "race" to do something at the same time, and the programmer doesn't have control over which "wins".
For example, if I put all these scripts on the same sprite, what is the final value of the score variable?
It doesn't matter what your guess is, because there's no sure way of knowing how it will behave next time. It might change depending on what else is going on in the program, or a minor update to Scratch might change the synchronisation too. Logically, it's not something you can control. If you ask the program to do four things at the same time that don't make sense together, you risk getting unexpected results.
From my own quick and dirty experiments, it looks like the one that runs last (and ultimately sets the score) is the one you edit or move last. So if you, in the editor, drag the set score to 0 block and then click the green flag, the final value of score is 0. To get the value 8, drag the blocks in this order: set score to 0, set score to 5, change score by 2, change score by 1, and then click the green flag. I put all these scripts on the same sprite. When you have more than one sprite with conflicting scripts on it like this, sprites that were added to the program first have higher priority over the final result. So the cat seems to trump other sprites, for example. I ran my test in Scratch 2.0, but the results are different in Scratch 1.4, and might even be different for you running Scratch 2.0. And they might be different tomorrow for either of us. There's no reason why they have to stay the same.
That's a bit of a diversion because this information isn't really useful to you: for the program to make sense to others (an important part of programming), and to always run reliably (even if someone else moves a script), you need to avoid race conditions like this, not work around them.
It might seem like this is a bit of an artificial example (okay, it is), but similar problems can often occur when lots of scripts start when the green flag is clicked, or the background changes, or when there is a particular broadcast. There have been a couple of times I've experienced problems similar to this, including when writing Hangman for my book Scratch Programming in Easy Steps and the Shaun the Sheep Football game more recently.
There are a few strategies you can use to avoid race conditions:
- Avoid having more 'green flag' or other hat scripts (with rounded tops) than you need. If you can combine them without causing any problems, it's best to do that. That enables you to determine the order the blocks run in.
- If you have a bug that might be caused by a race condition, try adding wait blocks to delay some of your scripts so they execute in an order you can influence. This is a real fudge so I wouldn't recommend it for final programs, but it can be valuable for finding bugs when you're testing your program.
- Use Scratch broadcasts to synchronise between sprites where necessary. For example, you could have a green flag script that sets up your variables and gets everything else ready, and then sends a broadcast to start scripts on other sprites. That avoids a clash where the other sprites might be trying to use variables you haven't set up yet (for example).
- Use the broadcast and wait block where it makes sense. That stops your script steaming ahead before getting the results it needs from other scripts that it's triggering.
Have you experienced bugs like this? How did you overcome them? Let me know in the comments below.
For more on Scratch, take a look at my books Cool Scratch Projects in Easy Steps and Scratch Programming in Easy Steps.
Permanent link for this post | Blog Home | Website Home