When a program has nothing surprising to say, it says nothing. — The Art Of Unix Programming
Let’s imagine, Le nix, a unix-style restaurant.
If it’s your first time at Le nix…
First time? Oh boy…
You walk in. You see the host. He doesn’t look at you. You stand there. He doesn’t look at you. You stare at him. He doesn’t look at you. You walk out in disgust. He doesn’t notice.
You didn’t ask him anything, so why would he say anything to you? He follows the rule of silence. This is why the rule is so controversial. It’s so gosh darn unfriendly.
A grey beard walks in…
You’re a unix grey beard. You know what you want. You walk in. You tell the host:
order SwordFishPlatter --payment card --no-tip
and hand him your card.
He immediately hands you back your card, and gives you a number where you can find a table with a perfectly prepared SwordFishPlatter. No conversation, no nonsense, and only takes 90 seconds.
Let’s compare this to the dining experiencing at a typical American restaurant, call it, Smilies:
You walk in.
You walk up to the hostess, she looks at you and smiles. You smile back (it’s rude not to)
She says hi, you say hi. She asks how many for your party. You tell her, maybe you make a joke. Then she brings you to your table (assuming there are seats).
You sit down. The booth is a bit hard, and the light makes it hard to read the menu. Your waiter comes over and introduces himself, maybe pours you some water (without you asking). He tells you about the specials and if they’re out of anything. Even though you don’t eat shellfish, he tells you they’re out of the clam chowder.
You sit, you chat. You wait. He comes by again and asks you for your order. You order. You wait. You get your food. You start eating. About 5 minutes later, you will be interrupted by the waiter. EVERYTHING OKAY? You answer him (usually it is). You eat. He comes by, you ask for the check. He comes back, you give him your card, he comes and goes, you take back your card and leave. Took about 90 minutes.
Writing a program to order lunch
Now let’s consider writing a program to order the SwordFishPlatter at Smilies. You’ll have to write the following:
def order_at_smilies(order) host = get_hostess() host.smile() # can't follow the host before listening host.listen() table = host.follow() waiter = table.waiter() # must listen to specials before waiter will accept order waiter.listen_to_specials() out_of_stock = waiter.listen_to_out_of_stock() if order["name"] in out_of_stock: # Could use exceptions, but will use statuses return "OutOfStock" waiter.wait_to_return() waiter.place_order(order) food = waiter.wait_for_order(order) # pain to implement, so I'm punting it eat_record_food_problems_and_handle_interrupt(food) waiter.wait_to_return() waiter.ask_for_check() waiter.hand_payment(order["card"]) waiter.wait_to_return() bill = waiter.take_bill() if bill.pay_status is not "paid": return bill.pay_failure_reason # punting tip depending on service bill.add_tip(order["tip"]) waiter.return_bill(bill)
Doable, but painful, and that’s with lots of the pain hidden away in methods like
If you’re writing a program to order something at Le Nix, it’s significantly easier.
def order_at_le_nix(order): host = get_host() # equivalent to the unix-like command presented above order_status = host.speak_order(order) if order_status != None: return status pay_status = host.hand_payment_and_tip(order["card"], order["tip"]) if pay_status != None: return pay_status # nothing surprising to say, so will say nothing return None
Le Nix doesn’t tell you about specials you’re not going to order.
Le nix doesn’t force you to smile.
Le Nix doesn’t interrupt you with IS EVERYTHING OKAY.
This might be cold and frightening to a human being, but it makes writing a program to order at Le Nix a breeze. Programmers love ordering at Le Nix. Smilies, however, is a nightmare (personality jokes aside).
The Most Important User
It turns out, the most important user of a program is not a human using a program. It’s another programmer. The programmer programming against your program, which often times is you.
Therefore, when designing programs, we should make our program friendly for other programmers.
That means designing quiet programs like “Le Nix”, not loud ones like “Smilies.”
If you liked this, let me know by giving it a like. If you didn’t, leave a comment so I can write more stuff you like, and less stuff you don’t.