Jun 15

Although languages like APL, Prolog and COBOL might seem unusual to many of today’s programmers, they are serious languages developed to address a specific requirement or a particular model of programming. We’re looking here at those languages that have been designed, first and foremost, to be odd. Referred to as esoteric programming languages, some are intended as jokes, some as parodies of other languages, whereas others were designed to be downright strange.

Esoteric programming languages: is there room in your brain for these nutty devices?

Bizarre or not, though, all of them truly are programming languages in the sense that they really can be used to provide instructions to your PC. Our intention here isn’t to show you a lot about any one language – after all, you’re not exactly going to be using them for genuine programming projects – but to look at three of then, fairly briefly, to give you a feel for the variety of esoteric languages.

INTERCAL

The names of programming languages are often acronyms that give some clue as to their purpose. So BASIC is Beginners All-purpose Symbolic Instruction Code, COBOL is COmmon Business Oriented Language and FORTRAN is FORmula TRANslation. So you start to get a feel for INTERCAL when you read in the manual (which you can find at www.muppetlabs.com/~breadbox/intercal/intercal.txt) that its full name is “Compiler Language With No Pronounceable Acronym, which is, for obvious reasons, abbreviated INTERCAL”. It was designed with the aim of being as obtuse as humanly possible, mainly so you that you can amaze your fellow programmers by your ability to do something useful in this bizarrely complicated language which was designed specifically to have nothing at all in common with any other major language.

Ironically, since our stated aim is to show you how to program in esoteric languages, we’ve not even going to try with INTERCAL. Instead we’ll show you how to use the INTERCAL-J compiler using a sample program provided and then we’ll leave you to peruse the manual. We suggest you do this in a darkened room and clear a week or two from your diary before you start. If you consider this a dereliction of our duties, take a look at the INTERCAL program below, which has been provided to illustrate how fiendishly involved even a simple program can be. Its purpose is to read in 32-bit unsigned integers, treat them as signed, 2s-complement numbers, and print out their absolute values, terminating if the absolute value is zero. A comparable APL program runs to 16 characters.

DO (5) NEXT
(5) DO FORGET #1
PLEASE WRITE IN :1
DO .1 <- 'V":1~'#32768$#0'"$#1'~#3
DO (1) NEXT
DO :1 <- "'V":1~'#65535$#0'"$#65535'
~'#0$#65535'"$"'V":1~'#0$#65535'"
$#65535'~'#0$#65535'"
DO :2 <- #1
PLEASE DO (4) NEXT
(4) DO FORGET #1
DO .1 <- "'V":1~'#65535$#0'"$":2~'#65535
$#0'"'~'#0$#65535'"$"'V":1~'#0
$#65535'"$":2~'#65535$#0'"'~'#0$#65535'"
DO (1) NEXT
DO :2 <- ":2~'#0$#65535'"
$"'":2~'#65535$#0'"$#0'~'#32767$#1'"
DO (4) NEXT
(2) DO RESUME .1
(1) PLEASE DO (2) NEXT
PLEASE FORGET #1
DO READ OUT :1
PLEASE DO .1 <- 'V"':1~:1'~#1"$#1'~#3
DO (3) NEXT
PLEASE DO (5) NEXT
(3) DO (2) NEXT
PLEASE GIVE UP

So to business and in particular we’re going to compile and run a program that prints out prime numbers. J-INTERCAL runs from the command prompt so Select Run… from the Windows Start menu, enter ‘cmd’ into the Open box in the Run window before clicking on OK. Then, at the prompt in the command line window, type ‘cd c:\jintercal-0.12\samples\’ and you’ll notice that the prompt will change to reflect the new default directory which is, in fact, the one where you’ll find an INTERCAL source file called primes.i. To compile it, type ‘Java intercal.Compile primes.i’, noting the capital C in ‘Compile’. All being well it will create the Java class file primes.class that you’ll be able to see if you type ‘dir’ at the prompt to list all the files in the folder. Now to run it, type ‘Java primes’ and you’ll see prime numbers flash down the screen expressed as Roman numerals which is INTERCAL’s standard form of output.

Brainfuck

