When you’re learning a new language, come in with all that you’ve learned,but remain open-minded. I know people who have sort of decided, “This isthe way that all programs should be written.” I won’t mention anylanguages, but some languages, for whatever reason, cause people to get thisway. Whenever they go to a new language, they criticize it to the extent itisn’t like God’s true language, whatever that happens to be. And when theyuse the new language, they try to program in God’s true language to theextent that you can in the new language. Often you’re missing what makes alanguage special if you do that.

It’s like if the only tool you have is a hammer and someone gives you ascrewdriver, and you say, “Well, this isn’t a very good hammer but I guess Ican hold the blade in my hand and whack with the handle.” You have acrappy hammer when in fact you could have used it as a fine screwdriver.So, a combination of open-mindedness and a willingness to apply everythingyou already do know. And of course, code, code, code! The more you usethe language, the faster you’ll learn it.

Seibel: Why do people get so religious about their computer languages?

Bloch: I don’t know. But when you choose a language, you’re choosingmore than a set of technical trade-offs—you’re choosing a community. It’slike choosing a bar. Yes, you want to go to a bar that serves good drinks,but that’s not the most important thing. It’s who hangs out there and whatthey talk about. And that’s the way you choose computer languages. Overtime the community builds up around the language—not only the people,but the software artifacts: tools, libraries, and so forth. That’s one of thereasons that sometimes languages that are, on paper, better than otherlanguages don’t win—because they just haven’t built the right communitiesaround themselves.

Seibel: Java strikes me as interesting in that regard because it has twocommunities. There’s the implementers and systems programmers—peoplewho worked at Javasoft or Weblogic or places like that. Then there’s all thepeople who use Java and app servers and prebuilt frameworks to buildbusiness applications. Those are very different bars.

Bloch: There are multiple communities associated with Java and with otherprogramming languages too. When there aren’t, it’s usually a sign that thelanguage is either a niche language or an immature language. As a languagegrows and prospers, it naturally appeals to a more diverse community. Andfurthermore, as the amount of investment in a language grows, the value ofit grows.

It’s like Metcalfe’s law: the value of a network is proportional to the squareof the number of users. The same is true of languages—you get all thesepeople using a language and all of a sudden you’ve got Eclipse, you’ve gotFindBugs, you’ve got Guice. Even if Java isn’t the perfect language for you,there are all these incidental benefits to using it, so you form your owncommunity that figures out how to do numeric programming in Java, orwhatever kind of programming you want to do.

Seibel: Do you enjoy programming as much as you did when you were akid?

Bloch: I do, although not necessarily in the same way. Like many kids, Ithink, to some degree programming was a refuge from aspects of life that Icouldn’t handle. And the other thing is, when you’re young you haveboundless energy and you can hack for hours and hours on end.

As you get older and have a family and kids and all that, you have otherresponsibilities, other important things in your life. And yet, there’s still thisundeniable high that comes from writing a program, watching the pieces fallinto place and coming up with several beautiful lines of code that arereadable, fast, and do what you want.

Seibel: Do you ever find that because of your greater awareness that it’snot just enough to get it to work, that there are all these other issues, thatit’s almost more daunting?

Bloch: Absolutely. Books too, by the way. I definitely go into avoidancebehaviors when starting things. Starting is the hardest part, whether it’s aprogram or a book or anything else. On the other hand, sometimes youremind yourself, “Come on Josh; you’ve been doing this for three decadesnow, you know how to do it as well as most other people, so just go for it.”And you just sort of remind yourself that, “Look, pretty much every othertime you’ve tried to do this the results have been good, so they’re probablygoing to be good this time too.”

Seibel: So you just talked about how as your life experience broadens, itcan be a distraction, but are there any things, experiences outside ofprogramming, that you feel have made you a better programmer?

Bloch: Oh, absolutely. I think almost everything you do, if you do it well.Ideas transfer from all over the place. One example that comes to mind is,when I wrote my thesis, I did an analysis of a distributed data structure, thereplicated sparse memory. And the basic idea that enabled me to do theanalysis came from a chemistry course I had taken. It was the notion of arate-balance equation: when you have a dynamic equilibrium in a system,you can write equations that say, “Things are entering a certain state at thesame rate that they’re leaving it.” I got three simultaneous equations inthree variables, solved them, and came up with results that preciselymatched the observed behavior of this complicated distributed datastructure. This was an idea I stole straight from chemistry and retargeted atcomputer science.

Many things that you see in life, whether in architecture—the way buildingsare constructed, in language—the way that communication occurs, many ofthese ideas can be retargeted. And, of course, there’s math. Math andprogramming are pretty darn similar. So keeping your eyes open and beingwilling to reuse ideas is a good thing.

Seibel: Do you know programmers who are great programmers but whoaren’t mathematical or well-educated in math? Is it actually important tohave learned calculus and discrete math and all this stuff in order to be aprogrammer? Or is just more a kind of thinking that you could have even ifyou hadn’t had that training?

Bloch: I think it’s a kind of thinking that you could have if you hadn’t hadthat training. But it sure helps. I worked with a guy by the name of madbot,Mike McCloskey. He’s very mathematically inclined but hadn’t taken numbertheory. He rewrote BigInteger. It used to be a veneer over a C package, andhe rewrote it in Java with marching orders to make it run as fast as the Cbasedversion. He actually pulled it off. In doing so he had to learn a heck ofa lot of number theory. He couldn’t have done it if he weren’tmathematically inclined, but he wouldn’t have had to learn it if he alreadyknew it.

Seibel: But that was an inherently mathematical problem.

Bloch: You’re right; it’s a terrible example. But I believe that even forproblems that aren’t inherently mathematical, the kind of thinking that youlearn in math is essential to programming. For instance, inductive proofs areso tied to recursive programming that you can’t really understand onewithout understanding the other. You may not know the terms base caseand induction hypothesis, but you have to understand these concepts if you’regoing to write correct recursive programs. So even if the domain isunrelated to math, a programmer who isn’t comfortable with theseconcepts is going to have a harder time.

You mentioned calculus—I think it’s less important. A funny thing hashappened over the years. It used to be just assumed that if you were aneducated person who had gone to college you had to know calculus. Andthere are a lot of beautiful ideas there—it’s nice to be able to get your mindaround infinity in that way.


Перейти на страницу:
Изменить размер шрифта: