Declarative Programming
fiction

"Well," he began, moving closer to her, "declarative programming is when you tell the computer what you want, and then the computer figures out how to get it. Pretty sweet, huh?"

"What kinds of things can you tell the computer you want?" she asked excitedly, her cheeks beginning to flush.

He thought for a moment, and began stroking her hair gently. "All kinds of things. There's a language called Prolog you can use to ask about logical relationships. In SQL you can ask questions about huge quantities of data. With a program like bison you can declaratively describe a language, letting bison generate a program that recognizes it."

"Oh," she said breathlessly, leaning her head on his shoulder, "so I don't have to worry about choosing an algorithm--the computer will pick one for me?"

He began caressing her breasts.

She took his silence as an affirmation. "That's so cool that it just does it--it must be really smart to pick the right algorithm!" she enthused.

"Well..." he trailed off, still fondling her breasts.

"What?" She asked, nervously.

"Um..." he said, "it's not quite like that." His hands stopped moving.

She sensed he was backpedaling. "Well?" she demanded.

He laughed awkwardly. "Heh... You see, most declarative programming systems only know about one algori--"

"It must be a great algorithm!" She interrupted, with renewed intellectual arousal. "What is it?"

He hesitated for as long as he could... "Brute force search," he said, guiltily.

"What the fuck!?!?" She yelled, straightening and yanking his hands from her chest.

"Wait, baby, it's not so bad!" He begged.

"I'm listening." She said, staring him straight in the eyes.

"Well, if you're careful and you program in an idiomatic way, you ca--"

A venomous glare silenced him mid-sentence. She stood suddenly, grabbing his hat from the night stand and moving towards the open window.

"My Stetson!" He shrieked, jumping to his feet, the spurs on his cowboy boots jangling feebly. "But baby, didn't that parser generator thing sound cool?" He pleaded.

She stopped. "Well... yeah, that was pretty neat..." she begrudgingly acknowledged, softening.

"And that doesn't use a brute force algorithm. It builds an automaton for you, an LR parser," he said.

She smiled to herself, seeming to relent momentarily. He could see that she was touched by the idea of a program that could understand other programs.

"See, declarative programming isn't all bad..." he cajoled, slowly walking towards her, palms outstretched.

She started, as if waking from a dream. She looked at him. "But what about in the case of an ambiguous grammar, for which an LR parser won't suffice?"

"Don't worry," he said, smiling, "bison can use a technique called generalized LR parsing, which allows it to follow all possible parses simultaneously, eventually finding a successful parse."

She thought for a moment. "But if we're following all possible paths simultaneously and discarding the ones which don't lead to successful parses, isn't that just brute force search?!?" She asked, her voice ringing with betrayal.

Her words were damning. Nothing he could say would placate her. He stood in embarrassed silence, eyeing his cowboy hat anxiously.

She turned away from him, her emotions a mixture of pity and rage. He moved towards her, reaching for her hands, but it was too late. She had already hurled his hat from the window, as hard as she could. They watched silently as it flew into the night, lofted through the cool air as if by the breath of angels.