INTERCAL programs are long and convoluted, aided and abetted, to no small degree, by the requirement to write polite programs with sufficient PLEASE statements included. Not so with the inappropriately sweary Brainfuck. Its programs couldn’t be more different. The aim was to implement a language with the smallest possible compiler – the compiler we’re using is just over 2Kbytes in length (yes, Kbytes, not Mbytes) and the record is somewhat less than 200 bytes. This required simplicity and despite the fact BF is Turning complete, meaning that it can perform any computation that “serious” languages can perform, it has just eight instructions, each of which is represented by a single character. That doesn’t make for the most readable program – so again you’ll reach guru status if you can master it – but it does mean that we can teach you the language in its entirety.

There is no concept of named variables, as there is in most languages. Instead BF has a string of 8-bit memory locations and a pointer that records which of those locations the current instruction will operate on. Initially all the locations contain zero and the pointer is initialized to the left-most location. With that bit of background we can now introduce the eight instructions, which are:

+    Increment the value at the pointer
-    Decrement the value at the pointer
>    Move the pointer to the right
<    Move the pointer to the left
[    Start of loop
]    End of loop (exit if value at pointer is zero)
,    Input an ASCII character and store it at the pointer
.    Print the ASCII character at the pointer

Of course a simple instruction set invariably means a complicated program so the simplest of operations, that might be achievable in a single instruction of a conventional language, can take dozens of instructions in BF. As an example we’re going to create a program that accepts two single digit numbers as its input and outputs their sum. The program to do this is as follows and, despite the fact it has 30 instructions, it still only works correctly if the answer is represented by a single decimal digit:

, > + + + + + + [ < - - - > - ] , [ < + > - ] < .

Your first job is to create a file containing the code showed above using Notepad. Since the space character isn’t a valid instruction it’s ignored and although we put a space between each character to make the code easier to read, you can leave them out. Note also that the full-stop at the end is part of the program. Call the file add.b and place it in the c:\bfd100 folder. Actually Notepad will try to give the file the name “add.b.txt” so you’ll have to rename it in Windows Explorer.

Now start up the command line window and change the directory to c:\bfd100\ – if you’re not familiar with command line prompts we did something very similar when we started to use INTERCAL. At the prompt type ‘bfd add.b’. BF will respond with the message ‘File assembled’, and if you do a directory listing you’ll see that the file add.com has indeed been created. This is a DOS executable file so all you have to do to execute it is to type ‘add’ at the prompt. Now type in your two one-figure numbers (with no space or punctuation between them) and the program will display their sum, immediately after the input, again without a separating space.

Now a slight aside. To be quite honest, of the three languages here, BF is the only one that you might want to delve into. After all, it’s quite an interesting language in its own way, in contrast to the others which are, quite frankly, plain dumb, and that’s being charitable. So to start you on your voyage of discovery, let’s see how the simple program above manages to add together two numbers.

The comma reads the first of the two figures and places it where the pointer is positioned which is, initially, in the left most memory location. However, the value read is an ASCII character which, for the figures 0 to 9, are the codes 48 to 57 so, to yield the actual number represented, we need to subtract 48. That’s achieved with the rest of the code up to but not including the second comma. It does that by moving the pointer to the right and incrementing that memory location six times so that it contains the value 6 which will then be used as a loop counter. Next it enters a loop that decrements the ASCII code eight times and the loop counter once. Since this loop will execute eight times, and each time it will subtract six from the ASCII code, when it does exit 48 will have been subtracted from the value input. The second comma inputs a second ASCII code which, because of the position of the pointer, will be stored one location to the right of the first value and again this will be used as a loop counter. The second loop causes the first value to be input (now decremented by 48) to be incremented as many times as the value of the second ASCII code input. When the loop exits, the value in the left-hand memory location (which is a valid ASCII value for a digit since we only subtracted 48 from one of the input values) is printed out.

BF commands might be terse but that doesn’t mean that programs can’t be made readable. Since all but the eight characters representing instructions are ignored, comments can be placed anywhere, as the following program shows.

===INPUT NUMBER===
+      cont=1
[
-      cont=0
>,
======SUB10======
----------

[      not 10
<+>     cont=1
=====SUB38======
----------
----------
----------
--------

>
=====MUL10======
[>+>+<<-]>>[<<+>>-]< dup

>>>+++++++++
[
<<<
[>+>+<<-]>>[<<+>>-]< dup
[<<+>>-]
>>-
]
<<<[-]<
======RMOVE1====
<
[>+<-]
]
<
]

Java2K

Unlike our previous two languages which were supported by compilers, Java2K is implemented as an Integrated Development Environment (so it’s a bit of a mystery why it’s referred to as DIE for Win32 instead of IDE). But before you get too excited, this doesn’t mean a fancy integrated editor and all the works, it just means that immediately after compiling the code it runs it. To start it just double click on the Java2K.exe icon in the c:\java2k\ folder it’ll open in a command line window and announce its presence with the rather puzzling statement “ELVIS HAS LEFT THE BUILDING AT 0.0.1900 <chair>:”. To see it in action just type the name of one of the sample Java2K programs supplied, say “26”, and you’ll see the output which, in this case, is the letter “F”. Having seen something of the astonishing power of this remarkable language you’ll be eager, no doubt, to try out more of the sample programs. However if, for the moment, you can get over your understandable excitement, we’ll first take a look at Java2K behind the scenes.

Like INTERCAL and most other languages, but unlike BF, Java2K has operators that work on variables. Like BF, Java2K is obscure in the extreme but whereas in the case of BF that was by necessity (i.e. to achieve the goal of producing a tiny compiler), in the case of Java2K it’s by design. First of all, where most languages use decimal numbers, perhaps with the option of binary, octal or hexadecimal, Java2K uses numbers to the base 11 which, as the manual points out, is close enough to decimal. Because base 11 numbers require an additional digit to the usual 0-9, Java2K uses 0-9 plus space. The upshot of this is that since a space will be interpreted as the number ten, spaces can’t be used just to make programs more readable. Second, function names are numbers rather than words, and so too are the names of variables. So you can forget, for example, of using meaningful variable names such as “Total” or sensible instruction names such as “Print”. In the case of this latter instruction Java2K uses the instruction “1 1 “ (note the two spaces, after all this is a base 11 number) instead. And finally, on the subject of obscuration, because numbers are interpreted as functions or variables, you can’t use them as numerical constants. Instead, if you want to refer to the number one, you have to use some function that will produce 1 as its output. The classic way of doing this is to use the code “11 6/*/_\”. If we point out that “11 6” is the divide function, “*” returns a random number, “_” repeats the previous argument, “/” is a separator and “\” is an end-of-instruction marker, it should be clear that this will produce a 1. Surprisingly, then, this statement isn’t quite correct as we’re about to see.

1 1 /125 /131 /119 /125 /11 6/*/_\/_\/125 /13 2
/*/_\/_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2
/*/_\/_\\/119 /125 /11 6/*/_\/_\/125 /13 2/*/_\
/_\\\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/
_\/_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/
_\/_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/
_\/_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/
_\/_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/
_\/_\\/119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/_\
\\\\\\\/*\1 1 /125 /119 /11 6/*/_\/13 2/*/_\\/
125 /131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_\
/_\\/119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/_\\\
/125 /131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_
\/_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_
\/_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_
\/_\\/131 /119 /125 /11 6/*/_\/_\/125 /13 2/*/_
\/_\\/119 /125 /11 6/*/_\/_\/125 /13 2/*/_\/_\\

Using the Java2K IDE (sorry, DIE) run the program 13 which is supposed to display “Hello, World”. We’ve included a small chunk of it above. Run it a few times and you’ll probably notice something odd – it doesn’t always get it right. The reason for this is that unlike virtually any other language, Java2K is a probabilistic language rather than a deterministic one so all its functions generate the “correct” answer only 90% of the time; for the remaining 10% it will give a random result. So the method of generating a one that we saw above only has a 90% chance of success. And that’s just for generating a one. The obvious way of generating a two is to add two ones together using the code “125 /11 6/*/_\/_\” but we’re now introducing another instruction that also has a 90% chance of success so the combined likelihood of getting the expected result drops to 81%. In this light of this you might find it surprising that the program 13 manages to produce “Hello, world” as often as it does.

The fact is that there are clever tricks that Java2K programmers can use to improve a program’s success rate but the result is that even the simplest of programs can be extremely long, not to mention virtually incomprehendable. As proof of this why don’t you take a look at program 13 using Notepad. Having done so we suggest that you use the experience to convince yourself that there are better ways of spending your time than attempting to learn Java2K. If you choose to ignore this advice you’ll find the programming manual, in all it succinct glory, at www.p-nand-q.com/humor/programming_languages/java2k/manual.html but we won’t be responsible for the consequences.

Apr 13

It’s not all iPods and MacBook Pros, Apple has been known to design, build and sell some serious flops.

When Steve Jobs speaks, the world listens. His fabled Reality Distortion Field makes even the shiniest piece of chrome and plastic glisten just that little bit more. The phrase ‘One more thing’ moves every member of the audience to the very edge of their seats, knowing that whatever follows, they’ll soon have one in their possession. But it wasn’t always like this, and even the all-powerful Apple of today sometimes stumbles in mid-stride. We’ve gone in search of the 10 biggest flops, missteps and bad ideas that found a half-chewed worm emerging from the apple of our eye.

1. Pippin

Super Nintendo. Master System. Jaguar. Megadrive. Pippin. Can you spot the odd one out? It sounded like a child’s toy, but not many children ever had the chance to play on Apple’s ill-fated games console, Pippin. Technologically speaking it was a Mac in a smaller box, intended to play hot CD-based gaming classics like Terror Trax, The Journeyman Project and Mr Potato Head Saves Veggie Valley.

But whereas most games manufacturers quickly learned the importance of controlling their ecosystem with a vice-like grip, Apple planned to sell the core technology to several different companies – which is ironic in light of the company’s current modus operandi. Unfortunately, like everyone who tried to take on gaming giants Sega and Nintendo, Pippin was a miserable failure. It was an underpowered, undersupported system that reportedly only sold around 5,000 units in the US. Being a computer, Pippin did have some interesting technology on its side, including innovations like internet access, but without the games to back it up, it was all for nothing.

Also, it was called Pippin.

After Pippin crashed and burned, Apple largely gave up on gaming – and most developers still avoid the Mac. However, times have changed. The iPhone’s gaming library hasn’t defeated the mighty Nintendo, but it’s the first thing for a long, long time to pose a really genuine threat to it, if only among casual players.

2. Apple USB Mouse

The infamous ‘Hockey Puck’ is one of Apple’s most mocked inventions, appearing with the launch of the iMac in 1998 and promptly hanging around homes and offices like a bad smell for years to come. Not only was it ugly, it made pointing and clicking about as much fun as typing on a keyboard covered with needles, using a speech recognition system that insisted you neck a balloon full of helium before every instruction, or anything involving Microsoft Office’s ‘helpful’ paperclip.

Not only was its round shape clumsy and uncomfortable, it was far too imprecise when gripped and prone to turning instead of moving. The cord was far too short if you plugged it into the machine rather than the USB ports on a Mac keyboard, and the buttons weren’t very comfortable. Some good did come out of it, though – third-party manufacturers made a fortune selling alternatives and adaptors.

3. iPhone Apps

When the iPhone was first revealed in all its wonderful glory, one thing was notably missing: applications. Apple got to write them, serving up sleek email and calendaring, maps and music playing. Everyone else was limited to creating websites that could be blessed with an icon on the home screen, without access to any of the interesting hardware that made the iPhone so innovative. Steve Jobs described this as “a very sweet solution”; everyone else went with ‘bad joke’. As was pointed out many times, if web pages were up to the job, why were all of Apple’s own apps Cocoa-based, with not a single HTML offering among them?

In retrospect, this was the first sign of trouble brewing. The App Store is now huge, and many have made a fortune from it, but Apple’s control over the platform is only becoming more problematic. From junk programs to bizarre rejections, scaling issues and the high cost of entry, every day sees new complaints from developers.

Ironically, the increased prominence of HTML5 coupled with Apple’s lockdowns has persuaded many that, just maybe, taking the web route might be better after all. One of the most notable examples is Google. After going through all kinds of trouble getting the Google Voice app approved, the company realised that it could allow anyone with a smartphone to log on by making the service available via the browser. Anyone in the US, anyway – Google Voice is still to be released here.

4. Apple Lisa

Apple kit is too expensive. That’s the most common criticism of the company, and it has been right from the start. The Lisa, launched in 1983, was an attempt to go after business customers by offering a more powerful system, higher resolution graphics and support for multitasking and protected memory. It found a market, particularly in document creation, but the cheap availability of both IBM PCs and standard Macintosh systems worked against it.

