First to file and first to invent

First to file (FTF) and first to invent (FTI) are legal concepts that define who has the right to the grant of a patent for an invention. The first-to-file system is used in all countries.
There is an important difference between the strict nature of the FTF under the European Patent Office (EPO) and the FITF (First inventor to file) system of the United States Patent and Trademark Office (USPTO). The USPTO FITF system affords early disclosers some "grace" time before they need to file a patent, whereas the EPO does not recognise any grace period, so early disclosure under the FITF provisions is an absolute bar to later EPO patent.
First to file.
In a first-to-file system, the right to the grant of a patent for a given invention lies with the first person to file a patent application for protection of that invention, regardless of the date of actual invention.
First to disclose.
The concept of a grace period, under which early disclosure does not prevent the discloser from later filing and obtaining a patent, must be distinguished here from the FTI system. Germany and the UK formerly had a concept of grace period. Both FTI and grace period systems afforded the early discloser protection against later filers. The FTI system allowed non-disclosers to overturn established parties, whereas the grace system only protects early disclosers. The US moved to a grace system on 16 March 2013, which has been termed "first-to-disclose" by some writers.
First to invent.
Canada, the Philippines, and the United States had been among the only countries to use "first-to-invent" systems, but each switched to first-to-file in 1989, 1998 and 2013 respectively.
Invention in the U.S. is generally defined to comprise two steps: (1) conception of the invention and (2) reduction to practice of the invention. When an inventor conceives of an invention and "diligently" reduces the invention to practice (by filing a patent application, by practicing the invention, etc.), the inventor's date of invention will be the date of conception. Thus, provided an inventor is diligent in actually reducing an application to practice, he or she will be the first inventor and the inventor entitled to a patent, even if another files a patent application, constructively reducing the invention to practice, before the inventor.
However, the first applicant to file has the "prima facie" right to the grant of a patent. Under the first-to-invent system, when two people claim the same invention, the USPTO would conduct an interference proceeding between them to review evidence of conception, reduction to practice and diligence. Interference can be an expensive and time-consuming process.
Canada's change to first-to-file.
Canada changed from FTI to FTF in 1989. One study by researchers at McGill University found that contrary to expectations "the switch failed to stimulate Canadian R&D efforts. Nor did it have any effects on overall patenting. However, the reforms had a small adverse effect on domestic-oriented industries and skewed the ownership structure of patented inventions towards large corporations, away from independent inventors and small businesses." 
USA change to first-inventor-to-file (FITF).
The America Invents Act, signed by Barack Obama on 16 September 2011, switched U.S. right to the patent from a "first-to-invent" system to a "first-inventor-to-file" system for patent applications filed on or after 16 March 2013.
Many legal scholars have commented that such a change would require a constitutional amendment. Article I, Section 8, Clause 8 of the US Constitution gives Congress the power to "promote the Progress of ... useful Arts, by securing for limited Times to ... Inventors the exclusive Right to their respective ... Discoveries.” These scholars argue that this clause specifically prohibits a first-inventor-to-file system because the term "inventor" refers to a person who has created something that has not existed before.
The change has not been short of detractors. For example, the IEEE stated in its submission to the House Judiciary Committee, charged with the study of the Patent Reform Act of 2007, that "We believe that much of the legislation is a disincentive to inventiveness, and stifles new businesses and job growth by threatening the financial rewards available to innovators in U.S. industry. Passage of the current patent reform bill language would only serve to relax the very laws designed to protect American innovators and prevent infringement of their ideas."
Proponents argue that the FITF aligns the U.S. with the rest of the world, according to the original U.S. patent system, and brings more certainty, simplicity and economy to the patent process, all of which allow greater patent participation by startups.