ときどきの雑記帖 濫觴編

最新ページへのリンク
目次ページへのリンク

一つ前へ 2011年9月(下旬)
一つ後へ 2011年10月(中旬)

ホームへ

2011年10月10日

■_

hello, world とメモってあったのだが、はて、これを種に何を書こうとしていたのだっけ?w

ああ、思い出した。 OS X での (Objective-C で書いた) GUIプログラムの hello, world ってどんな感じになるのかなあと。 Programming Mac OS X with Cocoa for Beginners/First Cocoa program - Hello World - Wikibooks, open books for an open world 一番初めのObjective-Cプログラム - @IT やら見ても断片的でよくわかんないんですよね。

Linux FreeBSD
えーと、こっちはなんだっけ。 PFDS 読書会の懇親会のときに、Linux (のコード)が企業にも使われるようになったのはなぜか とか、FreeBSD がそうならなかったのはなぜかという話が出たのですが、 BSD が例の裁判騒ぎで足を引っ張られたからではないか。 裁判でのごたごたを嫌った開発者がLinxuに流れて… という意見がありました。 これひとつということはないでしょうし、なんでかなあと。

んーもっと書くことあったはずなんだがw

今週の木曜日分(金曜日未明)の更新は多分ありません。

■_

■_ Will It Optimize?

元記事は、JavaScriptでインタラクティブに答えあわせができるようになってます ;)

問題をいくつか紹介。

Will It Optimize?

See how well you know (or can anticipate) gcc's optimizer. For each question, the left 
box contains some code, while the right box contains code that purports to do the same 
thing, but that illustrates a particular optimization. Will gcc apply that 
optimization? Put another way, will the code on the left be as fast as the code on the 
right, when compiled with an optimizing gcc?

I used a pretty ancient gcc 4.2.1 for these tests. If newer versions have different 
behavior, please leave a comment.

Beware: not all proposed optimizations are actually valid! 
1. Recursion elimination

Can GCC replace recursive functions with a loop?

1)
int factorial(int x) {
   if (x >1) return x * factorial(x-1);
   else return 1;
}

2)
int factorial(int x) {
   int result = 1;
   while (x > 1) result *= x--;
   return result;
}

2. Loop-invariant strlen()

Will GCC hoist out strlen()?

unsigned sum(const unsigned char *s) {
   unsigned result = 0;
   for (size_t i=0; i < strlen(s); i++) {
      result += s[i];
   }
   return result;
}

unsigned sum(const unsigned char *s) {
   unsigned result = 0;
   size_t length = strlen(s);
   for (size_t i=0; i < length; i++) {
      result += s[i];
   }
   return result;
}

3. Multiplication by 2 to addition - integer

Will GCC transform an integer multiplication by 2 to addition?

int double_it(int x) {
   return x * 2;
}

int double_it(int x) {
   return x + x;
}

■_

ボツ。

■_ PyPy's future directions

LLVM を使うのをあきらめたとかいうのをどこかで見かけたのですが

Lost in JIT: PyPy's future directions

Saturday, October 8, 2011
PyPy's future directions

The PyPy project was long criticised for being insufficiently
transparent about the direction of its development. This changed
drastically with the introduction of the PyPy blog, Twitter stream,
etc., but I think there is still a gap between the achievements
reported in the blog and our ongoing plans.

This post is an attempt to bridge that gap. Note, however, that it is
not a roadmap -- merely a personal opinion about some interesting
directions currently being pursued in the PyPy project. It is not
intended to be exhaustive.

(略)

Concurrent GC

(略)


JSON improvements

(略)


GIL removal

(略)

Minor improvements left and right

Under the radar, PyPy is constantly improving itself. Current trunk is
faster than 1.6 and has fewer bugs. We're always looking at bug
reports and improving the speed of various common constructions, such
as str % tuple, str.join(list), itertools or the filter
function. Individually, these are minor changes, but together they
speed up applications quite significantly from release to release.

All of the above is the ongoing work. Most of it will probably work out
one day, but the deadline is not given. It's however exciting to see so
many different opportunities arising within the PyPy project.

Cheers,
fijal

■_ currying と partial function application

定期的に出る話題ですが

Differentiating between function currying and partial function application

(略)

Now, in order to get this started I'd think the best approach should be to start with 
a formal definition:

    In computer science, partial application (or partial function application) refers 
    to the process of fixing a number of arguments to a function, producing another 
    function of smaller arity. Given a function f:(X × Y × Z) → N , we might fix (or
    'bind') the first argument, producing a function of type partial(f):(Y × Z) → N. 
    Evaluation of this function might be represented as fpartial(2,3). Note that the 
    result of partial function application in this case is a function that takes two 
    arguments. 

    Given a function f of type f:(X × Y) → Z , currying it makes a function
    curry(f):X → (Y → Z). That is, curry(f) takes an argument of type X and returns a 
    function of type Y → Z . 

Where the following definitions could be used for papply and curry:

  papply  : (((a × b) → c) × a) → (b → c)
  curry   : ((a × b) → c) → (a → (b → c))

以下略

最後の二行の比較が印象に残ったのでご紹介。

■_

またもついったから。

Twitter / @ikemo: コンピュータ関係者がRMSみたいな人ばかりなら業界が ...

コンピュータ関係者がRMSみたいな人ばかりなら業界が死んでた。
RMSはプログラム書けるgeek以外の人のことこれっぽちも考えたことないし。
Twitter / @ikemo: 自分の母みたいにコンピュータの仕組みが全く分からない ...

自分の母みたいにコンピュータの仕組みが全く分からない人にとってRMSのいう自由がなんの意味を持つのか。
プログラマー原理主義も大概にしてくれ。

rms みたいな人ばかりという仮定は極論に過ぎると思うけれども、 それはそれとしてなぜこうも激昂しているのかなあと疑問に感じていたのですが (前後のツイートを見ててもこれというのが見当たらなかったし)、 ひょっとしてジョブズの死に対しての rms のコメントにカチンときたんだろうか。 と思った。

2011年10月09日

■_

書店で見かけた

という本に

という記述があってとってもとっても気になったので思わず買って帰り

質問の手紙をしたためました。

さて返事はくるでしょうか?

■_ vs

まあどっちの言い分もわかるし、判断材料しだいでどちらの側にも転ぶと思うのですよね。 と逃げる :)

たぶんだいぶ見逃しているのがあると思いますが(フォローしていない方が多かったし) 全体的な流れは把握できると思います。

Twitter / @aizen76: C++を知らないゲームプログラマ達 http://t ...

C++を知らないゲームプログラマ達
http://d.hatena.ne.jp/alwei/20111008/1318090538

Twitter / @aizen76: ちょっと思うところがあったので書いてみた ...

ちょっと思うところがあったので書いてみた
Twitter / @sunpx: なるほどねぇ、PC育ちの人は普通にSTLとかnewと ...

なるほどねぇ、PC育ちの人は普通にSTLとかnewとか使うよな。イテレータですら、
使うにはものすごく神経使うけどな~、僕は。
Twitter / @snapwith: @sunpx 大名プログラムのアレンジ版なんですよ。 ...

@sunpx 大名プログラムのアレンジ版なんですよ。PSPじゃSTLは怖くて使えない、
みたいな環境が極端に制限された環境でもソースが共用出来ないと困る場合、
を想像できてない気がしました。
Twitter / @SAM_tak: @snapwith @sunpx DSでSTL使って ...

@snapwith @sunpx DSでSTL使ってましたけど、メモリプールさえかっちり整備しておけば特に問題なかったですよ。
カスタムアロケータすら書いた事無いです
Twitter / @sunpx: @snapwith 大名プログラムって、なに? ...

@snapwith 大名プログラムって、なに?
Twitter / @snapwith: @sunpx リソースは無限にあると信じて、きれいに ...

@sunpx リソースは無限にあると信じて、きれいにプログラムを書くことを80年代前半に大名プログラミングと呼んだのですw
Twitter / @117Florian: @snapwith @sunpx 今の「富豪的プログ ...

@snapwith @sunpx 今の「富豪的プログラミング」ですか? しかし、大名(^^;)。
Twitter / @sunpx: わはは。まぁ、16KBしかない時代で育った人間と、1 ...

わはは。まぁ、16KBしかない時代で育った人間と、16GBしかない時代で育った人間じゃ、
感覚が違いますよって話ですなww @117Florian @snapwith
Twitter / @sunpx: STLにしてもnewにしても、処理系が100%完全な ...

STLにしてもnewにしても、処理系が100%完全なら、安心できますが、
0.1%でも不完全(そもそも処理系のしよう自体が不完全w)なので、怖いです。
デバッグする時は、アセンブラレベルですることになりますから。
ソースコードデバッガで追えるうちは幸せなんじゃないですかw
Twitter / @aizen76: @sunpx そこに不安になるくらいなら他のユーザコ ...

@sunpx そこに不安になるくらいなら他のユーザコードがバグってる事の方がよっぽど怖いです…
Twitter / @sunpx: ユーザのプログラムのバグはソースコードが手元にあるの ...

ユーザのプログラムのバグはソースコードが手元にあるので、ソースコードを追うことができますが、
ライブラリやら、コンパイラの出力のバグだったらどうします? っていう恐怖感の問題なんです。
 @aizen76
Twitter / @aizen76: @sunpx そういう場合は明らかにおかしいことをベ ...

@sunpx そういう場合は明らかにおかしいことをベンダに報告して直してもらいます
最近もARM社に報告してコンパイラのバグを直してもらったところです
Twitter / @sunpx: そうそう、そうなりますよね。基本、おかしくなるコード ...

そうそう、そうなりますよね。基本、おかしくなるコードを渡して、
あとお願い・・・ってパターンですよね。
それの修正に何日とか返答をもらえたことありますか? @aizen76

Twitter / @aizen76: @sunpx 返答はありましたけど、大体対応までに一 ...

@sunpx 返答はありましたけど、大体対応までに一ヶ月とかは平気でかかりますねぇ…
まぁ別途対処方法はあったのでそれで対処してましたけど
Twitter / @sunpx: そう、時間があれば・・という話になることも多いですよ ...

そう、時間があれば・・という話になることも多いですよね。
別の処理に逃げられるケースはいいですけど、STLとかだと、一ヶ所見つかったら、
他にもあるかも・・って考えません? @aizen76
Twitter / @aizen76: @sunpx 現実的にSTL側に問題があったケースが ...

@sunpx 現実的にSTL側に問題があったケースが一度もないのでそうは考えないですねぇ…
コード自体はそもそも最も信用出来るものだと思っていますので
よほど問題のある環境(VC6)とかでなければ気にしません
Twitter / @sunpx: そうなんです。普通はそれで良いんです。問題さえ起きな ...

そうなんです。普通はそれで良いんです。問題さえ起きなければ。
HWやチップの開発からゲーム機の販売までの流れを経験した人は、多分そうはいかないでしょうね。
信じられるものが無い状態での開発ですから。
Twitter / @sunpx: まぁ、だから痛い目にあった人と、そうでない人の感覚の ...

まぁ、だから痛い目にあった人と、そうでない人の感覚の差なんですよ。 @aizen76
Twitter / @aizen76: @sunpx しかしそれを怖がっていたら何も出来ない ...

@sunpx しかしそれを怖がっていたら何も出来ないなぁと言うのが個人的な結論です
Twitter / @sunpx: そうそう、だから最初に断りを入れました。何を注意して ...

そうそう、だから最初に断りを入れました。
何を注意してプログラムを書くかはその人の経験の差が大きいので。 @aizen76
Twitter / @aizen76: まぁいいや 私は私の周りでなんとかしていこう そうし ...

まぁいいや 私は私の周りでなんとかしていこう そうしよう
Twitter / @sunpx: そそ、それがいいです。それは経験ですし、ノウハウです ...

そそ、それがいいです。それは経験ですし、ノウハウですから。 @aizen76
Twitter / @sunpx: まぁ、この問題、あんまり議論する気はないんです。そん ...

まぁ、この問題、あんまり議論する気はないんです。
そんなこと言ってたら、プログラム組めないじゃんっていわれて終わっちゃうからw
Twitter / @sunpx: 10年くらい前に、若いやつらに「なんでうちの会社はラ ...

10年くらい前に、若いやつらに「なんでうちの会社はライブラリ化されてないんだ」
って結構つっこれましたけどね。ソースの共有が出来るようになったのは、PS/DC以降だし・・・。
Twitter / @motekin: ゲームプログラマがC++を知らないんじゃなくて、お前 ...

ゲームプログラマがC++を知らないんじゃなくて、お前がゲームプログラム環境の特殊性(特にコンシューマ系)を知らないだけだろと。
/ “C++を知らないゲームプログラマ達 - Ideals and Reality” htn.to/BZUeeN

なぜ ツイッターをまとめよう - Togetter を使わなかったのか? なんとなく。です :)

■_ ありがちな光景?

どうしてこうなった

スレ立てるまでもない質問はここで 113匹目

955 デフォルトの名無しさん [sage] 2011/10/09(日) 18:32:12.22 ID: Be:
    拾得物管理システムを作らなければならなくなった・・・
    プログラムなんてしたことない。
    何から始めればいい? 

956 デフォルトの名無しさん [sage] 2011/10/09(日) 18:42:26.60 ID: Be:
    システム委託先の選択。 

957 955 [sage] 2011/10/09(日) 18:58:22.97 ID: Be:
    >956
    経費が無いから自作せよとの事です。
    予算は無しです。
    ちなみにローカルシステムです。

    とりあえず、今、ビジュアルベーシックというやつをインストールしてます。 

958 デフォルトの名無しさん [sage] 2011/10/09(日) 19:00:05.96 ID: Be:
    楽しそうなネタだな
    こういうのって、外注だといくらくらいなんだろう 

959 955 [sage] 2011/10/09(日) 19:02:53.61 ID: Be:
    >>958
    既成システムを購入すると、30万~50万円だそうです…

    「予算無、経費無し、好きに作ってくれ!!」
    と言われました。
    ちなみに私はただの警備会社の社員です… 

960 デフォルトの名無しさん [sage] 2011/10/09(日) 19:07:24.08 ID: Be:
    エクセルに延々と入力していくだけじゃ駄目なのか 

961 955 [sage] 2011/10/09(日) 19:08:04.22 ID: Be:
    拾得物管理システム システム概要

    ・拾得物に関する基礎情報が登録できること
    ・基礎情報の他に画像データが参照できること
    ・検索画面から任意の条件で検索できること
    ・警察提出様式のcsvファイルにデータを出力できること
    ・警察提出様式の提出書の作成が出来ること
    ・拾得物受領書と拾得物預かり書の出力が基礎情報登録画面からできること
    ・動作は可能な限り警戒であること


    どうしたらいいんだ・・・ 

962 955 [sage] 2011/10/09(日) 19:10:29.89 ID: Be:
    >>960
    可変性があってだめなの。
    excelでなくて、もっと簡単にしたいそうです。

    ちなみにexcelでつくられた、VBE?のやつは、警察が無償公開しているが、
    動作が遅く、処理件数が増えていくたびにデータが肥大化して劇オソで、安定性が無いのだ… 

963 忍法帖【Lv=40,xxxPT】 [sage] 2011/10/09(日) 19:11:44.10 ID: Be:
    >>961
    Excel-VBAでいいじゃん 

964 デフォルトの名無しさん [sage] 2011/10/09(日) 19:13:27.22 ID: Be:
    たとえば納期が一か月として、あなたの給料が月に30万とする
    プログラムを作る期間、一か月がまるまる潰れるとすると、
    会社としては30万で既存のシステムを買ったと同じ、またはマイナスの勘定になる
    しかも、未経験者だから作れるかどうかもわからない
    そう説明して外注にだすかどうかするといい

    …警察の無償公開のって見てみたいな 

965 デフォルトの名無しさん [sage] 2011/10/09(日) 19:14:05.50 ID: Be:
    すげぇけち臭い会社だな。
    つーか、会社名晒せよ。
    絶対警備を任せたくないから。 

966 955 [sage] 2011/10/09(日) 19:17:27.41 ID: Be:
    >964
    これです。
    ttp://www.pref.iwate.jp/~hp0802/oshirase/kaikei/ishitubutu/kanrisya/programhaifu.html

    写真が貼り付けられないし、遅いのですが改造すればできますか…
    毀損システムの買い取りだと、全社的に導入できないからダメだそうです。
    とにかく予算無、仕事の合間に作っていいのだそうです。
    ちなみに私は中間管理職の現業警備員ですが、勤務中はずーと書類なんかを作っているので、お前やれと言う事に…
    excelはちょっと触れるぐらいですよ… 

967 955 [sage] 2011/10/09(日) 19:19:58.17 ID: Be:
    >965
    中堅大手ですよ。
    拾得物管理業務は、煩雑かつ権利関係が複雑。
    大規模施設ならなおさら…
    このご時世ダンピングのし合いで赤ギリギリ…
    こんな事情で予算は無いそうです…
    ははは… 

968 デフォルトの名無しさん [sage] 2011/10/09(日) 19:22:55.95 ID: Be:
    なるほどなるほど
    言い方は悪いかもしれませんが、はっきり言ってあなたには無理な仕事ですので上司と、もっと上の上司に早急に伝えてください
    100くらい出るのなら作ってみたいけど、それじゃ他のを買った方が安いわな 

969 デフォルトの名無しさん [sage] 2011/10/09(日) 19:29:38.87 ID: Be:
    仕事の合間とか無理だぞ
    本職PGでも「ドキュメントや打ち合わせの合間にコーディング」だと効率が激悪くなる

    仕様も決して簡単じゃない。
    情報登録と検索はともかくとして(「任意の条件」てなんだよとは思うが)、
    画像データ・・つまり実ファイルのハンドリングをすると面倒な造りになる。
    csvファイルや提出書、受領書、預かり書についても仕様は明確なのだろうか。
    それに様式も1,2種類じゃないんだろう。提出先によってフォーマットが微妙に変わったりで。

    ・・動作が軽快だと!?・・あほかw

    結論からするとそれ50万でサクッっと作ってくれるとこがあるなら高くないと思うぞ。
    ソース買取りすれば全社導入も出来るだろ。 

970 デフォルトの名無しさん [sage] 2011/10/09(日) 19:31:29.21 ID: Be:
    うちの会社でも、受けるなら百万コースだな。 

971 デフォルトの名無しさん [sage] 2011/10/09(日) 19:34:29.17 ID: Be:
    >>967
    >写真が貼り付けられないし、遅いのですが改造すればできますか…

    著作権法的にもそうだけど
    改正遺失物法に基づくFD届け出用のプログラムだとすると改造はなおさらまずい気がする 

972 955 [sage] 2011/10/09(日) 19:38:16.09 ID: Be:
    おk、わかった。

    何も作らずに出来ないとは言えないから、がわだけつくるなら可能ですか?
    例えばウェルカム画面的な何かだけ表示して、
    「新規登録」「検索」「返還登録」とかの釦を押すと、Windowsが終了する的
    な何かの様なものは、可能でしょうか。 

973 デフォルトの名無しさん [sage] 2011/10/09(日) 19:39:57.98 ID: Be:
    絶対やめとけ
    そんなもん上司に見せたら「お、できるじゃないか、今月中に作っておけよ」で終わる 

976 デフォルトの名無しさん [sage] 2011/10/09(日) 19:51:27.54 ID: Be:
    どう考えても EXCEL に VBA で簡単な操作用のフォームをくっつければ ok じゃん。
    要求的には。 

977 デフォルトの名無しさん [sage] 2011/10/09(日) 20:00:56.34 ID: Be:
    予算ゼロのシステム導入事例か
    すごい時代になったな 

978 デフォルトの名無しさん [sage] 2011/10/09(日) 20:06:26.35 ID: Be:
    > 予算無し、経費無し、納期無し
    よし作ってるフリだけしてやり過ごすんだ 

979 デフォルトの名無しさん [sage] 2011/10/09(日) 20:22:35.57 ID: Be:
    EXCELの既存の奴が重くなるってのにEXCEL使ってどうするのかと
    やり方は色々あるんだろうけど 

980 デフォルトの名無しさん [sage] 2011/10/09(日) 20:25:54.28 ID: Be:
    フロントエンドがexcelでバックグラウンドにaccessで高速化
    とかそういうことはできないの 

983 955 [sage] 2011/10/09(日) 20:35:18.31 ID: Be:
    良い機会だから、excelVBAとやらを、やってみるか。。。
    カエルの本を買えば良い?

    とりあえず、上司には、ナニワ計算センターのパンフ渡して凌ぐわ
    どうせ夢がヒロガリングってまた馬鹿な事言うんだろうけど… 

985 デフォルトの名無しさん [sage] 2011/10/09(日) 20:38:00.59 ID: Be:
    だからexcelで作ったら同じことになるって
    ナニワなんちゃらのソフトがどんな環境になってるか見てくれよ 

986 デフォルトの名無しさん [sage] 2011/10/09(日) 20:40:17.18 ID: Be:
    ゴミのたわごとなどどうでもいい
    次スレ 

そんなに簡単に作れると思う何かがあるんでしょうかねえ。

■_ Articulate Coding

たぶんとても良いことが書いてあるような気がする (要するにまだ読んでいない :)

Case Statement, Lunch and Learn: Articulate Coding

Lunch and Learn: Articulate Coding

We get lunch brought in to work on Fridays. I took the opportunity to show great 
videos to the team while we all ate. It's a lunch and learn with zero effort.

Today we watched Kent Beck's QCon talk on Responsive Design. It's certainly worth 
checking out if you're bored, although it is a bit slow in parts and the non-mic'd 
audience questions do get annoying.

略

Beck's experiment is simple.
Beck の実験は単純です

He would type a few characters and then stop. He would think about those characters 
and determine what pattern they were expressing. Then he thought about why he chose 
that particular pattern. Next, he wrote down his findings and typed a few more 
characters. He would only continue if he had documented the new pattern or if he had 
already encountered the pattern previously.

#んーーわかんねえ
#なんとなくはわかるんだけど

