2016-06-04

Why I prefer merging over rebasing in git

The argument between rebase workflow vs merge-based workflow is a lot like the argument between spaces vs tabs. There are pros and cons for each side as well as compromises in or near the middle, but at the end of the day, it mainly comes down to one person's personal preference, typically held for unspecified reasons. So I'd like to share my preferences, and my reasons, when it comes to git: the (currently very popular) version control system which features Distributed Version Control for Directed Acyclic Graphs and a Command-Line Interface that many people mock or struggle with. If you don't already know what rebasing and merging are, you should probably just look them up yourself, as I am only going to give a brief overview. If you don't even know what git is, this blog post is not for you, and you can safely bookmark it for later when you do eventually learn programming.

On one hand, you have rebasing: you change a commit's parent to the one you want it to be, and maybe fix any conflicts that result from that change. In either case, the hash of the commit changes, because in git, a commit's hash is based on itself and all commits that come before it. Changing any commit changes its has and all the commit hashes after it. (This has the excellent property that simply having a commit's hash is enough to guarantee that it will always be the same way it was when you first found it). Thus, rebasing has the effect of destroying history by changing the parents of the commits and sometimes even the content of the commits. It can also result in commits appearing in the DAG out of chronological order. But the result is a DAG which is a nice straight line.
A "clean" DAG, typical of a rebase workflow.
On the other hand, you have merging: you create a new commit which has multiple parents. It should be pretty obvious what the implications of that are. A merge commit really only describes how to resolve conflicts. If there are no conflicts, you should consider a merge commit to be effectively empty (even if it isn't actually implemented that way). Note that merging does not modify any other commits - it only creates a new one that explains how to combine others properly. Thus, history is preserved, but at the cost of making the DAG look messy.
A "messy" DAG, typical of a merge-based workflow.
For the most part, the difference is aesthetic: you either want a clean DAG and could care less for history, or you want to preserve history and could care less how the DAG looks. However, I believe there are more compelling reasons to prefer one over the other, and that the aesthetics may actually not be what they seem.

Git supports signing commits with GPG for good reason, and GitHub supports it too. When you rebase commits, you change them, and thus it is impossible to keep the signature. Instead you have to either drop the signature, or create a new signature, and 99% of the time it can only be your signature (unless you want to rebase commits one-by-one and pass the responsibility around to each author in turn). This completely defeats the purpose of signing commits. With merging, not only do all of the parent commits keep their signature, but the merge commit itself can be signed too, which is especially useful when conflicts have to be resolved. This alone would be enough for me to avoid rebasing except in special cases.

But even if you don't bother with signing commits (even though you should), I still think it is important to preserve history. I'm not worried about little things like commits being out of chronological order. I'm concerned about making changes to resolve rebase conflicts. No matter what version control software you use, there will be conflicts that arise from simultaneous development. (Unless you don't allow simultaneous development, which is stupid). There are even conflicts which don't manifest at rebase or merge time, and are only evident when trying to compile the code or run the program. (For example, a unused variable is deleted in one branch, and another branch adds code that uses the variable - both independently work, and when rebasing or merging git will not detect any conflicts, but the resulting code will not compile without modification - I typically check for this during the merge and make changes in the merge commit).

With rebasing, you have to either modify commits to resolve conflicts (and which commit(s) do you modify?) or you have to create a new commit that resolves the conflicts (which is basically a merge commit with one parent - the wrong parent). This also causes trouble when bisecting the DAG - suddenly you run into code that would have normally compiled with a merge-based workflow but now doesn't compile due to the rebase-based workflow (if you don't modify each commit during the rebase to ensure it compiles). In either case, you are changing the commit authors' original intentions. They originally intended for their commit to be based on the parent(s) it was already based on, and they probably didn't intend for someone to modify their commit. Git does support multiple authors on a commit (but only one committer), but are you really going to go through all that effort? And how will you know which changes are attributed to which authors? This alone is enough of a headache for me to avoid rebasing except in special circumstances.

With a merge-based workflow, these problems do not exist: you never need to modify a commit, at all. No commit hashes are ever changed. Everything remains exactly as the author originally intended, and conflicts are resolved where they should be: in the merge commit. You have preservation of history as a side-effect.

As for the aesthetics, a rebase workflow only hides the complexities of parallel development. It hides them in a way that makes them difficult to rediscover when you need them. I don't believe you will never need to know how or why a change occurred in the past. A merge-based workflow doesn't try to hide the real complexity, and also makes it dead simple to discover it when needed: just look at the DAG. No detective work required, no bothering with commits not in chronological order, or wondering if all the changes in a commit were really made by the commit's author.

