Building an 8-bit Computer

A few weeks ago, I came across this article on the BBC news website about a guy called Julian Skidmore who builds primitive computers from everyday electronic components, similar in capability to the home computers of the early 1980s such as the Sinclair ZX81 and the Jupiter Ace.

Julian has designed a simple 8-bit computer called the Fignition, which you can buy as a kit from eBay for £20. Needless to say, I bought one.

It arrived yesterday and I’m assembling it today as a bit of a weekend project. What surprised me most was that the entire set of components fit inside a small jiffy bag and weighed next to nothing.

_DSC0108

Luckily, I already have the tools needed to assemble it – a soldering iron, a multimeter, some fine-nosed pliers and a steady pair of hands. I’ve just inserted all the resistors and am starting the delicate process of soldering them to the board. No mess-ups so far.

I’ll put up another post letting you know how it goes.

Introducing Microsoft Small Basic

For the past few weeks, I’ve been playing with Microsoft Small Basic. Small Basic aims to put the fun back into programming by making it easy for children and adults to learn computer programming.

It is the brainchild of Vijaye Raji, a Microsoft employee. It started off as a research project, but has now been released to the community so that Microsoft can gauge people’s interest in the product and get suggestions/feedback for future versions. The current version is 0.8.

Small Basic is deliberately simple. It comprises three distinct elements:

  • The Language
  • The Environment
  • Libraries

The Language

Small Basic takes its inspiration from early variants of the BASIC programming language, but has been built using Microsoft’s .NET framework. The language consists of just 14 keywords, so it is very easy to learn.

The language has no type system – so text strings and numbers can be assigned to variables and the value will be inferred from the content – so “1” + 2 is perfectly valid and will produce an answer of 3.

There is also no concept of “scope” – all variables are global and are always initialized. So there’s no need to declare a variable before you use it. Similarly, there are no classes or interfaces – all “objects” are static.

Small Basic also contains a very simple event-handling mechanism. You can write a subroutine and assign it to an event – this “wires up” the event to the routine that will handle it.

The Environment

The programming environment is very simple. A program consists of a single text file, and there is no need to declare a “Main” function or other entry point:

image

You can have multiple program files open at once, but there’s no easy way to switch between them, as there’s no “Window” option on the ribbon-style toolbar.

If you write a program that you’re particularly proud of, you can publish it to the Small Basic website and make it available to others. Likewise, you can import programs that have been published by others.

The “Graduate” option will take your Small Basic program and create a Microsoft Visual Basic.Net project from it, but I found this to be a bit unreliable. Offering an “upgrade” path like this though, is commendable.

Libraries

Libraries are groups of related areas of functionality that you can use in your Small Basic programs. Examples of some of the built-in libraries that come with Small Basic are:

  • TextWindow – for simple Console-style applications
  • Turtle – just like the old LOGO turtle from school days
  • Clock – provides access to the system clock
  • File – exposes methods for creating and copying files and folders
  • GraphicsWindow – for drawing and animating shapes
  • Desktop – allows you to set the desktop wallpaper
  • Flickr – get images direct from the Flickr website
  • Dictionary – get word definitions from an online dictionary

There’s a lot of useful stuff here and if there’s something missing, you can create your own libraries in any .Net language and use them in your Small Basic programs – how cool is that?

Useful Links

Silverlight 4 Hands-On

I recently had the opportunity to get some hands-on experience with Silverlight 4 in Visual Studio 2010.

When you start a new Silverlight 4 project, you’re asked which version of Silverlight you want to target – 3 or 4. Seeing as version 4 is the latest, I opted for that, only to get a prompt to download this update. This installs not only the Silverlight 4 tools for Visual Studio, but also a new version of the WCF RIA Services library.

WCF RIA Services simplifies traditional n-tier development by bringing together ASP.NET and Silverlight using Windows Communication Foundation (WCF). WCF provides a pattern to allow you to write application logic that runs on the middle-tier that controls access to data and services.

It also provides a rich framework for common business application development scenarios such as validation, authentication and user roles.

After installing the update, you get two new Silverlight project templates that showcase the new RIA Services functionality:

  • Silverlight Navigation Application
  • Silverlight Business Application

The Silverlight Navigation Application template is interesting because it also demonstrates the new navigation framework in Silverlight 4. This allows you to create Silverlight pages that are associated with the browser’s forward and back buttons, something which had been either difficult or impossible to implement in previous versions.

All in all, Silverlight 4 represents a major step forward and brings a compelling set of new capabilities to the line-of-business application developer.

Managing SQL Azure Databases

I’ve written previously about SQL Azure, Microsoft’s “database in the cloud” offering.

Whilst your SQL Azure account page will allow you to create and drop databases, it doesn’t (as yet) allow you to do much else. So how do you create tables, views and other objects? Well, if you’re migrating an existing database, you can use the SQL Azure Migration Wizard. If it’s a new database, you may choose to create it locally then use the SQL Azure Migration Wizard to migrate it for you. However, you can save yourself time by using SQL Server Management Studio to connect to your SQL Azure database directly.

