Strong and frequent participation, interaction and enthusiasm for the subject in class should get you a "good" letter--or at least more than the "She got an A in my compilers class" letter.
You need to do this because you are competing with other students that do this.
What I find upsetting is that so many students have no idea what their competition is up to. And, by the time they find out, it's way too late.
When I read grad school admissions packets, I'm blown away by what some undergraduates have done.
That's one of the reasons I wrote this blog post -- to take the blinders off. Hopefully it reaches some freshman, sophomores and juniors in college and a few high school students too.
During my second year, I also approached another professor in the dept who was a MacArthur Fellow and asked the same thing, and ended up helping him transcribe and code a bunch of interviews he had done. Wasn't the sexiest work I've ever done, but voila, at the end of three years, I had one very strong letter of rec from one professor (well published), who also reached out through his network to put in a good word for me at CMU, and another rec from a professor who was a MacArthur Fellow.
Granted, I think something that's really cool about my undergrad (UCSD) and department (Cognitive Science) is that they are very open to undergrads helping out in research capacities, but it doesn't seem like something that is out of the reach of most self starting undergrads.