"Borrowing" code

L

Lew

On 2/16/2012 12:59 PM, Lew wrote:
...

There is one situation in which asking a programmer about this is useful
- asking the author of the code about a proposed use.

That wouldn't be legal advice, per se. You'd still need legal advice in order to enter into a contract with the author. The usual colloquial meaning of the
term "legal advice" is expert counsel in the area of legal ramifications with
one's own interest paramount. That is unlikely to be the conversation one has
with a work's author. It is, granted, a useful conversation, but not one that
I'd call "legal advice".

The first step should, of course, be to look at the code itself and the
web site for licensing information. The next step, if the code contains
a copyright notice, an @author tag, or other indication of authorship,
should be to try to contact the author.

And if copyright law is an issue, or you have reasonable cause to expect liability concerns to be relevant, and absolutely if there's any money at
stake, somewhere in those early steps would be to seek legal advice.

In addition to the conversations with the author.
 
L

Lew

Arved said:
Bit of an overheated reaction to what I thought were reasonable questions.

Granted, but a real-life risk when one is asking about the cliff edge of
copyright law. Have you read about copyright cases that seemed ludicrous by
common sense but went the plaintiff's way? Of course, because that is common.

Do I think the OP is trying to game the system in an unethical way? No, not
really, but suppose he did run afoul of a copyright claim. We here, us legal
beagles, tell him, "Sure, copy what you need." Then he loses, in part because
this very thread is shown to the court as an example that he intended to steal
copyright material all along. It's happened.

So is my reaction overheated, or instructive of what some actual copyright
holders might do?
I'm the last person to advocate filching code that should be attributed
(or paid for or both). I make my living writing code for money, and I'd
be annoyed if someone copied it and passed it off as theirs.

*If* my code was non-obvious, that is. Or incorporated significant
domain knowledge. In other words, if it actually merited some legal
protections, according to commonsense.

There is a lot of code out there that ought to be under copyright
according to the rules, but should not be copyrighted according to
commonsense. There are myriads of code snippets that express concept
implementations, in every programming language, that any well-versed
person would code more or less in the same fashion, with only very
trivial tweaks. Tutorials, for example, are positively loaded with this
kind of code. Should any of it qualify for copyright? Why should it? Why
should code like that qualify when 500 or 5000 or 50000 other coders
have already independently written basically the same thing?

Code is not like prose or poetry. It's possible to provide a bunch of
programmers with the same detailed design of a proposed solution, and
assuming a good level of skill, it won't be unusual to see many highly
similar elements in the independent implementations. So why should any
of that be copyrighted?

Who amongst us hasn't seen code snippets on the Web that didn't look
remarkably like something we had written ourselves?

The defense against copyright infringement claims is that very plethora of
exemplars. You simply aver that you copied the other 4000 examples, and not
the plaintiff's.

As for "who amongst us?" I hope those snippets weren't from the Daily WTF, but
for all too many programmers that's where their code really belongs. This group
is relatively elite, but we're only going to think quality code looks familiar
if we are in the habit ourselves of writing quality code.
Anyway, there are much better reasons not to worry about copyright, even
in the frequent cases when it legally exists but is retarded. It's much
better - for several reasons - not to copy and paste. One, you have no

I agree with a caveat - it's bad to thoughtlessly copy and paste. A thoughtful
copy, which is actually copy-paste-edit (CPE), is a very useful technique. CPE
is a valid form of code reuse.
idea if the code is defective or not if you just copy it. If it's so

[emphasis on "just"]
trivial that you can immediately tell by visual inspection that it's OK,
as in a "public static void main Hello World" example (which the lawyers
would argue is under copyright), then you should just type it in yourself.

Whatever. Typing or copying, who cares as long as the end result is correct?
But mindful copying is probably a word at a time, not a snippet at a time, so
through the oppositional style I agree with your point. I just don't want
people to fear the clipboard. What to fear is carelessness.
Two, from a learning standpoint, and a downroad maintenance standpoint,
you shouldn't copy and paste non-trivial code because you're sacrificing
a learning opportunity. Presumably you went hunting for the code snippet
because you didn't know how to do it yourself. Learn from the code
snippet, and work through it. Build up your own implementation, *guided*
by the example. Quite frankly, if you end up with code that you typed
yourself, and you thoroughly understand it, and could now independently
write it, you can ethically feel good about your efforts. My sincere
opinion.

