When sharing code, which is recommended: with or without licensing declaration in code?

As the title asks, wondering if best to share with a reference to the likes of GPL, CC, MIT, BSD, etc licenses? or not (fully public)?

1 Like

Hello, Eric,
Just to avoid possible confusion it is best to explicitly mention license of your choice.

I'd like to ensure you that the absence of license does not make shared code public. Public domain status should be explicitly stated. E.g.

1 Like

Thank you, Eugene. Maybe I should have been clearer.

If I don't want business entities to "merge" the code into their own, and mask its contribution to their offerings success (and profits), which of the licenses would you recommend should be used, to ensure they must license-for-fee if they wish to do that? Otherwise, free for own use or non-profit offerings.


Update ...

I've decided to go with GPLv3 after reviewing the "opinion" offered by Google Search with the following query strings:

linux what is the difference between GPLv3 and Creative Commons licensing for software
1 Like

It depends a little on what the code is for.

I like both GPL2 and GPL3 but they can be messy. For example, if you need to link to GPL code you must also use a GPL compatible license. So choosing GPL can have considerable 'downstream' consequences for developers who want to use your code. On the other hand, there are benefits to you because if anyone improves or otherwise updates the code - they need to share that with you (basically).

This is why some projects opt for MIT or BSD because there are less restrictions on other developers but there is the risk that they don't share what they do back to you.

3 Likes

Just for the case there is LGPL, aka Lesser GPL.

4 Likes

For the main entry point in the program/script, I would say yes - consider adding a legal notice as comments at the top of the code. That way, if the file is split from the rest, it stands on its own.

GPLv3 Example

#!/usr/bin/python3
#
# PROGRAM NAME is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# PROGRAM NAME is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with PROGRAM NAME. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright (C) 2026 YOUR NAME <[email protected]>
#
5 Likes