Su-57 30mm canon
The cannon of a fighter aircraft has two main purposes, the first is to use it for close-range air combat, and the cannon has a very high degree of performance compared to missiles in a close range dogfight scenario. The second use of the cannon is to attack ground targets when necessary.
In the early days of military aviation, all kinds of cannons and machine guns were installed on all types of aircrafts, whether it is a fighter, bomber, attack aircraft, etc. In the most common ground strike missions a large burst of shells can achieve the devastating effects equivalent to a precision-guided bomb.
Therefore, the reason behind most of the modern warplanes cancelling the aircraft cannon is quite simple! In modern era air superiority fighters does not need to perform ground attack missions, that role has been taken by attack helicopters and ground attack aircrafts such as the famous A-10 Warthog and Su-25 Frogfoot. Plus modern air supremacy fighters uses air to ground missiles to attack ground targets, as they are more helpful as compared to cannon in terms of accuracy, also missiles are able to attack from very long distances. As a result, the cannon became a burden on the aircraft, which ultimately increases the complexity and maintenance costs of the aircraft.
One of the first aircraft which removed its internally mounted cannon was the famous F-4, and the British Lightning jet, although at that time the performance of air to air missiles was very limited. However, in the right environment, air-to-air missiles have relatively high hit accuracy. So it can be said clearly that, if the performance of the fighters air-to-air missiles is good enough, then there is really no need to install cannons for close combat.
Some 3rd and 4th generation fighters which still carry cannons, are all equipped with cannons which are able to fire rounds at a very high rate of fire. For example we have already mentioned the American M61 Vulcan 20 mm cannon which is in service since the 1960s. This cannon has extremely high rate of fire of 6,000 rounds-per-minute. The Russians and Chinese uses single-barreled 30mm cannons and dual 23 cannons on their jets respectively. Some 4th generation fighters which uses cannons specifically for close combat are F-16, F-15, Su-27 and J-10. Since these aircrafts are designed for air dominance the cannon is very important for them.
But the problem here is that in the large number of wars that American fourth-generation fighter jets and Russian fourth-generation fighter jets have participated in, the proportion of enemy air targets shot down with cannons is far less than that of air-to-air missiles. It should be known that the air-to-air missiles developed in the 1990s used by these fighters already have very good comprehensive performance, especially the Soviet and Russian fighters were even using air-to-air missiles such as R-73, which can almost kill in one hit.
In the late 1990s era, air-to-air missiles were developed in full speed with several different technologies. In addition to the increase in reliability, the missiles also started using infrared imaging guidance, and the missiles anti-jamming capability was also significantly enhanced.
The advanced air-to-air missiles such as AIM-9 were also equipped with thrust vectoring engine, infrared imaging plus this new engine has become the standard for close-range combats. Even a highly maneuverable fighter can’t get rid of this highly maneuverable monster.
During the development of the Advanced Tactical Fighter Project, or the F-22 Raptor, the United States Air Force has added a cannon into the aircraft. The aircraft is fitted with a 20 mm M61A2 Vulcan rotary cannon, along with 480 rounds of ammunition. The cannon on the F-22 may greatly help the aircraft in case of a very close range dogfight with enemy fighters. Although the F-22 was developed with the goal of producing a pure Air Superiority Fighter, but the aircraft also got limited ground-attack capabilities. So although the F-22 is a air dominance fighter, but maybe according to battlefield situation it may have to attack ground targets such as enemy armoured vehicles, etc, so the cannon will be helpful in this case.
Now in the case of the F-35 Lightning II, only one variant of this advanced fighter has got a internally mounted cannon, and that is the F-35A, the airforce version of the aircraft. The jet is equipped with a 25 mm GAU-22/A rotary cannon mounted internally near the left wing root with 182 rounds. This gun is much more effective and accurate against ground targets as compared to the 20mm gun used by other USAF fighters. The F-35C and the F-35B has got no internal gun, but if required or according to their mission profile they can carry an externally mounted gun pod mounted on the centerline of the aircraft.
Now talking about the Russian Sukhoi Su-57, this 5th-generation stealth fighter is also equipped with a cannon, it uses a 30 mm Gryazev-Shipunov GSh-30-1 autocannon.
Now the exceptional cases in the 5th-generation aircrafts list are two Chinese aircraft, J-20 and J-31, both of these two Chinese 5th-generation stealth fighters does not carry any type of internally or externally mounted cannons. It seems like China is very much confident on the probability to kill ratio of the air to air missiles carried by these two jets, the PL-10 and PL-15. Also, according to china the total weight of adding a cannon into the aircraft and weight of the rounds carried along exceeds more than 100 kilograms, so removing the cannon makes good space for additional air-to-air missiles to be carried plus also increases the aircraft operational range.
So overall we can say that although some fighters still carry the cannon, while some do not. But after having a deep review of the design of the next generation or 6th generation fighter aircrafts, it seems like the next generation jets will not make use of the cannon. The role of the next generation jets looks quite similar to the MiG-31 long range interceptor, so the 6th generation jets will make use of their extremely high speed and capability to operate at very high altitudes coupled with more advanced air-to-air missiles or laser weapons to shoot down enemy aircrafts. So we can say that the cannon age is going to be extinct soon.