Code vs. Poetry

David Plotz did an interesting interview with Google engineer Nina Kang for the Working podcast. Here’s an excerpt (edited for clarity):
T:大卫.普拉茲向在Working podcast工作的Google工程师康芯寧做了一次有趣的采访。这是谈话摘录(经过后期编辑润色):

Q: What is it when you’re writing code that makes particular code really good?
T: 是什么让你写特定代码时做得很好?

A: It depends on the situation and the company. Google is a very collaborative company. There were almost a thousand programmers on Google Maps. To my mind, what makes code good is that it is almost anonymous. You shouldn’t be able to read that code and say, oh, Kevin down the hall wrote it. Because if it’s idiosyncratic in that way, it means that it’s not something that’s gonna be so easy for other people to modify. Everyone should write in a uniform enough style within a team that we can easily grasp each other’s code and modify it. And there are a couple of things that I look for when I’m looking at code. One of the things is how few lines would it take for it to be modified. Code that requires a lot of repetition, some people find that poetic, but I find that tedious. […]
T: 这要取决于所处的环境和所在的公司。Google是一家特别讲究合作的公司。Google地图的程序员差不多有一千多名。

Q: Great word there, poetic. What does that mean when you say, some people find it poetic?

A: Computer programmers pride ourselves on writing elegant code, or poetic code. But usually what that means is writing code the way the individual programmer thinks is good and that is incredibly subjective. … I think that poetic code is code that you can read [easily]. […]

Q: Will great coders come up with very different solutions to a problem than non-great coders?

A: Absolutely. Great coders come up with solutions that are usually more concise and more easily verified. I think that the key metric is, can someone else read this code and confirm that it works by building a mental model in their head of what the computer’s gonna do at different steps? There are certain things that are really simple, like finding out how many characters are in a line, that you could write in a way that would confuse everybody. But if your code is well written, people understand what it does and they can tell that it works right away.

Q: So elegance, to your mind, corresponds with clarity and concision?

A: Yes, absolutely, just like English.

Q: But in English, as a writer, I pride myself on having a style that is distinctly my own. Do coders, should coders pride themselves on having a style that is distinctly their own or should they pride themselves on having a style which is so clear that it appears to have no style at all.

A: I think a mix of both. I think that if you have a style that’s distinctly your own for good reasons, you’ll find other people who work with you adopting that style and your style would abruptly be less individual. And I think that’s a sign that your style is good. Literature has certain qualities that good code should never have, like deliberate ambiguity, repetition for rhetorical effect, saying things in a slightly different way when you repeat them. I am hard-pressed to think of why that would be good in a team coding setting.

Q: Are you a reader of literature?

A: Yes. I have an MFA in poetry from Warren Wilson.

Q: That’s great. Do you write poetry?

A: Yes.

Q: And when you write poetry and when you write code, are you doing the same thing?

A: My poetry is actually weakened by my coding style and there are certain poetic devices that I have a lot of trouble with using, that I have to deliberately try to force myself to use because they would make for bad coding style. Rhetorical questions, repetition, rhyme, convoluted syntax. It’s so important in poetry to be able to surprise the reader and in coding you can surprise the reader for good effect, but you want to do it through new clarity and new concision. And in poetry the range of things, of emotions you want to give the readers is so much wider than that.

Q: Have you ever read a poet and thought this is like great code?

A: Never. I’ve never read a good poet and thought that.

Q: What do you think you would be doing if you weren’t a coder?

A: I actually took three months off and I wrote an article for Salon. I found writing essays pretty rewarding but not as rewarding as coding. It was just so open-ended and you don’t have that sort of tight collaboration with the computer to validate you. And I did a little yoga and I did gardening. Now pruning and weeding is a lot like coding. Especially maintenance coding in a company like Google.

I have this grapevine and it’s sending out tendrils very aggressively. And the vine might have three different stalks. Each stalk is sending out tendrils almost at random, the tendrils are twining on each other and even though the vine stalks don’t need each other for support, they’ve ended up in this sort of tightly nested space. And that’s actually something that can happen to code, especially in a company as big as Google.

You don’t want to write this one function, you’ll see that someone else on another team wrote a function just like that and you go send out a reference and you link in that function into your own code. Now the other person wants to change their function and suddenly they’re stuck. Yhey can’t change it too much without changing your code, too, and now they have a pickle. The process of untwining those little tendrils and chopping down my stalks felt a lot like what I have to do to decrease other people’s reliance on my code sometimes.

Q: So you’re a woman and you’re a software developer. You obviously work differently than other people because you are a different person than other people. Do you think the fact that you’re a woman has any relevance your working style or what you’re good at?

A: I don’t think there’s anything in me that makes me different from a male programmer. I do think people relate to me differently because I’m a woman. One example would be, especially now that I’m a mother, […] women leaders need to be in certain slots for people to feel comfortable, and one of those roles is the maternal role. So if I am going around asking people, “have you done your work yet?”, and I’m doing it in a way that they can see as motherly, it’s more comfortable than as some young woman trying to nag them. Another thing is that there’s sort of an expectation that women will be better at collaborative tasks, at mentoring, at documenting and explaining things. And there’s certainly been times in my career when I was good at those tasks and there’d be other periods where I was in a more solitary mode for whatever reason. And I definitely think people can relate to me better when I’m slotting into those sort of pink skills a little more clearly.


http://oleb.net/blog/2015/01/code-vs-poetry/