If understanding how and why code changes over time wasn't important, we wouldn't be using version control software like git; we'd be using dumb snapshot backups (aka primitive version control). This is a case where hiding complexity makes it harder to understand what has really happened. Again, this alone is reason enough for me to use a merge-based workflow.

Since there are multiple reasons to use merge-based workflows that I have said are reason enough alone, I think it's pretty obvious I almost never touch rebase. But I encourage you to do the research and make decisions for yourself, rather than just listening to the one guy who preferred one over the other for unspecified reasons or because "it makes the DAG look better". Of course, ninjas already know to do that, but you totally aren't a ninja, so I guess you just forgot.
I had a good reason for this, I promise. But I also wanted to see what it would look like.

2016-04-17

Identity Crisis

I just saw a video where college students could not explain why a short white man was not a tall asian woman and an article to go with it, and it got me thinking. I'm genuinely fascinated by this subject and thought experiment, and I feel compelled to write about it. So what do I think?

Well for one thing, I think those college students just haven't fully thought through the implications of their beliefs. This is something known as cognitive dissonance and it is something everyone is guilty of to some degree. I myself have found a lot of conflicting beliefs in my mind that I had to sit and think about for a while before resolving. It's really easy to come to believe that one thing is the way things should be without actually applying it to any of your other thoughts and behaviors - this often results in hypocrisy. (Though, you can be hypocritical without having relevant cognitive dissonance). It's also possible to believe two conflicting ideas at once without ever realizing it. When emotions and opinions get involved, people often forget to analyze problems and break them down, instead resorting to gut instinct, and gut instinct typically hides conflicting ideas.

Let's talk about identity. What kind of identity? Online identity? Social identity? Legal identity? No, in this case we want to discuss personal identity: what someone identifies as to themselves, even if they don't tell others; and physical identity: what someone is physically identified as by others. In most cases, personal and physical identity are mostly the same: a person who thinks they are a man also tends to have the physical properties of a typical man. An example of when they don't line up is with homosexuality - which, in my opinion, is a very misleading word.

To me, a human has three identities: their personal identity, their sexual identity, and their physical identity. All three of those things can be in any combination - they could all be the same, they could all be different, or a couple could be the same and one could be different. The word homosexual by definition should mean that a person's sexual identity is one which is attracted to others with the same physical identity as the person, but this doesn't account for a person's personal identity at all. It has been used to account for it, however, and so the term is now ambiguous and I will cease using it, because ambiguity is annoying. (By the way, note that sexual identity does not mean "do you have man parts or woman parts" - that's what physical identity is).

In the above video, none of the featured students seem to be able to explain even one of those three identities - some may not even know there is more than one in the first place. The interviewer has a physical identity of 'short white male', which could potentially be changed via surgery and other means. He then suggests that his personal identity may be 'tall Chinese woman', without ever mentioning what his sexual identity could be. (Since I get the strong impression this is a thought experiment and he doesn't actually personally identify as a female, I'm going to refer to him as a male). It is important to note that his personal identity is something only he can know for sure, and we just have to trust that he isn't lying about it. (Well, okay, if brain mapping technology gets far enough we could eventually find out if he is lying and know for sure what his personal identity is, but that's a discussion for another decade).

To be clear, it's perfectly fine if he personally identifies as a Chinese woman, but nobody will ever convince me that he physically identifies as one until he goes through the surgery to make it real, and I don't think it's healthy for him to believe he is taller than he really is. If he robs a bank and I am a key eye witness, I'm going to tell the police about a short white man, not a tall Chinese woman. If he dies and centuries later his bones are dug up and examined, he will be identified as a short male. If he so desired he could go through all the surgery to change those facts, or if the medical field advances far enough he could even swap bodies with someone else (exchange their brains) and thus break many people's perceptions of identities in the act. But if all it takes is swapping brains to change physical identity, what is physical identity?

The way I see it, our brains are the only thing that really matters in most cases. Yeah, our physical bodies matter in some cases, but most of the time they don't. Yes, the brain is physical too, but what surrounds it is merely an avatar. I see our physical bodies as avatars for our physical brains. You've probably even seen the movie Avatar and should at least have an idea of what I mean. It's perfectly fine to customize one's avatar if it isn't to their liking; most people probably aren't born with an avatar they actually want, but the cost of changing it varies from expensive to extremely expensive. So, most people just accept that it isn't worth the time and money to change their avatar when they have more important things to do, like researching a cure for cancer or taking out the trash. Ideally, one's avatar need only be modified to be suitable for the task it needs to perform (which in most cases means correcting birth defects and repairing injuries), but the cosmetics industry exists for a reason. People are vain, and vanity is still an integral part of our culture. (Also, I'm aware of mental disorders and the likes, and that's a whole different can of worms). But I digress.

