Twitter社のAngus Crollさんのbyfat.xxxへの投稿記事"If Hemingway wrote JavaScript"を訳してみました。



I loved literature long before I ever wrote a line of code. Now I write JavaScript, lots of it, and I’m writing a book about it.


What is it about JavaScript that attracts so many literature devotees? I have a few half-baked theories relating to the expressive potential of a limited syntax, but that’s for another time. What about the great writers? What would they have made of JavaScript? Even as a long-time Hemingway nut, I’d be the first to admit that Papa would probably have loathed programming (and programmers). Yet I’m betting that amongst all that general contempt there would have lurked a soft spot for JavaScript, because it’s his kind of language, am I right? A spare and deceptively plain surface, masking substance and drama beneath.


最近僕は、ヘミングウェイと他に4人の文芸大家にあるJavaScriptを書いてくれるようにお願いした夢を見たんだ; 与えられた長さのフィボナッチ級数を返す関数さ。興味深いことにそれぞれの作家は違った方法で問題を解くことにしたんだ。実際彼らはとてもうまくやったよ - すべての解答は(そう、アンドレ・ブレトンのでも)ちゃんと機能すると僕が言えるぐらいには。以下は僕がもらった解答:

Recently I had a dream in which I asked Hemingway and four other literary luminaries to write some JavaScript for me; specifically a function that returned a fibonacci series of a given length. Interestingly each author chose to solve the problem in a different way. They did pretty well actually - as far as I can tell every solution works as advertised (yes, even Andre Breton’s). Here’s what I got:

