Re:How to correctly use code you didnt write
by jakejake on Sunday March 11, 2012 @07:46PM
(#3691666)
I thought the article was going to be more along the lines of how to deal with people's code style, like spaces vs tabs, where the braces go, property naming conventions etc.
I try to take the "when in rome" approach and if I'm messing with a class, I try to style it consistently (even though it may drive me nuts to do so)
Re:How to correctly use code you didnt write
by cgs1019 on Sunday March 11, 2012 @04:23PM
(#3691186)
I feel like this argument could be made more strongly than "You shouldn't copy code without the license because...don't copy code without the license!"
I under-appreciated licenses for a very long time and only recently realized the very real risk of writing some code, posting it to github without any licensing, it being picked up by some commercial organization, and then them licensing it and (possibly, later) taking action against you for using their code without a license (ha!).
Anyway, I appreciate the spirit of the post, but it didn't make much of an argument...
Edit: I guess he also argues that it might upset the code's author to copy their code without attribution (totally possible), which would lead to their writing less open source code (seemingly less likely). I think the risk of commercialization of your code is more salient, though.
Re:How to correctly use code you didnt write
by raphman on Sunday March 11, 2012 @05:14PM
(#3691308)
I under-appreciated licenses for a very long time and only recently realized the very real risk of writing some code, posting it to github without any licensing, it being picked up by some commercial organization, and then them licensing it and (possibly, later) taking action against you for using their code without a license (ha!).
I am not completely sure about US copyright law. However, at least in the European Union, you are the sole owner of your code as soon as you write it. Therefore, anyone putting their license on your code would be violating your author rights.
Re:How to correctly use code you didnt write
by Cushman on Sunday March 11, 2012 @05:49PM
(#3691393)
You do, under the law, implicitly own the copyright to everything you create. This will not inherently protect you from costly lawsuits requiring you to prove that you do, however.
Re:How to correctly use code you didnt write
by true_religion on Sunday March 11, 2012 @05:53PM
(#3691404)
How is that a real risk?
If they're so unethical to try and sue you for using code they just found on the internets without a licence, they're just as likely to steal your code even if it had an MIT licence and claim you were the original thief.
Re:How to correctly use code you didnt write
by Someone on Sunday March 11, 2012 @08:20PM
(#3691785)
It does not require outright malice to have a company think code they have in their repository is theirs, and you having the same code must be stolen; it can just be a matter of sloppy attribution plus some 'to protect our interests, we have to do what everyone else does'. Adding licensing info to every file makes it less likely that that sloppy attribution will take place.
Re:How to correctly use code you didnt write
by richbradshaw on Sunday March 11, 2012 @04:47PM
(#3691239)
I've found that once I've converted all the tabs to spaces, moved the { and } into the correct places, removed trailing white space, added spaces before and after operators, changed all strings to be surrounded by ' or " depending on their use case, changed comments so that // comments are on their own line, and /* */ comments are formatted neatly, I'm ready to go.
Re:How to correctly use code you didnt write
by almondsays on Sunday March 11, 2012 @04:49PM
(#3691245)
Excuse me if this is a naive question but I'm kind of confused on using just a few lines of code. I know you must attribute the original creator when the license calls for it but where? For instance lets say I have 500 lines of code and 10 lines of borrowed code at lines 245-255. Whats best practice in that situation?
Re:How to correctly use code you didnt write
by tptacek on Sunday March 11, 2012 @05:22PM
(#3691328)
There's practically no difference between using 10 lines of GPL code and using a whole package. In either case: you must comply with the terms of the GPL license; your own code is now GPL'd. The exceptions to this rule aren't worth litigating.
If you're not interesting in (say) GPL'ing your code to match the 10 lines you lifted, you would be better of just reimplementing those 10 lines yourself.
Re:How to correctly use code you didnt write
by raphman on Sunday March 11, 2012 @05:11PM
(#3691295)
I don't think there is a commonly agreed practice.
My opinion (and what I tell my students):
Independent of the specific license, I would suggest listing sources (and uses) of all external code in your LICENSE file, and at the header of each file. This makes it much easier to check for license compliance later on. Most open-source licenses require attribution but do not explicitly specify how this should be done.
Example: "check_for_update() from stackoverflow.com/... (CC BY-SA)"
Depending on the license of the code you are using, you might be required to mention its use in your application's documentation (e.g. BSD, CC BY).
If the code is in the Public Domain or is not sophisticated enough to be protected by copyright (thin ice!), there is no need to mention it in the source code.
If it is just a few lines of code, try to put it into its own function and add a short comment. This also allows you to easily remove problematical code later on.
Generally, if it is just a few lines of code, dealing with the license issues is usually not worth it. For example, you can not legally mix CC BY-SA code from Stack Overflow with GPL code. I would suggest just looking at the SO solution and writing your own implementation of the algorithm (not completely safe but probably the most convenient solution).
Re:How to correctly use code you didnt write
by lnguyen on Sunday March 11, 2012 @05:14PM
(#3691307)
Treat it like a citation in a paper. Add comments acknowledging and saying where the code came from. If nothing else, it'll help refresh your memory on why you needed it.
Also be aware of the original licensing for the code. If it's any more than attribution you'll need to determine how it affects the rest of your code and if you might need to reimplement.
Re:How to correctly use code you didnt write
by citricsquid on Sunday March 11, 2012 @05:44PM
(#3691385)
If I'm using an entire file (example from 10 mins ago: http://michelf.com/projects/php-markdown/) I'll leave the license in the way I find it, I have no incentive to change it.
If I'm using parts of someone else's code I'll have a comment preceding it explaining where the code is from (eg: // code taken from: url). It's a massive annoyance to have to try and copy in licenses in the middle of code, it's ugly and makes reading through my code a pain. I guess I'll go to hell for it, but eh.
Re:How to correctly use code you didnt write
by pan69 on Sunday March 11, 2012 @04:16PM
(#3691166)
How does a licence impacts the distribution of plugins?
E.g. if I write a plugin for a system (e.g. Wordpress) and I sell this plugin?
Does the plugin code needs to be distributed under the same licence as the original system even though it wouldn't distribute any of the code provided by the original system? It would only call functions or inherit from classes described in the original system.
Re:How to correctly use code you didnt write
by tzs on Sunday March 11, 2012 @06:40PM
(#3691487)
There is case law that says that calling functions from something else does not make your code a derivative work of that something else. This issue arose when people started making unauthorized third party games for video game consoles that made use of code in the ROMs of those consoles.
The SFLC says that calling a function does make your code a derivative work of that function's code. I've never seen any analysis from them that explains why they think the video game cases don't apply. They are a free software advocacy organization--they naturally tend to take the most free software friendly interpretation possible of law, and I think that often takes them a little past what the law actually is into what they wish it was.
It would be interesting for someone to write a simple blogging system with a plugin interface that is compatible with Wordpress' plugin interface, and put it in the public domain.
Then anyone making a plugin could claim that they actually wrote it for the public domain system, and that is what they are a derivative work of rather than Wordpress. It would be amusing to see what the SFLC would make of that.
Something like this actually happened once, in the early '90s. Someone was distributing a secure email system that used RSA. It used RSA via the RSAREF library, which was freely distributable but not free software. The email system was distributed in source form. When you compiled it, you could compile it to use either the BSD arbitrary precision math library or GMP. Basically, the source had #if statements that selected whether it should assume the BSD library or GMP. (I believe GMP was under GPL, not LGPL, at the time).
Stallman didn't like this. The author of the email system then wrote a toy arbitrary precision library that had the same interface as GMP, and that satisfied Stallman.
Re:How to correctly use code you didnt write
by jakejake on Sunday March 11, 2012 @08:08PM
(#3691738)
Your code can be GPL and you can sell it, the only problem is that you can't prevent other people from selling it as well (or giving it away for free).
Also you don't have to provide a free download to the general public. It's just that everyone to whom you distribute your code has the right to request the source code. You don't have to provide source code to people to whom you did not distribute the software. Of course anybody that you did distribute the software is free to put the source code up for public download.
There are sites that do that type of thing, I've had GPL software I've written show up on download sites and such. But if you are maintaining your software then they will often be out of date and hopefully you'll be showing up ahead of those in search engine listings for your own products. Basically if you're providing good value, you're less likely to be affected by that type of thing.
Re:How to correctly use code you didnt write
by pimentel on Sunday March 11, 2012 @07:03PM
(#3691543)
At last, a simple and direct explanation of what you need to do with each license. I'm tired of answers like "just read the license and comply with it"
It should be titled: "How to correctly attribute code you didn't write"
I try to take the "when in rome" approach and if I'm messing with a class, I try to style it consistently (even though it may drive me nuts to do so)
I under-appreciated licenses for a very long time and only recently realized the very real risk of writing some code, posting it to github without any licensing, it being picked up by some commercial organization, and then them licensing it and (possibly, later) taking action against you for using their code without a license (ha!).
Anyway, I appreciate the spirit of the post, but it didn't make much of an argument...
Edit: I guess he also argues that it might upset the code's author to copy their code without attribution (totally possible), which would lead to their writing less open source code (seemingly less likely). I think the risk of commercialization of your code is more salient, though.
I am not completely sure about US copyright law. However, at least in the European Union, you are the sole owner of your code as soon as you write it. Therefore, anyone putting their license on your code would be violating your author rights.
That would just make me unethical, and you can't protect against that.
If they're so unethical to try and sue you for using code they just found on the internets without a licence, they're just as likely to steal your code even if it had an MIT licence and claim you were the original thief.
If you're not interesting in (say) GPL'ing your code to match the 10 lines you lifted, you would be better of just reimplementing those 10 lines yourself.
Independent of the specific license, I would suggest listing sources (and uses) of all external code in your LICENSE file, and at the header of each file. This makes it much easier to check for license compliance later on. Most open-source licenses require attribution but do not explicitly specify how this should be done.
Example: "check_for_update() from stackoverflow.com/... (CC BY-SA)"
Depending on the license of the code you are using, you might be required to mention its use in your application's documentation (e.g. BSD, CC BY).
If the code is in the Public Domain or is not sophisticated enough to be protected by copyright (thin ice!), there is no need to mention it in the source code.
If it is just a few lines of code, try to put it into its own function and add a short comment. This also allows you to easily remove problematical code later on.
Generally, if it is just a few lines of code, dealing with the license issues is usually not worth it. For example, you can not legally mix CC BY-SA code from Stack Overflow with GPL code. I would suggest just looking at the SO solution and writing your own implementation of the algorithm (not completely safe but probably the most convenient solution).
Also be aware of the original licensing for the code. If it's any more than attribution you'll need to determine how it affects the rest of your code and if you might need to reimplement.
If I'm using parts of someone else's code I'll have a comment preceding it explaining where the code is from (eg: // code taken from: url). It's a massive annoyance to have to try and copy in licenses in the middle of code, it's ugly and makes reading through my code a pain. I guess I'll go to hell for it, but eh.
E.g. if I write a plugin for a system (e.g. Wordpress) and I sell this plugin?
Does the plugin code needs to be distributed under the same licence as the original system even though it wouldn't distribute any of the code provided by the original system? It would only call functions or inherit from classes described in the original system.
The SFLC says that calling a function does make your code a derivative work of that function's code. I've never seen any analysis from them that explains why they think the video game cases don't apply. They are a free software advocacy organization--they naturally tend to take the most free software friendly interpretation possible of law, and I think that often takes them a little past what the law actually is into what they wish it was.
It would be interesting for someone to write a simple blogging system with a plugin interface that is compatible with Wordpress' plugin interface, and put it in the public domain.
Then anyone making a plugin could claim that they actually wrote it for the public domain system, and that is what they are a derivative work of rather than Wordpress. It would be amusing to see what the SFLC would make of that.
Something like this actually happened once, in the early '90s. Someone was distributing a secure email system that used RSA. It used RSA via the RSAREF library, which was freely distributable but not free software. The email system was distributed in source form. When you compiled it, you could compile it to use either the BSD arbitrary precision math library or GMP. Basically, the source had #if statements that selected whether it should assume the BSD library or GMP. (I believe GMP was under GPL, not LGPL, at the time).
Stallman didn't like this. The author of the email system then wrote a toy arbitrary precision library that had the same interface as GMP, and that satisfied Stallman.
Also you don't have to provide a free download to the general public. It's just that everyone to whom you distribute your code has the right to request the source code. You don't have to provide source code to people to whom you did not distribute the software. Of course anybody that you did distribute the software is free to put the source code up for public download.
There are sites that do that type of thing, I've had GPL software I've written show up on download sites and such. But if you are maintaining your software then they will often be out of date and hopefully you'll be showing up ahead of those in search engine listings for your own products. Basically if you're providing good value, you're less likely to be affected by that type of thing.