Can I request the code behind a research paper from the author?
Ask for the code. Please do, however, explain why you want it and what you intend to use it for.
Personally, I would be quite happy if someone contacted me about my research, and would try to give all the necessary tools to recreate my data. Especially so if I am not currently working on a follow up piece.
That said, I've asked for parameters, codes, procedures etc. several times from the authors when the description in a paper has been vague. I've had a lot of different responses: Some have plain ignored me, others have given me everything I asked for, and yet others have only obliged when I've suggested that I might be willing to put them as co-authors if I built upon their code in a way that leads to a publication. Finally, some have refused my request. This has happened for a number of reasons, for example those discussed in this question.
If you ask for code and say that you just want to verify some of the conclusions of the authors or use it as a reference for your own implementation, you can most typically expect a refusal or no reply. This, at least, is the experience I've had.
Yes, it is fine to ask. From my experience, not many researchers share their code. Sometimes the reason is that the authors are afraid that you will write a better algorithm or that you will extend their work before them. Some other reasons may be that the software has no documentation and they don't have time to prepare some documention, is not written in english, or has dependency to commercial software or software that belong to other authors. However, there is a lot of reasons for sharing the code. It gives more visibility to your work, helps other researchers so that they don't need to reimplement your work, allows for a more fair comparison when comparing algorithms, etc.
Personnally, I have asked the source code or datasets of other authors several times. If they don't want to share, they usually just don't reply to the e-mail, or they may say no. But there is no consequence to asking. So just ask. Besides, sometimes the authors will not provide the source code or datasets but often they can still give you the binary files. In that case, it can still be useful.
Personally, I share the source code and datasets of all my research papers as first author as part of an open-source data mining library ( http://www.philippe-fournier-viger.com/spmf/ )and I believe that all authors should also share source code and datasets. Here is a blog post where I explain in more details why it is important to do so: http://data-mining.philippe-fournier-viger.com/why-it-is-important-to-publish-source-code-and-datasets-for-researchers/
I think it is perfectly fine, and I encourage asking for the code. I actually support the position that any published results based on software are worth next to nothing if the authors are not willing to publish the source code along with them. If they have not already done so when publishing their paper, I find it their moral obligation to do so as soon as possible or at least upon request. If the reason for authors not publishing their source code is that they do not fully trust their own software, then the results should not have been published at all. Why should anyone trust your results if you are not willing to defend the way you produced them?