NEW YORK -- The Google engineer who blamed biological differences for the paucity of women in tech had every right to express his views. And Google likely had every right to fire him, workplace experts and lawyers say.

Special circumstances -- from the country's divisive political climate to Silicon Valley's broader problem with gender equity -- contributed to the outrage and subsequent firing. But the fallout should still serve as a warning to anyone in any industry expressing unpopular, fiery viewpoints.

"Anyone who makes a statement like this and expects to stick around ... is foolish," said David Lewis, CEO of Operations Inc., a human resources consulting firm.

WHY HE LOST HIS JOB

The engineer, James Damore, wrote a memo criticizing Google for pushing mentoring and diversity programs and for "alienating conservatives." The parts that drew the most outrage made such assertions as women "prefer jobs in social and artistic areas" and have a "lower stress tolerance" and "harder time" leading, while more men "may like coding because it requires systemizing."

Google's code of conduct says workers "are expected to do their utmost to create a workplace culture that is free of harassment, intimidation, bias, and unlawful discrimination." Google's CEO, Sundar Picahi, said Damore violated this code.

Yonatan Zunger, who recently left Google as a senior engineer, wrote in a Medium post that he would have had no choice but to fire Damore had he been his supervisor.

"Do you understand that at this point, I could not in good conscience assign anyone to work with you?" he wrote . "I certainly couldn't assign any women to deal with this, a good number of the people you might have to work with may simply punch you in the face."

Though one might argue for a right to free speech, however unpopular, such protections are generally limited to government and other public employees -- and to unionized workers with rights to disciplinary hearings before any firing.

Broader protections are granted to comments about workplace conditions. Damore argues in a federal labour complaint that this applies to his case, but experts disagree.

"By posting that memo, he forfeited his job," said Jennifer Lee Magas, public relations professor at Pace University and a former employment law attorney. "He was fired for his words, but also for being daft enough to post these thoughts on an open workplace forum, where he was sure to be met with backlash and to offend his colleagues -- male and female alike."

UNIQUELY GOOGLE

The fallout comes as Silicon Valley faces a watershed moment over gender and ethnic diversity.

Blamed for years for not hiring enough women and minorities -- and not welcoming them once they are hired -- tech companies such as Google, Facebook and Uber have promised big changes. These have included diversity and mentoring programs and coding classes for groups underrepresented among the companies' technical and leadership staff. Many tech companies also pledge to interview, though not necessarily hire, minority candidates.

These are the sorts of things Damore's memo railed against.

As such, experts say Damore might not have been fired at a company that doesn't have such a clear message on diversity.

In addition, had Damore worked for a smaller, lesser-known company, an internal memo might not have created such a "media storm," said Aimee Delaney, a Hinshaw & Culbertson attorney who represents companies on labour matters.

A DIFFERENT WORLD

Still, bringing so much public, negative attention would spell trouble for any worker. That's especially so in this age of fast-spreading social media posts, when internal company documents can easily leak and go viral.

It didn't help that this was in the heart of Silicon Valley, where typing fingers are on 24/7 and people rarely disconnect from social media, even on a quiet August weekend. Or that Google is a brand consumers interact with all day -- and want to read about when memos go viral.

Perhaps the biggest lesson is this: Don't be so quick to post your angry thoughts for thousands, then millions, to see.

Michael Schmidt, vice chairman of labour and employment at the Cozen O'Connor law firm, said that while workers might have refrained from such remarks around the physical watercooler, "people treat ... electronic communications much more informally than face-to-face speech."

But the consequences are similar, if not more severe.

EXPLOSIVE CLIMATE

Initially shared on an internal Google network, the memo leaked out to the public over the weekend, first in bits and pieces and then in its 10-page entirety.

It took a life of its own as outsiders weighed in. WikiLeaks founder Julian Assange took to Twitter to offer Damore a job. One conservative group, Americans for Limited Government, criticized what it called Google's politically correct culture and left-wing bias. Others called for a Google boycott.

Known for its motto, "don't be evil," Google is broadly seen as a liberal-leaning company, something Damore criticized in his manifesto. Liberals and tech industry leaders came to Google's defence and denounced Damore's claims as baseless and harmful.

"It's fair to say that whatever side of the political aisle you are on, ... we are in a climate where we are dealing with very highly charged and emotional issues," Schmidt said. "And those issues are spilling into the workplace."

Instead of looking for a bright-line test on what is permissible, he said, "both sides need to understand there has to be a sensitivity to the bigger picture," a level of respect and cultural sensitivity across all demographics.