Back on topic, the college students in the video don't seem to understand (or aren't able to adequately explain) that the interviewer's avatar is now and most likely will forever be, a short white male. They don't even seem to be comfortable with the idea that they can refer to the avatar as a separate thing. They're probably worried about sounding racist, sexist, or otherwise bigoted. This is, in my opinion, the biggest problem with society at the moment: confusion of the three identities, and intolerance for intolerance. (The latter being rather ironic).

Recall, the three identities are the personal identity, the sexual identity, and the physical identity, and any combination of them is perfectly fine (to me, anyway). When people confuse two or more of these identities as the same thing, or when they are afraid to talk about one or more of them, it leads to problems. The college students seem to be unable or reluctant to talk about the interviewer's physical identity, instead confusing it with or prioritising his personal identity. How does this happen? Let's break down the conversations:
"So if I told you that I was a woman, what would your response be?"
  1. "Good for you. Okay. Like... yeah."
  2. "Nice to meet you."
  3. "Wait, like... what? Really...?"
  4. "I don't have a problem with it."
  5. "I'd ask you how you came to that conclusion."
Now, to be fair, these street interviews are a horrible way of doing things. These students are worrying about classes, jobs, and relationships, and then suddenly you add more pressure by putting them in front of a camera and microphone, and then to top it all of you start asking them ridiculous questions. How are they supposed to respond? Well, they're supposed to respond quickly, and unfortunately that means their responses aren't very well thought out. When things are not well thought out...you get the above. Also, they probably interviewed dozens of students and hand-picked the responses that proved their point the most, while discarding ones that disproved their point. These types of videos are a powerful form of propaganda. But, I'm not here to judge the fairness of the video, only the questions raised and the responses given.

Responses 1, 2, and 4 are all accepting of the new information, but dodge the question. Response 3 is skeptical, asking for clarification. Response 5 is...well, we will have to come back to this guy.
"If I told you that I was Chinese, what would your response be?"
  1. "I mean, I might be a little surprised, but I'd say: good for you! Like... yeah, be who you are."
  2. "I would maybe think you had some Chinese ancestor."
  3. "I would ask you how you similarly came to that conclusion, and why you came to that conclusion."
  4. "I would have a lot of questions, just because, on the outside I'd assume that you're a white man."
