If I am programming in Rust, do I have to give my code credits to Rust or something and/or is it subjected to copyright; or do I have full ownership over the code that I produce?
Disclaimer: Extremely not a lawyer…
You retain copyright/ownership over your code, and can license it however you want. As with most languages though, the main thing you have to take into account is the licenses of the third-party code you’re pulling in.
For example, the Rust standard library is dual-licensed under MIT and Apache2, so if your code uses any any of that (which it probably does if it’s a binary) then you will have to follow the terms of one of those licenses. If you chose MIT, you’d basically just have to include https://github.com/rust-lang/rust/blob/master/LICENSE-MIT in your distribution.
This doesn’t mean that your code has to be MIT/Apache2 licensed, though - you could make your application totally closed-source and proprietary if you wanted, as long as you’re not breaking the license terms of your dependencies.
Maybe one day cargo docs will produce a summary page with links to all the licenses that each of the dependencies brings in. That would be kind of neat, and I guess as all the crates packages have to specify which license they use it should be fairly easy to do…
cargo-license does something similar to this, although it just dumps a list out to the console rather than generating a page
That’s real nice. Corporates really like that kind of thing. Just need to roll it into cargo docs so its done as standard - it’s important that people know what licenses they’re using.
Thanks for that
Hey man, i am looking at this post again and there is something I need to understand, so if I make a program (that is in exe for Windows) that prints out Hello World, is it subjected to any copyright or do I COMPLETLY own the copy of the program?
My understanding of things (which should not be taken as legal advice as I am not a lawyer) is:
- You have the copyright on everything except the bits of code you call into from the standard library (for example, the formatting logic inside the
println!macro that you use to print your string).
- Those bits of code are copyrighted by the contributors who originally wrote them.
- You are given permission to use these bits of code in your program under the terms of either the Apache 2 license or the MIT license. If you ever contribute a piece of code to the Rust project, you’re licensing that code for other people to use under those same terms.
- These are very permissive licenses, and don’t put significant limitations on how people can use the code. For example, you could make a horrible evil closed-source program, and it’d still probably be perfectly fine under the license terms. They do, however, state that you must provide a copy of the license with your program.
In languages like Java or Python, you don’t distribute any of the standard library code in your program, so you’d own the full copyright - but that standard library code still needs to exist on the user’s computer somewhere, so they have to download a runtime like CPython or the .NET Framework.
In practice, you’re almost certainly not going to get in trouble for leaving the license file out (especially not for a hello world program, that’d be ridiculous)! But it’s good to get into good habits with this kind of thing. Some good examples of how this has been handled in real life programs are Firefox’s about:license page and Chrome’s chrome://credits page.
In fact, an even better example of how this has been handled in a real life program - the Rust compiler itself!
If you go to the folder where your Rust toolchain is installed (for me that’s
%USERPROFILE%/.rustup/toolchains/stable-x86_64-pc-windows-msvc and look inside
share/doc/rust, there’s a file called
COPYRIGHT which contains all of the licenses for the projects that the Rust compiler itself depends on, like LLVM.
Oh ok so just one last question, so if I released my Hello World program that prints hello world then do I have to give any copyright notice or some stuff (for the exe file)?
Yeah, if you were publicly releasing the software, it would probably be a good idea to include the Rust standard library’s license/copyright notice, just to be on the safe side. That said, I really doubt anyone would mind if you didn’t - these kinds of licenses are there to stop big companies from abusing open source, not to stop Joe232 from showing off their hello world program
Lol, thanks for the help
One question, does the same apply to C/C++?
it’s strictly the same for other compiled languages, for C (assuming gcc) there’s libgcc & the runtime startup files, and if you link statically, glibc and other libraries—other compilers will have their equivalents
for C++ specifically there’s templated code from headers like
<vector> that gets included into your program
unless you write everything from scratch you can’t avoid including some code licensed by others, but the base elements of programming languages tend to be licensed extremely permissively to increase the utility of the language, so no one really worries about this
I wasn’t conscious of the need to provide an MIT-copyright notice for an app that uses only the Rust std library. I’ve never done the equivalent in any other language. I understand that in practice no harm will come to me if I do not, as pointed out above, but now I’m thinking that the proper thing is to provide the copyright notice in this case. What do other folks here do in this situation?
To add, when you depend on any other crate, you are responsible to comply with the license terms of the crate, plus the license terms of any of its dependencies (and recursively all the way down).
Example, if you have a crate
awesome_app, and you depend on
apple_counter depends on
counter, then you must comply with licenses from both those crates.
Alludes to security vulnerabilities as well – you are responsible for the security of your code, and of all code that you use.
Oh ya, no one really realizes what they use until they go and look, which is why I recommend setting up CI to check the licenses of all your dependencies against a whitelist (e.g. to make sure you don’t accidentally pull in an only-GPL license crate)
Notable dependencies — which dependencies-of-dependencies you'd like to be aware of?
IANAL. GCC uses a GPL linking exception. Quick scan gives “You may then convey such a combination under terms of your choice, consistent with the licensing of the Independent Modules.” Which may or may not allow you to use only your own license; anything legal is way too complex to bother thinking too much about.
This to me is more important about the license. Make sure it gives no warranty and no liability.
Still does not protect the world from politicians. Who uses the strategy of if an expert does not tell them what they want to hear then find another expert. In short don’t ever become ill.
In the context of Rust, even LGPL may be pretty impractical to comply with if you aren’t distributing the source code for your app as a whole. Check out the relinking clause (§6.a in LGPL 2.1 and section §4.d.0 in LGPLv3). (E.g. the Rust bindings for GTK+ have a mechanism to remove the LGPLed documentation comments for a good reason.)
You have full copyright over the source code that you write, no matter what libraries you use. The binaries you produce, however, will be constrained by the licenses of the libraries they link to, and depending on the license if you distribute the binary you may also be required to distribute the source code under a certain license.
Is this the same for C++?