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.
Smilies
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
eat_record_food_problems_and_handle_interrupt(food)
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.
What I do see a lot though, and maybe that's what this is getting at, is code that is broken into more parts and components and glue than is remotely necessary, making it much harder to understand that it all does, which might even be some very very simple thing. It's like each bolt is turned into it's own city. THAT kind of code is indeed, awful and disrespectful to humans all in sides (the programmer for obvious reasons, the user because what the software does & whether it even does that in a sensible way or whether it's even the right solution, is much further removed from the programmer's attention or even ability to analyze)
Although I 1000% support code that is as simple as possible, there's major problems with this comparison.
If the goal is just to order a damn meal, then yes all the "polite interaction" is a waste. But a commandline is not the same context as a restaurant. If you were coding a software driven restaurant of robot-workers, then you better damn well code them to create a good experience, or you've made a crappy service that will fail. But what if it's a restaurant for technologists who don't want to waste time with "nonsense"? Well, now we're taking about understanding the makeup of your users and what creates a good experience for them.
The user is the most important human, because it's the reason the software exists at all. Proper respect for the programmer is to respect the programmer as you say, but also help them to respect the user by providing a well thought out decomposition of the *human* experience that is to be delivered, in the form of clear chunks of behavior and state that map well to the thing the software is to be.
(This code reflects a poor understanding of what that would even look like, because the wrong objects own the wrong methods. The host does not follow, and the waiter does not wait for themself to be available. So in this sense you're disrespecting the programmer even more by presenting backwards abstractions. Maybe host.leadToTable(guest)?)
The human equivalent to the crappy code experience would be like a restaurant where before you can order food, you must talk about cars, and then try on different hats explain your favorite, and open and edit text files between every interaction. It doesn't fit the context at all!
Manners do exist in programming though, like good error messages, good naming so intention and purpose is clear, etc. Those things do *nothing* to improve the actual program itself, it's all about people. You've compared two very different contexts.