• Forum
  • Lounge
  • Discuss: Code copyright and legal issues

 
Discuss: Code copyright and legal issues

Pages: 1234
I haven't been able to sleep tonight so I've been pondering and doing a little reading.

Something I have never wondered about or read into was code copyright. It strikes me as odd. The code itself cannot be copyrighted, for instance the C++ syntax and keywords must be used by any programmer to get any work done, at all.

For instance:

1
2
3
4
int main()
{
    return 0;
}


This will be required in all programs, so I assume usage of keywords are not copyright bound.

However:

1
2
3
4
5
class MyClass
{
public:
	MyClass() {}
};


Isn't keyword specific, I use an identifier. However even though I define something, I still assume it cannot be copyrighted as there is no real solution.

But:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
class MyClass
{
public:
	MyClass(std::string s): SomeString(s) {}
	std::string MyString() { return SomeString; }
private:
	std::string SomeString;
};

// Solution for printing a class variable

void Print(MyClass& mc)
{
	std::cout << mc.MyString() << "\n";
}

int main()
{
	MyClass AClass("This is a class");
	Print(AClass);
	return 0;
}


Contains a user defined function with a solution to printing a class object. Yet I still feel this cannot be copyrighted, there's a finite amount of ways this solution is possible.

So I'm wondering about your thoughts about code copyright. If any of you have actually worked for a company that have gone through legal copyright lawsuits for code or anything of the like please share your experiences.

I also apologise if my examples are just outright stupid. I was struggling to think of code that is able to be copyrighted in such small examples.

Even as an example, here is a program I made, is this able to be copyrighted? I don't think so, it's pretty generic.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#include <iostream>
#include <string>
#include <fstream>

#define MAXFILES 256

class Archive
{
public:
	Archive() { FileCount = 0; }
	~Archive()
	{
		std::cout << "Creating buffer...";
		char* Buffer = new char[BufferSize(FileSize, FileCount)];
		std::cout << BufferSize(FileSize, FileCount) << " bytes\n";
		std::cout << "Writing archive...\n";
		ReadFiles(Buffer);
		if(WriteBuffer(Buffer)) std::cout << ArchName << ": Write Successful\n";
		else std::cout << "Error while writing buffer\n";
		delete[] Buffer;
	}
	void AddFile(char* fn)
	{
		std::cout << "Attempting to read " << fn << ": ";
		std::ifstream ifs;
		ifs.open(fn, std::ios::binary);
		if(ifs)
		{
			FileName[FileCount] = fn;
			FileSize[FileCount] = FileLength(fn);
			std::cout << "File exists (" << FileLength(fn) << " bytes)\n";
			FileCount++;
		}
		else std::cout << "Cannot open file\n";
	}
	void SetArcName(char* fn)
	{
		ArchName = fn;
		std::cout << "Archive name has been set\n";
	}
private:
	char* FileName[MAXFILES];
	long  FileSize[MAXFILES];
	int   FileCount;
	char* ArchName;
	
	std::streampos FileLength(const char* f)
	{
		std::streampos c; c = 0;				// Place to store size
		std::ifstream ifs(f, std::ios::binary);	// Open the file in binary mode
		c = ifs.tellg();						// In case it starts at 1
		ifs.seekg(0, std::ios::end);			// Go to the end of file
		c = ifs.tellg() - c;					// filesize = lastpos - firstpos
		ifs.close();							// Close the file
		return c;								// return size!
	}
	
	long BufferSize(long *fz, int fc)	// Not sure if you can use streampos
	{
		long result; result = 0;		// Place to store size
		for(int i = 0; i < fc; i++)		// Iterate through all the file sizes
		{
			result += fz[i];			// Accumulate the sizes
		}
		return result;					// Return how big the buffer has to be
	}
	
