Code for people

October 17th, 2009

univac

Early in the history of computing the structure of programs were quite informal. A programs code was thought of as love letter between programmer and computer. It was private and was not meant for the prying eyes of others. The intentions of the original programmer were easily lost when they had not been communicated by the code. Having to extend or maintain a program written by someone else was usually a source of huge frustration and increased the likelihood of defects being introduced. Over time, as more people work on the code, its quality starts to deteriorate and it festers into something that people avoid at all costs and are reluctant to change.

One of the ways to prevent a program from ending up in such a state is to code for a person instead of a computer. Laying out and writing a program with comments that can clearly communicate intentions and can answer the question of why it has been done this way is crucial. It will make extending and maintaining the code much simpler for another programmer and even for you. The initial cost in time and effort at the beginning is repaid many times over during the lifetime of the code.

Author: Posted by Ed No comments Categories: Programming Tags:

Are you prepared for the Singularity

September 13th, 2009

I’ve mentioned before that processor power is increasing exponentially. It’s speculated that there’s a point where the rate technology develops can accelerate dramatically, this is know as the technological singularity. The current generation of computers design the next which are more advanced than those before, who in turn design the next generation and so on. With humans removed from the equation this can happen faster and faster. The pace technology advances will enter a feedback loop. The result would be artificial intelligence that equals and quickly surpasses that of humans.

terminator

Now if this all sounds terribly scary with humans out of the loop, machines designing machines and super artificial intelligences then don’t panic it’s a natural reaction, you are right to be scared. It raises some uncomfortable questions about how super artificial intelligences would regard humans. Compassion, indifference, benevolence or hostility? Wiring in rules like Asimov’s three laws of robotics would be useless. A sufficiently smart artificial intelligence could be easily find ways to bypass them also removing them completely from subsequent generations it designed.

Critics argue that there are numerous insurmountable technological limitations that will prevent any of this coming to pass. That it’s nothing but pure science fiction and essentially the rapture for nerds.

There is a very interesting Wikipedia article on the technological singularity that covers it’s implications, feasibility, proponents and critics. Even if there is only small chance the technological singularity could occur shouldn’t humanity be prepared?

Netbook OS evolution

September 6th, 2009

Netbooks are very much here to stay. Consumers want them. Manufacturers want to make money selling them. The problem is they all have nearly identical hardware specs. Competing so aggressively on price does not give manufacturers much room to vary the hardware configuration from their competitors. Not being able to distinguish themselves from the crowd  with hardware leaves netbook manufacturers with only one ways to make their offerings stand out. Price. Retailing for a lower price than the competition is going to make that netbook very attractive to the cheapskate price conscious consumer. Volume purchasing of components can only offer a limited amount of savings overall. Shipping a netbook with Windows incurs a significant license fee from Microsoft.

The myzone screen from Moblin

The myzone screen from Moblin

As a result of this free open source operating systems designed specifically for netbooks are being built. This new breed of operating systems have been distilled to the few features that the majority of users need. Focusing on web browsing, emailing and instant messaging instead of trying to emulate the complete functionality of Windows. This makes them fast and lean. The netbook is about to add to it capabilities by being able to play back high definition video, something that has proved too taxing in the past. The Tegra graphics processor has been specially designed to go in handheld and netbook computers. It can deliver some impressive results while still being able to sip a small amount of power. If these netbook operating systems like Moblin, Chrome and Ubuntu can meet consumers needs and save them a few bucks then they will make Windows irrelevant on netbooks. With Microsoft being watched carefully in the US and Europe it won’t be able to bully manufacturers into shipping Windows on their netbooks. For the first time in a long while we might actually start to see some competition in the operating systems that consumers actually use.,windowss

Author: Posted by Ed No comments Categories: Other Geekery Tags: , , , , , ,

Software patents: more harm than good

August 30th, 2009

danger of software patents

Microsoft is the latest company to be facing a huge headache for apparently infringing on a patent with its software. It’s appealing an injunction that would prevent the sale of Word. As usual the case has been filed in the US District Court of Eastern Texas. Large numbers of patent cases are filed in Eastern Texas because judgements find in favor of the plaintiff more often than other courts in the US.

I believe that being able to patent a piece of software is in conflict with a fundamental principle of software development, standing on the shoulders of giants by building on the work of others. There is a minefield of patents that must be navigated by any company building software. It’s expensive, time consuming and patents are often ambiguous.

I’m not in favor of totally abolishing patents. It’s important to recognise and compensate those whose work is built upon. But the current system is stifling innovation and hampering the ability to advance software. There are companies that exist whose sole purpose is to own software patents and to litigate against anyone that infringes them. They don’t do anything useful with the patents they own all they do is litigate and charge licensing fees.

