I write military sf and read and watch a lot of the same. Blood, guts, and swearing abound. If you want good reads try John Scalzi and W.E.B. Griffin (pronounced "Web" Griffin), David Weber (the "Great One" in my opinion - this has nothing to do with his stature by the way), and Orson Scott Card. Card's Ender's Game is required reading, at least it should be. Frank Herbert is a must too. Dune made me fall for sf all over again.
Language is a regular trope in military sf. Think Gunny Hartman in Full Metal Jacket. Or the DI in Scalzi's Old Man's War. By the way, Scalzi can string colorful metaphors like a poet - I've never laughed or blushed so hard as I did in the first half of OMW.
If I tell you a character "swears like a sailor" I bet you know exactly what I mean. Thank Hollywood and reams of pulp for that. And ex-military like my late grandfather, God rest his soul. Chief Petty Officer Bill Coates was a sinner in his early years, and an unvarnished saint in midlife and retirement after a "come to Jesus meeting." Jesus came in, kicked the hell out of him, and never did leave. But grandpa kept some of his rough edges. I remember sitting with him in his den, and something on the news would spark one of his songs like "No More Navy, Gee Mom I Wanna Go Home" - which was actually pretty tame now that I think about it - and my mother would clear her throat as he reached the salty part in the song. "Ah, mom, come on." Grandpa always did an about-face in front of her, charged head on when it was just the two of us. Those were the days. Sure which he and his songs were still with us too.
As a writer, I'm mindful of characters and caricatures like Gunny Hartman. He's one type of soldier but he isn't every soldier or even every gunny. And I question how realistic his character is. I should state here that I've never served so I have to go on what I read about and hear and see, including my interviews with women and men in uniform. Are there counterparts to the foul-mouthed Gunny Hartmans of the world? You know, the ones who aren't. Foul-mouthed. Really? Well, yeah, I know some, and maybe they are more common than we realize. Maybe more so than a lot of us realize. My parents lived by a retired Marine Corps gunny for years. To paraphrase a conversation they relayed to me, the gunny said he took pleasure, and sometimes displeasure, in dressing down a lot of privates in his career. But he was always mindful about how he did it, and if he had to use a four-letter word to get his point across then he wasn't very good at his job. Really? If he had to swear he wasn't very good at his job? That's interesting...and it contradicts about every stereotype of a gunnery sergeant I can think of, right? Maybe, but maybe not. I know another retired Marine Corps gunny who isn't exactly straight-laced, but his mouth isn't an off-color fusillade either. He doesn't say a lot but what he says is weighty...and people listen...and he has an excellent command of the English language. I know a retired Army "Light" Colonel the size of a tank who is careful with his words and his life. He's an imposing man and only a fool would cross him. But he made a conscious decision years ago to watch his language. There's a retired Navy commander and a retired Air Force "Light" Colonel who made similar decisions during their careers too.
Living in a military town you meet a lot of military guys and gals. I've had the chance to get to know some better than others, and I've learned that some swear and some try not to, others just don't. Period. They will all tell you that stress and swearing tend to go hand-in-hand. Combat stress unleashes the tongue. It's just human nature. Go smash your thumb with a hammer and you'll get a small taste of what I mean. But, day-to-day, a lot of sailors and airmen and soldiers and Marines are as straight-laced as a boot.
Which brings me to my point. Hollywood doesn't always get it right. Authors don't always get it right. "Civvies" like me don't always get it right either. The military isn't a homogenous group of foul-mouthed war-fighters. The truth is a lot of us aren't in the military and don't know someone who is all that well. We are informed by the opinion of others, and those opinions are only types and shadows of a larger truth. Don't get me wrong. I don't doubt there are foul-mouthed sailors and Marines who are foul-mouthed all the time, and gunny's that can drop the f-bomb one hundred ways. And I'm sure their are many shades of grey. Soldiers who swear a bit, some a bit more, and some a lot but never around their mothers. But there's also a cadre of women and men who are as careful with their words as they are with the people under their command. And as a writer I feel a great burden to remember and respect and represent them in my stories too.