When it comes to software it can either be copyrighted or patented. They offer different forms of protection for programmers.
Copyright
As code is written it is immediately covered by copyright – whereby the creator of the code decides who has permission to use it and how. The Copyright Act 1968 protects source code, executable code, and data. It doesn’t protect the idea of a piece of software.
Other parts of a project are also automatically copyrighted, such as documentation and graphical user interfaces.
When software is distributed and used without agreement by the copyright holder this is known as piracy, and is illegal. People and companies who use or distribute (freely or sell) software can be fined.
Patents
Patents legally protect the way a program makes a computer work. It is not automatic, it must be applied for. For a patent to be obtained the invention must be novel (new) and different enough compared to any other method. An example would be a new way for users to interface with a computer through eye tracking.
Often patent attorneys are engaged to apply for patents as it’s such a complex process.
Side note: There is a Circuit Layouts Act 1989 which automatically protects integrated circuit layouts.