If you think about this, it's a pretty crazy experiment. When we program, we face 
multiple decisions on every line. For instance, imagine this method declaration in a 
typical oo language

この実験についてあなたが考えたなら、それはきっととてもおかしなものでしょう。
わたしたちがプログラムをするときは、一行ごとに複数の決定事項に直面します。
たとえば、典型的なオブジェクト指向言語で次のようなメソッドの宣言をしたと
考えてみましょう

  public function doSomething($id, $job, $newname = 'Anonymous') {

    * Why did I explicitly set the scope to public?
      なぜわたしはスコープを public にしたのだろう?

    * Why did I name the function like this?
      なぜわたしは関数の名前をこのようにしたのだろう?

    * Why did I use camel case for the function name?
      なぜわたしは関数名にキャメルケースを使ったのだろう?

    * Why didn't I define types for the parameters?
      なぜわたしはパラメーターの型をこのように決めたのだろう?

    * Why did I put the parameters in this order?
      なぜわたしはパラメーターをこの順番にしたのだろう?

    * Why did I choose these parameter names?
      なぜわたしはパラメータの名前をこのように決めたのだろう?

    * Why didn't I use camel case for the last parameter?
      なぜわたしは最後のパラメーターの名前にキャメルケースを使わなかったのだろう?

    * Why did I put the open brace on the same line?
      なぜわたしは開きのブレースを同じ行に置いたのだろう?

    * Why did I use single quotes instead of double?
      なぜわたしはダブルクォートではなくシングルクォートを使ったのだろう?

    * Why did I indent?
      なぜわたしはインデントしたのだろう?

    * Why did I use spaces instead of tabs for indent?
      なぜわたしはインデントにタブではなくスペースを使ったのだろう?

    * Why did I use four spaces for the indent?
      なぜわたしはインデントにスペース4個を使ったのだろう?

Here are twelve minor decisions[*] for a line containing only seven words, more 
significant design principles like dependency inversion or single responsibility 
haven't even been touched. You quickly realize that the number of instincts and habits 
that we all have as coders must be enormous. We arrive at these patterns deliberately, 
through convention, and by accident. For example, I deliberately put the $id parameter 
first because I know I'm building an api that uses that same parameter everywhere and 
it will maintain consistency for those calls. I use camel case and leave off the 
typedefs because that's the convention in the team's code base. And when I look 
through the rest of my code I find that my use of single quotes and double quotes is 
completely random, I suspect that my tendency to switch languages often has made it 
difficult to build up a consistent pattern in my mind.

この、たった七語しかない一行に対して12個もの decisions があります。さらに
dependency invension であるとか single responsibility のような明らかな
設計原則にはまったく触れられていません。

略

Personally, I can't wait to try this experiment. Maybe not for an entire project, but 
a new class file could provide me with some good material for introspection.

As I kick off this blog, with many of the same goals as I hope to gain from the 
experiment, I must remember there are no silver bullets. If I want to be able to speak 
about my craft more eloquently I have to speak about my craft more often. Although I 
may think about development every day, I hope that putting my thoughts down in writing 
will help me to articulate my code.

Follow the discussion on Hacker News

■_

2011年10月08日

■_

関内ではさすがに遠いなあ。かなりいいと思うんだけど。 会議室H 会議室ドットコム|会議室.com 料金(税込)は 午前・・4,200円 午後・・7,350円 終日・・9,870円となります。

larroy/Dive-into-C--11 - GitHub

■_ 読書会

ネタ本はこれ
Purely Functional Data Structures

懇親会で話題になったこと(たぶん抜け多数)。順不同で、思い出せる限り。

Java の設計を disる
Java の interface の問題とは
Object を頂点としたクラスライブラリについて
GoF のデザインパターンは(ry
visitor パターンってどんなのだっけ
sigleton って使う?
Haskell で書いたら
Scala 使い来てないの?
Scala のライブラリの実装について scalaz

ICFP での発表の話
発表では大事なことを最初に言おう
小学校の先生の話
等式変換
移項
挿入ソートがマージソートに
選択ソートがクイックソートに
いなばさんが最初に気づいた

λカ娘本をえらい人(名前忘れた)に500円で売った

PythonやらRubyでプログラム組むのは(ry
アルゴリズムイントロダクション
アルゴリズム in C
自分が何に悩んでいたのかは忘れてしまう
演習問題重要
解答もないと困る
解答がないのは筆者が実際に解いていないから?

Haskell は難しくない
「七つの言語七つの世界」
Coq で証明
→ α Γ subscript
Unicode にある数学記号を使ってるプログラム(Agdaやら) 入力どーすんの
Emacs のモードとか
××さん用モード
UCS-4 はなぜ31ビットなのか
mohta bit
「俺に半分よこせ」
void とか lala とか
UTF-8は UCS-4 が31ビットだから成り立った?
沖縄

printcap
CUPS
debian と CentOS と ubuntsu と FreeBSD と NetBSD と OpenBSD
debian の開発コミュニティについて
Linux のディストリビューション
GPL と BSDライセンス
Android のなんとか(よく聞こえなかった)



darcs
http で使えない
闇の軍団
git
Mercurial
仕様変更ではまった話

関数プログラミング
はいい本だ。
SICP ってどんな本?
Scheme だから書けた本(Haskellでは苦労なしに使えるものを実装してたり)

Introduction To Functional Programming, 2nd Edition (Prentice Hall Series in Computer Science)
の翻訳本の話とか

なんのかんのいってHaskellプログラマー増えたよね

トレーダーとプログラマー
2倍
Excel 上でHaskellプログラムが動く
ビジュアルに出力重要
PostScript
絵心

プログラミング Haskell と Real World Haskell を「きちんと」読め。話はそれからだ。
関数プログラミングの楽しみ
モナド
大統一理論
Maybe List IO State (だったかな)
エラーの対処もモナド
圏論
準同型



Real World Haskell―実戦で学ぶ関数型言語プログラミング
プログラミングHaskell
関数プログラミングの楽しみ

追加:

黒田さん
Mac で××したいんだけどできないので X から移れない
忍者
学校に入れるPCについて
Haskell をそういうところにインストールするには
レジストリに書き込みできない
Mac とか Linuxにすりゃあいーじゃん
それはそれでいろいろと
継続は力なり
λ口
λから入り××(思い出せない)から出る


第3章で、leftist heap とか binomial heap とか出てきたんですが、 ヒープって結構あるんですねえ。 いくつか知っているものもあったけど。 日本語での名称だけ知ってて、わからなかったものとかも。 原語で覚えろというのはそうなんですが、 日本語にされるとイメージしやすいってのもあると思うんですよね (迷訳もままありますが…)。 Leftist tree - Wikipedia, the free encyclopedia Leftist Heap - 言語ゲーム Binomial heap - Wikipedia, the free encyclopedia あと、本文で登場するのはちょっとあとですが、finger tree というのも話の中で出てきました。 Finger tree - Wikipedia, the free encyclopedia 2-3 フィンガーツリー - Wikipedia ヒビルテ(2007-07-29) d.y.d. Animated working of a Two-Three-Four tree - a kind of B-Tree ねじれヒープ - Google 検索

Heap (data structure) - Wikipedia, the free encyclopedia

Variants

    * 2-3 heap
    * Beap
    * Binary heap
    * Binomial heap
    * Brodal queue
    * D-ary heap
    * Fibonacci heap
    * Leftist heap
    * Pairing heap
    * Skew heap
    * Soft heap
    * Ternary heap
    * Treap

■_ しかし

来週こういうのがあるとは。 Tokyo.SciPy #2 - [PARTAKE] Tokyo.SciPy#2 2011/10/15(土) 開催案内と発表募集者 - Tokyo.SciPy | Google グループ

Tokyo.SciPy#2 2011/10/15(土) 開催案内と発表募集者 - Tokyo.SciPy | Google グループ

Tokyo.SciPyでは一人30分を目安に、以下のような発表を募集しています。
[NumPy/SciPy入門編](2-3件)
・NumPy/SciPy/周辺ツールの解説
NumPyとSciPyおよびmatplotlibなど周辺ツールの基礎を解説するセッション。
・実演ハンズオン
上記のような内容を、参加者がノートPC持参で実際手を動かして体験するインタラクティブなセッション。
・チュートリアル紹介
EuroSciPy等で発表された外部チュートリアル資料の内容を輪読のような形式でまとめて発表して頂きます。
例えば、以下のように多くの英語資料が公開されています。
http://conference.scipy.org/scipy2010/schedule.html

[NumPy/SciPy実践編](1-2件)
・NumPy/SciPy活用プロジェクト紹介
NumPy/SciPyエキスパートである方に、どのようにNumPy/SciPyを活用しているか発表して頂きます。
・NumPy/SciPyベースの自作ツール紹介
NumPy/SciPyエキスパートである方に、ご自身で公開しているツールについて解説して頂きます。
・NumPy/SciPy導入成果
Tokyo.SciPyをきっかけに得た情報とスキルを自分の研究or業務に応用してみた!という成果報告です。

(略)

[勉強会の目的]
NumPy/SciPyについて、「なるほどこういうことができるのか」「自分の研究ではこう使えそうだ」
「他の人はこんな風に使っているのか」という知見を共有し、それぞれの研究や業務において活か
すことが目的です。第2回も好評だった杜さんによるハンズオン形式のNumPy/SciPy体験セクション
続編があります。ぜひお手持ちのノートPCにNumPy/SciPy環境をインストールの上、お持ち下さい。

[対象者]
・数値計算ライブラリを研究や実務で使いたい人
・特に機械学習、データマイニング、パターン認識、画像処理、音声処理に関わる人
・最近NumPyやSciPyに興味が出てきた人
・Rの言語仕様が何となく肌に合わない人
・Matlabなど有償ソフトウェアは入手が難しい人
・いろいろな言語の中でPythonが得意な人

[前提知識]
・数値計算、確率、統計の基礎
・Pythonの基礎(→http://bit.ly/oSkcVK「事前準備-Python入門」参照) 

YAPC と被っていなければッ…!

■_ MapReduce as a monad

みんな大好きモナド

MapReduce as a monad - HaskellWiki


1 Introduction

MapReduce is a general technique for massively parallel programming developed by 
Google. It takes its inspiration from ideas in functional programming, but has moved 
away from that paradigm to a more imperative approach. I have noticed that MapReduce 
can be expressed naturally, using functional programming techniques, as a form of 
monad.

The standard implementation of MapReduce is the JAVA-based HADOOP framework, which is 
very complex and somewhat temperamental. Moreover, it is necessary to write 
HADOOP-specific code into mappers and reducers. My prototype library takes about 100 
lines of code and can wrap generic mapper / reducer functions.

2 Why a monad?

What the monadic implementation lets us do is the following:

    * Map and reduce look the same.
      Map と reduce が同じに見える

    * You can write a simple wrapper function that takes a mapper / reducer and wraps it in
      the monad, so authors of mappers / reducers do not need to know anything about the
      MapReduce framework: they can concentrate on their algorithms.

      mapper / reducer を引数にとるラッパー関数を間単に書け、それをモナドにラップするのも
      簡単にできるので、mapper / reducer の作者は MapReduce フレームワークについて
      一切知る必要がない。そのアルゴリズムに集中できる

    * All of the guts of MapReduce are hidden in the monad's
      bind
      function
      MapReduce のはらわた (guts) はみなモナドの bind、functionに隠されている

    * The implementation is naturally parallel
      その実装は自然に parallel となる

    * Making a MapReduce program is trivial:
      MapReduce プログラムを簡単にする

... >>= wrapMR mapper >>= wrapMR reducer >>= ...

(略)

■_ 10 programming languages worth checking out

ちょっと前の記事ですが、reddit 効果のせいか 昨日辺りのついったで見かけました 10 programming languages worth checking out : programming

挙げられた十個の顔ぶれを見てみると、三年という時間を考えさせられますね(大げさ)

10 programming languages worth checking out - H3RALD

Published on Sunday, December 21 2008
programming

By Fabio Cevasco

If you program for fun or profit, chances are that you know C, C++, Java, PHP, Perl, 
Python or Ruby. These programming languages are all widely known, and, to a different 
degree, used in commercial applications. At least some of them can safely be 
considered mainstream, even if that word has become so overused and misused that has 
almost lost its original meaning, if it ever had one.

If you are earning your living by coding, it's often one of these languages that pays 
the bills. Nevertheless, true hackers frequently meander in other directions, 
exploring and discovering different paradigms and methodologies, sometimes to the most 
esoteric extremes.


(略)
Haskell

Erlang

Io

PLT Scheme

Clojure

Squeak

OCaml

Factor

Lua

Scala



H3RALD Web Site v8.1.2 © 2004 — 2011 Fabio Cevasco

reddit での反応から

10 programming languages worth checking out : programming

    Sunday, December 21 2008

That explains why he mentioned PLT Scheme and not the new name Racket.


Or how Io was impossible to find a few months ago when I have known about it for years.


And that an article about it had recently been written by _why.

■_

■_

2011年10月07日

■_

Purely Functional Data Structures読書会 第1回 (13:50にIIJ集合) - [PARTAKE] の予習やらでほげほげ。

Leftist Heap - 言語ゲーム Binomial heap - Wikipedia, the free encyclopedia

■_ うぃきぺ

ブートストラップ問題 - Wikipedia
言語 X のコンパイラを言語 X で書く場合、次のような対処法がある。

    * 言語 X のインタプリタかコンパイラを言語 Y で実装する。ニクラウス・ヴィルトは、最初のPascalコンパイラをFORTRANで書いたとされている。
    * X の別のインタプリタかコンパイラが言語 Y で既に書かれて存在している。Schemeの場合がこれに相当する。
    * X のサブセットのコンパイラをまず用意し、その X のサブセットで X のコンパイラを書く。Javaのスーパーセットはこの方式で作成されている。
    * X のコンパイラが既に存在するプラットフォーム上で、別のプラットフォームのオブジェクトコードを生成する
      X のコンパイラをコンパイルし、クロスコンパイラとする。そのクロスコンパイラでコンパイラをコンパイルす
      れば、ターゲットのプラットフォーム上で動作するコンパイラが得られる。C言語コンパイラを別のプラット
      フォームに移植する際にこの方式が採用される。
    * X のインタプリタが実装されている場合に、そのインタプリタ上で X のコンパイラを実行し、 X のコンパイラ
      自身をコンパイルする。UCSD PascalのP-Codeで書かれたトランクコンパイラの場合がこれに相当する。トランク
      コンパイラは、オブジェクトコード生成部がコメントとなっている場合があり、その場合にはコンパイル前にタ
      ーゲットマシンに合わせたものに書き換える必要がある。
    * X で書かれたコンパイラのソースを、人間が(最適化なしで)コンパイル(つまり機械語に翻訳)し、それを使っ
      て最適化コンパイラをコンパイルする。ドナルド・クヌースは、文芸的プログラミングシステム WEB でこの方式
      を採用した。
Bootstrapping (compilers) - Wikipedia, the free encyclopedia
If one needs a compiler for language X to obtain a compiler for language X (which is 
written in language X), how did the first compiler get written? Possible methods to 
solving this chicken or the egg problem include:

    * Implementing an interpreter or compiler for language X in language Y. Niklaus 
      Wirth reported that he wrote the first Pascal compiler in Fortran.
    * Another interpreter or compiler for X has already been written in another 
      language Y; this is how Scheme is often bootstrapped.
    * Earlier versions of the compiler were written in a subset of X for which there 
      existed some other compiler; this is how some supersets of Java, Haskell, and the 
      initial Free Pascal compiler are bootstrapped.
    * The compiler for X is cross compiled from another architecture where there exists
      a compiler for X; this is how compilers for C are usually ported to other platforms.
      Also this is the method used for Free Pascal after the initial bootstrap.
    * Writing the compiler in X; then hand-compiling it from source (most likely in a 
      non-optimized way) and running that on the code to get an optimized compiler. Donald 
      Knuth used this for his WEB literate programming system.

どうも日本語版の記述が怪しい…(英語版の記述が更新されたという可能性もあるけど)

this is how Scheme is often bootstrapped.Schemeの場合がこれに相当する。 とか this is how some supersets of Java, Haskell, and the initial Free Pascal compiler are bootstrapped.Javaのスーパーセットはこの方式で作成されている。 とか。前者は「しばしば用いられる手法」てなところだろうし 後者は「some」がすっぽり抜け落ちてる。

■_

ブートストラッピングのところにあったリンクから。 日本語版だとキーワード扱いになってるだけでエントリはないのだけど 英語版はあるのでみてみると

NELIAC - Wikipedia, the free encyclopedia

The Navy Electronics Laboratory International ALGOL Compiler or NELIAC is a dialect 
and compiler implementation of the ALGOL 58 programming language developed by the 
Naval Electronics Laboratory in 1958.

It was designed for numeric and logical computations and was the first language to 
provide a bootstrap implementation.
Origin

NELIAC was the brainchild of Harry Huskey — then Chairman of the ACM and a well known 
computer scientist, and supported by Maury Halstead, the head of the computational 
center at NEL. The earliest version was implemented on the prototype USQ-17 computer 
(called the Countess) at the laboratory. It was the world's first self-compiling 
compiler. This means that the compiler was first coded in simplified form in assembly 
language "the bootstrap", and then re-written in its own language, compiled by this 
"bootstrap" compiler, and re-compiled by itself, making the "bootstrap" obsolete.

It is called a variant of ALGOL 58 because of similarities to that language, but, 
shortly after the ALGOL committee produced other versions of ALGOL, and NELIAC and 
ALGOL parted ways.

world's first self-compiling compiler. と。

■_

■_ Hard way

Zedの例の本がなぜかまたこのタイミングで reddit で話題に。

Learn C The Hard Way : programming

it's funny because it's the only way


True. Other books try to say "Teach yourself in X hours" which is not correct.


except when x → ∞


"Teach yourself C in hours approaching infinity."


Teach yourself C is less than or equal to infinity hours.

何だこのやり取り。

2011年10月06日

■_

昼頃に Hacker newsみたら上位がほぼ全てジョブズ死去に関連したものだったのにはびっくりした。 にしても、NeXT 時代のことにほとんど(まったく)触れないのは何故? (とはいえ想像できなくもない)

ある意味 NeXT には人生変えられたからなあ(などといってみる)。

R.I.P.

■_

Index of /~protzenk/caml-installer

■_

【原作: 森高夕次】 グラゼニ 3球目【画:アダチケイジ】 

499 名無しんぼ@お腹いっぱい [sage] 2011/10/05(水) 13:50:14.33 ID:oL5nvo350 Be:
    打球追ってフェンスに激突したりダイビングキャッチする奴はアホ、みたいな話かね 

500 名無しんぼ@お腹いっぱい [sage] 2011/10/05(水) 13:59:58.13 ID:YKQYsEBj0 Be:
    世の中には、全速力でフェンスに激突しても無傷なのに
    カレンダー撮影でジャンプして着地し損ねて、開幕に間に合わない選手もいる 

501 名無しんぼ@お腹いっぱい [sage] 2011/10/05(水) 14:57:26.94 ID:VVdazsIX0 Be:
    オフのイベントで相撲とって右肩脱臼した片岡さんの悪口はやめろよ 

502 名無しんぼ@お腹いっぱい [sage] 2011/10/05(水) 15:21:21.09 ID:BeqZlZJAO Be:
    >>500

    YBの多村さんですか? 

515 名無しんぼ@お腹いっぱい [sage] 2011/10/05(水) 22:40:11.53 ID:0hJ+XDsV0 Be:
    >>500
    多村と誰?? 

516 名無しんぼ@お腹いっぱい [sage] 2011/10/05(水) 22:41:30.45 ID:aWCdKAyW0 Be:
    両方多村 

517 名無しんぼ@お腹いっぱい [sage] 2011/10/06(木) 00:06:23.66 ID:7h18eYTt0 Be:
    >>515
    2番目は割と有名なんだけど、1番目も多村なんスよ
    実はフィジカル的にはかなり強靭なんだけどねw 

519 名無しんぼ@お腹いっぱい [sage] 2011/10/06(木) 00:35:11.82 ID:+vZB/EON0 Be:
    高校の県大会で外野から全力でマウンドきて優勝を喜ぼうとしたら足つっただかで輪に入れなかったってのと、
    カバンかけながらサイン対応してたら肩怪我したってのには笑ったw
    まあネタかもしれんけど。 

521 名無しんぼ@お腹いっぱい [sage] 2011/10/06(木) 00:50:21.55 ID:SlHW43+10 Be:
    >>519
    ネタだったら、横浜ファンもソフバンファンも、ここまで苦悩していない 

539 名無しんぼ@お腹いっぱい [sage] 2011/10/06(木) 11:44:30.23 ID:fLFlchKdO Be:
    >>519
    >足吊った
    骨折った、が正解 

544 名無しんぼ@お腹いっぱい [sage] 2011/10/06(木) 12:43:38.08 ID:E/XblROIO Be:
    飛ぶ吉見も右腕だったり投手の才能がなかったら今頃ベイスの3番ライトに定着してたんだろうな 

545 名無しんぼ@お腹いっぱい [sage] 2011/10/06(木) 12:50:46.65 ID:FGuntChm0 Be:
    吉見の打者転向は左腕ってより、2年目の二桁がネックだな
    後、年に1試合ほど、殆どボールを前に飛ばさせない日があるとか
    なんで、才能の方か
    意外とグラゼニでは使いやすいんでない?w 

多村も吉見もベイスターズからトレードで移っちゃったなあ。

■_ 読み方

この手の記法、TAPLでもたくさんでてきて読みがわからなくて悩んだw

Lisp Scheme Part32

957 デフォルトの名無しさん [sage] 2011/10/05(水) 21:59:06.78 ID: Be:
    論理記号は知ってるけど

    分数みたいな記号あるじゃないですか
     G |- a ↓b
    ------------
    G|- ¥forall a

    みたいなの。これの読み方がいまひとつ分からない 

958 デフォルトの名無しさん [sage] 2011/10/05(水) 22:31:13.02 ID: Be:
    俺は
    G |- a ↓ b から G |- \forall a を導ける
    と読んでいた。

959 デフォルトの名無しさん [sage] 2011/10/06(木) 07:15:45.01 ID: Be:
    >>957
    はい
    http://ja.wikipedia.org/wiki/%E8%87%AA%E7%84%B6%E6%BC%94%E7%B9%B9 

■_ いくつかの真実

そりゃないっしょ ○| ̄|_

InfoQ: JavaOne Keynoteにおける、JavaFX 2.0をリリース、Java 9の概要

JavaOne Keynoteにおける、JavaFX 2.0をリリース、Java 9の概要

(略)

プロジェクトラムダは、Javaがマルチコアプロセッサのシステムで効果的に動作するためのもの
である。「ラムダ表現を追加することは、クールキッズに追いつくことであり、いくつかの真実
です」とReinhold氏は言う。「しかし、本当の理由は、マルチコアプロセッサを処理するのにラ
ムダはベストな方法だからです。」ラムダの実装は、もともとJava 7で動的型付け言語である
RubyやPythonをサポートするためのInvokeDynamic 機能を使っている。

(以下略)
InfoQ: JavaFX 2.0 Released, Java 9 Outlined During JavaOne Keynote

JavaFX 2.0 Released, Java 9 Outlined During JavaOne Keynote

(略)

Project Lambda will enable Java to work much more effectively with multicore processing
systems. "Some would say adding Lambda expressions is just to keep up with the cool
kids, and there's some truth in that," Reinhold said. "But the real reason is
multicore processors; the best way to handle them is with Lambda." The implementation
of Lambda is making use of the InvokeDynamic feature, originally added to Java 7 to
support dynamically typed languages such as Ruby and Python.

"Some would say adding Lambda expressions is just to keep up with the cool kids, and there's some truth in that," は 「中には Lambda 式の追加が単に cool kids に追いつくためだけのものだという 人もいるだろうし、それはある程度は真実でしょう」 てな感じなのでは。んで 「とReihold は言い、さらにこう続けました しかし本当の理由はマルチコアのプロセッサーです。 マルチコアプロセッサーを扱うには Lambda は最適な手段なのです」

しかし「いくつかの真実」て…

■_

訳している時間がねー

Agile is Bullshit

Agile is Bullshit
5th October 2011

Nowhere in the Agile Principles does it say that the development team should mock estimation.

This comes from an understandable source. Project managers, in their haste to make 
detailed plans using evil tools like Microsoft Project and whatnot, force developers 
to make unreasonable and unrealistic guesses as to what it would take to develop 
against a set of unfinished requirements. In backlash, the developer uses one of the 
principles to tell him to stuff it:

(略)

ふたつめ

development - Switching from C++ to R - limitations/applications - Quantitative Finance - Stack Exchange

I've only recently begun exploring and learning R (especially since Dirk recommended 
RStudio and a lot of people in here speak highly of R). I'm rather C(++) oriented, so 
it got me thinking - what are the limitations of R, in particular in terms of performance?

みっつめ

PHP needs to die. What will replace it? | Seldo.Com Blog
PHP needs to die. What will replace it?

posted 11 August 2011

It's time for PHP to die. And I say this as a die-hard PHP developer currently converting
an existing Ruby on Rails codebase to PHP.

PHP は死すべき時だ。現在既存の Ruby on Rails のコードベースを PHP へ移植している
die-hard PHP developer としてわたしは主張する。

History repeating
歴史は繰り返す

The reason I know PHP has to die is because I've seen this before. Roughly a decade 
ago, PHP killed Perl. Not completely, of course; it still clings on in some 
environments, it has a sizable legion of die-hard fans, and legacy apps will need to 
be maintained in it for decades to come. But as a language for newcomers, and 
especially for web developers, it was already dying in 1999 and was mostly dead by 
sometime around 2005. 

わたしが知っている PHP は死ななければならない理由は、それが十年ほど前にもわたしが
目撃したことだからです。PHP は Perl を殺しました。もちろん完全に、ではありません。
Perl は今でも一部の環境で生き残っていて、die-hard なファンの sizable な legion
を確保しています。そして、legacy apps はこの先十年メンテナンスされる必要があるでしょう。
しかしある言語の新参者、特に web developer たちにとっては
#むー dying と died をどうしたもんか

続く

■_

2011年10月05日

■_

コーディングしている時間が。

■_

■_

JavaやCに「染まってしまった」プログラマーにHaskellを教えるにはどうすればよいか。 的な。

RuMiNaTiOnS: @ConalElliott re: What resources & practices (teaching Haskell)


Conal Elliott asks: What resources & practices would you recommend for helping a 
group of Java & C++ programmers learn to work in Haskell? I saw the question first 
on Twitter, but my compression skills were not up to the task of answering there.

I have two recommendations: teach them the simplest definitions of the fundamentals; 
read programs with them, out loud, like children's books, skipping nothing.

These steps are often passed hurriedly, by teachers so steeped in a subject they don't 
realize how different their worlds are, by students eager to build things as quickly 
in a new programming language as they do in the old. Most likely, the students will 
assume that they just need to learn new syntax to be off and running. Indeed, I am 
sure they are capable, self-motivated software professionals and that they would 
succeed in learning Haskell, just without the deeper understanding that can make it 
such a joy.

略

■_

InfoQのインタビュアーの質問のとこだけ切り出し。

InfoQ: David Pollak and Dick Wall Discuss Barriers to Scala Adoption

Is Scala is hard? 
Scala は難しいですか?

Is a lack of good IDE support and big corporation backing hurting Scala adoption? 
優れた IDE のサポートがないことや、大企業の backing がないことは Scala の採用に悪い影響を及ぼしているでしょうか?

It is hard to find good Scala developers? 
優れた Scala developer たちを見つけるのは難しいことでしょうか?

Will learning Scala make you a better developer?
Scala を学ぶことはあなたをより良い developer にしますか?

Competitors around the bend: 

Kotlin and Ceylon are inspired by Scala strong types with modern language features. 
The pressure of Kotlin and Ceylon could be pushing folks like David to question 
Scala's broader appeal.  Certainly, a vocal minority of Scala developers seem to 
pounce on every announcement of any JVM language that is strongly typed with modern 
language features.  Scala could see some stiff competition for adoption. Does a less 
powerful language with a more mainstream syntax, and good tools support that fixes 
Java's warts have a place? If so can it eclipse Scala adoption? Time will tell. It is 
here where Scala's strength (its power) could become a weakness due to a longer 
learning curve. On the other hand, Kotlin and Ceylon could become gateway languages to 
even wider Scala adoption.

Kotkin と Ceylon は Scala に inspire された


(略)

■_

コードレビューに関するものはほかにもいくつか見かけてるなあ

Why code review beats testing: evidence from decades of programming research | Kevin Burke

tl;dr If you want to ship high quality code, you should invest in more than one of formal
code review, design inspection, testing, and quality assurance. Testing catches fewer
bugs per hour than human inspection of code, but it might be catching different types of
bugs.

Everyone wants to find bugs in their programs. But which methods are the most effective
for finding bugs? I found this remarkable chart in chapter 20 of Steve McConnell's Code
Complete. Summarized here, the chart shows the typical percentage of bugs found using
each bug detection technique. The range shows the high and low percentage across
software organizations, with the center dot representing the average percentage of bugs
found using that technique.

↓ チャートを見るとなかなか興味深いものが。

Scala, Groovy, Clojure, Jython, JRuby and Java: Languages by Jobs

So what can this tell us about the how the industry sees the major language of the JVM: 
Java, Groovy, Scala, Clojure, Jython and JRuby*. What happens when we have a look at 
the percentage of all jobs that mention these languages

So what can we say; while you'll want to dust off the old Groovy text books and maybe 
have a look at some Scala tutorials, the best thing you can do is to keep your Java-fu 
in top notch order. As far as the industry is concerned Java is still the Daddy of the 
JVM languages and seems to being staying this way for some time.

2011年10月04日

■_

「プログラム意味論」、復刊したのがすでに書店に出てきているようで。

■_

■_ Discuss Barriers to Scala Adoption

InfoQの記事なので訳されるでしょう。

InfoQ: David Pollak and Dick Wall Discuss Barriers to Scala Adoption

David Pollak, famous Scala advocate, wrote a blog post, "Yes, Virginia, Scala is 
hard" that has caused a bit of a brouhaha in the Scala community. The post claims 
that Scala tries to do too many things, has poor IDE support, has an intimidating type 
system, and more. Ultimately David's assertions question Scala's broad appeal and if 
Scala will ever be the next Java. The Scala community seems to be upset with what they 
perceive as attacks on Scala. David asserts that he is doing his best to preserve 
Scala success by addressing its issues publicly and level setting where Scala fits in 
the market. InfoQ caught up with David Pollak and another Scala advocate, Dick Wall, 
to discuss the adoption, success and future of Scala and to discuss this blog post, as 
well as related topics like Ceylon.


(略)

David's goal was to make Scala a top tier language like Python. His post was about his 
frustration with the pace of this goal. "This Spring, I gave up that fantasy. I 
realized that Scala was never going to become as popular as Python." He holds 
hope that Scala has the staying power of Smalltalk or Lisp as a second-tier language. 
His worry seems to be that Scala will not hit that goal because Scala is being hyped 
as a Java replacement. David goes on to explain his position to InfoQ

David の目標は Scala を Python のような top tier な言語にすることでした。
彼のポストはその目標に向かうペースについての不満に関してでした。
「今春、わたしは fantasy を断念した。Scala は決して Python ほどには popular なものには
ならないことを認識した」
彼は second-tier な言語として Smalltalk や Lisp のパワーを持っていることを希望すると語った。
彼の心配ごとは、Scala が Java を置き換えるものであるがゆえに目標に到達しないのではないか
といったことのようです。
David は InfoQ に彼の positon を語ってくれました。
#ちょっと時間かけてやらんとまともな文章にならん

■_

Why Python? - All this

Why Python?
なぜ Python なのか

October 2nd, 2011 at 11:44 pm

A reader1 asks:

    It seems like everywhere I look people are pushing the Ruby programming language…
    What reasons are you using Python? Is it because of certain characteristics of the
    language itself or because you are more familiar with it (due to coming from a Perl
    background)?

A fair question, and I'm going to pretend that my answer is worth knowing.

Ruby is the it scripting language and has been since Rails came out several years ago. 
I've tried it in the past and—mainly because of MacRuby—will probably try it again. 
But there are things about Ruby that set my teeth on edge.

First, though, the titular question: why do I use Python? I can't say my reasons for 
switching from Perl were entirely rational, but it was some combination of:

   1. The feeling that Perl 5 was a dead end (that had an awful object syntax) but that Perl 6
      would never come online. The years have proved me right about Perl 6. Perl 5 isn't the
      dead end I thought it would be, but it isn't the vibrant language it was in the 90s,
      either.

      Perl 5 は(その不恰好なオブジェクトの構文で) dead end にあり、Perl 6が現れることは
      ないと感じていました。
      The years have proved me right about Perl 6.
      Perl 5 は渡した思っていたようには dead end にはありませんでしたが、
      90年代にそうであったような vibrant languege ではありません。

   2. The no braces, no semicolons, no begin/end syntax. I think the people who hate Python's
      use of indentation to denote structure are nuts. Unless you're writing one-liners,
      you're going to use indentation—why not take advantage of that to get rid of all the
      nonfunctional characters?

      (Python には) ブレースもないし、セミコロンも begin/end 構文もありません。
      わたしはPython のインデントで構造を表すというやり方を嫌っている人は石頭なのだと
      思っています。一行野郎を書こうとしない限りは、役立たずのキャラクターを取り除く利点が
      あるインデント方式を使わない理由はないでしょう。

   3. The “batteries included” philosophy of the standard Python distribution. There's
      seldom a question of which library to use; you use the one that came with Python.

      Python の標準ディストリビューションの "電池込み" という philosophy。
      どのライブラリを使うべきなのかという疑問はほとんどありません。
      Python についてきた物を使えばよいのです。

   4. The NumPy package and the adoption of Python by many scientists and engineers. This
      turned out to be a false reason, as I've never used NumPy. But when I was thinking
      about which language to switch to, NumPy and SciPy were pluses for Python.

   5. The from __future__ import division statement. This seems really stupid, but I hate
      when a scripting language tells me that 1/2 is zero instead of 0.5. I suppose this
      comes from my being an engineer instead of a programmer; I almost never use integer
      arithmetic and don't like it when I have to think about how my language is going to
      interpret a simple division. In fact, I tried Python a couple of times in the
      90s—before the __future__ module—and gave up because integer division mistakes were
      so frustrating. I was happy to see that Guido recognized his initial mistake and made 
      floating point division the default in Python 3.

Items 2 and 3 (and yes, 5) are why I still use Python.

What annoys me about Ruby? Small things, mostly, some silly, some substantive:
Ruby についてわたしがうんざりしていたのはどういったことでしょうか?


   1. Integer division, obviously. That Ruby uses it seems especially odd to me, because
      Ruby is obviously and outgrowth of Perl, which uses floating point division. This is
      a case of Matz not learning from Larry Wall's example.

      整数除算について。

   2. That include and require sound like they should do the same thing. I know that if I
      used Ruby enough, I'd learn the difference (and probably just use require 99% of
      the time), but the seeming similarity bothers me.

      include と require は同じ事を行うべきもののように思えます。
      Ruby を使い込めばその違いをわかるようになるのでしょうが、その相似性は
      わたしをうんざりさせたのです。

   3. The ever-changing notion of the “right” way to do things. Maybe this is just the
      ignorance of an outsider, but it seems to me that Ruby best practices are a 
      fast-moving target. For example, I get that the gem system is the standard way to 
      install modules, but I don't see how a newcomer to the language is supposed to know 
      whether require 'rubygems' is a good idea or not.

      何かを行うための “正しい”ever-changing notion 。
      おそらくこれは、部外者の無知にすぎないでしょう。しかし、わたしにとって、
      Ruby の best practices は fast-moving target のようだったのです。
      たとえば、わたしは gem システムがモジュールをインストールする標準の方法だと
      理解しましたが、require 'rubygems' が良い考えなのかそうでないのかを
      新しい人たちが判断する手段がありません。
      #ちと微妙

   4. The accretion of tools built upon tools. This is similar to my previous complaint.
      When I read about some clever Ruby library/utility that I might consider using, the
      installation instructions often refer to gem or rake or rmv or some other add-on. I
      appreciate that experienced, expert Rubyists can get a lot of leverage out of these
      tools, but they're a barrier to entry for newcomers.

      ツールに依存したツールの構築の acceretion 。
      これは前にあげた不満とも共通します。
      わたしがいくつかの関心を持った clever な Ruby のライブラリやユーティリティについて
      調べたとき、そのインストール手順はしばしば gem や rake やそのほかのアドオンを
      参照していました。経験をつんだ、エキスパートの Rubyist たちにはそれは
      ツールを大いに leverage out できる適切なものかもしれませんが、新しい人たちが
      飛び込むには障害になるものなのです。


I know the solution to my problems with Ruby is to just dive in and start bulling my 
way through—the best way to learn a new system is to just keep using it. So far, 
though, I just haven't had the need to stick with Ruby long enough to get comfortable. 
This is going to change. There once was a time when I thought PyObjC would let me 
write Mac-like programs in Python, but it's clear now that MacRuby is the better 
choice. I need to expand.


This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.

Why Python? : Python

■_ Java8

Oracle: Java 8 will be revolution, not evolution • The Register

JavaFX 2.0 released, Java 9 detailed

By Iain Thomson in San Francisco • Get more from this author

Posted in Developer, 3rd October 2011 18:20 GMT

Free whitepaper – ASCI uses 10 GbE grid computing and hi-def media streaming

JavaOne Mark Reinhold, chief architect for Java at Oracle, gave details on developments in
Java 8 and beyond, and announced the release of JavaFX 2.0 during his turn on the keynote
stage at the JavaOne conference in San Francisco.

Oracle cut back on its plans for Java 7 in order to get the new build released in July, 
adding three of the five key improvements it had planned: Project Coin, InvokeDynamic, 
Fork/Join framework, Project Jigsaw and Project Lambda. The latter two functions were 
cut from the JDK 7 release and will be bundled in version 8.

“Java 7 was an important release, but in the history of Java it was more evolutionary 
than revolutionary,” Reinhold told the crowd. “Java 8 will be more revolutionary.”

Java 7 は重要なリリースではありましたが、Java の歴史においては革命的というよりは
進歩的といったものでした。

Java 8 はより革命的なものとなるでしょう。

(略)

© Copyright 1998–2011

■_

時間たんねー

2011年10月03日

■_

(自粛)

■_ 2.0

ruby-core で興味深いやり取りがいくつか。

[ruby-core:39810] 2.0 feature questionnaire
[ruby-core:39815] Re: 2.0 feature questionnaire
[ruby-core:39826] Re: 2.0 feature questionnaire
[ruby-core:39817] Re: 2.0 feature questionnaire
[ruby-core:39819] Re: 2.0 feature questionnaire
[ruby-core:39853] Re: 2.0 feature questionnaire
[ruby-core:39853] Re: 2.0 feature questionnaire
> proc is Proc and lambda is ->(){}.  No confusion now.
That's easy for people who know what a proc is, and what a lambda is.
But that may not be everybody.
[ruby-core:39857] Re: 2.0 feature questionnaire
[ruby-core:39822] Re: 2.0 feature questionnaire
[ruby-core:39822] Re: 2.0 feature questionnaire
[ruby-core:39846] Re: 2.0 feature questionnaire
[ruby-core:39847] Re: 2.0 feature questionnaire
[ruby-core:39848] Re: 2.0 feature questionnaire
[ruby-core:39852] Re: 2.0 feature questionnaire
[ruby-core:39829] Re: 2.0 feature questionnaire
[ruby-core:39830] Re: 2.0 feature questionnaire - new main method

[ruby-core:39823] Discussion results
[ruby-core:39825] Re: Discussion results
[ruby-core:39832] Re: Discussion results
[ruby-core:39834] Re: Discussion results
[ruby-core:39835] Re: Discussion results
[ruby-core:39840] Re: Discussion results
[ruby-core:39844] Re: Discussion results
[ruby-core:39851] Re: Discussion results (here documents with indents)
[ruby-core:39845] Re: Discussion results
[ruby-core:39842] Re: Discussion results
[ruby-core:39856] Re: Discussion results

[ruby-core:39824] Road to 2.0
[ruby-core:39836] Re: Road to 2.0
[ruby-core:39837] Re: Road to 2.0
[ruby-core:39838] Re: Road to 2.0

適当なところでまとめ…られたらいいなあ。

■_ くろじゃ

IIFE って何かと思った。

Closures for Dummies (or why IIFE !== closure) | Unscriptable.com

There are lots of blog posts and online articles about javascript closures. Many of 
them are well written. Closures have also been discussed at length with Brendan Eich. 
I really shouldn't have to write another blog post. Yet, here I am.

ブログなどのネット上の書き込みには JavaScript のクロージャーについてのものがたくさんあります。
そのうちの多くが良く書かれたものです。


Why? Because I still see many people misusing the term, “closure”. Specifically, I 
see people confusing IIFEs with closures.

なぜか? それは多くの人が“クロージャー”という言葉を間違って、特に IIFE と混同して
使っているのを今でも見かけるからなのです。

I was going to see if I could craft a twitter-friendly 140-char explanation of the 
differences between IIFEs and closures. A noble cause, for sure, especially since I 
suspect that the reason that there's so much confusion is that many of the 
explanations are either tl;dr or too technical.

140 characters may have been too ambitious. Let's see if I can do it in 140 words or 
less. Starting… now. Well, not including code snippets, mmkay? OK. Starting… now.

Definitions
定義

A closure is what happens when you've made a function's private variables (and/or 
embedded functions) available to outside code. That's it. There's no specific 
pattern you need to use, it just happens. That said, there are lots of patterns that 
take advantage of closures.

クロージャーとはあなたがある関数のプライベートな変数をその関数の外側でも有効に
なるようにしたときに起きることです。それだけです。使うのに必要となる特別な
パターンはありません。
とはいえ、クロージャーの利点を活用するようなパターンはたくさんあります。



IIFEs are simply a way to create a private set of variables and functions. You create 
an IIFE by constructing a function expression that contains some private variables 
and/or embedded functions — and then executing it. Immediately. Most meaningful IIFEs 
create a closure, but they don't have to.

IIFE はただ単に変数と関数の private な集合を生成するための方法です。
いくつかの private 変数と式に埋め込まれた関数とを持った
関数式を構築することによって IIEF を生成し、それを実行します。
即座に。大部分の meaningful な IIFE はクロージャーを生成しますが
そうしなければならないわけではありません。

Stop. Not bad. Only four tweets-worth.

(略)

What's it all mean?

IIFEs are a useful construct. They're a great way to isolate variables (and can also 
be used to capture copies of transient variables, but that's too tl;dr for this 
discussion). IIFEs can also create closures. In fact, any function can create a 
closure if it returns a function — directly or indirectly — and uses local variables.

Closures are also very useful, but you don't create closures via an explicit pattern. 
Closures just happen under the right circumstances and are used in many different 
patterns.

(略)

Copyright © 2007-2011 Unscriptable.com
Theme by mg12. Valid XHTML 1.1 and CSS 3.

IIFE → Ben Alman » Immediately-Invoked Function Expression (IIFE)

■_ S05

機械翻訳されたという例のものを見てみたら、見覚えのないものが。 最初の頃しか追いかけ続けてなかったからなあ。

Synopsis 5:正規表現とルール

変換機

    * 延長された構文(/x)もう必要とされない...それはデフォルトだ. (実際、それはおおかた
      管理 - 戻る唯一の方法をから構文がそれと一緒の古いものへの - だ:Perl5/ :P5 修飾子。)

    * そこ(に・で)ノーだ/s あるいは/m 修飾子(メタ文字のリプレイスそれらに対する変更-下を参照)。

    * ノーがある/e その代わりに使用置換の上の評価修飾子:

       s/pattern/{ doit() }/
       

      あるいは:

       s[pattern] = doit()
       

      代わりに/ee 言え:

       s/pattern/{ eval doit() }/
       

      あるいは:

       s[pattern] = eval doit()
       

この s[pattern] = doit() とはなんぞ?

後のほうに解説があった。

Synopsis 5:正規表現とルール

置換

同じくメソッドフォームがあるのm// そしてs///:

  $str.match(/pat/);
  $str.subst(/pat/, "replacement");
  $str.subst(/pat/, {"replacement"});
  $str.=subst(/pat/, "replacement");
  $str.=subst(/pat/, {"replacement"});
 

.match そして.subst メソッドが副詞をサポートするのm// そしてs/// あなたが書くことができる
ように、引数と命名されるように

  $str.match(/pat/, :g)
 

等価物としてそうするために

  $str.comb(/pat/, :match)
 

ここに構文的な構文糖がない、それで代替物の延期された評価を得るために、あなたはそれをクロー
ジャに入れなくちゃならない。 構文的な構文糖は quotelike フォームによってだけ供給される。
最初に標準的な「3つの要素から成るクォート」形状がある:

  s/pattern/replacement/

ただ非括弧の文字だけが「3つの要素から成るクォート」のために使われるかもしれない。 それが
クォートにかかわらず選択された二重に引用された文字列であるかのように、右側は常に評価される。

Perl 5 と同じように、フォームをかっこでくくることが同じくサポートされる、しかし Perl 5 と
異なり、 Perl 6 はただパターンの周りに括弧を使う。 それが、普通の引用ルールで、普通の項目
割り当てであるかのように、取り換えはそれから指定される。 あなた自身のクォートが右手にただ
1(人・つ)を使う指名にq フォーム。 上の置換は同等の値:だ

  s[pattern] = "replacement"

あるいは

  s[pattern] = qq[replacement]
 

置換がマッチする(擬似割り当てとほとんど同じように宣言子に奇妙な時に起きることができる)た
びに、これは右側が評価されるから、標準の assigment じゃない。 従ってそれは「thunk」として
取り扱われる、すなわち、それはかなりのレキシカルスコープではなく、ダイナミックスコープを作
成するコードと呼び出されるだろう。 (あなたは同じく thunk を寄生するように現在のレキシカル
スコープを使うクロージャであると考えることができる。) 実際、言うことはまったく意味をなさない

  s[pattern] = { doit }

なぜならそれは文字列の中にクロージャを代用しようとするだろうから。

Any スカラー割り当て演算子が使われるかもしれない;置換マクロはどのように向きを変えるべきか
知っている

  $target ~~ s:g[pattern] op= expr
 

何かにあたかも:

  $target.subst(rx[pattern], { $() op expr }, :g)
 

例えば、あなたが缶詰めにするように、すべてのドルの量に2を掛けろ:

  s:g[\$ <( \d+ )>] *= 2
 

(もちろん、オプティマイザは実際のメソッドより速い何かを呼び出しですることが自由だ。)

あなたは最後の例から置換がただマッチの「公式の」文字列結果、すなわち、中間の文字列の部分
を偶然発見するだけであることを指摘するだろう$/.from そして$/.to ポジション。 (ここで我々
は人たちに明示的に使わせた<(...)> 対になれ;さもなければ我々は後読みをマッチするため
に使わなければならなかっただろう$.)

元の英文がどんなのだか想像してみるとなかなか楽しいw

なんにしても、全部読み返さないとだめだなあ>Sxx

■_

■_

busybox みたいなものを作ろうかと思うのですよ。Windows 向けの。 pclouds/busybox-w32 - GitHub

2011年10月02日

■_

どうなるんすかねー。ベイスターズ。

■_

Pythonのお勉強 Part44 

264 デフォルトの名無しさん [sage] 2011/10/01(土) 23:55:51.29 ID: Be:
    pythonchallengeのlevel6で1000ちかいテキストファイルを順次開いていくって処理で
    400くらいでIOErrorでtoo many open filesってエラーがでて例外処理がわからないんだけど
    なんかどうすりゃいいのか教えて 

265 デフォルトの名無しさん [sage] 2011/10/02(日) 00:27:13.61 ID: Be:
    >>264
    ファイルは使い終わったら閉じましょう。
    OSは、同時に開けるファイルディスクリプタ数を制限しています。 

267 デフォルトの名無しさん [sage] 2011/10/02(日) 00:37:32.75 ID: Be:
    >>265
    あーお恥ずかしいかぎりですわ
    どうもありがとう
    おかげで今後閉じ忘れることなくなるだろうな 

268 デフォルトの名無しさん [sage] 2011/10/02(日) 01:54:56.43 ID: Be:
    それってOSの種類で制限の上限がかわったり制限が無かったりするの? 

269 デフォルトの名無しさん [sage] 2011/10/02(日) 01:56:14.39 ID: Be:
    OSってかファイルシステムの範疇になるような気がするけど……。
    エロい人回答頼む 

270 デフォルトの名無しさん [sage] 2011/10/02(日) 03:21:43.16 ID: Be:
    Linuxは1プロセスの最大がデフォルトで1024 (ulimit -nで参照・変更可能)
    Windowsは1プロセスの最大が2048 (stdio経由だとデフォルトで512)

    (間違ってるかもしれません) 

271 デフォルトの名無しさん [sage] 2011/10/02(日) 05:20:19.14 ID: Be:
    あれ?

    for filename in filelist: dosomething(open(filename).read())

    みたいなのを 10万個くらいのファイルに対して実行してるけど、とくに叱られた
    ことないんだが……

    ちょっと調べたら、ここでは close() しないといけないように書かれていて、
    http://stackoverflow.com/questions/1834556/does-a-file-object-automatically-close-when-its-reference-count-hits-zero

    こっちでは参照がなくなったら勝手に close() するようなことが書かれている。
    http://www.tutorialspoint.com/python/file_close.htm

272 デフォルトの名無しさん [sage] 2011/10/02(日) 05:31:52.02 ID: Be:
    現行のCPythonは参照がなくなったらクローズする
    けれど他のPython実装はそうするとは限らないし
    CPythonも将来的にはどうなるかわからない
    なので明示的決定的にclose()するかwithで書いたほうがいいよって話だろう 

273 デフォルトの名無しさん [sage] 2011/10/02(日) 10:47:48.94 ID: Be:
    >>271
    stackoverflowのほうもよく読めば分かるのに……
    CPythonの「実装では」参照カウントが0になるとクローズされるが、
    Pythonが「言語仕様として」それを保障しているわけでもないし、
    Jythonのような他の実装では、実際クローズされないと書かれている

    >>264との違いは、単に書き方の違いだろうな
    >>271の書き方ならリファレンスカウントならすぐ参照が破棄される
    想像だけど、>>264は
    result = (dosomething(f.read()) for f in map(open, filenames))
    みたいな書き方でもしてたんじゃないの 

gawk はこの辺、結構とんでもないことをやってたりする(笑) 簡単に言うと、 一番古くからオープンされているファイルを、 現在のファイルポインターの位置を保存した上でクローズし、 それによって新たにファイルをオープンする。 というものです。ここでクローズされたファイルに再度書き込む必要ができたら 追加書き込みモードでオープンしてファイルポインターを設定して… となります。 最悪の場合、スラッシングみたいな状態になるはずなんですがさて。

■_ Failure-oblivious computing

最近良く見かけるなということで調べてみた(つーかうぃきぺ見ただけ)。

Failure-oblivious computing - Wikipedia, the free encyclopedia

Failure-oblivious computing is a technique that enables computer programs to continue 
executing despite memory errors. The technique handles attempts to read invalid memory 
by returning a manufactured value to the program, and it ignores invalid writes. This 
is a great contrast to typical memory checkers, which inform the program of the error 
or abort the program. In failure-oblivious computing, no attempt is made to inform the 
program that an error occurred.[1]

The approach has performance costs: because the technique rewrites code to insert 
dynamic checks for address validity, execution time will increase by 80% to 500%.[2]

■_

Carlos Oliveira ってのがありまして。 結構面白い話題があったりします。 Articles たとえばシリーズものになっている

    * Day 1: Read Other People's Code
    * Day 2: Write Shorter Methods
    * Day 3: Keep a Programming Diary
    * Day 4: Learn a New Programming Language
    * Day 5: Write a Unit Test Before Coding
    * Day 6: Write a Tech Spec
    * Day 7: Give Only One Responsibility to Each Class
    * Day 8: Take the Rest of the Day Off
    * Day 9: Learn To Use Your Debugger
    * Day 10: Learn Keyboard Shortcuts
    * Day 11: Understand the Lower Layers of the System
    * Day 12: Keep the Focus on Your Application
    * Day 13: Write Functions in a Functional Style
    * Day 14: Understanding Software Libraries
    * Day 15: Use Meta Programming When Possible
    * Day 16: Measure Performance Before Optimizing
    * Day 17: Write Clean Code
    * Day 18: Development Speed is Important

とか。

■_

■_

2011年10月01日

■_

土曜日は勉強会(とか読書会とかその辺)の日。ということで スタート圏論 第一回 - [PARTAKE] スタートC language面白論文紹介&読み会 - [PARTAKE] x86/x64最適化勉強会2 : ATND いろいろあったようですが、三つ目のx86/x64最適化勉強会に行ってきました。 会場は秋葉原UDXの6Fだったのですが、行き方が良くわからず(案内のpdfがあったのねー) 数分遅刻。 研究動向から考えるX86/x64最適化手法 などなど興味深い発表の数々でした。

■_ Common Lisp Tips

例の format

Common Lisp Tips

Common Lisp Tips

Most format control directives can take parameters. These parameters are often embedded
in the control string. For example, to print some text at column 16, you could do this:

ほとんどの書式制御ディレクティブは引数を取れます。そのパラメータはしばしば制御文字列に
埋め込まれます。たとえば16桁めにテキストを出力するには次のように書けます:

* (format t "~16THello, world")
                Hello, world

What if you only know the parameter at runtime? You might be tempted to try something
like this:

実行時のパラメーターしかわからないとどうなるでしょうか?
次のような記述をしたくなるかもしれませんが


* (format t (format nil "~~~DTHello, world" width))    ; BOGUS
                Hello, world

Don't do that! You can use “v” and pass the parameter as a separate argument to format:

このようにしてはいけません!
"v" を使って、書式のための分離した引数としてパラメータを渡せるようにできます:

* (format t "~vTHello, world" 16)
                Hello, world

Here's a function that prints the bits in an integer with a configurable width:

ある整数を指定された幅のビット数で表示する関数

(defun bits (integer &optional (width 8))
  (format t "~v,'0B" width integer))

* (bits 42)
00101010

* (bits 42 16)
0000000000101010

This is one of several ways to avoid creating a format control string at runtime. 
(format t (format nil …) …) is almost always a mistake.

A little tip every day, by Zach Beane.


© Common Lisp Tips. All Rights Reserved.
Powered by Tumblr. Lightweight Theme by Artur Kim

■_ sed

sed でやるのは「簡単」じゃあないと思うけどなあ

linux テキスト処理 | OKWave


お世話になります。

linuxのテキスト操作でご質問です。


(1)
-------------------------
[root@*** ***]# vi test.txt
1
2
3
4
------------------------
↓
↓
(2)
--------------------------
[root@*** ***]# vi test.txt
1 2 3 4
------------------------

何百行もあるテキストデータを(1)⇒(2)に一発でできる方法は
あるでしょうか?

以上、宜しくお願いいたします。

ANo.4

いろいろありますね。

echo `cat test.txt` > out.txt

まあ、普通は tr でしょう。

ANo.3

こんな方法はいかがでしょう。

% xargs < test.txt > test2.txt

ANo.2

# 質問文のようにviで開いた状態からならば、コマンドモードで次のように打ってみてください
:%s/\n/ /g

# シェルからなら、trが簡単だと思います。
tr '\n' ' ' < test.txt

ANo.1

SEDで簡単に出来ます

(3) 改行にマッチさせる を参照して下さい
http://www.kabipan.com/computer/sed/

ん、awk がねーじゃんw awk -vORS=' ' '1' こうか? と、これだと最後の改行もないか。 といってENDルール書き足すのは美しくないw

■_

Twitter / @ichiro_satoh: ソフトウェアに求められているのは生産性よりも信頼性や ... Twitter / @esumii: @taroleo @ichiro_satoh 「きれ ... Twitter / @taroleo: @ichiro_satoh 確かにIDEの成熟度の評 ... Twitter / @ichiro_satoh: いまはIDEを含むツール類で生産性が決まりますから、 ... Twitter / @taroleo: HaskellとかScalaとか最近(?)の言語を見 ...

Twitter / @takkanm: @nagachika オブジェクトに対するinsta ... Twitter / @nagachika: @takkanm さっきの説明はちょっと間違ってて、 ... Twitter / @takkanm: クラスに対する、class_evalとinstanc ... Twitter / @takkanm: @nagachika なるほど。試してみたら意味がわ ... Twitter / @nagachika: @takkanm instance_eval は c ...

書くことを纏めている時間がががが

■_ 最適化勉強会

13:35~14:00 	maropu 	intel lab.の研究動向からみるx86/x64最適化手法
14:05~14:30 	kzmogi 	適応フィルタのSIMD最適化
14:40~15:05 	w_o 	perfの使い方
15:10~15:35 	herumi 	JIT profiling with VTune
15:45~16:10 	t_teruya 	Kronecker-Jacobi記号の実装
16:15~16:40 	shinh 	edit distanceの高速化
16:50~17:15 	herumi 	高速な倍精度指数関数expの実装
17:20~17:45 	msiro 	Intel Architecture Code Analyzerについて

の、shinh さんの発表に出てきた 「edit distance」をぐぐってみたら odz さんのはてダが結構上位で引っかかりました。 edit distance - odz buffer 何かを調べてて、結構 odz さんのはてダがひっかかったりすることがあるので 最近こういった方面の書き込みがほとんどないのは残念だったり。

「編集距離」で覚えてたような気がするけどいろいろあるのねえ レーベンシュタイン距離 - Wikipedia

■_ Python 3.2.2

変更点の説明で出てきたPEPが気になるのだけど、さすがに日本語訳はまだないか。

Python 3.2.2 Release

Since PEP 3003, the Moratorium on Language Changes, is in effect, there are no changes 
in Python's syntax and only few changes to built-in types in Python 3.2. Development 
efforts concentrated on the standard library and support for porting code to Python 3. 
Highlights are:

    * numerous improvements to the unittest module
    * PEP 3147, support for .pyc repository directories
    * PEP 3149, support for version tagged dynamic libraries
    * PEP 3148, a new futures library for concurrent programming
    * PEP 384, a stable ABI for extension modules
    * PEP 391, dictionary-based logging configuration
(略)

PEPIndex - Python Japanese Environment Wiki - SourceForge.JP

■_ おもしろい

shift しながらフィボナッチ数列を計算していくのは (実用性はともかく)面白いなあ

Fibonacci Hash Magic

Fibonacci Hash Magic

I've been reading through The Well-Grounded Rubyist by David Black–an excellent book 
by the way–and was fascinated by a really cool feature of Hash. It turns out this 
feature allows us to easily use a nice trick called memoization to create the 
Fibonacci series.

Sounds scary doesn't it? Don't worry, it's really pretty easy. Let's give it a try.

The Fibonacci series is defined in a really simple way: each number is just the sum of 
the two previous numbers. How do you get started if you don't have any numbers yet? We 
‘seed' the series with two numbers: 0 and 1. So the third number is just the sum of 
these two: 1. The fourth is the sum of the second and third, or 2. We keep going like 
that.

More formally, the n-th Fibonacci number is:

Where:

  f[0] = 0
  f[1] = 1

Then:

  f[n] = f[n-2] + f[n-1]

That's it. The rest of the numbers are generated ‘automatically':

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, ...

So a nice introductory programming problem is to generate this series. The most efficient
way to do this is to iterate, but the resulting program doesn't look a lot like the
definition given above. Here's one way to do it using arrays:

  def fibonacci(n)
    return n if n < 2
    f = [0, 1]
    n.times do
      f[2] = f[0] + f[1]
      f.shift
    end
    return f.first
  end

(略)
Hash Magic to the Rescue

The Hash class has a nice feature that allows you to give it a Proc to run whenever a 
lookup is done on the Hash for a key that doesn't exist. Let's say our Hash stores the 
Fibonacci numbers keyed by the index n. We ‘seed' the hash with the first two numbers, 
and we give the hash a Proc to execute whenever a lookup is done on a key that doesn't 
yet exist in the hash:

  fibonacci = { 0 => 0, 1 => 1 }
  fibonacci.default_proc = proc { |h,k| h[k] = h[k-2] + h[k-1] }

What does this do? Remember that the default proc is executed whenever a lookup is done
on the hash for a key that doesn't exist. So if we lookup 0 and 1, we're fine. But if we
lookup 2, 3, etc, the default_proc gets called.

これで何が行われるのでしょうか? デフォルト proc がそのハッシュの存在していないキーを
参照したときにはいつでも実行されることを思い出してください。ですから、0 や 1 を
参照したときには何の問題もありません。しかし、2 や 3 あるいはそのほかのものを
参照した場合には default_proc が呼び出されるのです。


If we lookup fibonacci[10], for example, it executes the proc by passing in the hash itself
and 10. The proc then adds the entry to the hash for the new Fibonacci number by looking
up the previous two Fibonacci numbers, 8 and 9. If these don't exist the proc gets executed
again, but remember that they get executed sequentially. Looking up fibonacci[9] will
calculate fibonacci[7] and place it in the hash. So when fibonacci[8] requires
fibonacci[7], it's already done.

たとえば fibonacci[10] を参照したとすると、ハッシュ自身に 10 が渡された状態で
proc が実行されます。この proc はそれから新しいフィボナッチ数のためのハッシュエントリに
先行する二つのフィボナッチ数(8と9)を加算します。もしそれらが存在していなければ
proc が再度呼び出されますが、それはシーケンシャルに実行されることを忘れないでください。
fibonacci[9] に対する参照は fibonacci[7] を計算し、その結果がハッシュにセットされます。
ですから、fibonacci[8] は fibonacchi[7] を必要とするときにはすでにそれは計算されて
いるのです。

We can see this in action. We start out like so in ‘irb':
以下略
© 2011 Kevin Beam

■_

どこかで見たような話題な気もしますが盛り上がってたので。 Is floating point math deterministic? : programming Is floating point math deterministic? - Shawn Hargreaves Blog - Site Home - MSDN Blogs

Is floating point math deterministic? : programming

Is floating point math deterministic? (blogs.msdn.com)


Ok /r/programming, it looks like we need to have a discussion on what it means to be 
"deterministic".

Deterministic means that given some input, will a operation produce the same output 
every time. So, for example, lets say you have a function that says add(a, b); that 
function always returns 4 when a = 2 and b = 2, then that function is deterministic. 
If that function always returns 7 when given a = 2 and b = 2, that function is STILL 
deterministic. If that function always returns 3 when a = 2 and b = 2 and the micro 
architecture is a ARM version 7 processor, that function is STILL deterministic. The 
key is that the function ALWAYS returns the same result given a certain input 
regardless of if the result is correct or not.

Deterministic means something behaves exactly the same way given the same input. It 
has nothing to do with compiler optimization, architecture differences, or data 
representation limitations. A piece of code that behaves differently across platforms 
is still deterministic, but inconsistent across platforms.

In that light, it should be clear that floating point math IS deterministic. 
Processors don't randomly spit out numbers when you tell them to add two floating 
points, the answer is predictable. It may be different across platforms, but it is 
still consistent. When it is inconsistent, generally the processor has more issues and 
is due to cause the system to crash.

If it was not deterministic, we would have a source for good solid random numbers on 
all platforms. We could do floating point math on a couple of static numbers, and then 
pull off the last bits of the results. Viola, real random numbers done quickly. Alas, 
floating point math is deterministic and that doesn't work (hence, nobody does it).
Is floating point math deterministic?

Yes. Making it more so was the point of the IEEE 754 standard (and extensions) 
supported by major CPUs and widely used computer languages.

Do compilers produce exactly the same floating-point operations under differences in 
settings, operating systems, and versions?

No. RTFM.

The author needs to learn what deterministic means.

Case closed.

■_

もうひとつ。 I hate almost all software --Ryan Dahl : programming

Ryan Dahl - Google+ - I hate almost all software. It's unnecessary and…

I hate almost all software. It's unnecessary and complicated at almost every layer. At 
best I can congratulate someone for quickly and simply solving a problem on top of the 
shit that they are given. The only software that I like is one that I can easily 
understand and solves my problems. The amount of complexity I'm willing to tolerate is 
proportional to the size of the problem being solved.

わたしはほとんどすべてのソフトウェアが嫌いです。ほぼすべての階層において、不必要であり
かつ複雑です。せいぜいが、与えられた shit の top にある問題を即座に、また単純に
解決する誰かを祝福できるだけです。
わたしが好きなソフトウェアとは、簡単に理解ができ、同時にわたしの問題を解決してくれる
ものだけです。わたしが耐えるであろう数多の複雑さとは
解決しようとしている問題の大きさを調整することです。
#いまいち

略
Those of you who still find it enjoyable to learn the details of, say, a programming 
language - being able to happily recite off if NaN equals or does not equal null - you 
just don't yet understand how utterly fucked the whole thing is. If you think it would 
be cute to align all of the equals signs in your code, if you spend time configuring 
your window manager or editor, if put unicode check marks in your test runner, if you 
add unnecessary hierarchies in your code directories, if you are doing anything beyond 
just solving the problem - you don't understand how fucked the whole thing is. No one 
gives a fuck about the glib object model.

The only thing that matters in software is the experience of the user.


481 人が共有 
コメント 105 件

■_


一つ前へ 2011年9月(下旬)
一つ後へ 2011年10月(中旬)

ホームへ


リンクはご自由にどうぞ

メールの宛先はこちらkbk AT kt DOT rim DOT or DOT jp