Forum > General

Open Source code copying/borrowing Etiquette?


Tony Stone:
This really isn't Lazarus specific but I thought I would bring it up here... as I don't really talk to any other programmers anywhere else.

I am Learning to program in Lazarus and trying to learn my way around GitHub.

I found some code in an opensource project called PascalCoin that I want to use in my open source program (both on GitHub).  Now they have some functions and procedures I would like to have included in my project.  Is copying and pasting acceptable if I leave credit with a comment for the code?  I notice in the .pas files that have the MIT license and it says header must not be removed.  Should I just copy the entire .pas file and "merge" it into mine?  Or keep it as a separate file to use its functions?  I know this may be a ridiculous question for most of you but I am trying to keep my project code and files clean and organized and I am looking for ways to do this without stealing anyone elses work.

Tony, the MIT license allows modification, thats what you do when you take some part and use ii in your project.  if its more than  a handful of lines you should probably copy the license header and note the parts copied, especially if copied intact.  Your own license header can sit before or after the pasted in bits assuming its not wildly incompatible. If you plan to make your project available via a license sensitive body such as Debian very important you have good records of what was obtained from where.

Often, people post code here or on the wiki without defining a license and that can be an issue occasionally.

On the other hand, very, very few projects don't have code 'inspired' from other projects.  Concepts and approaches to a problem are not really license-able, and common sense says snippits of code are intended to be copied. The application of the term "derivative work" is a much discussed thing.


Tony Stone:
After reading the license I came to the conclusion I can use and modify the code.  I however found while Googling this topic many people saying not to copy and paste and keep it in tact... either way I am a reasonable person... I will leave notes for any code I can re use.  I have nothing worthy of trying to be distributed in any Debian or other distros repositories right now.  Maybe some day.  I will cross that bridge if i get there but since you mentioned it I will try to keep a good habbit of tracking this info just in case!

The more I play around in Lazarus the more these types of issues pop into my head.  Thanks for the reply!

With MIT, BSD and similarly permissive licenses it's usually enough that you add something like:

--- Code: ---Portions from (X project) version x.x. by [somebody] used under a [MIT, BSD or whatever] license
--- End code ---

to your own copyright and license statement and, if you distribute also the source and can be done easily, you add that note on the header comment of the unit and mark each function/procedure with a comment like:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---{This routine taken from "X project" version x.x, under a [MIT, BSD or whatever] license}
The whole point is that, if possible, you identify which portions of the code you took from whom and based on which license, or at least tell the world that you took some parts from someone based on some license.

Read the about box of any browser and you'll see what I mean ;)


--- Quote from: lucamar on May 11, 2021, 08:17:15 am ---The whole point is that, if possible, you identify which portions of the code you took from whom and based on which license, or at least tell the world that you took some parts from someone based on some license.

--- End quote ---

Although /if/ /possible/ I think it would be nicer to use complete files. I don't know what the more vocally-debated licenses say about transclusion etc.

I was looking at something a few months ago and found that the reference material I was using had a CC license but cited code by Torvalds, Torvalds cited something which was GPL3, the GPL3 code cited the CC reference material I was using. Torvalds doesn't like GPL3 and other files in his repository had an explicit GPL2 license without "or later version", but the one I was using had no license text... in the end I uploaded what I'd done to Github with GPL3 and with an explanation of why I'd chosen it. In the unlikely event that my code becomes the centrepiece of a billion-dollar court case I'll let somebody else's lawyers sort it out.

I think that over the last few weeks I've seen an example of an agreed "one-liner" that can be used to insert the abbreviated name of an open-source licence without having to insert the entire text... presumably that means that the community has agreed that there's some central repository of the licence terms that will be there "in perpetuity".




[0] Message Index

Go to full version