
Open source is just throwing some code on GitHub. Learn what it is and what it’s not.
Simply put, open source programming is writing code that everyone can freely use and modify. But you’ve probably heard that old joke about Go language, which says Go is “simple enough to understand the rules at a glance, but it takes a lifetime to learn to use it.” Actually, writing open source code is the same way. It’s not hard to throw a few lines of code on GitHub, Bitbucket, SourceForge and other websites, or on your own blog or website, but to be effective, it requires personal effort and foresight.
Our Misunderstanding of Open Source Programming
First, I want to make it clear: putting your code in a public repository on GitHub doesn’t mean you’ve open-sourced your code. In almost the entire world, copyright is automatically generated as soon as a work is created, without the creator having to do anything. Before the creator authorizes it, only the author can exercise copyright-related rights. Code without the creator’s authorization is a time bomb, no matter how many people are using it, and only fools would use it.
Some creators are kind and think, “It’s obvious my code is freely available for everyone to use.” They don’t want to sue anyone who uses their code, but that doesn’t mean the code is safe to use. No matter how kind you think the creators are, they have the right to sue anyone who uses, modifies, or embeds the code without explicit authorization.
Obviously, you shouldn’t publish your source code online without specifying an open source license and then expect others to use it and contribute to it. I also suggest you try to avoid using such code, even potentially unlicensed code. If you develop a function and routine that is similar to a previously potentially unlicensed code, the source code author can sue you for infringement.
For example, Jill Schmill wrote AwesomeLib and put it on GitHub without explicit authorization. Even if Jill Schmill doesn’t sue anyone, as long as she sells the complete copyright of AwesomeLib to EvilCorp, EvilCorp will sue those who previously used this code without permission. This behavior is like planting a computer security vulnerability, which will be used by people one day.
Code without a license is dangerous, remember that.
Choosing the Right Open Source License
Assuming you’re about to write a new program and plan to let people use it in an open source way, all you need to do is choose the license that best fits your needs. As advertised, you can start with choosealicense.com supported by GitHub. This website is designed like a simple questionnaire, which is particularly convenient and fast. You can find the right license with just a few clicks.
Warning: Don’t be too conceited when choosing a license. If you choose a widely used license like Apache License or GPLv3, people can easily understand what rights they and you have, and you don’t need to hire a lawyer to check for loopholes. The less people use the license you choose, the more trouble it will bring.
The most important point is: Never try to create your own license! Creating your own license will bring more confusion and trouble to everyone, don’t do it. If you can’t find the terms you need in the existing licenses, you can add your requirements to the existing licenses and highlight them to remind users to pay attention.
I know some people will stand up and say: “I don’t care about licenses, I’ve already put the code in the public domain.” But the problem is that the legal effect of the public domain is not recognized worldwide. In different countries, the effect and form of public domain are different. Under the control of some governments, you can’t even put your source code in the public domain. Fortunately, Unlicense can fill these loopholes. It is concise in language and clearly describes “just put it in the public domain” in a few words, but its effect is recognized worldwide.
How to Introduce the License
After determining which license to use, you need to clearly and unambiguously specify it. If you are publishing on GitHub, GitLab, or BitBucket, you need to build many folders. In the root folder, you should create the license as a plain text file named LICENSE.txt.
After creating the LICENSE.txt file, there are other things to do. You need to add a comment block at the top of each important file to declare the license. If you are using an existing license, this step is very simple for you. A comment block like # Project name (c)2018 Author name, GPLv3 license, see https://www.gnu.org/licenses/gpl-3.0.en.html is much more effective than a vaguely referred license.
If you are going to publish on your own website, the steps are similar. First create a LICENSE.txt file, put the license in it, and then indicate the source of the license.
What Makes Open Source Code Different
One of the main differences between open source code and proprietary code is that open source code is written for others to see. I’m a 40-something system administrator who has written a lot of code. At first, I wrote code for work, to solve company problems, so most of it was proprietary code. The purpose of this code is simple: as long as it can work in a specific way in a specific occasion.
Open source code is very different. When writing open source code, you know it may be used in various environments. Maybe your use case has very limited environmental conditions, but you still hope it can work ideally in various environments. Different people will have various use cases when using this code, you will see various conflicts, and ideas you haven’t considered. Although the code doesn’t have to satisfy everyone, it should at least handle their problems properly, even if it can’t solve them, it can convert back to common logic without causing trouble to users. (For example, “Zero division error on line 583” cannot be used as a response to incorrectly providing command line parameters.)
Your source code may also drive you crazy, especially after you modify the wrong function or sub-procedure over and over again, and finally get the result you want. At this time, you won’t sigh and move on to the next task. You will clean up the process because you don’t want others to see the traces of your repeated attempts. For example, you will replace all $variable and $lol with meaningful $iterationcounter and $modelname. This means you have to comment professionally (although it’s not difficult for you based on your background knowledge heat), because you expect more people to use your code.
This process is inevitably painful and frustrating, after all, it’s not something you do often and you will be a bit不习惯. But it will make you a better programmer and elevate your code. Even if your project only has you as a contributor, cleaning up the code will save you a lot of work later. Believe me, when you look at your app code again a year later, you will be glad that you wrote $modelname and clear comments, not some unknown sequence, or even $lol.
You Are Not Writing for Yourself Alone
The real core of open source is not the code, but the community. Projects with larger communities last longer and are more easily accepted by people. Therefore, not only join the community, but also contribute more ideas to the community development, so that your project can be used by the community.
Batman spent a lot of time alone in the dark to achieve his goals, you don’t need to do that. You can log in to Twitter, Reddit, or send emails to people related to your project, publish the news that you are preparing for a new project, talk carefully about the design purpose and your plans, let everyone help, solicit data input from everyone, similar use cases, integrate this information into your code. You don’t have to accept all suggestions and requests, but you need to have a general grasp of it, so that you can avoid some traps when you improve it later.
The process of publishing the first announcement is not complete. If you want people to accept your work and use it, you should design it with this in mind. The public may be able to help you, you don’t have to be like facing a big enemy about publicizing it. So don’t work behind closed doors, since you are writing for everyone, set up a real, open project, imagine you are under the help and supervision of the community, carefully complete it step by step.
How to Establish a Project
You can register an account for free on GitHub, GitLab, or BitBucket to manage your project. After registration, create a knowledge base, establish a README file, assign a license, and write code step by step. This can help you establish good habits, so that when you work with real teams later, you can also carry out work steadily towards the goal with clear purpose. The longer you do this, the more interested you will be - usually users will first become interested in your project.
Users will start asking questions, which will make you happy and unhappy. You should treat them kindly and politely, even if many of them have many misunderstandings about the project or don’t even know what your project does. On the one hand, you can guide them to understand what you are doing. On the other hand, they will slowly bring you into a larger community.
If your project is very popular with users, there will always be senior developers who appear and show interest. This may be a good thing, or it may anger you. At first, you may only do simple bug fixes, but one day you will receive pull requests, which may be hard-coded or special use cases (which may make the project difficult to maintain), it may change the scope of your project, or even change the original intention of your project. You need to learn to distinguish which one contributes, and decide which one to merge and which one to decline politely.
Why Do We Open Source?
Open source sounds like a heavy task, and it is. But it also has many benefits for you. It can invisibly hone you, make you write pure and durable code, and also teach you to communicate with people and work in teams. For an ambitious professional developer, it is the best resume material. Your future employer is likely to open your repository to understand your ability range; developers of community projects may also bring you work.
Finally, working for open source means personal improvement, because what you are doing is not for yourself alone, which is much more important than supporting yourself.