I interpret the question as "I need code to do
- The classic option, the one that you are doomed to use if everything fails, and the way things were before open code repositories, is: just hire / take a BSc student. They would need to implement that thing from scratch using papers / books on the topic as a part of their job / BSc thesis.
- Ask the PI on the project / the corresponding author of the paper, if they would share the code with you. They might not agree. I am sure, other answers will detail on the open access and availability bit, I suspect some internal shenanigans.
Basically asking for code is not the best way to do it in my opinion. You do not want to study the code, you want to do
stuff, right? Then ask about it. There are multiple options.
- "I need your code, because I want to understand how it works / reproduce the results in the paper." That's what the availability thing is for, officially.
- "I want to build upon your code to produce new research results." This is the most favourable version. Mostly implied with it (but it does not hurt to state it explicitly) is: "you get to be a coauthor on the new paper".
- "I want to apply your method to my data and to use the results in my paper." It is a milder version of the above. Some authors are not inclined / not allowed to give the code to anyone. (This behaviour becomes less frequent, for good, but is still present.) Still, they might be interested in a collaboration. A possibility is to give them your data (if you, on your end, are comfortable with it), let them process it, obtain the results. Again, it implies "you get to be a coauthor", as they do work for your new paper.
- "I want to compare your method to mine." It is a valid concern, in most of the cases it produces just a citation of the others' paper.
- "I want to do some statistics / automatic code analysis on your code." That's a citation, I'd say.
I'd say that people are in generic more inclined to provide data or to collaborate on one of the above terms that are more exact and clear than just "let me see your code".
I would assume that the most frequent "fears" that lead to not giving code to other people are: "they might 'steal' it" – i.e., an idea that someone would build upon your code and not acknowledge you; and "legal" limitations, ranging from "I have transferred the copyright to my research unit and they don't share" to "my supervisor said 'no'". (Again, I am not discussing here, how the data availability statement of the publication agrees with those.)