Archive for the ‘computer’ Category

Copyleft loophole

Sunday, September 11th, 2011

A while back I showed that it is possible to work around the anti-Tivoization provision of GPLv3. I've since realized that the GPL itself has a similar loophole.

The entire thing is predicated on the idea that if you change a program, you've created a "derived work" which therefore falls under the same copyright protection as the original. But is a change necessarily a derived work? If it doesn't include any of the original program, I don't think it necessarily would be if the change was distributed as a delta from the original. Normally a diff file says things like "in file x, look for the line that contains y and change it to z". Because this file will contain the line "y" (and even the filename "x", if it could be considered a creative work) it is a derived work of the original program. But one were to use a diff format that says "in the third file, change line 327 to z" that would contain no copyrighted information from the original, and could be distributed without restriction. There really isn't any difference between a code change and "mere aggregation".

What does this mean? Suppose you're Microsoft and you want to include GCC in Windows, modified with some proprietary algorithms and you don't want to release the source code. It turns out that this can be done. All Microsoft would have to do is include in the installer some code that will download the source (or binary) from a known location (perhaps from GNU servers, or a trusted third party's servers) patch it and (if necessary) compile it. Hey presto, there's the MS-GCC binary. The patch could be in the form of obfuscated code, object files or even (with some difficulty) binary deltas as long as care was taken to ensure none of the GNU-copyrighted works ended up in the Microsoft-distributed patch. Microsoft would not be committing copyright violation since none of the things they actually distributed contained any GNU-copyrighted code. The end-user would not be committing copyright violation either since they aren't distributing the software.

Essentially, with this hack, we've shown that the GPL is essentially equivalent to a BSD license. This isn't something that can be fixed by changing the license - it's a fundamental fact of copyright law.

The reason people don't do this is because it's more convenient to just release changes under GPL (so that a compiled binary of the aggregate can be released) than go through this hacky patching process. So it doesn't mean that copyleft isn't worth doing - in fact, I have heard it said that there are important parts of gcc which would never have been contributed if their authors' hands were not forced by the GPL.

Rewinding DVDs

Saturday, September 10th, 2011

Some DVD players now remember where you stopped playing a DVD, even if the disk is removed. When you put the disk back in, it reads the disk identifier, looks in its memory to see if it has a previous position for that disk, and (if it does) starts playing from that point.

This is all very well, except for the situation where you have a rental house containing such a DVD player and a selection of DVDs to watch - at the end of the rental period, the remembered positions of the DVDs might not all be at the start, leading to somebody putting on a movie and it unexpectedly starting half way through.

What is needed to solve this problem is some kind of mechanism... for rewinding DVDs!

(Perhaps just a button on the front that says "rewind all" which causes all the remembered positions to be forgotten. Or what our DVD player does when it starts somewhere other than the beginning - putting a "press such-and-such button to start from the beginning".)

Fortunately the problem is rather less severe than the problem of rewinding VHS tapes, so we won't have to remember to rewind rental DVDs.

What to do about software patents

Friday, September 9th, 2011

Patents are an enormous problem for the software industry. Software development organizations can never be sure that the software they develop doesn't infringe on somebody else's patent, so the only defence against being sued for patent infringement is to build up an arsenal of your own patents on methods as trivial as you can get away with in the hope that if someone sues you can counter-sue them for infringing on your patents and end up cross licensing. This doesn't protect against patent trolls, though (who produce no products and therefore don't need to worry about infringing someone else's patents). Also, it favours large software development organizations over smaller ones - patents are very expensive to obtain.

The usual answer to this is that we should get rid of software patents altogether. Perhaps this will happen, if enough powerful companies are burnt by patent trolls. On the other hand, perhaps some software patents are actually useful for progress - perhaps there are areas of software development where patents make much more sense than copyright - where simply examining the end product would allow somebody to (without infringing copyright) copy the part that took hard work to discover (i.e. an idea rather than the implementation). Perhaps there are ideas could not have been had without the investment that a promise of patentability would bring. Perhaps the additional secrecy that would have to be put in place without patents would cripple the industry.

Here's a proposal for a different sort of patent reform, which aims to solve these problems:

First, get rid of all the patent examiners. They're doing a lousy job anyway, granting all sorts of patents on things which have been done before and which are perfectly obvious to a person skilled in the art. Many of these patents don't stand up in court, but it's still expensive to defend against attacks from bogus patents. Instead, the patenting process should be a simple rubber stamp - anyone can send in a description of their idea (preferably not written in patent-ese), have it published on the USPTO (or equivalent) website and hey presto, that concept is now patented.

Of course, that doesn't get rid of the problem of bogus patents - it just moves the workload from the patent office to the court, which seems like it would make things worse. So the next stage is to set up a special patent court. If A wants to sue B for infringing on A's patent, it all gets sorted out in this court. The court needs to find a person skilled in the art (PSITA) who is not affiliated with A or B, and also to determine if B referred to A's product or patent. If the patent is bogus, or if B is determined to have invented the same thing independently, then the patent is thrown out and A has to pay the costs of the entire proceeding. If the patent stands up and B is found to have based their product on A's product or patent, then B must suffer the usual consequences, including having to pay for the proceedings. So (assuming the system works justly) all B needs to do to say safe is not to read unexpired patents and not to refer to competitors products - there should be no cost to them for accidental infringement or bogus patents (which really amount to the same thing - if it's possible to accidentally infringe on a patent it's a bogus patent by definition).

The third element we need is a way for a B to be sure that the product they want to release doesn't infringe on any patents (or to find out which patents it does infringe on). In practice it isn't possible to avoid seeing all competing products, so this step is necessary. The costs of this step must be borne by B, since otherwise B could cost A a lot of money by frivolously requesting repeated patent checks. The benefit is that (assuming the report comes back clean) there is then no risk of B losing a patent court battle. This sounds like it would be a very expensive exercise since it's essentially the cost of a patent trial multiplied by the number of active patents - however, a properly indexed patent database should make it reasonable.

One other element I'd like to see is a "use or it lose it" rule for patents, like those for trademark infringement. If you hold a patent, become aware of someone infringing that patent, and not choose to sue them immediately, you lose that patent altogether. This avoids problems with "submarine" patents.

CPU usage visualization

Monday, September 5th, 2011

I saw this interesting visualization of Atari 2600 binaries. It makes me want to do something similar, but arrange the instructions according to the position of the raster beam when the instruction is executed rather than the position in the ROM. The 2600 is a unique platform in that it lacks a frame buffer, so to produce coherent images, the code must be synchronized with the raster beam. If we make an image that has 4 horizontal pixels per color carrier cycle, that gives an 912 pixel wide image. There are 76 CPU clock cycles per raster line and instructions take 2-7 cycles giving us 24-84 horizontal pixels per instruction, which (with a bit of squishing) ought to be enough. A raster line would have to correspond to a line of text so we probably wouldn't want to show a full frame (field). However, a typical game will only have a few different "line sequences" so a full frame image would be very repetitive anyway.

Hacker show and tell

Saturday, September 3rd, 2011

As CodeSourcery employees work from home, we get together for a week-long meeting once a year in order to better understand each other. CodeSourcery was bought by Mentor Graphics last year, but the tradition continues for the division.

One of my favorite parts of the annual meeting is getting together with extremely talented people and having fascinating discussions about all sorts of technical things. Sometimes these are work related and sometimes we show each other our personal programming projects (the same sorts of things I talk about in this blog).

I often think it would be great to be able to have these kinds of in-person discussions more often than once a year. I've thought about setting up some kind of regular meetup in Seattle for just this kind of thing. I found Hack and Tell which seems to be exactly what I'm looking for except for the fact that it's in New York, so perhaps I should try to set up a Seattle chapter.

I also found a few things in Seattle which are similar but weren't quite what I was looking for one way or another:

  • Dorkbot seems be more "electronic art" centric (although I haven't been to one of their meetings).
  • Ignite Seattle seems to have a more formal format - 5 minute talks.
  • Saturday House and Meet at the Pig seem to be inactive.
  • Seattle Wireless HackNight at Metrix Create:Space - I actually went to this for a couple of months earlier this year. It's a very cool space and the people there seemed interesting, but the focus seemed to be more on having a set place and time to do some hacking and less on showing off personal projects to each other. I stopped going after a while partly because it didn't seem to be quite what I was looking for but mostly because it was in the evening which is problematic when you have two children who wake up you up at 7am sharp (at the latest) every day - if I don't go to bed at a sensible time I tend to be a bit of a zombie the next day.

Euclid's orchard improved image

Friday, September 2nd, 2011

I wasn't very impressed with the Euclid's Orchard perspective picture on Wikipedia (grey background, limited number of "trees", no anti-aliasing) so I made my own:

Postel's law revisited

Thursday, September 1st, 2011

There is a general principle in computing called the Robustness principle or Postel's law, which says that you should be conservative in what you send but liberal in what you accept.

This seems like a no-brainer, but adhering to the principle does have some disadvantages. Being liberal in what you accept introduces extra complexity into software. More problematically, being liberal in what you accept allows others to be less conservative in what they send. Nowhere is this more noticable than HTML. The first web browsers were extremely liberal in what they accepted - allowing HTML that is broken in all sorts of different ways. Many people wrote HTML by hand, tested it on just one browser and then uploaded it. Other browsers would often mis-render the broken HTML, leading people to put little buttons with slogans like "best viewed in Netscape 4" on their pages. As HTML evolved, continuing to accept all this misformed HTML while adding new features became a big headache for browser developers.

Lately, the best practices involve marking your HTML in such a way that browsers will only accept it if it's correct - that way you find out quickly about any mistakes and fix them early.

In general, I think that new protocols should now be designed to have a very simple canonical form and that only data that adheres to this form should be accepted - other data should be rejected as early as possible.

Inputs directly from users can still be interpreted liberally just because it makes computers easier to use, but that data should be transformed as early as possible into canonical form.

Progressively optimizing compiler

Wednesday, August 31st, 2011

Normally when compiling a program, you tell the compiler how much optimization you want and what the input files are, it goes off and does its thing and comes back when it's done. Sometimes I think it might be nice if one instead told the compiler how much time to spend doing the compiling. It would then do the absolute minimum to make a working binary, and then gradually do more and more optimizations until the timer ran out. This would make the time it takes to rebuild things much more predictable. One downside is that the performance of the resulting program would depend on unpredictable things like how busy the build machine was. Another is that it's probably more efficient for a compiler to decide upfront what the optimizations should be rather than making lots of intermediate binaries of different optimization levels.

However, this sort of thing might be more useful as a run-time process - i.e. a JIT compiler. The system can monitor which bits of the code are being run most often (this is very easy to do - just interrupt at a random time and see what code is being run) and concentrate optimization efforts on those parts. The compilation can continue (gradually making the program faster and faster) until the point of diminishing returns is reached. I understand there's a Java Virtual Machine which can do this.

The slow intelligence explosion

Monday, August 29th, 2011

Each new technology that we invent has improved our ability to create the next generation of technologies. Assuming the relationship is a simple proportional one, our progress can be modelled as \displaystyle \frac{dI}{dt} = \frac{t}{\tau} for some measure of "intelligence" or computational power I. This differential equation has solution \displaystyle I = I_0e^\frac{t}{\tau} - exponential growth, which matches closely what we see with Moore's law.

The concept of a technological singularity is a fascinating one. The idea is that eventually we will create a computer with a level of intelligence greater than that of a human being, which will quickly invent an even cleverer computer and so on. Suppose an AI of cleverness I can implement an AI of cleverness kI in time \displaystyle \frac{1}{I}. Then the equation of progress becomes \displaystyle \frac{dI}{dt} = I^2(k-1) which has the solution \displaystyle I = \frac{1}{(k-1)t}. But that means that at time t = 0 we get infinite computational power and infinite progress, at which point all predictions break down - it's impossible to predict anything about what will happen post-singularity from any pre-singularity time.

Assuming human technology reaches a singularity at some point in the future, every human being alive at that time will have a decision to make - will you augment and accelerate your brain with the ever-advancing technology, or leave it alone? Paradoxically, augmentation is actually the more conservative choice - if your subjective experience is being accelerated at the same rate as normal progress, what you experience is just the "normal" exponential increase in technology - you never actually get to experience the singularity because it's always infinitely far away in subjective time. If you leave your brain in its normal biological state, you get to experience the singularity in a finite amount of time. That seems like it's the more radical, scary and dangerous option. You might just die at some point immediately before the singularity as intelligences which make your own seem like that of an ant decide that they have better uses for the atoms of which you are made. Or maybe they'll decide to preserve you but you'll have to live in a universe with very different rules - rules which you might never be able to understand.

The other interesting thing about this decision is that if you do decide to be augmented, you can always change your mind at any point and stop further acceleration, at which point you'll become one of those for whom the singularity washes over them instead of one of those who are surfing the wave of progress. But going the other way is only possible until the singularity hits - then it's too late.

Of course, all this assumes that the singularity happens according to the mathematical prediction. But that seems rather unlikely to me. The best evidence we have so far strongly suggests that there are physical limits to how much computation you can do in finite time, which means that I will level off at some point and progress will drop to zero. Or maybe growth will ultimately end up being polynomial - this may be a better fit to our physical universe where in time t we can access O(t^3) computational elements.

To me, a particularly likely scenario seems to be that, given intelligence I it always takes the same amount of time to reach kI - i.e. we'll just keep on progressing exponentially as we have been doing. I don't think there's any reason to suppose that putting a human-level AI to work on the next generation of technology would make it happen any faster than putting one more human on the task. Even if the "aha moments" which currently require human ingenuity are automated, there are plenty of very time-consuming steps which are required to double the level of CPU performance, such as building new fabrication facilities and machines to make the next generation of ICs. Sure, this process becomes more and more automated each time but it also gets more and more difficult as there are more problems that need to be solved to make the things work at all.

In any case, I think there are number of milestones still to pass before there is any chance we could get to a singularity:

  • A computer which thinks like a human brain albeit at a much slower rate.
  • A computer which is at least as smart as a human brain and at least as fast.
  • The development of an AI which can replace itself with smarter AI of its own design without human intervention.

Debugger feature

Sunday, August 28th, 2011

Here is a debugger feature that I think I would find really useful: avoid stopping at any given location more than once. This would be particularly useful when finding my around an unfamiliar bit of code - it would step into a function that I hadn't stepped into before, and then step over it the next time it was called, for example. In fact, I often find myself trying to do exactly this, just remembering which functions I've stepped into before (and often getting it wrong).

The other use case for this feature would be doing a sanity test once some new code has been written - the debugger would just stop on the new/changed lines of code so that you can make sure that they're working as expected.

One difficult part about this feature (especially for the second use case) would be keeping track of which locations have been stopped at even across recompiles (so the instruction pointer location won't necessarily be the same) and across source changes (so the source line location won't necessarily be the same either). So really to implement this properly we need to completely overhaul the entire compilation system so that it takes as input the deltas from the last compilation and performs the corresponding modifications to the output files (including both the binary and the list of which locations have been visited).

Such an overhaul would be extremely difficult, but would be useful for other reasons as well - in particular, it has the potential to make builds much faster, which shortens the edit/recompile/test sequence and makes programming much more pleasant. Also, it could integrate with editor syntax highlighting and code completion features, so that these always reflect the current state of the program.