Between two hackers, the question is silly. If the code works we'll use it, and if not, we won't. This worked just fine until software escaped the universities and was commercialized. Commercialization of software brought money and law into the picture, and it is law that answers this question. Specifically, it is intellectual property law, the branch of law that deals with the property rights of ideas and their creators, that both asks and answers this question.
In the USA (and many other countries) today, all publications are automatically copyright the author, with all rights reserved, unless other arrangements are made and declared. When a work's copyright expires it passes into the Public Domain and loses all protection under copyright law. Bluntly put, when your great American novel (say) becomes public domain, you no longer have any say in who publishes it, on derivative works, edits, or re-publication with no mention of your contribution. This does not happen quickly, and under current USA law could take at least seventy (70) years.
Software and source code is subject to copyright law, but software is more like music than books. In fact sheet music and source code have been treated similarly by the law. To grant someone the right, defensible by law, to use your composition (source code) in their own creative works (projects) you have to license the music (code) to them. A license is a specific kind of contract which grants some rights and reserves others to the creator or publisher. All software in common use is licensed to the user, but the licenses vary quite a bit. For example, the license for Microsoft Windows 2000 Professional says, in part, that for your $150 USD you are granted the right to install and use the software on one machine, and to make a backup of te installation media. Further use or installation would require purchasing an additional license, and redistribution is prohibited. The license for FreeBSD states, in part, that you can install and use the software on as many machines as you like, change the software, and redistribute the software with (or without) your changes, as long as you preserve the copyright statement and authorship information. The license for the Linux kernel is somewhat more complicated. It says, in summary, that you can do whatever you like with the software, including changing and redistributing it, as long as you include the original version (or link to it) and that anyone who you distribute or license the software to maintains these same rights.
To protect the freedom of the software, and to maintain the author's credit for their work, even freely distributed (Free, OSS) software must have a license, and a license is a contract between two parties. It is for this reason that the original author of a piece of software may become important, at least in court. Hackers, on the other hand, would probably be happier just to know who to credit (and blame), as well as where to send patches and bug reports.