In class today my teacher mentioned that most small coders don't bother filing patents for their programs because it's too expensive to be worth it. Is this true in the "real world"?
Not true. An algorithm, even a mathematical algorithm, is patentable unless (1) it is not sufficiently disclosed to overcome the "abstract idea" exception, or (2) it is executed with no useful application in mind.26 This description of just what an "algorithm" is may be helpful: "Although one may devise a computer algorithm for the Pythagorean theorem, it is the step-by-step process which instructs the computer to solve the theorem which is the algorithm, rather than the theorem itself."27 Under Alappat, the algorithm might be patentable. The theorem itself, being an abstract idea, certainly would not.
Generally, it's very rare for a 'program' to be patented. What usually gets patented is algorithms and frameworks.