Response 1 is again accepting. Response 2 is trying to take the "this is a riddle, isn't it?" approach. Response 3... well, this is the same guy from the previous question's response 5, and I'll just call him "conclusion guy" - more on him later. Response 4 is actually pretty decent, as it correctly realizes that the interviewer is physically not Chinese, but it also uses the word "assume" showing lack of confidence. (Nothing wrong with lack of confidence here - it's a crazy world we live in). Also note that response 4 specifically says "on the outside" - this is directly referencing the physical identity in simpler words.
"If I told you that I was seven years old, what would your response be?"
  1. Speechless.
  2. "I wouldn't believe that immediately."
  3. "I probably wouldn't believe it, but I mean, I... it wouldn't really bother me that much to go out of my way and tell you 'no, you're wrong', I'd just be like 'oh, okay, he wants to say he's seven years old'."
  4. "If you feel seven at heart, then... then so be it, yeah, good for you."
Responses 1 and 2 are probably most people (citation missing). Response 3 is a masterpiece, and after listening to it several times I'm still not sure what he actually meant even though I feel pretty confident about what he actually said. It wouldn't bother him that much to say 'you're wrong', but at the same time he'd either be okay with it or just accept that what was said was said. I'm confused. Response 4 uses the phrase "at heart" and I'm not really sure if it means the same thing to me as it does to her. I think a lot of people feel like a kid at heart but would never really identify as a kid in any of the three ways.
"So if I wanted to enroll in a first grade class, do you think I should be allowed to?"
Suddenly, we shift from "what would your response be" to "do you think I should be allowed to", and I think this has a big impact on the responses. Where before the interviewer was querying each person's own reaction, now they use the phrase "allowed to". This is a very subtle way of changing how they approach the question, because now their response is more general - after all, if one person is allowed to surely others should be too? Also, do note that there is never any mention of how the 'first grade class' is to be implemented - will he be inserted with other kids who are actually the correct age, or with other adults? The word 'class' is used when the word 'education' could have been used. Let's hear the responses:
  1. "Probably not, I guess, I mean unless you haven't completed first grade up to this point and for some reason you need to do that now."
  2. "If that's where you feel, like, mentally, you should be, then I feel like there are communities that would accept you for that."
  3. "I would say so long as you're not hindering society and you're not causing harm to other people, I feel like that should be an okay thing."
Whew. People really struggled to push words out of their mouths with this one. And, as expected, their responses seemed more general and less personal. Response 1 seems to be hinting at what I mentioned earlier, about a class of adults needing to take first grade classes for some reason. Response 2 takes the optimistic approach while assuming that he'll actually be with little kids - the parents of which would make up the "community" that would "accept" him. Response 3 takes a very optimistic approach - where response 2 at least acknowledged that most people are not going to be very accepting of the situation, response 3 goes directly for the "appearance doesn't matter" motto. It certainly would be nice if nobody cared how anybody looked, but I have a feeling that isn't going to change much in the next century. In other words, it's a good general response, but a bad practical response.
"If I told you I'm six feet, five inches, what would you say?"
Back to "what would your response be" but now going to the next extreme: height mismatch.
  1. Speechless.
  2. "That I would question." "Why?" "Because you're not! No, I don't think you're six foot five."
  3. "If you truly believed you're six five, I don't think it's harmful. I think it's fine if you believe that. It doesn't matter to me if you think you're taller than you are." "So you'd be willing to tell me I'm wrong?" "I wouldn't tell you you're wrong."
  4. "No, but I'd say that I don't think that you are."
  5. "I feel like that's not my place as, like, another human to say someone is wrong or to draw lines or boundaries."
  6. "No, I mean, I wouldn't just go like 'oh, you're wrong, like, that's wrong to believe in it', because I mean, again, it doesn't really bother me what you want to think about your height or anything."
Strange things have started happening. Through conversation these students may have backed themselves into a corner that makes it difficult to say contradictory things, or they may actually believe that it's okay to not tell someone they have a misconception about their physical appearance. There are disorders where people look into a mirror and see themselves differently than they actually are, there are people who have a simple misunderstanding or misread their height, there are many situations where a person can believe they are one height when they actually are not. Unless someone is torturing you to believe there are five lights instead of four, I think you should always tell someone they don't look like the height they claim to be.

But that isn't what happens in these selected responses. Response 2 is directly pointing out the problem, but not very confidently at first. Response 3 is amazing - rather than confront the false information, they would rather ignore it because it isn't affecting them, it isn't "harmful". Except it is harmful - it's harmful to the person who believes they are a different height than the actually are. If I were to take this to the next extreme, I would bring up suicide - "I don't think it's harmful" would get you investigated by the police for negligence. Okay, so believing you're a different height than you really are is more mundane than that, but I still think it is negligent to not tell someone about a potential problem that directly affects them. Look at part I bolded, "I wouldn't tell you you're wrong." To me, this means she believes he is wrong, but she isn't willing to say so. This is a conscious decision to be negligent. People have told me that it's disrespectful to say certain things to people, but there are also times where is is disrespectful to not say certain things to people.

Responses 4 and 6 both start with "No", so I assume they take place after "So you'd be willing to tell me I'm wrong?" was asked. Response 4 then reads as, paraphrased, "I would not tell you you're wrong, but I would tell you I don't think you're right." - so, lack of confidence. Response 5 is astonishing to me. The only way I can rationalize response 5 is to imagine that this person believes we all exist in our own separate pocket universes and can in no way have any effect on each other. This simply isn't true - society works because we draw boundaries, and court cases work because we admit that some people are wrong. We all affect each other, whether we like it or not, and not drawing boundaries or telling people they're wrong is very close to giving in to chaos.

Response 6 is like response 3 - "it doesn't bother me". Again, I see this as negligent - someone has an obvious disconnect between what they believe to be true and what is actually true, which is usually a sign of a mental disorder, and instead of telling that person about that disconnect and helping them to realize there may be a problem, these people are opting to keep away and not think about it. Obviously there's a time and a place, but previously these people were giving altruistic responses and have suddenly switched to selfish responses. It seems very strange to me.
"So, I can be a Chinese woman...but I can't be a six foot five Chinese woman..."
  1. (a) "Sure." (b) "Yes."
  2. "If you thoroughly debated me or explained why you felt that you were six foot five, I feel like I would be very open to saying that you were six foot five, or Chinese, or a woman."
Ah, now we get to talk about Conclusion Guy. In this last question he generates response 2. Conclusion Guy really stood out to me because of his unusual responses. I have actually met several people like this - their solution to any problem is to talk about it. In fact, I think I might actually be a Conclusion Guy myself. Doesn't make sense? Let's have a discussion. Goes against my views? Let's talk about it. Sounds completely unreasonable? Let's debate it. In all honesty, it seems like a good way to do things - rather than limit himself to a quick response under pressure, Conclusion Guy tries to lock in a long term agreement to talk things out and get a better understanding of the situation than what he currently has from such a brief question. Conclusion Guy is open minded, but wants to see the whole picture first. Really, I think everyone should be this way to some extent.

Where Conclusion Guy takes the spotlight, everyone else seems to fall flat, defaulting to a generic response that evades the question, or barfing out a mindless response that is not well thought out and will likely make them feel pretty embarrassed after the fact. One of the comments on the YouTube comment section points out that many responses include the phrase "I feel" - I don't fully understand the implications of that, but I noticed it too, and I think it has to do with the pressure the students were feeling causing them to give gut responses.

The world isn't magically going to become an easier place to understand. People need to take the time to learn and think. Learning is one thing, but you can learn all day long without thinking at all. Some even go as far as saying that you aren't learning unless you're thinking, and I'd tend to agree. So, people need to think about the implications of their beliefs. I split identity into three parts when I took the time to think, and as a result a lot of things make a lot more sense to me now. I feel a lot more comfortable talking about things that would have previously left me confused.

You should probably also take some time to think things over. Once you've done that, move on with your life! You've got other important things to do. I appreciate that you read some random 20-year-old's half-assed blog about identity that sounds like it might be preaching some kind of strange identity religion, but please get back to curing cancer after you've thought things over. Also, take out the trash. That's important too, because it gives you time to think.


So, this blog post about my thoughts on identity turned into an informal essay where I break down a video, followed by a cheesy 'how this affects the world' set of paragraphs that I was compelled to write out of habit. Interesting. Well, at least it's safe to say that ninjas identify as ninjas.

2016-03-26

Micro Libraries and Monoliths

The internet is abuzz with the kik controversy and the 11 lines of code from left-pad that, when removed, 'broke the internet'. This whole thing is fascinating to me, and I feel compelled to talk about it.

Kik is a registered trademark, and trademarks are a thing for a reason. Also, companies are required to defend their trademark or they will lose it. I'm not a lawyer, so that's all I can say with certainty. Now, you are not at all related to Kik and you make an NPM package called kik. Then you are asked to rename it because Kik wants their name. How would you respond? Personally, I'd recognize that I'm in over my head already and just go ahead and pick a different name. The legalities of the situation are beyond my comprehension, but I have a strong feeling they are not in my favor. That's not what happened, though. The real kicker? None of this would have happened if packages were namespaced under their owner's name (what I consider to be 'sane'). "someperson/kik" and "Kik/kik" could have happily coexisted and nobody would have ever complained.

The end result is that NPM gave Kik their name, and the other guy reacted by removing all his code from NPM. Of that code was left-pad, an 11 line snippet that is now duplicated everywhere on the internet and probably etched in stone somewhere, so I will refrain from perpetuating it here as it isn't too impressive. What is it? It's a micro-library that lets you pad the left side of a string. By removing it from NPM, it broke the build of several projects that directly depended on it and caused a resonance cascade from the further indirect dependencies. Everything that depended on it in some form or fashion broke. Until this point most people didn't even know it existed or that they depended on it.

The whole situation has sparked several discussions on the various parts in play. The way I see it there are three main discussion points:

  • Who was in the right, Kik or the other guy?
  • Is it a good or bad idea to have so many dependencies like this?
  • Should left-pad really even have existed in the first place?
I'm more interested in the last two. Let's start with micro-libraries. There's an excellent GitHub comment about the benefits of micro-libraries that basically sums up my own thoughts on the subject pretty well.
People get way too easily caught up in the LOC (Lines Of Code). LOC is pretty much irrelevant. It doesn't matter if the module is one line or hundreds. It's all about containing complexity. Think of node modules as lego blocks. You don't necessarily care about the details of how it's made. All you need to know is how to use the lego blocks to build your lego castle. By making small focused modules you can easily build large complex systems without having to know every single detail of how everything works. Our short term memory is finite. In addition, by having these modules as modules other people can reuse them and when a module is improved or a bug is fixed, every consumer benefits.
The difference between a 'normal' library and a 'micro' library is scale, but there isn't much agreement on what that scale should be. The general consensus, at least, is that it should not be at the scale of a single function. Let's consider left-pad: my first thoughts are, what about right-pad? Middle-pad? Vertical-pad? Shouldn't this really be string-pad which contains several functions including left-pad and right-pad? I want the level of granularity to be more than just a single function. The fact that left-pad exists and was used in so many projects is mind-boggling to me. It doesn't make sense to exist on its own without other string-related functions to go with it. It doesn't make sense to be used on its own when you could easily replicate it better yourself in less time than it takes to find it. I find myself wishing it to be part of a larger collection of functions.

But then I see huge monolithic monstrosities like Boost, a massively bloated project with dozens of actual libraries that should really be independent projects in their own right but which are instead clumped together and treated as one. Because they are grouped together they have a tendency to depend on each other rather strongly, making it hard to get what you want without pulling in two or three other components. They actually had to create a special tool to let you isolate the stuff you want because of how non-trivial it is. It also takes a long time to compile when you just want to use a single function from it. That doesn't sound good to me either, and to be honest, I think I'd rather take left-pad.

But what about the language? They say PHP is a fractal of bad design, but at least it actually was designed. JavaScript was made in such a short time that I find it hard to believe any real thought went into it at all. In JavaScript, design is an overstatement. Worse, fixing problems in newer versions  of the language doesn't really work because everyone still wants to support older browsers anyway, which as a result requires sticking to older versions of the language. The whole mess has resulted in the necessity for entire packages just to determine if a value is a positive integer. You may scoff at that, because in any other language it would be trivial, but it's downright dangerous in JavaScript and the chances you will make a mistake when doing it yourself are high enough to warrant relying on external code.

The problem is scale. Why does an entire package need to be fully dedicated to just seeing if a value is a positive integer? Couldn't you fit in other things like, you know, seeing if a number is a negative integer? Seeing if a number is equal to or close to 0? My point is, splitting out such closely related questions into such separate answers is unhealthy because it results in more dependencies. More dependencies results in more trust, and more trust results in more risk.

It's clear there are two ends of the spectrum: massive all-in-one megalibraries like Boost which aim to provide everything you could ever want or need in one neat package whether you like it or not, and a gazillion microlibraries all owned and operated by different people to perform simple tasks that are trivial enough to be one liners but complex enough that you could screw it up if you did it yourself. Thankfully, I think most libraries fall in the middle of the spectrum and that most people would agree the middle is better.

So if most people would agree the middle is better, why do so many libraries still go the extreme route? Well, micro-libraries are easy to write, easy to reason about, and easy to use. Seems like win-win-win! We should totally all start making micro-libraries that are just one function with no more than 11 lines of code! Except you're missing a huge glaring problem: the dependency. This entire incident highlights the catastrophic flaw of removing one block from the jenga tower and watching it collapse. Sure, it can be repaired, but only if you notice it.

There are other more subtle ways to do bad things to a jenga tower. You could add malicious code to one of the blocks, or change the behavior of one of them in a not-so-obvious way. As long as it doesn't break builds, you can do a lot of damage without anyone even noticing. Remember when I mentioned trust and risk?
In addition, by having these modules as modules other people can reuse them and when a module is improved or a bug is fixed, every consumer benefits.
So what happens when a module is made worse or a bug is added? What happens when malicious code is introduced? Micro-libraries impose a problem caused by their sheer number. Where you can easily examine the practices and behavior of the maintainers of a single library like Boost, it becomes an overwhelming task to look at each and every developer of each and every micro-library, and so on for each of their dependencies recursively. It takes a lot of trust to use so many dependencies from so many different people.

Each micro library is typically maintained by a single person, whereas each megalibrary is typically maintained by many people. If we say that most people are good people, then megalibraries are generally immune to evil code because the other project members can spot it and stop it. But microlibraries don't have a self-check, they just have a single person to do with them what they please, and as we have already seen it only takes one.

At the end of the day, though, microlibraries aren't in general a bad idea, and neither are megalibraries. I just think we could avoid the problems of both with middle-sized libraries, even if it means we partially sacrifice some of the benefits. So I leave you to answer the non-trivial question of how related various things need to be to be in the same library and how unrelated they need to be to be in separate libraries. I'm sure ninjas can totally answer that.

2016-02-25

Fizzlers

I haven't really studied game design much, but seeing as I want to make games, I figured I had better at least pay attention to the games I play and see what I can learn from their design. I've learned a lot of things about game design and a lot of things about myself - namely, I like puzzle games, and there's a trend in puzzle games that makes them more fun for me.

I've recently been playing a lot of Portal. A lot. I've played Portal 1, Portal 2, Portal Stories: Mel, Aperture Tag, Rexaura, and many, many community maps for Portal 2. (Though I have not played anywhere near as much as this guy). One thing I have noticed consistently is that I enjoy fizzler puzzles - you know, those ones where one or more Aperture Science Material Emancipation Grills play a crucial role in the puzzle?

A fizzler in Portal 2, with a nearby cube to show the effect.
Fizzlers in Portal 2 allow you to pass through them, but they impose certain limitations. You cannot shoot portals through them, and when you pass through them your existing portals are cleared. Also, any objects that come into contact with them are fizzled - that is, destroyed. However, lasers, light bridges, and excursion funnels can all pass through them without issue. From a simple standpoint, this makes them a sort of special kind of wall that you can only pass through if you are willing to lose your portals and any carried objects. However, there is a bit more to them than that - for you see, they can also be turned on or off.

If you can, you should play The Winter Testing Initiative - the last puzzle is a fizzler puzzle and had me stumped until I looked up a walkthrough. Fizzler puzzles become very challenging when you can turn off the fizzler temporarily - you suddenly have to think far more carefully about when and why you would turn it off, because when you turn it off you can shoot portals on both sides, but then you may be required to turn the fizzler back on. Suddenly, you have to keep your portals on each side of the fizzler and never touch the fizzler. You also have to decide which side of the fizzler you want objects on. It introduces a whole new level of challenge despite the rules being so simple.

The Portal trilogy aren't the only games with this concept, though; Antichamber, another of my all time favorite games, also employs fizzlers - a few different kinds, actually. Some fizzlers don't let you carry bricks through in your brick tool, but you can shoot bricks through them and move them to the other side. Other fizzlers will let you carry bricks but won't let bricks exist within them, destroying them on contact. There are also fizzlers that do both. Several puzzles in the game revolve around outwitting the fizzlers.

A fizzler in Antichamber.
Another game, The Swapper, also features fizzlers - there are fizzlers that clear your clones when you pass through them (which are only used for story purposes and never as puzzle elements, unfortunately), but there are also red and blue light sources which block swapping and clone creation, respectively. When red and blue light overlap, it creates purple light that blocks both. Nearly every puzzle in the game uses these lights to prevent you from taking the obvious approach - in fact, the game would not work without them. The lights are also often turned on or off by switches, and the light sources themselves can even be blocked by physical objects.

A fizzler (left) and colored lights (center) in The Swapper.
Even The Witness has something a little similar - what I like to call "strategic breaks". The line puzzles in the game often have breaks in the grid that prevent the line from passing that way, forcing you to use a different path. I often found that these breaks were placed in such a way so as to block all the obvious and trivial solutions, forcing me to get creative and think outside the box.

A puzzle in The Witness with two "strategic breaks".
So what is it about fizzlers that makes puzzle games so much more fun and challenging, aside from the fact that the English spellings of the words both have the double Z? Well, I think it has everything to do with constricting movement in a logical manner. Fizzlers force you to act in a certain way that no other puzzle element does. Sure, a wall will block your path, and a light bridge is only so wide, but fizzlers can be turned off and they have special rules about what they allow through. They require far more strategic thinking - can I walk through this fizzler and reset my portals? Do I need the cube on this side or the other side? Can I shoot bricks under or above this fizzler and access them on the other side? Can I create a clone on the other side of the light and then switch to it after pressing this button? Can I draw my line this way and satisfy the requirements like that instead?

Fizzlers require thinking about alternative solutions. They aren't always wall, because the player might be able to pass through them effortlessly. They aren't always door, because you might be able to walk through them whether they are on or off. They generally aren't deadly, though Portal 2 does have deadly player fizzlers. They don't have to be moved from point A to point B. They don't have to be stood on to satisfy a requirement. They might not even have on and off states.

The interesting thing about fizzlers is that they can be found even in games which are not primarily puzzle games. Think force fields which allow passage but cannot be shot through. Sci-fi shooters are full of them. Sometimes they are even just invisible walls to prevent objects from leaving areas. However, despite the fact that you can find a fizzler in so many games, very few actually take advantage of their properties - generally fizzlers are just used to prevent the player from doing something that the developer doesn't want them to do. Things get interesting when developers use them to force the player to do something they want the player to do.

A picture I totally didn't steal from the internet. Only ninjas do that sort of thing.
The Legend Of Zelda: Twilight Princess has a very interesting mechanic in one of its dungeons. You are required to carry around cannonballs so that you can place them into cannons and destroy obstacles (walls, enemies). However, Link cannot carry cannonballs through doors - you have to set down the cannonball before traversing the door. Sounding familiar? Additionally, next to certain doors are devices in which you can place a cannonball and then retrieve it in the other room. Yes, I am saying that fizzlers exist in the Zelda universe too, they are just cleverly hidden in a puzzle mechanic. Or, rather, they are the puzzle mechanic.

My point is, whether fizzlers are obvious or not, you can usually find them in good games, and for me the most challenging and engaging games are the ones that take advantage of their properties. But what do I mean when I talk about fizzler in the general sense? In Portal, fizzlers are a field that disintegrates objects and resets portals. In Antichamber it is much the same. The Swapper is where things get interesting - not only is there a traditional fizzler that resets your clones, there are the colored lights that I also consider fizzlers, just a different kind. The colored lights in The Swapper don't disintegrate objects or clones, but they do prevent using your abilities in certain areas. Where you cannot shoot a portal through a fizzler in Portal 2, you cannot swap to a clone through red light in The Swapper.

What about The Witness? Surely I don't consider the strategic breaks to be fizzlers too? There are no objects to be destroyed, no guns to shoot, no switches to toggle them on or off. Well, you're right - I don't consider them to be fizzlers. I threw them in as a red herring - they are just plain ordinary walls. Basically, I lied to you in order to get my point across. Will you accept my apology? Yes? Good. Now let's talk about my general definition of a fizzler.

To me, a fizzler is any selective filter in a puzzle game - it must allow travel for some things but not others. Things that can be filtered by a fizzler include the player, various objects, and remote abilities (such as portals as in Portal, energy orbs as in The Turing Test, or bricks in Antichamber). This definition supports fizzlers in Portal, Antichamber, The Swapper, Twilight Princess, and The Turing Test.

That's it! We have a definition. Are there any other games which contain fizzlers by that definition, obvious or not? Let me know! Or don't. That's fine too.

UPDATE 2016-07-20: I've played more puzzle games and found more fizzlers! It's almost as if there is a correlation...
In "The Talos Principle": a classic fizzler (left) and a toggleable barrier (right)
In "Red Trigger": a basic fizzler that resets your blocks and energy when you pass through it, but you can also shoot through it

2016-01-04

Why do people like puzzles with multiple solutions!?

I've asked this question before and I still want to talk about it, because I still cringe when people mention it.

I frequently notice reviewers and players complaining about puzzles with only one solution, saying they instead want puzzles with multiple solutions. I cannot wrap my head around why, as there are so many drawbacks both from the player's perspective and the designer's perspective. Why would people want this when it only subtracts from the experience?

Having multiple solutions can either make a puzzle too easy, or too confusing. For example, the player often thinks that every part of the puzzle has a purpose (this is how our brains naturally work), but with multiple solutions, some parts of a puzzle might never be used for the solution the player uses, leading to confusion - red herrings may be enjoyable in some circumstances, but puzzles are not any of those circumstances. It is also significantly more difficult to design a proper puzzle with multiple solutions that are all the same level of challenge, especially since the level of challenge is highly subjective - for any given person, one solution will end up being easier, even if on average both solutions are about the same difficulty. This ends up watering down the puzzle, taking away some of the challenge. Having one solution be noticeably easier can often make the player feel stupid when they realize they did it the hard way, and that's not a nice feeling to have.

I like the feeling of knowing I did something the right way. Not just one way of many possible ways, I mean the right way - it's idealistic because real life often doesn't have a single right answer. Real life has choices, and choices are annoying - they require an entirely different kind of thinking from puzzle solving and it's not something I enjoy.

This XKCD comic perfectly describes my life and the reason it takes me so long to ever do anything.

If I want to make choices, I will play a game centered around choice - not a puzzle game. A puzzle game should challenge me to solve each puzzle by figuring out how all the pieces fit together, not throw possible solutions at me until one of them finally sticks. Having secrets is fine, but having entire other solutions to the same puzzle just makes me feel cheated and patronized. Weren't you confident enough in my cognitive ability to do it the right way?

If this doesn't make sense to you, it might be because of how I am using the word "choice". When I say you have a choice, it means you can completely avoid one or more interactions by using one or more other interactions. In a good (single-solution) puzzle, all elements require an interaction at one point or another, so there is never any choice to be made. The puzzle is about when to make interactions and in what order the interactions should happen. I don't consider doing things in a different order as adding multiple solutions, nor do I consider walking in a slightly different way to be a different solution. You might "choose" to stand in one spot for an hour, but that's not a choice from the perspective of the puzzle.

Back on track - having multiple solutions to a puzzle generally seems like a mistake to me; an oversight. It distracts me from the game and instead makes me focus on the meta aspects, which is the opposite of immersive. I shouldn't have to ponder why a puzzle element went unused, making me wonder if I abused a glitch. It gives me the impression that the puzzle was not playtested very well, or at all. It just looks awkward.

I've heard people say that having puzzles with one solution is basically putting the puzzle 'on rails', but I don't even understand how that's bad if the challenge is finding out where the rail even is in the first place. Puzzle games aren't about creativity, they're about logic. I want to solve something, not discover something - there are other kinds of games that focus on discovery rather than solving, and I wouldn't be playing a puzzle game if I were interested in that instead. Besides, many people enjoy 'walking simulators', and movies are still incredibly popular despite always having the same outcome at every corner - having multiple paths and/or choices to make isn't always necessary or even desirable.

I hate puzzles with multiple solutions because they subtract from the experience in so many ways and require additional effort from the developer to create them - effort that could have been spent elsewhere. At least ninjas know better than to waste effort.