It’s clear that the current system is badly broken. Software patents should incur a nominal licensing fee no greater than $1 for each product sold. If the software is made available under an open source license then no license fee should be incurred. After five years the patent should expire and incur no license fee. A central database of patents could provide an easy way to find any patents a piece of software would need to license.

Unfortunately the status quo is so lucrative for those holding patents and their lawyers that they will resist any attempts to change it. It’s a deeply flawed and unsustainable system, that will inevitably collapse in on itself. The only question is how long do we all have to wait?

Author: Posted by Ed 1 comment Categories: Programming Tags:

Blu-ray won the battle but may lose the war

August 22nd, 2009

HD-DVD-RIP
HD-DVD and Blu-ray slugged it out in a battle to become the next generation high definition disc format that replaces DVD. Blu-ray seemed like it had an edge from the beginning. With Sony taking a Trojan horse approach to getting Blu-ray players into consumers living rooms by enabling the PS3 to play the high definition discs. The only inroads HD-DVD could make in the console arena was as an expensive add-on to the Xbox 360. This helped Blu-ray build momentum and eventually emerge as the winner.

However victory may be fleeting for Blu-ray. A new challenger is beginning to emerge that could make Blu-ray obsolete before it even gains widespread adoption. Downloading and streaming high definition films from the Internet is becoming easier for several reasons. High speed broadband is now widely available and its price has fallen making it affordable for consumers. There are a growing number of providers like iTunes and Netflx that offer a large library of TV show and films to rent or purchase. Computers, game consoles, TVs, phones and even Blu-ray players can download or stream content from those online providers. The cost of distribution is minimal because there is no disc to produce, warehouse, package and ship. It’s just bits flying across the Internet. Lastly, convenience. For the couch potato generation, you don’t even have to get up from the sofa if you want to rent a film!

We are already storing our music digitally the next logical step is to do the same with films. I believe Blu-ray and downloading will co-exist for a little while but that downloading will inevitably come to dominate. The big question is will the movie studios voluntarily drop Blu-ray after so much money and effort went into it or will they be forced to.

Author: Posted by Ed No comments Categories: Technology Tags: , , ,

Three things every new Java developer should know

August 15th, 2009

java

