Programming for kids
Posted on 28 Apr 2009 at 12:02
MySQL fan Ian Wrigley discusses computer programming for children, and goes back in time with linux.
To give you a taste of just how easy things are to create, try downloading Shoes and following along with this basic tutorial. For your first program type the following Shoes code into a text editor. If you don't have a programmer's editor on your machine then just use the faithful old Notepad on Windows, or TextEdit on the Mac (being sure to choose "Make Plain Text" from the Format menu). When you're done, save it as program1.rb.
Shoes.app {
background red..white
@btn = button "Click me...", :margin => 10
@text = para "", :margin => 10
@btn.click {
@text.replace "Hi there! You clicked the button!"
}
}
Once it's saved you can run it by launching Shoes from the Start menu on Windows and selecting your file when you see the file selector box, or else just launch Shoes and choose "Open..." from the File menu on the Mac and select the file. You should see a window appear with a graduated red-to-white background and a button. Click on the button, and the text will appear.
If you've ever done any programming before - or even if you haven't but you have a relatively logical mind - that code should be pretty easy to understand. All I've done is specify that the background should go from red to white and then I've created two graphical elements, a button and a blank textbox, insetting them both by a 10-pixel margin from the edges of the window. When the button element is clicked, the blank textbox is replaced with that "Hi there..." message.
Let's get just a little more complex now. Type the following program into your editor as before:
Shoes.app :width => 300, :height => 500 do
background white
stack :margin_top => 50, :left => 50, :width => 200, :align => 'center' do
para "Simple addition"
@f1 = edit_line(:width => 30)
@t = para "+"
@f2 = edit_line(:width => 30)
@b = button("=")
@res = para ""
end
@b.click do
@res.replace @f1.text.to_i + @f2.text.to_i
end
end
In this program I've created two edit fields and a button, and when the button is clicked the @res paragraph is replaced by the sum of the values you enter in those two text fields. The only tricky thing here is that I needed to turn the text values in those two fields into numbers, and I did this using the standard Ruby method to_i which tries to convert any data type to an integer. (Incidentally, since Ruby supports fractions called Rationals and complex numbers right out of the box, this program can be trivially modified to add those too.)
These aren't particularly exciting applications, but they're just the very tip of what you can use Shoes to program. For example, take a look at the screengrab of a game of Tetris on this page, which was completely programmed in Shoes. Its source code is freely available on the website along with the code for tons of other games and utilities.
If you have a child who's starting to get interested in programming then Shoes might just be the way to get them started off. It isn't perfect of course and there are bound to be frustrations as you learn your way around the different widgets the graphical builder offers, but it's a great little utility, and I really like it despite the incredibly irritating, cutesy feel of the manual. Those who know me well will confirm that for me to accept something that irritating means that the product must be something quite special...
Managing MySQL
Regular readers will know that I'm a huge fan of MySQL. In fact, I have to declare an interest as I'm currently working for Sun/MySQL as a trainer here in the States, teaching courses for database administrators and the like: take that as a disclaimer concerning any positive mentions of the product I make from here on in.
From around the web
Ian Wrigley
Ian Wrigley runs W A Communications, a Los Angeles-based technology consultancy. He's an advocate of open-source technologies, particularly on the server side, and is on the board of directors of the British Academy of Film and Televsion Arts/Los Angeles.
advertisement
- Why virtualisation hasn't slowed the growth of data
- How to make Google AdWords work for your business
- The curse of sloppily written software
- Paying for your crimes with Bitcoin
- Behind the scenes: tech support for Formula 1
- The security risk of fat fingers
- Why Windows Phone 7 isn't quite ready for business
- When will Microsoft stop fiddling with Windows 8?
- Flash down the pan?
- Metro Style apps vs desktop applications
- Chrome's shine getting lost in translation
- BytePac: the cardboard hard disk enclosure
- How tech loosens our grip on reality
- Hokum watch: Safer Internet Day
- Why I'm deleting Adobe from my PC
- Prepare to be patronised: it's Safer Internet Day
- Dear Sony, Samsung and every other tech company in the world: stop trying to be Apple
- Will Apple's Final Cut Pro X update placate the pros?
- Smartr Contacts for iPhone review
- Switching to Office 365's Outlook Web App
- VeriSign slammed for security breach cover-up
- SAP willing to share HANA with Oracle
- Why using a tablet could harm your health
- New RIM boss: no need for drastic change
- RIM founders fall on their swords
- Slow economy helps boost Red Hat revenue by 23%
- Google+ pages get multiple admins
- One in five companies lack card industry compliance
- Oil industry warns hacking attacks could kill
- British workers fear email monitoring
advertisement

