How to ask for code from authors who have proposed algorithms in computer science? I am developing an algorithm, and I want to compare its performance with various existing state-of-the art methods. I would like to contact the authors of these methods and ask if they can send me the code for their methods.

What should I tell them? Should I say that I am developing a method that is in some way an alternative to their method? Or is enough to ask to say that I want to do generic comparisons?
Tell them what you told us. You are working on a different algorithm and implementation for the same problem and you'd like to compare to the state of the art. You've read their papers (cite them), and you'd like to see if their code is available for cross-comparison. 

If they don't make theirs available, you may have to reimplement their algorithm in your code as well. This latter case is pretty common. There's a chance you might not do this as well as them, so there's some incentive for them to give you their code to get a proper comparison done.