The hardboiled detective, i.e., that cynical, grimy tough guy who acknowledges the corruption of the world he lives in and strives to overcome it, is an existentialist figure, although he would scoff at the idea that he is the embodiment of the work of early twentieth-century egg-headed European philosophers and other intellectual heavyweights.
Existentialism begins with the idea that human life is essentially meaningless, even absurd, and without inherent value or purpose. Existentialists see the world as naturally corrupt, violent, and chaotic.
Sounds pretty bleak, doesn't it? I mean, in a dark, corrupt, violent world that is devoid of any order or purpose, why go on? What's the point? Might as well give up, right?
Not so fast, there, Sunshine! Existentialist philosophers declare that the individual human, having no assigned or divine purpose, is free to create his own meaning and reason for existing. Starting at a point of existential angst, where the individual realizes that existence is a purely random event rather than the result of any sort of plan, divine or otherwise, the individual refuses to be overwhelmed by the inherent meaningless of existence, but rather accepts responsibility for carving out his own purpose for existing. The individual accepts the world for what it is, but strives to overcome the darkness and shine a little light, knowing that failure is likely, maybe even inevitable, but trying anyway because it is the striving that makes him human.
And that brings us to our dogged hardboiled hero. Surrounded by injustice and immorality, jaded cops and corrupt city officials, slimy blackmailers and scheming femme fatales, and mayhem, mystery, and murder around every corner, the stalwart loner with the steely eyes and the iron jaw keeps plowing forward, searching for answers and struggling to plant a tiny seed of order in the chaos. Will he solve the mystery? Probably. Will the results bring him satisfaction? Probably not much, if any. He might not even get paid. He probably won't get the girl, who was only playing him anyway. And along the way, he'll probably get shot at, beat up, and scorned by pompous elitists as a dirty little man in a world that has no use for him.
So why does he do it? Because that's who he is. It's his self-imposed reason for existing. He dedicates himself to his purpose, striving not for money or love, but for professionalism.
He'll spend most of his life in his own company, drinking alone and too much, pondering the irrationality of human existence, and questioning his own motivations. And then another desperate client will walk into his office with another sad story and no money. He'll knock back the last of his drink, pick up his gun, and step out into the dark mean streets that he's come to know so well, seeking something he knows he'll never find, content to continue the search.
Note: Please excuse the lack of variety in my pronouns. I blame the limitations of the English language, and I mean no disrespect to anybody. Our hardboiled hero can as easily be any one of the forty-plus genders gaining recognition these days, but until we get an acceptable universal pronoun, I'm sticking with the traditional ones, strictly for convenience.