As Arne pointed out in some other thread, the goals vary between coding for
learning and coding for work. You should never copy code you don't fully grok,
I agree there, but it's not the copy-and-paste one should eschew, rather the
failure to grok. To fix that, the retype route is superior when coding for
learning. Once you've learned, the clipboard is a tool like any other when
coding for work.
 
L

Lew

Novice said:
Exactly! This is why it seemed to me that it might be okay to "borrow"
such examples. It seemed self-evident that someone writing a tutorial
meant for it to be used in developing code.

On the contrary, it is obvious that that is not the intention. A tutorial by
definition is meant for use in learning how to develop code. It is almost
certainly not meant for use in developing code.
I wasn't contemplating stealing the full source code for Windows here,
just using a small class or two that someone had figured out and
displayed publicly.

Public display does not confer right to use!

Besides, Arved's advice really, really applies here. So what if you *can* copy
some code into yours? The question you should ask yourself is if you *should*.

The term for copying code snippets from outside sources (like tutorials on the
Web) into your code is "cargo-cult programming".

I have seen many tragically laughable results in real-life projects from this
style of coding.

Now, CPE (copy-paste-edit) is a different matter, properly employed.
 
L

Lew

Roedy said:
Novice wrote, quoted or indirectly quoted someone who said :


I think anything that looks like teaching examples is fair game for
incorporation. Otherwise look for their policy. In general POSTED

That may be what you think, but that's not what copyright law says. Copyright
law says that material is protected unless reproduction rights are granted
explicitly.
code is fair game. Downloaded code is likely to have restrictions.

Everything on my site, including docs, is for non-military use only.

But that's code "that looks like teaching examples", so by your own policy
that "is fair game for incorporation". The "Otherwise" clause never kicks in.
 
M

Mark

I think anything that looks like teaching examples is fair game for
incorporation. Otherwise look for their policy. In general POSTED
code is fair game. Downloaded code is likely to have restrictions.

Everything on my site, including docs, is for non-military use only.

Copyright law does vary from country to country. In the UK all such
work has automatic copyright so there is no requirement to display
copyright notices (although there's nothing to stop people displaying
notices). Unless the author gives permission for you to use the code
then you must assume that you cannot.

Whether the author would do anything about it is another matter.
Copyright infringment is usually a matter for the civil courts so the
victim would have to take you to court and prove you use the code and
prove losses as a result.

The concept of fair use is commonly misunderstood and, in the UK,
there are only a small number of specific conditions that are allowed.
 
N

Novice

On the contrary, it is obvious that that is not the intention. A
tutorial by definition is meant for use in learning how to develop
code. It is almost certainly not meant for use in developing code.


Public display does not confer right to use!
In a legal sense, sure. Still, if someone posts a recipe for chili on a
cooking page, it seems to me the intent is to offer it to the world as in
"Here's how I make a great chili in case you want to do the same." A code
example seems like the same thing to me.

I suppose a code example could just be someone showing off, as in "I
wrote this clever bit of code so I'm putting this code on a public web
page so that you can see how clever I am. But don't you dare try to use
it because if I find out you did, I'll send my lawyers after you and make
a truckload of money!" But that doesn't all that likely to me.
Besides, Arved's advice really, really applies here. So what if you
*can* copy some code into yours? The question you should ask yourself
is if you *should*.

The term for copying code snippets from outside sources (like
tutorials on the Web) into your code is "cargo-cult programming".

I have seen many tragically laughable results in real-life projects
from this style of coding.

Now, CPE (copy-paste-edit) is a different matter, properly employed.

I totally agree with that. If you don't know how it works, you can't fix
it if it doesn't work. You also don't know if it is going to introduce
unexpected side-effects to your code or perform horribly because the
developer of the code was only trying to show a way to do something, not
necessarily the most efficient way. Etc. etc.

For what it's worth, I've contacted the author of the classes I've seen
and received his encouragement to use the classes, even for commercial
projects, but to please credit him in the source code. He has not asked
for any money whatsoever. I was not specific about which classes I wanted
and referred only to a significant number of examples that he has
published online so his permission seems to be a carte blanche
authorization to use anything at that website.

Also, since I don't actually LIKE using borrowed code - I really would
rather write my own - I am studying his code and developing my own
solution that will hopefully use his concept but do it in my own way.