	int ReadFiles(char* buffer)
	{
		int Position; Position = 0;
		for(int i = 0; i < FileCount; i++)
		{
			std::cout << "Storing file: " << FileName[i] << "\n";
			std::ifstream ifs;
			ifs.open(FileName[i], std::ios::binary);
			if(ifs)
			{
				for(int j = Position; j < Position + FileSize[i]; j++)
				{
					buffer[j] = ifs.get();
				}
			}
			else
			{
				std::cout << "\nERROR: Could not open: " << FileName[i] << "\n";
				return 0;
			}
			Position += FileSize[i];
		}
		return 1;
	}
	
	int WriteBuffer(char* buff)
	{
		std::ofstream ofs(ArchName, std::ios::binary | std::ios::ate);
		if(ofs)
		{
			for(long i = 0; i < BufferSize(FileSize, FileCount); i++)
			{
				ofs << buff[i];
			}
			return 1;
		}
		else
		{
			return 0;
		}
	}
};

int ProcessSwitch(int c, char* args[], Archive &a)
{
	bool IN, OUT, EX;
	IN = 0; OUT = 0; EX = 0;
	for(int i = 1; i < c; i++)
	{
		if(args[i][0] == '-')
		{
			switch(args[i][1])
			{
				case 'F':
				case 'f':
							IN = 1; OUT = 0; EX = 0;
							break;
				case 'O':
				case 'o':
							IN = 0; OUT = 1; EX = 0;
							break;
				case 'X':
				case 'x':
							IN = 0; OUT = 0; EX = 1;
							break;
			}
		}
		else
		{
			if(IN) { a.AddFile(args[i]); }
			else if(OUT) { a.SetArcName(args[i]); }
			else if(EX) {}
			else
			{
				std::cout << "ERROR: USAGE NOT CORRECT\n";
				return 0;
			}
		}
	}
}

int main(int argc, char *argv[])
{
	Archive MyArchive;
	if(!ProcessSwitch(argc, argv, MyArchive)) return 1;
	else return 0;
}
First of all remember that there is different copyrigt law in different countries. For example in Russia algorithms cannot be patented (however concrete implemetation is protected by copyright laws) and I can use ABCsort for free without violating the law.
http://sysmagazine.com/posts/201534/

The code itself cannot be copyrighted
Concrete words and names cannot be copyrighted, but code can.
As natural language words cannot be copyrighted, but text wrutten in that language and using exclusively non-copyrighted words is still copyrighted.

Some links:
http://haacked.com/archive/2006/01/24/TheDevelopersGuideToCopyrightLaw-Part1.aspx/
http://timreview.ca/article/121
Copyright has nothing to do with solutions; that's more the realm of patents. Basically any bitstring may be copyrightable.
Thanks for the links Miinipaa will give them a read when I am on my laptop.

@Helios

Hmm.. If code is copyrighted at a binary level, wouldn't any standard compiler generate almost identical machine level instructions to a given software?

Say loading the GDT for any intel 386 processor, the exact steps must be taken to load it in the right order. So would that mean generic systems level programming cannot be copyrighted?

I think that is the thing that confuses me the most, a computer is a finite machine. Would it ever come to a point where every bit pattern is copyrighted and can no longer be used? Or does it come down to scale? Or corporate law? I imagine a billion dollar company would only mind about their trade secret being used if another company uses it to generate income which would affect their monopoly.
You're still thinking in terms of patents. If a method is patented and someone chances upon it, they'd be infringing that patent. If it's possible to chance upon a bitstring that follows some general form, then that bitstring is not original work, and therefore not copyrightable. For example, you can't copyright the idea of the four temperaments, but you can copyright the idea of, say, the Ninja Turtles.

When I said "bitstring" I should have clarified that I was talking about whole works. When you copyright something you're not also copyrighting all possible substrings in it. You're not even copyrighting the general outline of your work. Writing a story that was basically a clone of another one only phrased differently and with the names changed would be plagiarism and unethical, but not a breach of copyright.

Copyright is primarily concerned with literal copy of work, particularly with regards to distribution. You can't protect against even clean-room reverse engineering (the reverse engineers and the re-engineers are completely separate groups; the re-engineers need to have never been exposed to the internals of any products by the original developer. Thus you ensure that the result is "original") just with copyright.
I wrote this a long time ago, I don't remember if I still agree with it or if I needed to make changes:
http://www.lb-stuff.com/combination

