There are a lot of ways you can categorize code, but in this blog post, I will mostly focus on their usefulness. Some code can be useful, or designed to be useful but actually useless. You might already discover that the categorization is incomplete: what about the code that is designed to be useless? There is an even more interesting follow-up question: why would anyone write that kind of code? There is an even more interesting answer to that follow-up: I do.
Useful code tends to be produced at work. After all, the purpose of a six-figure salary is to produce useful code so that the companies can earn much more than what they pay the engineers. There is also a place where you can find a lot of useless code that is designed to be useful: the majority of the public personal repositories on GitHub that are not forks. I believe a lot of them start with great hope that they will one day take off and change the world. Among the vast majority of the useless public repositories on GitHub, there were exceptions that are designed to be useless from the start. My programming language, samlang, is one of them.
The question remains: why would I do that? Why spend time writing this useless code instead of just playing video games? Well, things happen for reasons and this is no exception.
Since middle school when I first learned how to code, I was always trying to code something that is popular and useful (See My Decade in Review). The desire was so strong that in high school I even named the platform I created after myself (See CS in High Schools). However, the hope was never materialized. I was never a good PM and was never a good marketer. It was too much for me to handle both the engineering side and the business side when I had a clear favorite. Such inconsistency between my desire and reality always makes me depressed and anxious. During high school, I need them to prove my worth for extracurricular activities, and during college, I need some successful CS projects to prove myself before I had real work experience.
After I finally got my first internship offer, I knew my future career will no longer depend on random side projects. As a corollary, the popularity and success of those side projects no longer matter. Then somewhen at the end of 2018, I had a refreshing thought: if I give up the popularity or usefulness of my projects, will it make me happy? I tried with samlang, and the answer was a resounding yes. From now on, my side projects become real useless hobbies rather than some tasks that might lead to some rewards.
Now with the layer of usefulness and success stripped away, what remains? For the code, nothing remains because it's designed to be useless from the start. For me, it is about engineering pride. I can finally pursue my once hidden and faint yet never-ending desire from childhood to create and to artistically craft things with full dedication even no one cares.
Hence, the useless code isn't completely useless after all.