In a moment of weakness, I was tempted to just borrow the code (with
attribution) and move on to other tasks due to time pressure so I asked
my question to try to determine the consequences of doing so.
 
L

Lew

Novice said:
Lew wrote
In a legal sense, sure. Still, if someone posts a recipe for chili on a
cooking page, it seems to me the intent is to offer it to the world as in
"Here's how I make a great chili in case you want to do the same." A code
example seems like the same thing to me.

You still don't get it, do you? The "legal sense" is what you asked about!

The "legal sense" is also what will bite you in the ass if you are not
responsible for it.

Why have you suddenly in mid-thread lost interest in the "legal sense"?

Making chili is not copyright infringement. The printed form of the recipe is
what is copyright, not the recipe itself. The situation is entirely non-
analogous.

The code example is NOT the same. Get over "it seems to me" and deal with
reality. If you are such the expert, why did you ask the question in the first
place?
I suppose a code example could just be someone showing off, as in "I
wrote this clever bit of code so I'm putting this code on a public web
page so that you can see how clever I am. But don't you dare try to use
it because if I find out you did, I'll send my lawyers after you and make
a truckload of money!" But that doesn't all that likely to me.

Another "seems to me". It might not seem like standing on train tracks is
dangerous, but do step off before the train arrives anyway.

The question you asked, and we answered, is if taking code from a tutorial
or other sources constitutes copyright infringement. We have told you that yes,
in many cases it is. Now you attempt to deny this fact (fact!) on the basis
of "it seems to you" that it shouldn't infringe. Disregard the law at your own
peril, dude.

A point you obstinately refuse to acknowledge.
I totally agree with that. If you don't know how it works, you can't fix
it if it doesn't work. You also don't know if it is going to introduce
unexpected side-effects to your code or perform horribly because the
developer of the code was only trying to show a way to do something, not
necessarily the most efficient way. Etc. etc.

For what it's worth, I've contacted the author of the classes I've seen
and received his encouragement to use the classes, even for commercial
projects, but to please credit him in the source code. He has not asked
for any money whatsoever. I was not specific about which classes I wanted
and referred only to a significant number of examples that he has
published online so his permission seems to be a carte blanche
authorization to use anything at that website.

Get it in writing.
Also, since I don't actually LIKE using borrowed code - I really would
rather write my own - I am studying his code and developing my own
solution that will hopefully use his concept but do it in my own way.

Now THAT, as we've said upthread a few times, *is* the purpose of tutorials.
In a moment of weakness, I was tempted to just borrow the code (with
attribution) and move on to other tasks due to time pressure so I asked
my question to try to determine the consequences of doing so.

And despite many good answers to that question, you take issue with the truth.

In matters of law, "it seems to me that should be different" will not excuse
you from liability.

We've given you the advice. The consequences of following it or not are on you.
 
G

glen herrmannsfeldt

(snip, someone wrote)
In a legal sense, sure. Still, if someone posts a recipe for chili on a
cooking page, it seems to me the intent is to offer it to the world as in
"Here's how I make a great chili in case you want to do the same." A code
example seems like the same thing to me.

You might even be able to go into the canned chili business
with the recipe, but publishing it in a cookbook is a different
question.

But the usual thing with both recipes is to modify them, as
they say (in the recipe) to taste.

There is some explanation of this in "Numerical Recipes", but
maybe not quite good enough. Many of the programs are adapted
from others generally known, yet different enough not to
violate a previous copyright. (Or so the authors hope.)

Despite the name, it is my understanding that it is best
to use the programs as test programs for implementing the
given algorithms.

You might have a math book with an explanation of an algorithm,
but have a hard time visualizing it. With a sample program, you
can try out a few cases, see how they work, and then write your
own implementation.
I suppose a code example could just be someone showing off, as in "I
wrote this clever bit of code so I'm putting this code on a public web
page so that you can see how clever I am. But don't you dare try to use
it because if I find out you did, I'll send my lawyers after you and
make a truckload of money!" But that doesn't all that likely to me.

If it is only a few lines long, there likely aren't that many
different ways to do it. As it gets longer, there is more
possibility for variation.