The Lisa did however offer expansion ports, and a snappy name – although one with no easy explanation. The official version is that it stands for Local Integrated Software Architecture, but nobody believes that. The standard backronym is Lisa: Invented Stupid Acronym, but most believe it was simply named after Lisa Jobs, Steve’s daughter. Jobs worked on the project for a while before jumping ship to work on the Macintosh project.

The Lisa was just too expensive to take off when it was launched in the early ’80s.

5. Newton

Pity the poor Newton. Probably Apple’s least-deserved flop, this PDA platform (the actual devices were called MessagePad) was truly ahead of its time. It featured integrated handwriting recognition (which worked reasonably, if not completely reliably), was controlled by a touchscreen, and offered lots of applications to make early adopters’ lives easier, including notes, contacts and dates. That’s nothing too special by today’s standards, but it was an exceptionally powerful device in the early ’90s. However, this was only intended to be the start of Newton’s capabilities. Apple saw the devices as computers in their own right, and we’ve yet to truly see a successor that has actually pulled off that massive leap. Perhaps the iPad will be it…

6. Motorola ROKR

While the hardware was Motorola, the appeal of the ROKR was all down to Apple. This was the first phone built around syncing to iTunes, and one of the few third-party products to get the full Steve Jobs stage treatment. And… it wasn’t good. At all. Not only was it a tacky product, it was stuffed with infuriating limitations, like only being able to hold 100 songs no matter how much extra storage it was given, offering no way of buying music online and connecting to your Mac or PC via a slow USB 1.1 cable instead of the faster 2.0 standard. Jobs’s demo of the phone conveyed absolutely none of his usual enthusiasm, and for good reason. This was 2005. In 2007, Apple released the iPhone, and the failed first attempt at a Jobs-approved phone was consigned to history.

7. Apple TV

The Jobs seal of approval isn’t always a guarantee of quality, then – and Apple TV is another example of a product that failed to make the grade. Apple TV combined the worst of several worlds – reliance on the Apple ecosystem, lack of an optical drive and the state of internet-available entertainment in the UK back in 2007 – to produce a largely useless electronic paperweight. In fairness, the Apple TV wasn’t a terrible unit, but it hit too early and was too much a company player instead of focusing on what customers would actually be best served by.

Nowadays there are so many other options available that the window of opportunity for it has well and truly closed. Apple still makes the devices, but even it has largely moved on to focusing on new products. Apple TV may have introduced people to the idea of media streaming in their house, but it’s products like the WD-TV Live and PlayOn that are finally making the humble computer a fundamental part of the TV-watching experience.

8. QuickTake Camera

Much like the Newton, the QuickTake’s failure had less to do with the product itself than the situation it found itself in. It was one of the first consumer-level digital cameras, so it was fairly rough and ready – no screen, no easy photo deletion – and it shot at a resolution of 640 x 480, with a pitiful 1MB of memory. Three different versions were released from 1994 onwards, but like most of Apple’s non-computing-focused products, Jobs axed the line after returning to power.

9. The Twentieth Anniversary Mac

$7,499. We shall repeat that: $7,499. No matter how much of an Apple obsessive you might be, no matter how much you think the user interface and style warrants high price tags, dropping $7,499 on a new machine to celebrate a company’s milestone is on the wrong side of the Lala River in the valley of Areyoukidding. This was 1997, when a regular Mac of the same specification would cost you just $3,000. Apple managed to sell a handful at this insane price, but it was quickly forced to back down.

Fancy spending $8k on a prettified Mac? Didn’t think so.

By 1998, when the unit was discontinued, the price was down to under $2,000. It may have looked snazzy next to the resolutely ugly beige boxes of the time, but the Twentieth Anniversary was proof that you can in fact put a price on style, and it’s one that most people aren’t ultimately that willing to pay. It has become something of a collector’s item, however; perhaps that counts as success of a kind.

10. MobileMe

