documentation is thoroughly hard
Documentation is good, so therefore more documentation must be better, right? A few examples where things may have gotten out of control.
more...
Documentation is good, so therefore more documentation must be better, right? A few examples where things may have gotten out of control.
more...
Why don’t unix commands have any vowels in the name? cp and mv are obviously devoweled standins for copy and move. But they’re less intuitive for new users. The user wants to copy a file. Why shouldn’t the name of the command be exactly the operation the user wants to perform?
What exactly does the user want to do? Instead of copying files, maybe I want to link two files. What does that mean? In unix, we have hard links and symbolic links. If I replace the “original” file, do I want the link to refer to the original file or the replacement? Or maybe what I mean by link two files is to combine two object files into an executable. Do we call that loading instead? ln is the name of a command, but link is the name of a concept. And sometimes the concept evolves over time. The linker is called ld because it used to be the loader. (I think.)
grep is a remarkably useful tool, but with a most unintuitive name. Why not call it find like Windows does? I want to find some text, I run find. So obvious. But some users may want to find files in the filesystem, not strings in a file. What command do they run? Probably locate.
There may be a great deal of historical accident in the names of commands (what if the inventors of awk had different initials?), but that doesn’t mean we can’t recognize the value of unique and precise identifiers.
The Solitaire cipher is perhaps the best known encryption algorithm implemented with a deck of cards. Ignoring security, it has a few drawbacks. It’s pretty complicated. I can never quite remember the rules. Sure, with practice it’s possible to memorize, but ideally we want something easy to teach. It’s also pretty slow. Even with practice, the shuffling and cutting manipulations take time.
more...
Unlike other languages which have one preferred means of signalling an error, C is a multi error paradigm language. Error handling styles in C can be organized into one of several distinct styles, such as popular or correct. Some examples of each.
more...
A fun iPhone (and many more) game. Your job is to build and manage an ever growing subway system, until eventually unhappy riders revolt. The gameplay is fairly simple, with very few different types of resource to manage, but each play through is different. I’m still working out a few strategies, but just when I think I’ve nailed it, I’ll get an uncooperative map. It’s both like and unlike Flight Control. In many ways better. More variation. The intensity builds up over time, but it never demands unblinking concentration. More strategy than action. The game strikes a very good balance between abstraction and realism. Station types and passengers are just shapes like circle and square, but it’s easy to imagine them as residential and commercial districts.
I rarely comment about politics, and rarely regret not posting, but this is one of those times I thought about saying something earlier and didn’t, and now I regret it. This should have been said months ago, but there will be more elections to come, so better late than never. It’s about talking to people, but don’t worry, it has nothing to do with respect.
more...
A few thoughts on what it means for software to be production ready. Or rather, what if any information is conveyed to me when I’m told that something is used in production. Millions of users can’t be wrong!
more...
Hello there, inquisitive friend! I’m pleased to announce the newest Links As A Service offering. It’s called inks which is like links, but without the L for loser. Basically Reddit or Hacker News, but without the disagreeable trolls and military industrial complex shills downvoting everything to hide the truth.
One day you wake up, infused with the entrepreneurial spirit. Enthused even. The time has come to bring forth your vision of a better future. You hike up the road to magic mountain to meet the wizard. Impressed with your spark, he gives you his blessing and so you go to work. Soon, your dream will become reality. Banana peeling as a service.
A few short months later, and you already have 101 customers. Growth is spectacular! Just like the wizard and his magic beans promised. Of course, 99 of those customers are fellow inhabitants of magic mountain and the other two are your mom and college roommate, but magic growth is magic growth.
A few long months later, and you still have 101 customers. But not to worry. Elsewhere on magic mountain there’s a deep fried burritos as a service dream become reality, and they actually have paying muggle customers. With only a tiny pivot, your banana peeling expertise can become burrito unwrapping expertise. You are a true master of the monad. And so, your incredible journey synergizes into theirs.
Some may ask why it was necessary to absorb an entire village of banana peelers instead of hiring a single burrito unwrapper, and why it was necesssary to pay everyone so many millions of hexes, but that’s just quibbling. The council of elder wizards met under the moonlight and decided this was the happiest outcome for everyone.
The end.
The average time to check if a random array is sorted is e - 1. This was not the result I was expecting, but it’s also easy to check.
#include <stdio.h>
#include <stdlib.h>
typedef unsigned int unt;
const unt length = 100;
unt
sortlen(unt *arr)
{
unt i;
for (i = 0; i < length - 1; i++)
if (arr[i] > arr[i + 1])
break;
return i + 1;
}
void
shuffle(unt *arr)
{
unt i;
for (i = 0; i < length - 1; i++) {
unt j = i + arc4random_uniform(length - i);
unt t = arr[j];
arr[j] = arr[i];
arr[i] = t;
}
}
int
main(int argc, char **argv)
{
const unt trials = 1000000;
unt arr[length];
unt i;
unt count = 0;
for (i = 0; i < length; i++)
arr[i] = i;
for (i = 0; i < trials; i++) {
shuffle(arr);
count += sortlen(arr);
}
printf("avg sort len %f\n", (double)count / trials);
}
And the results:
carbolite:/tmp> ./sort
avg sort len 1.718539
carbolite:/tmp> ./sort
avg sort len 1.717483
carbolite:/tmp> ./sort
avg sort len 1.718032
I’m not sure if it’s reasonable to expect the inputs to such a function to be uniformly random arrays. Any program which checks if an array is sorted probably deals with sorted arrays more frequently. But at least the math checks out.