In the Apple II days, there were claims that the only possible
implementation of the ROMs was the one that Apple used. The code
was so tight, using as many space-saving tricks as one could
think of, and much had to fit in a certain space, that it
might have been close to true. When you are not space or time
constrained, it is much easier to write an alternate implementation
of an algorithm, and avoid copyright problems. (Though you can
still run into patent problems.)
(snip)
I totally agree with that. If you don't know how it works, you can't fix
it if it doesn't work. You also don't know if it is going to introduce
unexpected side-effects to your code or perform horribly because the
developer of the code was only trying to show a way to do something,
not necessarily the most efficient way. Etc. etc.

And if you do know how it works, it usually isn't so hard to change
it enough to avoid copyright problems.

If I remember, there were some interesting examples in one
of the Unix suits. There are a few unix derivatives, such
as FreeBSD and NetBSD that are supposed to be reimplementations.

Someone might find something like the old C favorite:

while(*s++ = *t**) ;

in both copyright version and a derived version, and claim it
as infringement. (You might look it up for more accurate
details.) But that is so common in C programming that it
doesn't make much sense to claim copyright for it.

There are also some fun cases in literary fiction, where
one claims that another copied their story too closely.
(I believe some related to Harry Potter, where any story
with a magical boy could be considered to be infringed.)

-- glen
 
L

Lew

glen said:
There are also some fun cases in literary fiction, where
one claims that another copied their story too closely.
(I believe some related to Harry Potter, where any story
with a magical boy could be considered to be infringed.)

Uh, how about a book where a magical boy named "Larry Potter" goes into a
magical world to fight evil magicians? Or another work where non-magical humans
are called "muggles"? These were the works that claimed infringement, not just
random stories about magical boys.
<http://en.wikipedia.org/wiki/Legal_disputes_over_the_Harry_Potter_series>

I'm not saying the claims were valid (they weren't), but that they were more
finely tuned than simply "any story with a magical boy".
 
G

Gene Wirchenko

It's too strong a conclusion, "freely" available. A tutorial's code very
reasonably could be licensed only for personal use in service of learning the
material in the tutorial. Presence in a tutorial is not presumptive evidence
that code is licensed freely or in the public domain.

How would it be licenced without some sort of statement? If
there is no such statement, then the code is freely available. If
there is such a statement, then the code is not freely available.

[snip]

Sincerely,

Gene Wirchenko
 
G

Gene Wirchenko

Uh, how about a book where a magical boy named "Larry Potter" goes into a
magical world to fight evil magicians? Or another work where non-magical humans
are called "muggles"? These were the works that claimed infringement, not just
random stories about magical boys.
<http://en.wikipedia.org/wiki/Legal_disputes_over_the_Harry_Potter_series>

I'm not saying the claims were valid (they weren't), but that they were more
finely tuned than simply "any story with a magical boy".

There are coincidences, too. Dragon Magazine (former mag by TSR
for roleplaying games) had an article wherein it was stated that two
people had once submitted ideas that were extremely close.

With enough volume, these coincidences can happen.

Sincerely,

Gene Wirchenko
 
L

Lew

Gene said:
How would it be licenced without some sort of statement?

Exactly so. It wouldn't be.

Mere presence in a tutorial is not a license.
If there is no such statement, then the code is freely available.

Wrong. In most jurisdictions, certainly in the U.S., all rights are reserved by
default. Ergo if there is no statement of license, then the code is completely
unavailable, outside fair use.
If there is such a statement, then the code is not freely available.

Possibly. If the statement is "this code is freely available", then and only
then is the code freely available.
 
A

Arved Sandstrom

Exactly so. It wouldn't be.

Mere presence in a tutorial is not a license.


Wrong. In most jurisdictions, certainly in the U.S., all rights are reserved by
default. Ergo if there is no statement of license, then the code is completely
unavailable, outside fair use.
[ SNIP ]

What do you do if you can find essentially the same code, except for WS
and variable names and such, on dozens of different websites?
Acknowledge everyone?

I'm not talking about plagiarism either. I'm talking about code snippets
that, given a certain situation, really won't deviate from a certain
form. Any adequate programmer, confronted with the same problem, would
arrive at essentially the same expression. There are numerous examples
of this on the Internet or in books or in magazines.

Code is not prose or poetry. That's why automatic copyright for source
code is a flawed concept. Ideally people should have to explain why they
think their code rates copyright. I understand that we shouldn't be
flouting the current (broken) system, but we shouldn't be passively
accepting it either.