Apple had no excuse for MobileMe to flop. The idea was as obvious as it was brilliant – syncing mail, calendars, files and photos between your computer, your iPhone (you did buy one, right?) and the web. So what went wrong? Well, everything. Not only was it overpriced – and at £50 for a year, remains so – but the original version barely worked. File sharing was missing in action, online storage was too slow and the calendar was a joke compared to Google’s offering. As for email, it was fine if you actually wanted to use an Apple-branded address, but with more and more of us switching to personal domains, especially for professional purposes, MobileMe’s lack of proper domain mapping really bit down hard.

Even the launch of the service was a big disaster – the pages were slow, the servers were constantly down, the push messaging promised didn’t work, and worst of all, a number of trial users found their credit cards charged too early. Apple tried to patch up problems by extending the service’s free trials, but there’s no doubt that what most who tried it in those early days remember is a horrible experience from a company that makes its money providing the best. Not cool, Apple. Not cool at all.

Mar 23

The future of scalable, distributed computing is in the cloud. This is a nebulous concept that’s supposed to describe a cloud’s perpetual elasticity in providing online storage, processing and bandwidth. There are user-facing cloud services such as Google’s web-based applications, the Ulteo online desktop and Canonical’s One service for silently cross-computer folder synchronicity. And there are the more ambitious services of Amazon’s EC2 platform, enabling websites like Facebook to expand and contract their resource requirements in realtime, catering for peaks and troughs in demand and only paying for the capacity and the CPU cycles it actually uses.

Tux: the ideal combination of experienced mountain climber and feathered networking expert.

This latter kind of cloud is a big enterprise oriented subject, and Facebook-like scenarios are way off the scale when it comes to the ordinary Linux user. But Linux is at the heart of many of these installations, and there’s plenty of enterprise cloud technology left lying around for us mortals to play with. Incredibly, considering it’s user-friendly approach to Linux, that includes the latest release of Ubuntu.

Ubuntu 9.10 bundles something called ‘Eucalyptus’, an open source tool for generating private clouds that can dynamically connect to Amazon EC2. Eucalyptus, an acronym for ‘Elastic Utility Computing Architecture Linking Your Programs To Useful Systems’, originated as an ambitious project run by the Computer Science Department at the University of California. But it quickly became apparent that the technology it was developing was in great demand, and professor Rich Wolski, as well as many of his students took sabbatical leave from their day jobs and founded Eucalyptus. So far, they haven’t gone back.

STEP 1: Getting Started

Before trying Eucalyptus for yourself, there are some demanding requirements. Installation is relatively straightforward, but you will need to use the Linux command line, and possibly, troubleshoot any problems by reading the log files.

You will need at least two machines. One for front-end management and another to act as a single nodes on the cluster. Clouds like these rely on virtualisation to provide the elasticity and software scaleability of the hardware doing the processing. They run virtualised instances, called images, of your chosen operating system. In the case of Eucalyptus, virtualisation is handled by either KVM or Xen at the kernel level, which is why you need a VT-enabled CPU for the node machines, along with plenty of horsepower, memory and storage. It also means that you will need to configure your cloud to do something useful after you’ve got it working, just as you would a standard Ubuntu server installation.

You’ll be given the option of installing a new cluster or adding a node to an existing one.

The machine used to control and manage your cloud is usually referred to as the backend, and to get started you need to insert the Ubuntu 9.10 Server into its drive and reboot. When you see the boot menu, select a language followed by ‘Install Ubuntu Enterprise Cloud’. Choose language, location and keyboard layout, then enter a host name, we used ubuntu1. The next step will ask whether you want to create a ‘Cluster’ or a ‘Node’, and you need to select the first option, ‘Cluster’.

You will then need to work through the standard Ubuntu partition options. Ideally, use the entire disk for the installation unless you need to keep data on the machine, and leave the most options at their default values. The installer will then go off and create the partitions it needs then download and install a few packages. After this, it will ask for the default username and password for the machine, and whether you need your home directory encrypting. Skip the HTTP proxy question and leave the automatic updates off for now, and set Postfix to ‘No Configuration’.

STEP 2: Network and Nodes

We now have a couple of questions that deal specifically with the Eucalyptus configuration. The first asks for a cluster name, and you can call it what you like. This is the name people will see if they access your cloud. The second question asks for a range of IP addresses on your LAN that Eucalyptus can safely use to assign to each node. To answer this, you need to know the range of addresses that your router is using.

