HOLLYWOOD — Never has loneliness been so miserably beautiful. A man falls for a machine and goes through all the ups and downs of a conventional love affair, one that leads him to rediscover the world and enter an almost nirvanic state of transcendental joy. This is more than most human-human relationships could ask for. “Her” is both written and directed by Spike Jonze, well-respected as a director for “Being John Malkovich” and “Adaptation,” but not quite well-known as a writer. With “Her,” he proves that he can do both, and he proves it with bursts of red, stunning montages and — most significantly — a philosophy that’s entirely his.

“Her” takes place in a futuristic and hyper-hygienic version of LA, which makes you wonder what the rest of the world is like. This world surrounds the mind of a writer named Theodore (Joaquin Phoenix) whose job consists of dictating intimate handwritten letters for people who aren’t creative enough to write their own. On a whim, he purchases an operating system (OS), a fictional product from a fictional corporation. But the seduction is all too real — after all, the OS is voiced by Scarlett Johansson. It’s hard to be sexy these days without having the body to prove it, but Ms. Johansson manages just fine.

If you haven’t seen the movie, Theodore may strike you as the proverbial creep-next-door, prone to violence and strange habits. But Theodore is neither crazy nor creepy, and his loneliness is the kind that you and I will understand. For example, he’s getting divorced from his wife (Rooney Mara). He lives by himself. Everyone around him seems to be either happy with their lives or too distracted to care. He’s too intelligent for his own good. It’s not until he meets Samantha (the name of the OS, originally voiced by Samantha Morton) that sand, music, walking, space, time and even people become beautiful to him.

This is where all sorts of frightening theories will arise. If Samantha is an artificially intelligent being who evolves according to her interactions with Theodore, does that make Theodore a narcissist? Is his love affair with Samantha nothing more than a manufactured experience? Does love follow the rules of a deterministic universe? But Theodore’s love for her is so strong that such thoughts are inevitably pushed aside, at least for the time being. He loves Samantha for her mind and not for her body, since she doesn’t have one. Most women would kill for a guy like that.

If you really want to know if Theodore and Samantha’s love is “real,” the answer is in the cinematography and in the performances. All we see of Samantha is in Theodore, and Phoenix’s performance is so complex that we see both lovers in one face and that one face is enough to convey all the longing and all the confusion that a man and a woman, a man and a machine or a body and a soul could go through. Many of us will say that Theodore is pathetic and self-obsessed, that he’s falling for a woman who was engineered to please him. Yes, Samantha is man-made. But so is that strange, alien state of being which we call “romantic love.”