But, in general, I think copyright is pretty silly. I'm not sure why people get so upset about it other than stupid money reasons.
One thing I didn't quite see as a younger man (at 2^5 years, I am quite older than average in this forum), is that laws - and their interpretations - are works of man; they are nothing to be taken literally. Laws are free to interpretation - "the spirit of the law".

So, what people here may think copyright is - a programmer's strict machine-like interpretation of statements called "law" - is not quite what would hold in a court of law. No one would really bring you in front of the law for your hobby project (assuming that hobby is not harming anyone's business). However, they might bring you to the court when your project is large enough.

At the moment, I am a member of a project in mathematical education, with a number of mathematical problems - together with solutions, presentation slides, answer keys, etc. - in an sourceforge repository. Some of these problems are literally taken from the standard crappy textbook (James Stewart, Crapculus, edition N). No one from the publishing company (very very shady folks) have approached us to object - our project is too small - they probably haven't even heard of us. However, we may one day be large - our materials are free (a single svn checkout command to get all materials), and of higher quality than the said crapculus textbook. Once we have everything we need for doing teaching (two three years of work, perhaps) - I see no reason why we wouldn't be able to take over a reasonable chunk of mathematical education.

If ever some evil publishing company tries to invoke the copyright law to protect their evil math textbook scheme of robbing poor students - and I am waiting for that - I am ready to test the letter, the spirit and the interpretation of the copyright law.
Last edited on
@tition
I'm curious what issues you have with Stewart's calculus books. I'm currently using his seventh edition multi-variable calculus book and have definitely found it helpful.
*Sorry for the tone of my first post, I had a beer too much, so my language was a bit too grumpy.

As for Stewart's text: it is written by a person who wants to make money, and not by a person who wants to teach you anything.

(Off the copyright topic follows:) Here are the multivariable calculus issues I've discovered so far (I am teaching this course for the first time this semester):
1. He says vectors are different from points, and even dares to use different notation for points and vectors. That is complete bs, vectors are simply points in a vector space (by definition). So, I have to use angle brackets for vectors and regular parenthesis for points, just to be in line with the textbook. What nonsense and extra unneeded work!
2. He doesn't define n by n determinants. That is a huge pedagogical mistake. I covered the definition in about 20 minutes in class, together with a full explanation of how the 2x2 and 3x3 determinants arise from the n x n definition,
3. He uses cross product way too much. Cross product exists only in dimension 3; you should use cross products only for formulas that do not generalize to n dimensions.
4. He doesn't even prove the linearity of the cross product.
5. His section on lines, distances, planes does not give you a minimal set of practical skills. If I give you two lines via two pairs of points (4 points total), how do you write the distance between the two lines?
6. He says "traces" - instead of "level curves", "horizontal slices" or "horizontal cross-sections". Trace is a mathematical term reserved for the sum of the diagonal elements of a square matrix.
7. His list of quadratic surfaces is incomplete.
8. He has shuffled the material on multivariable functions, chopping it into two and repeating most of it, in two different sections of his textbook. The only explanation I have is he was trying to increase the number of pages.
9. He teaches curves in space without making any parallels to curves in n dimension or curves in two variables. Unacceptable!
10. He lists spherical coordinates in such an order that the Jacobian of the spherical coordinates map has negative sign! In his variable order, \rho, \theta, \phi, the oriented volume of the unit ball has sign -1!

Now these are the issues I've discovered after about only 1/3 of the course. If I dig into concrete paragraphs and concrete statements, the list will be much longer.

(Back to the copyright topic). If there was no copyright, I could easily take a pdf editor and fix the problems in Stewart's textbook "wikipedia style". So, copyright in this case prevents me from doing a service to my students and fixing the textbook. Of course, there is a solution to that - simply write my own materials - and that is exactly what I am doing (together with two or three other contributors). However the amount of work is huge - and so my students will not get the teaching materials they deserve this year or the next (maybe in two years however).