I’ve been a Java developer for several years. During that time I’ve built up a few rules of thumb that I use daily almost without thinking about them. They save me time, make my code simpler and help minimise errors. I’ve picked the three most important that I believe every new Java developer should know. I have assumed some basic knowledge of Java but there is nothing here that I believe is too difficult. They are intended to be guiding principles rather than strict rules to follow.

  1. Code to interfaces rather than a concrete classes. A good example is the way Java collection classes can be used. Lets say we have the following method.
    public ArrayList<String> getDetails() {
    ArrayList<String> list = new ArrayList<String>();
    //Some processing operations
    return list;
    }

    Any classes calling this method will be expecting to get an ArrayList back. If you ever wanted to change the return type to something else like a LinkedList you’d have to change all of the places that made a call to the method to expect a LinkedList instead of an ArrayList. This would be a better implementation.

    public List<String> getDetails() {
    List<String> list = new ArrayList<String>();
    //Some processing operations
    return list;
    }

    Instead of the return type being a specific concrete class the return type now is an interface. So the actual concrete class used in the method could be an ArrayList, LinkedList or even a class you created yourself, as long as it implements the List interface it can be returned. Any places calling the method can expect a List back. This means the concrete class can be changed without having to alter all the places where the method is called.

  2. Favor composition, has-a, over inheritance, is-a, relationships. Inheritance is powerful but composition is usually more flexible, here’s why. Imagine we have a Sphere class with methods that return circumference, diameter and volume. Also that we have a Bounce class with methods that return the number of bounces, velocity and acceleration. If we want to have a RubberBall class that is a type of sphere that can bounce it can’t be done only using inheritance. When we use inheritance we can say that a RubberBall is-a type of Sphere or Bounce. Java is a single class inheritance language so our RubberBall class can only inherit from one parent class.
    A more flexible solution would be to give our RubberBall class a Sphere and a Bounce object. We’d be composing our RubberBall class so that we could say it has-a Sphere object and it has-a Bounce object. If we followed the previous principle and coded to a Sphere and Bounce interface things would be better still because we wouldn’t need to worry about any concrete classes. Our RubberBall class could be composed with any types of Sphere or Bounce implementations like an IrregularSphere, PerfectSphere, EarthBounce or a MarsBounce. The methods in the RuberBall class would only need to delegate to the Sphere and Bounce objects. Which would look like this.
    public class RubberBall implements Sphere, Bounce {

    private Sphere sphere;
    private Bounce bounce;

    public BigDecimal getDiameter() {
    return sphere.getDiameter();
    }

    public long getNumberOfBounces() {
    return bounce.getNumberOfBounces();
    }
    //Rest of the Sphere and Bounce methods
    }

    We can take things a step further. Although a class can only inherit from a single class an interface can inherit from multiple interfaces. A class that implements an interface that inherits from multiple interfaces must implement every method defined in all interfaces. Our new solution would look like this.

    public interface RubberBall extends Sphere, Bounce {
    }
    public class DefaultRubberBall implements RubberBall {
    private Sphere sphere;
    private Bounce bounce;

    public BigDecimal getDiameter() {
    return sphere.getDiameter();
    }

    public long getNumberOfBounces() {
    return bounce.getNumberOfBounces();
    }
    //Rest of the Sphere and Bounce methods
    }

  3. Keep class variables private and access them through public methods. If a class exposes a public variable it can be changed to any value at anytime during the programs execution. This can cause all sort of problems if the variable is changed during an operation that relies on the value staying the same or if the variable is changed to a value outside of the expected range. It is much safer if the variable is made private and accessed through public methods. Lets say we want to have a Person class and have a date of birth for the person. But we only want the date of birth to be set when the Person object is created and for it not to change after.
    public class Person {
    private Date dateOfBirth;

    public Person(Date dateOfBirth) {
    this.dateOfBirth = dateOfBirth;
    }

    public Date getDateOfBirth() {
    return dateOfBirth() {
    }
    }

    This might seem like a good solution but there are still some problems. If I create a new Date object and pass it into the Person constructor it is possible for me to alter the value in the Person object. This is because when I created the Date object I have a variable that references it and when I created the Person object a copy of my reference is passed to the constructor. There is a single Date object variable with two references to it one in the Person object and one outside. So I can make changes to the Date object using my reference to it outside of the Person object.

    The same problem exists with the getDateOfBirth method. It returns a reference to the Date object, so any changes made to the returned Date will affect the Person object. So it is little better than making the variable public!

    The solution is to make a copy of the Date when setting or getting it. This way the Date reference in the Person object is kept inside the object.

    public class Person {
    private Date dateOfBirth;

    public Person(Date dateOfBirth) {
    this.date = new Date(dateOfBirth.getTime());
    }

    public Date getDateOfBirth() {
    return new Date(dateOfBirth.getTime());
    }
    }

Author: Posted by Ed 2 comments Categories: Programming Tags: ,

The Windows 7 Gamble

August 8th, 2009

The release of the new version of Windows is nearly upon us. Microsoft is betting that it will be more successful than Vista. After failing to convince consumers that the initial problems with Vista had been addressed the launch of Windows 7 was brought forward. Vista won’t work on low spec netbook and nettop computer so Microsoft has been forced to extend the life of Windows XP and put it on those machines so as not to give Linux a toe hold.

The environment that 7 is being released into is very different from the one Vista entered into. The economic downturn has consumers focused on getting value for money and saving instead of spending. Rightly or wrongly the perception of Vista is that it’s been a failure so Microsoft has to make sure 7 doesn’t get labelled as just a Vista service pack. Apple have been able to take and hold 91% of the high end computer market from Microsoft. There is increased Linux competition on netbooks and nettops with Ubuntu, Googles Chrome OS coming next year and even Microsoft’s BFF Intel is working on a Linux OS called Moblin. Ironically the most serious competition that 7 faces in the netbook, nettop and business markets is from Windows XP.

So Apple has the high end, various flavors of Linux are positioning themselves to take the low end and Windows XP/Vista has a huge installed base in the low end, the middle and business. Oh yeah, and consumers don’t want to spend much money right now. The question is, how can 7 fit into this market place?

Apple has done a good job of producing premium products and building brand loyalty. It will be tough to win those consumers back,they will need some compelling reasons to abandon Apple and 7 isn’t enough. If history is any guide fighting a war on two fronts inevitably leads to disaster. Microsoft shouldn’t be trying to win back the high end from Apple and holding off Linux from the low end at the same time. Apple has already taken the high end but for the moment the low end still belongs to Microsoft. Linux is the immediate threat that Microsoft must face.

My strategy would to be to forget about chasing the high end market for now. Simplify the number of version from 6 down to 2, home and ultimate. Price the home version extremely competitively at $29.99 and the ultimate version at $149.99. An upgrade from Vista or XP to 7 home version should be $14.99 and to ultimate $74.99. This would form a two pronged attack: making it cheap to buy a netbook or nettop running 7 home version and also a no brainer to upgrade from an older version of Windows. Once consumers are using the home version of 7 they would be more amenable to upgrading to the ultimate version. Microsoft needs to appeal to the mass market with Windows 7 by showing it’s strengths the most important of which is price.

So I was surprised to read this week that Microsoft plans to “re-adjust those prices north” for Windows 7 and that thin, light and sexy full sized notebooks are what consumers are going to want this Christmas. It’s a big gamble for Microsoft to make considering what is at stake. Our modern times have shown that even the mighty can fail.

Author: Posted by Ed No comments Categories: Technology Tags: , , , , ,

Chunking data

July 31st, 2009

Chunking is the term used to describe the splitting of a big piece of information into smaller pieces, chunks if you will. Our simple brains struggle to cope with more than five or six pieces of information at a time. The optimum size of a chunk is about four characters. This is why credit card numbers are split up into chunks. Which credit card number is easier to read.

This?

5621902343246071

Or this?

5621 9023 4324 6071

It’s obviously the second number (not my credit card number in case you’re wondering). Telephone numbers are split up in a similar way. Chunking data makes it easier to remember and significantly reduces the chance of errors when recalling the information. We’ve come to expect information to be chunked, so it can be very jarring when it isn’t. If people are going to be reading it there is no reason not to chunk it!

Author: Posted by Ed 1 comment Categories: Other Geekery Tags:

Future of the iPhone

July 25th, 2009

It’s been a month now since the iPhone 3GS launch. There wasn’t the same fanfare surrounding this launch as past years, the phone received a modest but respectable bump in specifications. Which included a faster processor, more memory, video camera, compass and voice control. Attention has now turned to what the next iPhone will be like.

An indication of the future direction being taken can be found in the present iPhone 3GS. A feature that received poor reviews and has been mostly overlooked is voice control. Only a few actions can be controlled by voice and the chance recognising a command has been hit and miss. On the surface it seems nothing more than a gimmick or novelty that’s just been chucked in because it seems like a neat idea. However it’s important to remember that everything about the iPhone has been carefully thought through and considered, it seems unlikely that voice control would just be tacked on as an afterthought.

So the questions is, why would Apple add voice control when it doesn’t work all that well?

Apple likes to dip its toe in the water before diving straight in. It prefers to get a feel for something before committing fully. The best example of this is when Apple partnered with Motorola to produce the Motorola ROKR which was released in 2005 and offered the ability to playback songs purchased on iTunes with a music player similar to the iPod. Apple used Motorola and the ROKR to try out concepts before releasing the iPhone two years later. I believe this is what Apple is doing now with voice recognition on the iPhone.

The biggest shortcoming of the iPhone and every other smartphone out there has to be the mechanism for entering text on the device. I see people poking at their phones with their finger and it just strikes me as terribly inefficient. The most natural and efficient way of entering text would be simply dictating to the phone. Achieving this would be the most significant advancement to date, even more important than multi-touch.

Voice recognition has proved a tough nut to crack. Even with all the decades of research and money invested the best software still falls short of the mark. That software is running on desktop PCs and with all their memory and processing power at its disposal it still struggles to achieve a decent level of accuracy. Considering the constrained hardware of the iPhone and with no training, on what the users voice is like, Apple’s first stab at voice recognition is actually quite impressive.

We won’t know what the next generation iPhone will be like until it’s unveiled next year. Personally I would expect much improved voice recognition, more actions that can be controlled by voice and possibly the ability to dictate text for email or SMS. The challenges of voice recognition are great especially on a phone but I know one thing for certain. With Apple’s track record of innovation I wouldn’t bet against them.

Author: Posted by Ed No comments Categories: Technology Tags: , , ,

Crowbarring software into the browser

July 18th, 2009

The general trend in software today is to create web applications where in the past a desktop application would  have been built. Using clever Javascript frameworks it’s possible to make a web page behave like it was a desktop program. I believe one of the reasons for the trend is software developers are most happy when they are doing something that they find interesting and challenging. Trust me making a web application behave like a desktop one is certainly interesting and challenging.

The assumption is that if software is on the web it is inherently better and shinier than a dull old desktop version. In reality this is not the case at all.

  • Creating a web application that works in the most popular browsers and their different versions is not an easy task. It also becomes a maintenance headache supporting the older browsers as new versions with new quirks are released, yeah I’m looking at you Microsoft. While supporting new versions of operating systems for desktop programs can also be a headache they do not come along as frequently as new browsers.
  • The browser places limitations on communication with the server. With a program running on the desktop there is not this issue.
  • Problems with scaling on the server side can also come into play. As I’ve mentioned before the humble desktop computer has an enormous amount of processing power that is rarely fully used, so why not put it to use?
  • The cleverness that goes into making a web application behave like a desktop one can add complexity to the software that hurts maintenance and future extension.

Now I’m not slamming all web applications. There are a great many that could only work on the web and are truly excellent. They don’t feel like they have been crowbarred into a browser. So the next time you’re writing a web application ask yourself a little question. Am I crowbarring this software into the browser?

Author: Posted by Ed No comments Categories: Programming Tags: , ,