Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have this portfolio website containing some personal projects/algorithm implementations. I want to get attribution if and when other people use my code or snippets of it. I initially thought of using Creative Commons but, as CC itself points out, CC doesn't fit well with software/code distributions. I would've used CC0 but CC0 does not enforce attribution.

So, is there a way for me to enforce attribution on my code ala CC? Including a copy of a FOSS license with every code distribution I have seems overkill---the license itself might be longer than some of my codes. Will copyright claims on top of source codes work if I say there that attribution is required?

share|improve this question
If you want to allow usage under certain terms, you gotta specify these terms. And it takes some lines to state these terms unambiguously. Besides that, if your code is shorter than the 14 lines of MIT (the shortest widely-used one I'm aware of, but 2-clause BSD is still 25 lines) is it even original enough to pass the threshold of originality, much less be worth attribution? – delnan Dec 29 '11 at 9:01
@delnan "If you want to allow usage under certain terms, you gotta specify these terms." Sorry if I sound so newbie but are you saying that all I need is to specify my terms and people who use my code will have to respect it (so long as it is reasonable, of course)? Also, thanks for mentioning the MIT and BSD licenses---I didn't know they're that short. – occlean Dec 29 '11 at 9:15
As you can read in various other questions here, the default is fully copyright with "all rights reserved" (if copyright applies at all). Every right you grant beyond what's allowed by default (very little, and even that may depend on which country you're in) has to be granted and communicated somehow. And for strangers you never meet, putting it in the source code is by far most reliable for everyone. – delnan Dec 29 '11 at 9:36
up vote 5 down vote accepted

Don’t include a copy of the license then, just name it, and as a curtesy, provide a link. For instance:

// This code is licensed under the BSD license.
// The license text can be found at

This should be fine.

If it’s particularly important to you, separately mention that you’d like attribution for usage of the code.

share|improve this answer
Thanks. I think I'll do just that. – occlean Dec 29 '11 at 13:50
The only issue with this is if the link becomes invalid at some point in the future. – Bernard Dec 29 '11 at 16:35
@Bernard, I've thought of a workaround to that though it may be specific to my case: Since I'm making a portfolio website, why not host a copy of the license on my own server? I'll just indicate the "mirror link" in my code. – occlean Dec 29 '11 at 16:56
@occlean: Not a bad idea. – Bernard Dec 29 '11 at 17:26
And make sure your copyright notice is in each file. – David Thornley Dec 29 '11 at 17:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.