Sweet, Sweet Copypasta
Posted: 08 Mar 2008, 11:38
Anonymous wrote: "What's declarative programming?" she asked sweetly.
"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, 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 expressions. In SQL you can ask about relationships between data. With a program like bison you can use declarative programming to describe a language, letting bison generate something 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 silently began caressing her breasts.
She took this 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 gently fondling her breasts.
"What?" She asked, suddenly nervous.
"Um..." he said, "it's not quite like that." His hand 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 hand from her breast.
"Wait, baby, it's not so bad!" He begged.
"I'm listening." She said, looking him in the eye.
"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 an open window.
"My Stetson!" He shrieked, standing quickly. The spurs on his cowboy boots jangled feebly. "But baby, didn't that bison parser generator thing sound cool?" He pleaded.
She stopped. "Well... yeah, that was pretty neat..." she begrudgingly acknowledged, softening for a moment.
"And that doesn't use a brute force algorithm. It builds an automata 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 suddenly ringing with betrayal.
Her words were damming. Nothing he could say would placate her. He stood in embarrassed silence, eyeing his cowboy hat nervously.
She turned away from him, her emotions halfway between 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 through the night, lofted on the cool air as if by the breath of angels.