Many routers on a home network, for example, will issue IP addresses in the range of 192.168.1.2 – 192.168.1.100, or similar. You need to find this information from your router and enter a range that isn’t going to be assigned automatically from the router but is on the same domain. ‘192.168.1.100-192.168.1.200’ would work with our previous example. But for the sake of our experiment, you only need to find a couple of spare addresses on the same domain.

It’s best to assign a range of currently-free IP addresses to make up your cluster. It saves a lot of hassle later on.

After entering these details, the remainder of the packages will be installed and you’ll be asked to reboot the machine without the disc in the drive. When the backend reboots, login to your account. You should see the IP address for the server displayed and the message about documentation, and you need to make sure this address in within your network’s range.

It’s now time to tackle the node. Take the same disc you used for the backend and use it to boot your node machine. Choose ‘Install Ubuntu Enterprise Cloud’ from the boot menu again, and go through the first few questions. After entering a new hostname, you should be told that there’s already a Eucalyptus cluster controller on your network, and ‘Node’ will be selected automatically. Just press return. Installation will now be identical to the earlier install, only without any further Eucalyptus questions. Even your user name and password are grabbed from the backend machine, and at the end of the process, you can reboot and the node is now running.

STEP 3: Configuration

On each machine, you should login and type ‘apt-get upgrade’ to download and install the latest package updates for the system. You’ll probably have to reboot each machine again.

We now need to tell the backend about the existence of our single node. Login to the backend machine, and type ‘sudo euca_conf –no-rsync –discover-nodes’. You should see something like the following:

New node found on 192.168.1.62; add it? [Yn]

Just press return, and you should see that the two machines connect and synchronise a pair of keys that will be used to authenticate future connections. Now launch a browser from any other machine on the LAN and go to ‘https://backend_ip:8443’. You will get a security warning about the unverified nature of the certificate used for the connection, but you’ll need to add an exception for this site. Firefox will step you through this process automatically.

You should run the configuration tool as a super user.

You will then see the ‘Eucalyptus Enterprise Cloud’ login screen. Enter ‘admin’ for username and the password, and you’ll be immediately asked to enter a new administrator password, and check the IP address of the server so that a new certificate can be generated. After clicking submit, you’ll find yourself at the Eucalyptus management console, but before we can get stuck into the details, we need to download something called a credentials file, that we can use to authenticate our own tinkering with the server, as well as any other cloud service you may want to use to expand your installed.

STEP 4: Credentials

Click on the Credentials tab followed by the ‘Download Credentials’ button. This will leave you with a zip file that you will need to transfer to your user account on the backend machine. The easiest way is from the command line, using ‘sftp backend_ip’ to connect to the machine, followed by the command ‘put’ with by the path to the zip file, ‘put euca2-admin-x509.zip’ for instance. On the backend, you then need to unzip the file into a hidden folder in your home directory with ‘unzip -d ~/.euca euca2-admin-x509.zip’ and run the script it contains that configures various environmental variables and keys for managing the cloud, ‘. ~/.euca/eucarc’. This script will need to be run whenever you re-connect to your backend system.

Once it’s properly installed, Eucalyptus’ web interface looks after much of the heavy lifting.

To check that everything is working as it should be, type ‘euca-describe-availability-zones verbose’. The output should look like the following:

AVAILABILITYZONE pcp_cloud 192.168.1.48
AVAILABILITYZONE |- vm types free / max cpu ram disk
AVAILABILITYZONE |- m1.small 0002 / 0002 1 128 2
AVAILABILITYZONE |- c1.medium 0002 / 0002 1 256 5

This is important information. The critical data is beneath the free/max columns. This shows the CPU cores available on your cloud for immediate use. The more nodes you have on the network, the higher the number here. If you see only zeros, then there has been a problem with the node starting the appropriate controller, and you’ll need to check its /var/log/eucalyptus’ directory for the log files.

STEP 5: Run an image

It’s now time to create a virtual instance of a machine to run on our node. Eucalyptus makes this very easy because it allows you to download pre-built packages.

Go back to the browser and click on the ‘Store’ tab in the management console and choose a pre-built image to download. We opted for Karmic Koala (i386), which is a 174MB download. You will also have to wait a couple of minutes for the image to be installed after the download has completed, but before long you should see the message ‘How to run?’, and you’re ready to go. We did have problems with our backend machine hanging at this point, but we added more memory to the system and it worked though a hitch.