Now, copyright law is not the direct cause of the low quality of math teaching materials; but copyright law appears to be one of the main weapons used to keep this quality low.

Also the price of math textbooks is exorbitant. Again, this is not directly caused by copyright law - but certainly copyright law has indirect contribution. By the way - 7 Editions of a textbook - by now Stewart's text would have to be perfect! - but no, it's still of very bad quality. Also the price of the textbook is terrible - 230+ USD! In my home country, we had much higher quality textbooks (perhaps not as well illustrated), sold at prices of about 10 USD (still expensive, but not prohibitively). So, if high quality textbook is worth 10 USD, how is it possible that in the US a lower quality textbook is sold for 230? Again, this is not directly caused by copyright, but I do think that copyright has some contribution to this problem.

Last edited on
> So, if high quality textbook is worth 10 USD,
> how is it possible that in the US a lower quality textbook is sold for 230?
> Again, this is not directly caused by copyright, but I do think that copyright has some contribution to this problem.

Don't think that this is a problem related to copyright at all. That colleges in the US prescribe mandatory text books that are distinguished by the patently illogical combination of extreme poor quality coupled with extreme high price is a cultural problem, pure and simple.

It is of little consolation to discover that C++ students are not the sole victims of this abiding swindle.
http://www.cplusplus.com/forum/lounge/123484/#msg672436
Don't think that this is a problem related to copyright at all.
Copyright is a tool that publishers are trying to use to uphold their dominance. And with huge money reserves, army of lawyers and lobbysts they often get what they want.

Luckily they are not always successfull:
http://arstechnica.com/tech-policy/2013/03/thai-student-protected-by-first-sale-supreme-court-rules/
1. He says vectors are different from points, and even dares to use different notation for points and vectors. That is complete bs, vectors are simply points in a vector space (by definition). So, I have to use angle brackets for vectors and regular parenthesis for points, just to be in line with the textbook. What nonsense and extra unneeded work!

Vectors and points are different things.
6. He says "traces" - instead of "level curves", "horizontal slices" or "horizontal cross-sections". Trace is a mathematical term reserved for the sum of the diagonal elements of a square matrix.

A level curve is a trace, but a trace is not necessarily a level curve. Many terms are different when applied to different objects. A trace of a surface is different than the trace of a matrix. I suspect that it's use in linear algebra as a property of a matrix came after.
Last edited on
Vectors and points are different things.
Do go on.
@helios
Is that supposed to be helpful?

I understand that mathematicians consider them equivalent but for the purposes of learning vector calculus it certainly helps me if I consider them different. Also, I have so far been taught vectors have magnitude and direction, do points have those properties?

@tition
The book uses the term traces before level curves are discussed, but it does use the term level curves. I'm not a mathematician so I can't comment on your other complaints.
I have so far been taught vectors have magnitude and direction
Yes. Look at the point represented in polar system.
Note that there is several means to "vector". There is a geometric vector which is defined as line segment with specified begin and end. You can get it by "applying" "pure" or coordinate vector to a point in space.
It's supposed to be a prompt for further arguments. An assertion is not a refutation.
My assertion doesn't need an argument. It's not something debatable.

I understand that mathematicians consider them equivalent

No they don't.


For example, you could give their respective definitions and point out how they differ.

No they don't.
That's odd, because tition happens to be one.
I guess it depends on what field you are viewing it from. From linear algebra a vector is just a special case of matrix. Where one of the components is equal to 1. Then there's two cases of those vectors, which is a row vector or a column vector.

The distinction is made in physics, where a point and vector are different things. I guess from a mathematical perspective, they share the same structure but their meaning is irrelevant to a mathematician.
1
2
using Row_t = int;
using Col_t = int;
Row_t and Col_t are completely unrelated types, but they have the same underlying representation. You'd add a Row_t to a Col_t on the same day that you'd add a point to a vector.
Last edited on
Pages: 1234