My incredulity is not because I think it's easy to write reliable software, but because a cannon shouldn't need more than "if button then fire." From the other reply, apparently it's way more complex than that though.
Additional complexity comes from the F-35's Stores Management System (SMS). In addition to the basic accounting tasks of keeping track of what kinds of weapons are loaded, and on which stations, the SMS keeps track of how much the stores at each station weigh and provides that information to the flight control system (FLCS). FLCS can then compensate for the weight distribution of the stores. The gun must integrate with the SMS.