Oh God yes.
Historically, Gunslingers were the rough-and-tumble frontier men of the Old West, where, armed with the two most famous guns ever made, the Colt revolver and the Winchester rifle, they fought the natives, the animals, and one another in the name of Humanity Fuck Yeah.
Culturally, the gunslinger was the American equivalent of the European knight-errant, with many an old story of their wandering from place to place righting wrongs and shooting bandits. One famous aspect of these stories is the quick-draw duel, where two men stand in the street at high noon (when everyone knows to get out of the way and the sun is in neither of their eyes), and stare each other down, each waiting for the other to draw first so that he will have the benefit of arguing "self-defense" in court after the duel is over. In most, but not every case, the villain draws first, but the hero is faster than him and kills him.
Just like the medieval knight underwent a series of anti-heroic revisions recently, the cultural myths around the Gunslingers of the Old West have been reexamined in a number of realistic Westerns that paint them in a more morally-ambiguous light.
Because of the usual problem, for years the closest thing the D&D family had to a playable Gunslinger class were the gunfighting Paladins of Murlynd who resembled sheriffs from these Westerns, and whose holy text was basically a pulp novel of his exploits. In 3rd Edition, this amounted to a single feat buried in an issue of Dragon Magazine.
5th Edition has sought to resolve this lengthy injustice by introducing Gunslingers as a sub-class of Artificer. They're quarter-casters, like the Fighter and Rogue spellcasting archetypes, that get a semi-magical "thunder-cannon" that only they can use, and which takes an action to fire and a bonus action to reload. While this obviously restricts them to one shot per round, the base shot has the damage-progression of the Rogue's sneak attack, and they learn to fire other shots with various effects (blast, cone, etc.) as they level up. They also have the tools needed to recreated their weapon if it's destroyed, and a wonky ammunition bag that doesn't technically give them as many bullets as they want in theory, but definitely does in practice since they're almost certainly not going to fire more shots than they can produce in a given long rest.
Unfortunately, the thunder cannon was removed with the March 2019 Unearthed Arcana, but instead the new Artificer (now renamed Artillerist) has the means to create a turret buddy by sacrificing spell slots (as well as one free one each day). This turret, while incapable of scaling in damage, can either be a flamethrower, a force-damage ballista, or a healing station. You can also create wands with this subclass, though it's only usable by you and it lets you add your Intelligence Modifier to the damage of one cantrip.
Pathfinder actually had the balls to add the Gunslinger as a character class in a world of knights and swords, because fuck medieval stasis; in canon, it's because there's an entire region that's just a massive anti-magic zone so they needed something to defend themselves. They're built on the "Fighter" template, so they get lots of hitpoints and lots of feats, and they enjoy a resource pool called grit that they can use for various effects. Grit is actually regenerated by doing badass deeds of derring-do as much as by rest, so shooting out chandeliers, challenging villains to quick-draw duels, and leaping sideways through the air while firing are all heartily encouraged.
More than perhaps any other class, Gunslingers benefit from Pathfinder's "archetype" system. One Gunslinger class feature basically lets the character pick a gun off a rack to start the game with, since otherwise you'd have to spend more money than the entire party probably has at character creation to buy a single weapon, let alone ammunition; sticking with one type of gun and picking an archetype to go with it is very advantageous. Musket Masters get lots of free reloading powers, Pistoleros get sneak-attack-style extra precision damage, Siege Gunners get to be cannon fighters, etc. Note that there is only one "good" way to do a dual pistol build ("Gun Twirling," which is super feat-heavy), outside of weird stuff (being a member of the four-armed kasatha race, multi-classing to either witch or alchemist long enough to pick up an extra limb, picking the bard archetype for juggling weapons, etc.), so it's tricky to do.
Your firearm is your friend and your bosom buddy. You won't be starting out with a multi-shot firearm for balance, and getting one later is pretty iffy, so making reloading as quick and easy as possible is absolutely paramount. Take the Rapid Reload feat if your archetype doesn't already come with one, and take at least one rank in the Craft: Alchemy skill to make alchemical ammunition at half-cost with no crafting roll. Alchemical ammunition, even when it doesn't have any special powers, further reduces the time necessary to reload a weapon. Getting it down to a free action by the time you can take multiple shots per round is important. Also, when you inevitably roll a critical fumble and your gun breaks, don't be stingy with your grit. Doing a quick clear may cost you time later, but it will save your goddamn life now, whereas having your weapon explode will basically kill you even if you survive it.
They also manage to sidestep most MAD problems, since, although they need more WIS than the average fighter-derivative for grit points, they need less STR if they aren't lugging around an artillery piece. And even then, there's a dirt cheap magic item called Muleback Cords that can easily get around that problem. And at fifth level, they start adding their Dex to damage with their guns, essentially making them actual fighters, complete with their own version of Power Attack (Deadly Aim).
Gunslingers aren't really overpowered, since their abilities basically begin and end at pointing guns at bad things to make them dead; they have to stay uncomfortably close for their ranged features to actually matter, and their whole shtick can be shut down in a hurry if the enemy spellcaster summons cover or manages to get their gun wet. That said, they do need to be played against very differently from many other martial classes, so DEFINITELY clear this class with your GM/DM before you roll one. Misfiring is also a perpetual bane, and if you aren't always prepared for it, you will most likely die.
Most of the listed problems can be easily fixed with cheap wondrous items and weapon enchantments (+1 distance on your musket will double the range to 80 feet), and combat feats like Cluster Shots and Improved Precise Shot remove the problem of DR and Cover. Also, Alchemical Cartridges can't get wet, and even if the GM is smart enough to cast water on your musket (and you lack any Dry Load cartridges), just ask a caster to cast Prestidigitation (lvl 0 spell) on your gun and it will be dry in less than a standard action. Or, if you're willing to get really pulpy "science-fantasy", try and score yourself some of the technological guns from Numeria; any gun works for a gunslinger, whether it's a blackpowder musket or an ancient alien laser pistol. And for those wanting to go ham on this angle, there's the Techslinger archetype from the Technology Guide.
The issue with this is, of course, dependent on the setting and feats in particular. In general, a lot of DMs just aren't happy with the changes having gunslingers around would necessitate in their settings, and it is their game, after all. Paizo has ported some of the 'slinger's class features into other class variants in some of their new material, and the "Bolt Ace" archetype basically ports most of their cool stuff into crossbows, so if the mechanics sound interesting to you but the DM is unwilling, take a look.
In the end, Gunslingers are tier 5 at lower levels or tier 4 at higher. They can throw out a lot of damage, but at lower levels they struggle to do it consistently. While good at this, base Gunslingers can't do anything else very well, although with some clever skill points, and use of their heavier CHA focus the Mysterious Stranger can take up the place of a Party Face, and the Blast Lock deed can be used to bypass locks (However the subtlety of such a tactic leaves a lot to be desired), so there are some ways to make an "infiltrator" Slinger. They also have a pretty good skill list and a decent number of skill points, so they edge out the fighter in that regard.
Come Heroes of Golarion, any ranged Gish that wants to be is a better Gunslinger than an actual gunslinger thanks to the feat Spell Cartridges. In exchange for a swift action each turn to use Arcane Strike and slightly less damage (1d4 per 5 caster levels) your firearm is semi-automatic, requires no ammo and deals force damage (which is almost never subject to Damage Reduction or Energy Resistance so your damage is almost certainly higher in actual practice).
|The Classes of Pathfinder|
|Core Classes:|| Barbarian - Bard - Cleric - Druid - Fighter - Monk |
Paladin - Ranger - Rogue - Sorcerer - Wizard
| Alchemist - Antipaladin - Cavalier |
Inquisitor - Oracle - Summoner - Witch
| Arcanist - Bloodrager - Brawler - Hunter - Investigator |
Shaman - Skald - Slayer - Swashbuckler - Warpriest
| Kineticist - Medium - Mesmerist |
Occultist - Psychic - Spiritualist
|Ultimate X:||Gunslinger - Magus - Ninja - Samurai - Shifter - Vigilante|