I guarantee that each and every one of us writes code routinely,
independently and without copy & paste and without reference to others'
material, that could be attacked on the basis of copyright, simply
because someone published something basic. Are you cool with that?

AHS
 
A

Arne Vajhøj

How would it be licenced without some sort of statement? If
there is no such statement, then the code is freely available. If
there is such a statement, then the code is not freely available.

That is not how copyright law works.

Default is no license.

Arne
 
J

Joshua Cranmer

That is not how copyright law works.

Default is no license.

Where by "no license" the correct interpretation is "it is illegal for
you to reuse the code." The only rights that copyright law gives you by
default is those covered by fair use (which are inviolable,
incidentally); any other right is not presumed to be present unless
explicitly mentioned.

Caveat: this is copyright law as it exists in the US since 1976.
However, to my knowledge, similar interpretations are valid for most
jurisdictions.
 
A

Arne Vajhøj

It's too strong a conclusion, "freely" available. A tutorial's code very
reasonably could be licensed only for personal use in service of learning the
material in the tutorial. Presence in a tutorial is not presumptive evidence
that code is licensed freely or in the public domain.

Regardless of our assumptions, the law is what prevails. In the U.S., the law
does not require a copyright notice for there to be an enforceable copyright.

So while you may presume anything you want, presumptions not being things that
require or benefit from evidence, that presumptuousness can lead you into
trouble. The law will still hold you to account, and that trumps all
presumption.

It's safer to assume, assumptions being things that can benefit from evidence.
In the case of U.S. copyright law, the safe assumption is that the material is
copyright, that the rights are restricted, and that you may not disseminate that expression beyond the boundaries of fair use, absent affirmative evidence
otherwise.

That's also a safe conclusion. Conclusions are things that require evidence.

Generalizing about the web is difficult. The web is partly commercial
and source code is made available under many different licenses. So
it would be difficult to argue that source code being freely available
on the web means us as you want.

But for usenet or certain specific web sites dedicated to help
other with programming problems, then the only realistic purpose
of posting code is for people to use it. So I would argue that
clicking submit indeed is giving out a permissive license to the
code.

You do need a permission to use code, but I am not sure
that the permission need to be in writing.

Arne
 
A

Arne Vajhøj

Where by "no license" the correct interpretation is "it is illegal for
you to reuse the code." The only rights that copyright law gives you by
default is those covered by fair use (which are inviolable,
incidentally); any other right is not presumed to be present unless
explicitly mentioned.

Caveat: this is copyright law as it exists in the US since 1976.
However, to my knowledge, similar interpretations are valid for most
jurisdictions.

Yep.

Bern convention standardized copyright rules a lot.

But explicit does not specify whether it is written in
paper, written on a web page, given verbally or given by
clicking submit.

Arne
 
G

glen herrmannsfeldt

(snip describing convergent evolution of code)
I'm not talking about plagiarism either. I'm talking about code snippets
that, given a certain situation, really won't deviate from a certain
form. Any adequate programmer, confronted with the same problem, would
arrive at essentially the same expression. There are numerous examples
of this on the Internet or in books or in magazines.
(snip)

I guarantee that each and every one of us writes code routinely,
independently and without copy & paste and without reference to others'
material, that could be attacked on the basis of copyright, simply
because someone published something basic. Are you cool with that?

I believe in the unix case, which this sounds like to me,
that they lost. Still, having to go to court to defend it,
and that judges and juries may not understand something so
obvious to programmers, means it might be worth fixing.

-- glen
 
G

glen herrmannsfeldt

(snip)
Generalizing about the web is difficult. The web is partly commercial
and source code is made available under many different licenses. So
it would be difficult to argue that source code being freely available
on the web means us as you want.

(snip)

I explicitly copyright this newsgroup post. I don't authorize
you to copy it to your computer memory, view it on the screen,
store it on a news server, disk, tape, or any storage and
retrieval system, or otherwise do anything with it.

Even more, I don't allow you to even think about doing one
of those things.
You do need a permission to use code, but I am not sure
that the permission need to be in writing.

(Copyright 2012)

-- glen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

borrowing Constants 22
Arduino Code Please Help 0
Can't understand code 2
Code efficiency 3
AttributeError in pygame code 4
Code sharing 2
Problem with code 2
Age gate code 0

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,817
Latest member
AdalbertoT

Latest Threads

Top