Before you start, use your SQL Azure account page to create a new empty database. Go to the “Firewall Settings” tab and create a new firewall rule to allow access to your server from your external IP address:

image

When the rule has been added, switch back to the “Databases” tab, select your database and click the “Connection Strings” button to get the connection string, as you’ll need it shortly.

Next, fire up SQL Server Management Studio. When prompted to connect to a server, cancel out of the dialog and instead click the “New Query” button on the toolbar. When the connection dialog prompt appears, you’ll need to do the following:

  1. For the server name, use yourservername.database.windows.net
  2. For Authentication, choose SQL Server Authentication
  3. For the Login name, enter the username as it appears in the connection string – this will be in the form username@server.
  4. For the password, enter the password for the user account – for security reasons, this is not shown in the connection string.

So far, your server connection dialog will look something like this:

image

Next, click the “Options” button. This will expand the dialog box and switch to the “Connection Properties” tab. In the “Connect to database” text box, enter your database name and click “Connect”:

image

You should now be connected to your SQL Azure database. What you’ll notice immediately is that the server and database do not show up in the Object Explorer. This will supposedly be fixed in SQL Server 2008 R2 which is due to be released in May 2010.

You can now use the Query Editor window to issue CREATE TABLE and CREATE PROCEDURE statements. Note that there are some syntactical differences in the Transact-SQL statements you can use with SQL Azure. For more information, check out the SQL Azure Database Transact-SQL Reference pages on MSDN.

Windows Azure Development Storage

When developing applications that utilise Windows Azure storage, you will more than likely want to develop locally before deploying to the cloud.

Luckily, the Windows Azure SDK includes an offline storage simulator, called the “development storage” service. Development storage simulates the Table, Blob and Queue storage services in the cloud. The development storage service uses a database contained in a local SQL Server instance. The SDK will install SQL Server Express for you if you don’t already have it.

image 

If you have a different version of SQL Server, or a different instance name from the default, you can create the database manually by calling the “dsInit” utility from the Windows Azure SDK command prompt.

You must supply the name of the SQL Server instance you want to use via the “/sqlinstance” argument e.g. dsInit /sqlinstance:INSTANCENAME

This will produce the following dialog:

imageNote: you can also specify the “/forcecreate” argument to overwrite an existing database and reset it to it’s initial state.

More information about Development Storage and the dsInit utility can be found on this MSDN page.

SQL Azure Migration Wizard

If you want to migrate an existing SQL Server database to a SQL Azure database in the cloud, you will find the SQL Azure Migration Wizard very useful indeed.

The SQL Azure Migration Wizard is an open-source project hosted on CodePlex, so you could, if you wanted to, download the source code and  add your own features.

I can’t believe that Microsoft themselves didn’t think to include something like this in the Azure SDK. Without it, I would have found the process of creating a SQL Azure database a lot more time-consuming and error-prone.

As it is, the wizard will analyze your database, warning you of potential incompatibilities with SQL Azure features, then generate a script that will create your SQL Azure database for you, complete with data. I tried it on the Northwind database, and had a version running in the cloud in minutes.

It’s worth pointing out a couple of minor ‘gotchas’ I came across whilst using it:

  1. Your SQL Azure user name must be in the form user@servername where ‘servername’ is the dynamically-generated name of your SQL Azure server instance.
  2. The wizard is not yet sophisticated enough to work out dependencies between objects and create them in the right order. I had an instance where the creation of a view failed because the table had not yet been created. The table creation statement was a few lines further down in the script.

Despite these minor points, it’s a great time-saver and best of all, it’s free!

Overview of SQL Azure

SQL Azure is a relational database service that operates in “the cloud”. It is based on Microsoft SQL Server and is hosted on servers in Microsoft’s data centres.

Is SQL Azure the same as SQL Server? Well, yes and no. It is similar in that you have a virtual SQL Server instance which operates very much like a physical instance, but which is administered differently. For example, whilst you can create and manage databases, users and logins, you have no control over the physical environment such as the location of data files and logs.

Features Not Currently Supported

SQL Azure does not yet support all of the features found in SQL Server, though it has been hinted that more features will gradually be added in future. At the moment, SQL Azure does not contain:

  • Analysis Services
  • Reporting Services
  • Service Broker
  • Database Mirroring

Note: Replication is not supported, either, but since SQL Azure automatically replicates and load balances in order to provide a high-availability service, this seems fairly irrelevant.

Other Differences

SQL Azure supports most of the data types you would find in SQL Server 2008, but not all. For example, the new spatial and geometry types are not supported. A full list can be found in this MSDN article. Other features that are currently missing include:

  • Common-language runtime
  • Multiple active result sets (MARS)
  • Linked servers/distributed queries

Despite the differences, there are certainly enough features to cater for the vast majority of line-of-business applications.

A more complete overview can be found on this MSDN page.

Windows Azure Links

Following on from the Azure Open Space Coding Day, below are some useful links regarding Windows Azure:

Note: the Windows Azure Training Kit is based on the November 2009 CTP, which means that when the installer checks your system for the necessary prerequisites, it will display an error if you only have the February 2010 SDK installed. This doesn’t actually prevent you from using the kit and running the hands-on labs and tutorials.