TWO men, both in technological fields, were in the news last week because of their homosexuality. The first was Tim Cook of Apple, whose coming-out essay in Bloomberg Businessweek made headlines because it established him as the first openly gay C.E.O. of a Fortune 500 company. The announcement generated considerable optimism that with his influence and visibility he would be a force for far-reaching advocacy in years to come.

The second man, an unidentified 32-year-old engineer for the Indian software company Infosys, faces a much bleaker future. Distraught over his lack of sexual interest in her, his wife secretly videotaped him having sex with another man at home in her absence. She took the footage to the police, who arrested him under Section 377 of India’s penal code. This law, recently reinstated by the Indian Supreme Court after a four-year hiatus during which it was invalidated by a lower court, makes homosexual conduct punishable by prison — up to a life sentence. The story of the so-called Bangalore Techie, broadcast in full sensationalist mode by the Indian press, has evoked reactions in the country from sympathy to ridicule.

Both men’s experiences make a strong case for attitudes and policies that respect individual freedoms. Born in Alabama, Mr. Cook writes about rising above “adversity and bigotry” and developing “the skin of a rhinoceros.” As someone who also chose a gradual coming-out process, I can attest to the countless calculations needed along the way: whom to trust, what to disclose, how much to risk, and the hours wasted over such anxieties. Not to mention the opinions suppressed, the artistic interests concealed, the personality traits reined in, so as not to appear too unconventional. This seems especially important in technical fields where people wear their 24/7 commitment to their subject as a macho emblem, and any deviation from the prevailing culture (be it engineering or even mathematics) can be construed as a sign of weakness.

Clearly, Mr. Cook’s journey has taught him about these costs. He described Apple as “a company that loves creativity and innovation and knows it can only flourish when you embrace people’s differences.”