Hacker News new | ask | show | jobs
by Sjonny 1729 days ago
Code is for humans, not for computers.

Choose:

  AddElement(object, true, false);
  AddElement(object, true, true);
  AddElement(object, false, false);
  AddElement(object, false, true);

or

  AddElement(object, visible::on, deletable::off);
  AddElement(object, visible::on, deletable::on);
  AddElement(object, visible::off, deletable::off);
  AddElement(object, visible::off, deletable::on);
The latter is more readable, you can spot bugs easier, you don't need to remember which parameter was for visibility, and which was for indicating deletable. And it doesn't take much more to write this than a confusing boolean. It doesn't scale.
1 comments

With a good IDE, the first one can be configured to look like the 2nd one.

But the 2nd one will always be more verbose, no matter if you need it or not.

So I'd choose the first one.

The first one will probably look confusing if you're looking at the repo through a web interface though. Or if you're looking at examples in a readme. I have personally never been limited by my "raw code writing speed", and if that was the case, I would look into touch typing/autocompletion before sacrificing readability.
Most source code will also be badly readable if you print it out ;)

So should we change our use of C++ to make it more GitHub-friendly? Or should we fix GitHub to properly work with the C++ source code that already exists?

I think it's not an issue of Github or not Github. Either you think of code as plain text first, or you think plain text is just another way to present it. I think of code as plain text first, and thus I like programming languages that don't need to be analyzed to be displayed properly. Other people may not think the same.