You’re provided with a selection of pre-configured virtual machines just begging to be run on your new cloud.

Before we go back to the command line, click on the ‘How to run’ link next to the download, and make a note of the ‘emi’ value at the end of the command. This is the unique identifier for the image, and we’ll need to use this when we run it. Back on the command line, type ‘touch ~/.euca/mykey.priv; chmod 0600 ~/.euca/mykey.priv; euca-add-keypair mykey > ~/.euca/mykey.priv’ to create a key pair to authenticate the connection to your running image. Then type ‘euca-describe-groups’ followed by ‘euca-authorize default -P tcp -p 22 -s 0.0.0.0/0’ to enable SSH access to the virtualised machine, and finally, type the following to launch it:

euca-run-instances -k mykey -t c1.medium emi

Replace the emi value with the identifier you took from the web interface. You should also notice that we’ve specified ‘c1.medium’ as the type of image, and this is a preset for the amount of resources the image is given. These can be viewed and modified using the Configuration page of the web management interface. It may take a while to initialise as there’s a lot of data being copied across the network, but you can check it’s status with the ‘euca-describe-instances’ command, and wait for it’s state to switch to ‘running’ rather than ‘pending’. On our hardware, this took about 20 minutes.

You’ll also see the IP address of the new instance, and you can now connect to your new cloud server by typing ‘ssh -i ~/.euca/mykey.priv ubuntu@ip_address’. You’re now ready to install and run your mind-blowing web 2.0 application!

See also: Amazon EC2

Private clouds, of the kind we’ve started to build above, are an excellent raw resource if you need a dynamic pool of processing power. But the beauty of cloud computing is that it’s designed to be elastic, and this means you needn’t be restricted by the physical limitations of your own setup. With Eucalyptus, for example, you can take exactly the same images you’re running on your local machines, and move them to Amazon’s EC2 service as and when you need the extra horsepower.

This gives you relatively unlimited resources in terms of processing power, storage and network bandwidth, and you only have to pay for what you need, rather than the old model of paying for a rack of servers somewhere that spend most of their time idle. Eucalyptus manages this by building an API that’s compatible with Amazon’s, making the images that you configure on your local network drop-in compatible with the images that run on Amazon’s servers. Also, the tools that you use to manage and maintain your private cloud are the same you use to manage an Amazon-hosted cloud, making the transition between the two almost seamless.

There are other advantages to this compatibility too. You can create, test and experiment with private clouds before committing your concept to the costs and scrutiny of a public cloud running on Amazon’s servers. And private clouds, such as the one we create in the main text, can give you an excellent feel for how the technology works, and how you and your company may find it useful.

Troubleshooting

As you might have noticed, despite the Ubuntu installation being the easiest way of getting a usable cloud system, it’s still far from easy. There are a lot of aspect to the configuration that can go wrong, from the hardware that you choose, to the network that the various machines are communicating across. Another problem is that the Eucalyptus project is only in its infancy, with Ubuntu 9.10 being the first distribution to include packages by default. This means there isn’t a great deal of support, especially if you’re new to the world of clouds.

But there are several things you can do to help solve problems yourself. Firstly, you should run ‘euca-describe-availability-zones verbose’ to check whether your node machine has been detected and added to the cloud. If you have zero resources available, then it hasn’t. The most common cause for this problem is that the synchronisation of the keys from the backend to the node has failed, stopping the node from registering itself. Check ‘/var/lib/eucalyptus/keys’ on both machines to make sure the keys are available. If the keys on the backend are missing, trying running ‘/etc/init.d/eucalyptus-cc-registration restart’ to regenerate the keys, then then try to add the node again using ‘euca_conf –no-rsync –discover-nodes’. If all else fails, try ‘sudo /etc/init.d/eucalyptus-sc-registration restart’ too.

We also had problems trying to register nodes after updating the system with new packages. The solution to this problem is to either add nodes to the cluster before you update any packages, or leave your installation with the packages include with the default install. This shouldn’t matter for an experimental installation. Finally, if all else fails, trawl through files within the /var/log/eucalyptus directory on both machines, as this should give you some idea of where your setup may be failing.