Software can be protected by both a patent and a copyright.
A patent is used to protect the methods or process that the software performs while a copyright would protect the code only.
So, a copyright should always be used to protect any new code that you write while a patent may sometimes be used if your program performs a new method or a new process.
A simple blog or website would only be protected by a copyright while a new gaming engine to run video games faster would also have a patent. You can read more about how to patent software here:
Hope that helps. http://patentfile.org/how-to-patent-software/
---Registered USPTO patent agent with 11+ years of patent filing experience. Filed over 500 patent applicaiton in many technology areas. Check out my website: http://patentfile.org