function fibonacci(size) {

  var first = 0, second = 1, next, count = 2, result = [first, second];

  if(size < 2)
    return "the request was made but it was not good"

  while(count++ < size) {
    next = first + second;
    first = second;
    second = next;
  return result;

特に驚くようなところはないね。コードは、無駄な言葉や変数はなく本質的なところまで削られている。手が込んでなくて; 少し細かいところにうるさい感じ - でもそれがヘミングウェイの文体の美しささ。凝った論理や賢い変数名など不要。それは簡素で、それは明白で、それはしなければいけないことをする - それ以外何者でもない。

No surprises here. Code reduced to its essentials with no word or variable wasted. It’s not fancy; maybe its even a little pedantic - but that’s the beauty of Hemingway’s writing. No need for elaborate logic or clever variable names. It’s plain and its clear and it does what it has to - and nothing more.


Hemingway didn’t suffer fools gladly so if you ask for a series with less than two numbers he’ll just ignore you. “I’m tired and this question is idiotic”.

function theSeriesOfFIBONACCI(theSize) {

  //a CALCKULATION in two acts.
  //employ'ng the humourous logick of JAVA-SCRIPTE

  //Dramatis Personae
  var theResult; //an ARRAY to contain THE NUMBERS
  var theCounter; //a NUMBER, serv'nt to the FOR LOOP

  //ACT I: in which a ZERO is added for INITIATION

  //[ENTER: theResult]

  //Upon the noble list bestow a zero
  var theResult = [0];

  //ACT II: a LOOP in which the final TWO NUMBERS are QUEREED and SUMM'D

  //[ENTER: theCounter]

  //Commence at one and venture o'er the numbers
  for (theCounter = 1; theCounter < theSize; theCounter++) {
    //By divination set adjoining members
    theResult[theCounter] = (theResult[theCounter-1]||1) + theResult[Math.max(0, theCounter-2)];

  //'Tis done, and here's the answer.
  return theResult;


「詩人」は少し饒舌だけど、僕らはそのほかには考えられない。(表題や演出を除いて)コメントが弱強五歩格を踏んでいることに注意して - 対になった10の音節の拍子にはそれぞれの対の二番目の音節にアクセント。劇の中でシェークスピアはよく、厳格な弱強五歩格から逸脱することで劇的な迫力を加えた - 彼なら余分な音節を加えたり、代わりのアクセントを使ったかもしれない。まるで彼はこのコーディング演習で同じ技巧を使っているように見える。いいぞ、ウィル!

The Bard gets a little wordy here but we wouldn’t have it any other way. Notice how the comments (other than titular captions and stage directions) are written in iambic pentameter - a meter of ten paired syllables with the stress falling on the second syllable of each pair (or foot). In his plays Shakespeare often adds dramatic emphasis by deviating from strict iambic pentameter ― he might add an extra syllable or use an alternate stress. It looks as though he’s using the same trick in this coding exercise. Way to go Will.

function Colette(umbrella) {
  var staircase = 0, galleons = 0, brigantines = 1, armada = [galleons, brigantines], bassoon;
  Array.prototype.embrace = [].push;

  while(2 + staircase++ < umbrella) {
    bassoon = galleons + brigantines;
    armada.embrace(brigantines = (galleons = brigantines, bassoon));

  return armada;

シュールレアリスト運動の創始メンバーとしてブレトンは、夢は現実よりも興味深く創造的な試みの基礎を形成するはずだと信じていた。名詞はそれに従って選ばれている。ブレトンをけなすのは簡単だけれど、彼の仕事はよく熟成し、変わることなく気持ちのこもっていて美しい - 彼自身の意識の表現に織り込まれた心象の無意識な噴出。素晴らしい詩Facteur Chevalの翻訳です。

As a founding member of the surrealist movement, Breton believed dreams were more interesting than reality and should form the basis of our creative endeavors. Nouns are chosen accordingly. Although it’s easy to knock Breton, his work has aged well and is invariably heartfelt and beautiful - an unconscious upwelling of imagery folded into his own conscious expression. Here’s a translation of the gorgeous poem Facteur Cheval.

ブレトンはフィボナッチ演習に昔の恋人の名前を付けたようだ。その一方で彼は結論の集合を古代の船団に見立てた。解答は、らしく優雅なロジックで強調されている - 彼はコンマ演算子を使ってgalleons, brigantines, bassoons間で要素を同時に移している。アンドレ、脱帽だ!

Breton has most likely named his fibonacci exercise after uan old flame, while he imagines the resulting collection as a fleet of ancient vessels. The solution is underscored by characteristically elegant logic - he’s using a comma operator to simultaneously shift elements between galleons, brigantines and bassoons. Hats off Andre!

function LeonardoPisanoBigollo(l) {

  if(l < 0) {
    return "I'd prefer not to respond. (Although several replies occur to me)"


  //Everything is getting complicated.
  for (var i=2,r=[0,1].slice(0,l);i<l;r.push(r[i-1]+r[i-2]),i++)


  //Here are some other mathematicians. Mostly it's just nonsense.

  rationalTheorists = ["Archimedes of Syracuse", "Pierre de Fermat (such margins, boys!)", "Srinivasa Ramanujan", "Rene Descartes", "Leonhard Euler", "Carl Gauss", "Johann Bernoulli", "Jacob Bernoulli", "Aryabhata", "Brahmagupta", "Bhaskara II", "Nilakantha Somayaji", "Omar Khayy&#225;m", "Muhammad ibn M&#363;s&#257; al-Khw&#257;rizm&#299;", "Bernhard Riemann", "Gottfried Leibniz", "Andrey Kolmogorov", "Euclid of Alexandria", "Jules Henri Poincar&#233;", "Srinivasa Ramanujan", "Alexander Grothendieck (who could forget?)", "David Hilbert", "Alan Turing", "von Neumann", "Kurt G&#246;del", "Joseph-Louis Lagrange", "Georg Cantor", "William Rowan Hamilton", "Carl Jacobi", "&#201;variste Galois", "Nikolay Lobachevsky", "Rene Descartes", "Joseph Fourier", "Pierre-Simon Laplace", "Alonzo Church", "Nikolay Bogolyubov"]


  //I didn't understand any of this, but here it is anyway.
  return r


  //Nothing happens here and if it does I'd rather not talk about it.

死ぬまでにボラーニョの本を一冊も読まなかったなら、君は人生を無駄にしたことになる。ボラーニョの文体は素晴らしい: まずごく自然に洗練されて、可愛らしく無邪気だ - 彼の語りのスタイルは、警戒心を解くような魅力ある正直さが特徴だ。人の弱さのいかなる側面にも聖域を作らないが、短所を伝える時の暖かさとユーモアは魅力的で気分を高揚させてくれる。

If you don’t read at least one Bolano book before you die then you’ve wasted your life. Bolano’s writing is remarkable; at once effortlessly sophisticated and charmingly naive - his narrative style is characterized by a disarmingly winsome honesty. No aspect of human frailty is off limits, but the warmth and humour with which every foible is conveyed is both engaging and uplifting.


True to form, Roberto’s exam paper is peppered with admissions of insecurity, embarrassment and ignorance. The solution, though rather brilliant, is presented as something of an afterthought. Always the obsessive, always tangential, he’s much happier offering us a mildly interesting but ultimately useless list of mathematical genii.

以下にボラーニョの別の特徴がある - 長い段落と短い段落の並記、(彼の小説でのクォーテーションマークの欠落を映している)セミコロンの欠落、暗黙のグローバル変数の使用 - それは変数それぞれが続く章で再び現れるよう運命付けられていることを暗示している。

There are other Bolano traits here - the juxtaposition of long and short paragraphs, the absence of semicolons (mirroring the absence of quotation marks in his novels), and the use of implicit globals - suggesting that each variable is destined to make further appearances in subsequent chapters.

function mrFibbowicksNumbers(enormity) {
  var assortment = [0,1,1], tally = 3, artfulRatio = 1.61803;

  while(tally++ < enormity) {
    //here is an exceedingly clever device
    assortment.push(Math.round(assortment[tally-2] * artfulRatio));

  //should there be an overabundance of elements, a remedy need be applied
  return assortment.slice(0, enormity);


I’m not a fan of Dickens. Mostly I agree with Henry James' damning assessment:

「もしも彼の文学的特徴の定義を言い切ってしまおうとしたなら、我々は彼を取るに足らない小説家の中で最も偉大な人物と呼んだだろう。この定義が、彼が飾る文学部の中の下位のランクに彼を押し込めることを我々は知っている: しかし我々は、この、我々の主張の結果を受け入れる。我々の意見では、ディケンズ氏を最も偉大な小説家の一人として位置づけることは人類に対する侮辱である。なぜなら、既にほのめかしたことを繰り返すと、彼は比喩表現以外何も産み出さなかった。彼は人類の特徴に関する我々の理解に何も付け加えなかった。」- チャールズ・ディケンズに関するヘンリー・ジェームズ、"The Nation" 1865年12月21日号の"Our Mutual Friend"の書評の中から:

“If we might hazard a definition of his literary character, we should, accordingly, call him the greatest of superficial novelists. We are aware that this definition confines him to an inferior rank in the department of letters which he adorns; but we accept this consequence of our proposition. It were, in our opinion, an offense against humanity to place Mr. Dickens among the greatest novelists. For, to repeat what we have already intimated, he has created nothing but figure. He has added nothing to our understanding of human character.” - Henry James on Charles Dickens, in a review of Our Mutual Friend, in The Nation, December 21, 1865:


Boz’s superficiality is borne out by his fibonacci solution. Yes, there are some mildly amusing names, but a complete lack of substance and understanding at its heart. He has failed to appreciate the underlying philosophy of the fibonacci series and has instead resorted to bludgeoning his way through the problem with multiplication. Sigh.


クロックフォードの保護卵白かそれともコンピュータサイエンスのクラスの乾いて狭い考え方の範囲か、教義や定説は良きJavaScriptの敵だ。規則集や文例集が好きな開発者もいる - それが私がJavaを持っている理由だ。JavaScriptの楽しみは厳格さの欠落とこれが許す無限の可能性に基づいている。自然言語は同じ兆しを持っている。最良の作者や最良のJavaScript開発者は言語について考え続ける人たちだ。毎日言語を使って探求、実験し、そうする中で自らのスタイルや自らの慣用句、自らの表現を開発する人たちだ。

Whether it’s Crockford’s protective albumen or the dry and narrow minded confines of computer science classes, doctrine and dogma are the enemies of good JavaScript. Some developers like rulebooks and boilerplate - which is why we have Java. The joy of JavaScript is rooted in its lack of rigidity and the infinite possibilities that this allows for. Natural languages hold the same promise. The best authors and the best JavaScript developers are those who obsess about language, who explore and experiment with language every day and in doing so develop their own style, their own idioms, and their own expression.


That’s all. Hope you enjoyed it. It’s mostly nonsense.