ときどきの雑記帖 i戦士篇

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

一つ前へ 2009年10月(上旬)
一つ後へ 2009年10月(下旬)

ホームへ

2009年10月20日

■_

・音音ちゃんネットブック欲しいなあ
今日の17時から予約開始とか、よく零時から販売とかちとなあ。 【やじうまPC Watch】Windows 7 Starter搭載「音々ちゃんネットブック」10月22日発売

あとで読む。
とっても興味がある方面なので。

InfoQ: ソフトウェア品質の神話に関する実証的研究
http://www.infoq.com/jp/news/2009/10/exploding-myths
から

http://research.microsoft.com/en-us/projects/esm/nagappan_tdd.pdf
http://research.microsoft.com/apps/pubs/default.aspx?id=70290
http://research.microsoft.com/apps/pubs/default.aspx?id=70535
http://research.microsoft.com/apps/pubs/default.aspx?id=102351
http://research.microsoft.com/en-us/news/features/nagappan-100609.aspx

Assessing the Relationship between Software Assertions and Code Quality:An Empirical Investigation - Microsoft Research
http://research.microsoft.com/apps/pubs/default.aspx?id=70290

http://research.microsoft.com/pubs/70290/tr-2006-54.pdf

■_ 公式?

オラの通販だろうか? ノベルティ目当てで頼めばよかったか(あと一品買わないと規定の値段超えないけどw)

関数型プログラミング言語Haskell Part11

156 デフォルトの名無しさん [sage] 2009/10/20(火) 19:40:16 ID: Be:
    realwoldhaskellはやくもきたー
    ざっとみると、ghc6.10.1で動作確認してあるみたい? 

157 デフォルトの名無しさん [sage] 2009/10/20(火) 19:42:14 ID: Be:
    6.10.4て書いてあった… 

158 デフォルトの名無しさん [sage] 2009/10/20(火) 21:52:20 ID: Be:
    え?もうジュンク堂にあるの? 

159 156 [sage] 2009/10/20(火) 22:37:41 ID: Be:
    公式で通販しました
    原著よりも一回り小さいので文字も小さいw 電車で読みやすそうだからいいけど 

160 デフォルトの名無しさん [sage] 2009/10/20(火) 23:32:35 ID: Be:
    今日もseqを挟む作業だお……のAA下さい! 

原書よりも一回り小さい? プロダクティブプログラマあたりと同じ版型? だと小さすぎるか。でもあれくらいのが持ち歩きやすいよなあ。 今日当たり、池袋ジュンク堂のついったのつぶやきに入荷したってのがくる鴨。

コーディングスタイルにこだわるスレ 
327 デフォルトの名無しさん [sage] 2009/10/17(土) 11:55:45 ID: Be:
    javaで

    public void XXX() throws YYY, ZZZ {
    }

    のthrows以下が長くなると80桁超えますけど見やすい折り返し方ないですか?
    eclipseのデフォルトで整形すると

    public void XXX() throws YYY,
        ZZZ {
    }

    とやってくれましたけど見づらいな。 

330 デフォルトの名無しさん [sage] 2009/10/20(火) 11:51:05 ID: Be:
    >>327
    行が長くなるときどう折り返すか
    ttp://java-house.jp/ml/archive/j-h-b/009166.html#body 

331 デフォルトの名無しさん [sage] 2009/10/20(火) 12:09:53 ID: Be:
    C++ 使っててカンマとか演算子の「前」で折り返して、演算子の類が行頭にくるように
    してたんだけど、 Python 使い出したらそうもいかなくなって、今は微妙な気持ちです。 

332 デフォルトの名無しさん [sage] 2009/10/20(火) 12:20:08 ID: Be:
    >>331
    英語では普通、カンマやセミコロンなどは単語の後ろに空白なしにつける。当然、改行はその後。
    演算子もそれに準じる。 

333 デフォルトの名無しさん [sage] 2009/10/20(火) 13:57:32 ID: Be:
    >>331
    ( ・∀・)人(・∀・ )ナカーマ

    .append(foo)
    .append(bar)
    .toString();

    + fooooooooooooooooooooooo
    - (baaaaaaaaaar % baaaaaaaaz);

    = {
    11111111111
    , 2222222222
    , 3333333333
    }

    if (
    (cooooooooooooooond)
    || (baaaaaaaar && bazzzzzzzz)
    )

    文末を見るより、文頭を見るほうが目の動きが少ない。 

334 デフォルトの名無しさん [sage] 2009/10/20(火) 14:05:42 ID: Be:
    . を先頭にもってくるのは許せるが、 , を先頭にもってくるのが許せないのはなぜだろう。 

カンマの前置きはやらないけど(SQLラヴな某氏は好きそうな気がしないでもない)、 if の条件式で出てくる && とか || は頭に持ってくるなあ。

■_ 本日の巡回から

Fabulous Adventures In Coding : What is this thing you call "thread safe"?
http://blogs.msdn.com/ericlippert/archive/2009/10/19/what-is-this-thing-you-call-thread-safe.aspx

Defeating the Matasano C++ Challenge with ASLR enabled at time to bleed by Joe Damato
http://timetobleed.com/defeating-the-matasano-c-challenge-with-aslr-enabled/

Monad (functional programming) - Wikipedia, the free encyclopedia
http://en.wikipedia.org/wiki/Monad_(functional_programming)

All About Monads
http://www.sampou.org/haskell/a-a-monads/html/

state
http://ha6.seikyou.ne.jp/home/yamanose/haskell/state.html

Journal of chromatic (983)
http://use.perl.org/~chromatic/journal/39773?from=rss

The Art of Library | Engine Yard Blog
http://www.engineyard.com/blog/2009/the-art-of-library/

Why is this OCaml program faster than my C program? - Stack Overflow
http://stackoverflow.com/questions/1586423/why-is-this-ocaml-program-faster-than-my-c-program

StackOverflow cool Ruby questions - Khaled alHabache’s official blog
http://www.khelll.com/blog/ruby/stackoverflow-cool-ruby-question/

"On-line" (iterator) algorithms for estimating statistical median, mode, skewness, kurtosis? - Stack Overflow
http://stackoverflow.com/questions/1058813/on-line-iterator-algorithms-for-estimating-statistical-median-mode-skewness

Looking for OO gurus, need some help in the design of my programming logic. Nothing fancy, just new to it. - Stack Overflow
http://stackoverflow.com/questions/1586247/looking-for-oo-gurus-need-some-help-in-the-design-of-my-programming-logic-nothi

■_ キャスト

このネタ、二年位前に取り上げたことがあるような気がする。

Specifically, what's dangerous about casting the result of malloc? - Stack Overflow

Now before people start marking this a dup, I've read all the following, none of which 
provide the answer I'm looking for:

   1. C FAQ: What's wrong with casting malloc's return value?
   2. SO: Should I explicitly cast malloc()’s return value?
   3. SO: Needless pointer-casts in C
   4. SO: Do I cast the result of malloc?

Both the C FAQ and many answers to the above questions cite a mysterious error that 
casting malloc's return value can hide, however none of them give a specific example 
of such an error in practice. Now pay attention that I said error, not warning.

C FAQ と上に挙げられている質問サイトでの多くの回答の両方が、malloc の戻り値をキャスト
してしまうことで mysterious error を隠してしまう可能性があるとしているのですが、そのよ
うなエラーが実際に起きるような例を示してはくれていません。ここでわたしが述べているのは、
警告ではなくエラーについてです。

Now given the following code:

次のようなコードがあったとします:

#include <string.h>
#include <stdio.h>
// #include <stdlib.h>

int main(int argc, char** argv) {

    char * p = /*(char*)*/malloc(10);
    strcpy(p, "hello");
    printf("%s\n", p);

    return 0;
}

Compiling the above code with gcc 4.2, with and without the cast gives the same 
warnings, and the exec executes properly and provides the same results in both cases.

上記のコードをgcc4.2でコンパイルするとキャストがあってもなくても同じ警告を発しますまた、
実行した場合どちらのケースでも正常に実行され、同じ結果となります。

anon@anon:~/$ gcc -Wextra nostdlib_malloc.c -o nostdlib_malloc
nostdlib_malloc.c: In function ‘main’:
nostdlib_malloc.c:7: warning: incompatible implicit declaration of built-in function ‘malloc’
anon@anon:~/$ ./nostdlib_malloc 
hello

So can anyone give a specific code example of a compile or runtime error that could 
occur because of casting malloc's return value, or is this just an urban legend?

そこで誰か、mallocの戻り値をキャストしたことによってコンパイルエラーや実行時エラーにな
るコード例を示してもらえないでしょうか?あるいはこれは都市伝説に過ぎないのでしょうか?

Edit I've come across two well written arguments regarding this issue:

   1. In Favor of Casting: CERT Advisory: Immediately cast the result of a memory 
      allocation function call into a pointer to the allocated type

   2. Against Casting

2009年10月19日

■_

・シグルイ、締めに入ってんですかねえ。

・定期
定期券の継続での購入をしたんですが、PASMOと一緒になっているものなので 券売機で。前回やったときよりも処理が完了するまでがだいぶ早くなったような気がするんですが 気のせいかなあ。

■_

推薦図書/必読書のためのスレッド 52
322 デフォルトの名無しさん [sage] 2009/10/19(月) 02:44:00 ID: Be:
    おまいらパソコン見ながら本みるときって
    本はどこに置いてるのよ?

323 デフォルトの名無しさん [sage] 2009/10/19(月) 02:59:49 ID: Be:
    机の上.
    最近ブックスタンドを買おうかと悩んでいる. 

329 デフォルトの名無しさん [sage] 2009/10/19(月) 12:36:46 ID: Be:
    >>323
    お勧め!
    ttp://www.amazon.co.jp/%E3%82%AB%E3%83%BC%E3%83%AB-%E3%83%96%E3%83%83%E3%82%AF%E3%82%B9%E3%82%BF%E3%83%B3%E3%83%80%E3%83%BC-NO-820-%E3%83%96%E3%83%A9%E3%83%83%E3%82%AF-NO-820-K/dp/B001A1V9R6/ref=sr_1_1?ie=UTF8&\1s=office-products&\1qid=1255923263&\1sr=8-1

    タブレットPCの台にも使えるので、タブレットPCをブックリーダー代わりにして快適だよ! 

330 デフォルトの名無しさん [sage] 2009/10/19(月) 12:41:33 ID: Be:
    >>329
    おまえはその前に [amazon url] でググってこい。 

331 デフォルトの名無しさん [sage] 2009/10/19(月) 12:43:23 ID: Be:
    貼るときは短く!!
    http://www.amazon.co.jp/dp/B001A1V9R6/ 

332 デフォルトの名無しさん [sage] 2009/10/19(月) 12:46:38 ID: Be:
    もっと短く

    http://amazon.jp/dp/B001A1V9R6/ 

333 デフォルトの名無しさん [sage] 2009/10/19(月) 12:48:21 ID: Be:
    もっと短く
    amazon.co.jp/dp/B001A1V9R6/ 

334 デフォルトの名無しさん [sage] 2009/10/19(月) 12:49:02 ID: Be:
    もっと短く
    アマゾン/dp/B001A1V9R6/ 

335 デフォルトの名無しさん [sage] 2009/10/19(月) 12:51:16 ID: Be:
    amazon.jp/B001A1V9R6/ 

336 デフォルトの名無しさん [sage] 2009/10/19(月) 12:53:46 ID: Be:
    尼/B001A1V9R6 

337 デフォルトの名無しさん [sage] 2009/10/19(月) 13:03:51 ID: Be:
    amazonにはこだわるんだなw 

338 デフォルトの名無しさん [sage] 2009/10/19(月) 13:59:41 ID: Be:
    C++でロベールのC++入門講座というのをやったんですが
    「これを読んだら」ライブラリ系の本をやってくださいとあったので
    C++のライブラリ系の本でお勧めを教え下さい。 

339 デフォルトの名無しさん [sage] 2009/10/19(月) 14:07:46 ID: Be:
    私もライブラリの本知りたいな
    サウンドプログラミングの勉強中なので良いライブラリがあると非常に助かります
    アマゾンとかもみてみますけどね 

340 323 [sage] 2009/10/19(月) 14:32:12 ID: Be:
    >>329-336
    おまいらありがとうw
    さっそく注文してみるよ! 

341 デフォルトの名無しさん [あさげ] 2009/10/19(月) 18:06:30 ID: Be:
    マイケルシプサ 「計算理論の基礎」が第二版でどのくらい変わったのかわかる人いますか?
    初版では練習問題の解答がついてなかったようなのですが、第二版ではどうなんでしょ 

342 デフォルトの名無しさん [sage] 2009/10/19(月) 18:39:33 ID: Be:
    >>341
    どのくらい変わったのかはわからないけれど
    第二版では答えを載せてあるやつと載せてないのがあるよ 

343 デフォルトの名無しさん [sage] 2009/10/19(月) 18:42:00 ID: Be:
    ・3分冊になって使いやすくなった
    ・解答がついた
    ・内容はそれほど変わってない。ちょっと詳しくなった程度

    だと思う。前書きに「解答がついたことが最大の変更点だぜ」みたいに書かれていたような気が。
    日本語版は、授業で使いやすくするために分冊にしたとか書いてあったけど、1, 2, 3それぞれ単体では使いにくい。
    どの巻も中途半端なんだよねぇ。 

346 デフォルトの名無しさん [sage] 2009/10/19(月) 19:44:58 ID: Be:
    ライブラリはまあヘルプでも見て、使ってみるのがいいと思うよ
    よほど複雑なのでない限りは 

347 デフォルトの名無しさん [sage] 2009/10/19(月) 19:49:19 ID: Be:
    >>346
    STLは、ちゃんと勉強しないとダメだろ。

    ぶっちゃけ、中の仕組みを知らなくても使える、
    って言うオブジェクト指向のウリを無視して、
    かなり中身を知ってないと使いこなせないからな。 

348 デフォルトの名無しさん [sage] 2009/10/19(月) 20:06:06 ID: Be:
    Effective STLは読んどいた方がいいかもね
    下手なコード書いて苦労する前に 

349 デフォルトの名無しさん [sage] 2009/10/19(月) 20:09:14 ID: Be:
    Effectiveシリーズは全般的に評価が高いみたいだけど本当にいい内容なの?
    Effective C++は良かったけどC#とか他の評価が気になる 

350 デフォルトの名無しさん [sage] 2009/10/19(月) 20:33:20 ID: Be:
    独習ってつければ良いと思ってるくらい、
    Effectiveってつけてるだけだよ、出版社が。 

351 デフォルトの名無しさん [sage] 2009/10/19(月) 20:34:46 ID: Be:
    Effective STLなんか読むよりGoW 

352 デフォルトの名無しさん [sage] 2009/10/19(月) 20:36:17 ID: Be:
    >>350
    そんな翔泳社やMYCOMみたいなことはしません
    http://www.informit.com/imprint/series_detail.aspx?ser=342248&rll=1 

353 デフォルトの名無しさん [sage] 2009/10/19(月) 20:57:32 ID: Be:
    >>349
    Effective C#も秀逸だったよ。
    More Effective C#と合わせて買っておくべき。
    nativeじゃない人にも読まれてることを想定してるからなのか
    平易な単語しか使わないという配慮もあって読みやすかった。 

354 デフォルトの名無しさん [sage] 2009/10/19(月) 21:00:30 ID: Be:
    >>338
    C++の標準ライブラリなら、C++ 標準ライブラリ チュートリアル&リファレンスが最適。
    多くの本では無視されるロケールについて解説がなされているのもありがたい。
    それを読み終えたらEffective STLで陥りやすい罠について補完しておくといい。 

355 デフォルトの名無しさん [sage] 2009/10/19(月) 21:03:27 ID: Be:
    >>350
    いや、Effectiveシリーズは、メイヤーさんが監修してる。 

356 デフォルトの名無しさん [sage] 2009/10/19(月) 21:04:19 ID: Be:
    >>354
    >>338ではないけどありがとう 

357 デフォルトの名無しさん [sage] 2009/10/19(月) 21:06:30 ID: Be:
    EffectiveシリーズというのはScott Meyersのアレでいいのかな 

358 デフォルトの名無しさん [sage] 2009/10/19(月) 21:11:43 ID: Be:
    Effective JavaはMeyers監修ってわけでもないよね?
    ややこしいけど 

359 デフォルトの名無しさん [sage] 2009/10/19(月) 21:13:02 ID: Be:
    Effective 独習 

360 デフォルトの名無しさん [sage] 2009/10/19(月) 21:15:34 ID: Be:
    Effective mayers 

361 デフォルトの名無しさん [sage] 2009/10/19(月) 21:19:15 ID: Be:
    本なんか読まなくても勝てるお!! 

362 デフォルトの名無しさん [sage] 2009/10/19(月) 21:27:21 ID: Be:
    Effective DOKUGAKU 

352 のリンク先見ると、Code Quality や Code Reading もシリーズの一環なのね。 そいや今週辺りの予定に More Effective C# があったけど、More じゃないほうって 日本語訳出てないよね?

Ruby 初心者スレッド Part 31 

887 デフォルトの名無しさん [sage] 2009/10/19(月) 14:06:10 ID: Be:
    配列の各要素とそのインデックスを関連付けるハッシュをつくるとき、Perlでは以下のように
    しますが、

    my @arr = qw(a b c d);
    my %hash;
    @hash{@arr} = 0..$#arr;

    Rubyではどのようにするのでしょうか?

    arr = %w(a b c d)
    hash = ????
    p hash #=> {'a'=>0, 'b'=>1, 'c'=>2, 'd'=>3} 

888 デフォルトの名無しさん [sage] 2009/10/19(月) 14:12:22 ID: Be:
    残念ながら、うまい方法はない

    irb> p Hash[arr.zip((0..arr.size).to_a)]
    {"a"=>0, "b"=>1, "c"=>2, "d"=>3}

    こんなもん 

889 デフォルトの名無しさん [sage] 2009/10/19(月) 14:36:47 ID: Be:
    >>888
    ㌧
    多分、Rubyのバージョンが古いせいだと思いますが、エラーが出ました。

    in `[]': odd number of arguments for Hash (ArgumentError)

    当方のRubyのバージョンは、以下です。

    ruby 1.8.6 (2007-06-07 patchlevel 36) [i386-mswin32]

    以下の修正で意図した結果が得られました。

    hash = Hash[*arr.zip((0..arr.size).to_a).flatten] 

890 デフォルトの名無しさん [sage] 2009/10/19(月) 14:58:41 ID: Be:
    ああ、1.8.7 は>>888 でも動くのか
    厄介な修正だのう 

891 デフォルトの名無しさん [sage] 2009/10/19(月) 15:17:34 ID: Be:
    マイナーバージョン間で非互換なんですねわかります 

892 デフォルトの名無しさん [sage] 2009/10/19(月) 15:32:59 ID: Be:
    1.8.6 の記述が 1.8.7 で動作しないんじゃないんだから別にいいだろ
    1.8.7 での記述が 1.8.6 で動作しないというのはそれなりにフツーだろう 

893 デフォルトの名無しさん [sage] 2009/10/19(月) 16:12:48 ID: Be:
    >>889
    ruby 1.8.6、1.9.0両方で動かすなら

    h = {}
    arr.each_index{|i|h[i] = arr[i]}

894 デフォルトの名無しさん [sage] 2009/10/19(月) 16:15:34 ID: Be:
    いや、1.9.0はもう終了してるから
    それにキーと値が逆

    h = {}
    arr.each_with_index{|e, i|h[e] = i}

895 デフォルトの名無しさん [sage] 2009/10/19(月) 16:17:16 ID: Be:
    いや h = Hash[*arr.zip((0..arr.size).to_a).flatten] のほうは 1.8.7 でも 1.9.0 でもきちんと動作するから 

897 デフォルトの名無しさん [sage] 2009/10/19(月) 16:41:24 ID: Be:
    require 'enumerator'
    p Hash[*arr.enum_for(:each_with_index).to_a.flatten]
    # => {"a"=>0, "b"=>1, "c"=>2, "d"=>3}

    とか

    h = Hash.new{|t, k| t[k] = arr.index(k) }
    p [h["a"], h["b"], h["c"], h["d"]]
    # => [0, 1, 2, 3]

    とか

    だがしかしお薦めは>>894 

898 デフォルトの名無しさん [sage] 2009/10/19(月) 16:45:14 ID: Be:
    >>887のへんてこな感じを考慮すると
    配列サイズの Range を to_a して zip するのが一番近い答のような気もちらっとせんでもない 

899 デフォルトの名無しさん [sage] 2009/10/19(月) 16:52:08 ID: Be:
    1.9だと

    p arr.each.with_index.with_object({}){|(e, i), memo| memo[e] = i }
    #=> {"a"=>0, "b"=>1, "c"=>2, "d"=>3}

    で済むんだけどなぁ 

900 デフォルトの名無しさん [sage] 2009/10/19(月) 21:09:36 ID: Be:
    >>887
    Perlではハッシュの複数の要素に対して一度に代入できるのか。すごいけど、どれくらい使用頻度があるのやら。

    Rubyには直接該当する機能はないから、>>894をEnumerableに定義するのがいいと思う。

    module Enumerable
    def indexing
    h = {}
    self.each_with_index {|x, i| h[x] = i }
    h
    end
    end

    p %w(a b c d).indexing #=> {"a"=>0, "b"=>1, "c"=>2, "d"=>3}

901 デフォルトの名無しさん [sage] 2009/10/19(月) 21:16:08 ID: Be:
    >>900
    Hash→Array はありだと思うが、Array→Hash は変だと思う 

902 デフォルトの名無しさん [sage] 2009/10/19(月) 21:26:54 ID: Be:
    1行で書くなら、1.9 のこれが多分一番素直

    Hash[arr.each_with_index.map{|e,i| [e,i]}]

    2行でいいなら>>894だが 

903 デフォルトの名無しさん [sage] 2009/10/19(月) 21:42:04 ID: Be:
    需要的にはわかるけどね
    つまりは逆引きだし、Array#indexを多用するケースには使えそう
    h = indexing(arr)
    p arr[0] #=> a
    p h["a"] #=> 0

    Perlの動作は知らないけど、indexingの名前を付けるなら
    Array#indexとの対称性を考えて重複時は上書き無しにしとくといいかも
    self.each_with_index {|x, i| h[x] ||= i } 

結構いろいろ書けるもんだなあ。each_with_index ってなんかあまり好きでないので 自分の好みとしては 898 の 配列サイズの Range を to_a して zip する かなあ。

■_ 辞書引け辞書

CPANの膨大なモジュールから必要なモジュールを探す方法 -OKWave
連想配列の足し算は出来ないものでしょうか。

例えば
 %x=('a'=>1,
   'b'=>2);
 %y=('b'=>3,
   'c=>4);
 
 %z=%x+%y;
で
 %z=('a'=>1,
   'b'=>5,
   'c'=>4);

とか
 %z=%x.%y;
で
 %z=('a'=>1,
   'b'=>23,
   'c'=>4);

となれば便利だと思うのですが。

今回はこれでCPANを跳梁してみたのですが、挫折してしまいました。
CPANを眺めていても時間が経つばかり・・・意地になって探すより、サッサと自分でコードを
書いた方が遥かに早いですね。

こういう時、CPANを使いこなしている方はどのようにされているのでしょう。時々、こんなの自
分でコードを書かなくても、絶対にCPANにあるよなと思うことがあるのですが、ズラ~ッと羅列
されている各モジュールの説明に一つ一つ目を通して行くと、間違いなく普通の人は挫折すると
思うんです。

跳梁 - 類語辞典(シソーラス)

「連想配列」、じゃなくて「ハッシュ」を手がかりにすれば見つけられたんじゃなかろか。

■_ よこくへん

ペースが上がらん喃。 Eli Bendersky's website ≫ Blog Archive ≫ The C++ bashing season is back から。 reddit でも順調にスレッドが伸びてますが。 The C++ Bashing Season is Back : programming

Where do you stop? Which subset of C++ do you pick and stick to it to really make it a 
"better C"? Let me paste that quote once more:

どこで止まるのでしょうか? あなたが選んだC++のサブセットのどれが本当に "better C"
となるものでしょうか? ここでもう一回引用しておきます。

    You like C++ because you're only using 20% of it. And that's fine, everyone only 
    uses 20% of C++, the problem is that everyone uses a different 20% :) 

    あなたが C++が好きだというのは C++ の 20% しか使っていないからだ。And that's fine,
    誰もが C++ の20%しか使っていない。問題は皆がそれぞれ異なる 20% を使っているという
    ことだ :)

For someone the good parts of C++ are exceptions and RAII. For another it's templates 
and STL containers. Each one is picking his own subset, and no one seems to agree 
whose subset is better/safer/more comprehensible.

ある人にとっての C++ の good parts は例外とRAIIですが、別のある人にとってはテンプレー
トとSTLのコンテナーです。各々が自分なりのサブセットを取り出し、そしてそれは
better/safer/more comprehensible であることを当人以外には認めるものが皆無であろうもの
なのです。

This is how all religious wars start.

  

関連。 C++ is frequently reviled both by those who never use and by those who use it all the time : programming C++ in Coders at Work

■_ 本日の巡回から

2009年10月18日

■_

・今月これからどれくらい本やらDVDで出費するのやら(笑) わかっているだけでも、Real World Haskell の日本語訳、Rの本、 Modern Compiler in ML の日本語訳…えーと他にもあったような。

書こうとしていた日記ネタを忘れたw

・探し物
ラジカセみたいな感じで、mp3(とできればwma)をSDカードか何かのメディアで 取り込んで再生できるようなものってなにかないでしょうか? 乾電池駆動ができるとなお良いです。 あー、風呂場で使うようなのでなんかいいのあったかも。

■_

丸善なあ。丸善にはやーな思い出があるんだよな。 服装チェックとか昭和のディスコ(死後)ぢゃあるまいしw

推薦図書/必読書のためのスレッド 52 
249 デフォルトの名無しさん [sage] 2009/10/17(土) 16:21:51 ID: Be:
    京都に住んでるのですが、大阪まで本を見に行こうと思ってます。
    大阪で一番コンピューター系の本が充実している本屋はどこになりますでしょうか? 

250 デフォルトの名無しさん [sage] 2009/10/17(土) 16:43:50 ID: Be:
    マルツパーツ 

251 デフォルトの名無しさん [sage] 2009/10/17(土) 17:31:21 ID: Be:
    プログラミング系の専門書ならダントツでジュンク堂だね。
    梅田本店,難波店ともに充実してる。
    梅田ヒルトンプラザ店は2フロアに拡張されてからまだ行ってないけど
    ここも同じくらい揃ってるらしい。 

252 デフォルトの名無しさん [sage] 2009/10/17(土) 20:17:05 ID: Be:
    >>251
    ありが㌧
    早速、行ってみます。 

253 デフォルトの名無しさん [sage] 2009/10/17(土) 20:37:21 ID: Be:
    梅田ヒルトンプラザ店に着て行く服が無い、っていうかどっから入っていいのか解らずそのままアバンザまで歩いてった・・・orz 

254 デフォルトの名無しさん [sage] 2009/10/17(土) 21:09:52 ID: Be:
    わかりやすい回転ドアの入り口があるじゃねえかw 

255 デフォルトの名無しさん [sage] 2009/10/17(土) 21:37:59 ID: Be:
    おまえらやっぱり本買うときは立ち読みしてから買ってんの?

256 デフォルトの名無しさん [] 2009/10/17(土) 21:41:45 ID: Be:
    >>255
    基本は立ち読みしてから だね
    #それでも、はずれ引くときは引くけど 

257 デフォルトの名無しさん [sage] 2009/10/17(土) 22:12:33 ID: Be:
    >>254やっぱりソコだったか・・・あれはセレブ様専用で
    一般客用勝手口が別に在るもんだとorz 

258 デフォルトの名無しさん [sage] 2009/10/17(土) 22:26:29 ID: Be:
    でまたエスカレータやエレベータでこっち行っていいのか?ってとこに上がっていくと

259 デフォルトの名無しさん [sage] 2009/10/17(土) 23:48:38 ID: Be:
    セレブ専用の入り口ってどんな場所だよw
    普通にスーツ着ていけば、よほど汚れてない限りどこでもいけね? 

260 デフォルトの名無しさん [sage] 2009/10/17(土) 23:59:35 ID: Be:
    都会なのに、今時どき回転ドア? 

261 デフォルトの名無しさん [sage] 2009/10/18(日) 00:28:55 ID: Be:
    都心って古くに造られたビルが残ってる箇所もけっこーあるな 

262 デフォルトの名無しさん [sage] 2009/10/18(日) 00:53:21 ID: Be:
    挟まれるwwスーツでww 

266 デフォルトの名無しさん [sage] 2009/10/18(日) 01:13:25 ID: Be:
    >>259普通にスーツ着ていけば
    ハードル高いんだな。あした しまむらに行って来よう・・・。 

267 デフォルトの名無しさん [sage] 2009/10/18(日) 07:51:28 ID: Be:
    >>266
    気にしすぎだろ
    ジャージとかで行くぞ 

268 デフォルトの名無しさん [sage] 2009/10/18(日) 10:12:23 ID: Be:
         ∧_∧
         ( ゚ω゚ ) ジャージとかで行くぞー
     バリバリC□l丶l丶
         /  (   ) やめて!
         (ノ ̄と、 i
            しーJ 

270 デフォルトの名無しさん [sage] 2009/10/18(日) 14:44:02 ID: Be:
    東京でコンピューター系の書籍が充実してる本屋は? 

271 デフォルトの名無しさん [sage] 2009/10/18(日) 15:02:45 ID: Be:
    スーツなんかなくてもおかしな格好じゃなきゃ大丈夫だよ 

272 デフォルトの名無しさん [sage] 2009/10/18(日) 15:11:36 ID: Be:
    ジーパン白Tシャツでビーフジャーキーを咥えながらでおk 

273 デフォルトの名無しさん [sage] 2009/10/18(日) 15:22:12 ID: Be:
    >>270
    新宿紀伊国屋の南口の方の店舗じゃない?
    あそこなら洋書もあるし。 

274 デフォルトの名無しさん [sage] 2009/10/18(日) 15:24:17 ID: Be:
    >>270
    アマゾンのコンテナとかどうよ?
    いっぱい詰まってるぞ 

275 デフォルトの名無しさん [sage] 2009/10/18(日) 15:28:17 ID: Be:
    池袋のジュンク堂もいい 

276 251 [sage] 2009/10/18(日) 15:29:55 ID: Be:
    >>252
    ごめん難波店じゃなくて千日前店という名前らしい。
    難波店は別にあるみたいだけどそこは行ったこと無いからわからない。
    もしもう行ってたらごめんね・・ 

277 デフォルトの名無しさん [sage] 2009/10/18(日) 15:45:50 ID: Be:
    大船周辺で書籍が充実してる本屋おしえてよ

278 デフォルトの名無しさん [sage] 2009/10/18(日) 16:31:53 ID: Be:
    >>270 >>273
    高島屋の紀伊国屋よりも新宿三越ジュンク堂の方が充実死てる 

279 デフォルトの名無しさん [sage] 2009/10/18(日) 16:36:11 ID: Be:
    新宿ならジュンク堂 

280 デフォルトの名無しさん [sage] 2009/10/18(日) 16:39:18 ID: Be:
    本屋スレになってるぞ、お前ら 

281 デフォルトの名無しさん [sage] 2009/10/18(日) 17:13:17 ID: Be:
    東京駅近くの丸善が最強帰りの電車も始発で座れすし 

282 デフォルトの名無しさん [] 2009/10/18(日) 17:15:35 ID: Be:
    東京始発の電車乗って帰る時点で負け組みwww 

283 デフォルトの名無しさん [sage] 2009/10/18(日) 17:23:34 ID: Be:
    ジュンクと丸善が経営統合というから巨大書店もいつまであるか分からんぞ。
    おまいらアマゾンで買うなよ。 

285 デフォルトの名無しさん [sage] 2009/10/18(日) 17:33:07 ID: Be:
    中身閲覧が可能なのが増えてきているんでもうAmazonだけで構わん 

286 デフォルトの名無しさん [sage] 2009/10/18(日) 17:49:51 ID: Be:
    amazonで買うと金が地元に落ちず海外に吸われていくだけってのはあるな。 

287 デフォルトの名無しさん [sage] 2009/10/18(日) 17:51:50 ID: Be:
    >>286
    日本の企業はもっと改善するべきだよな

288 デフォルトの名無しさん [sage] 2009/10/18(日) 17:52:22 ID: Be:
    本屋近い人は本屋で買う方がいいと思うよ。

289 デフォルトの名無しさん [sage] 2009/10/18(日) 18:58:35 ID: Be:
    東京駅近くの丸善って意外と行きにくいんだよな
    千代田線の大手町で降りると非常に遠いし
    東京駅が最寄になるの? 

290 デフォルトの名無しさん [sage] 2009/10/18(日) 19:23:33 ID: Be:
    >>283
    田舎民には事実上amazonしか選択の余地が無い 

291 デフォルトの名無しさん [sage] 2009/10/18(日) 19:47:57  ID: Be:
    >289
    東西線の大手町駅で降りろ

    あるいは丸の内線かJR京浜東北線の東京駅 

292 デフォルトの名無しさん [sage] 2009/10/18(日) 20:32:11 ID: Be:
    田舎在住だが、
    東京や大阪のコンピューター関連の書籍がいっぱいある
    大きな本屋は、スーツ着て正装してないと、
    中に入れてもらえないの? 

293 デフォルトの名無しさん [sage] 2009/10/18(日) 20:33:14 ID: Be:
    >>292
    うん、そうだよ。あたりまえじゃん。 

294 デフォルトの名無しさん [sage] 2009/10/18(日) 20:34:18 ID: Be:
    >>292
    入り口でやんわりとチェックされる

295 デフォルトの名無しさん [sage] 2009/10/18(日) 20:46:12  ID: Be:
    >>292
    土足厳禁だよ 

296 デフォルトの名無しさん [sage] 2009/10/18(日) 20:53:15 ID: Be:
    広島でいいとこないかなー?
    コンプマートぐらいしか知らないんだけど。 

297 デフォルトの名無しさん [sage] 2009/10/18(日) 21:03:31 ID: Be:
    >>293-295
    またそんなでたらめをいう‥‥‥。 

298 デフォルトの名無しさん [sage] 2009/10/18(日) 21:16:54 ID: Be:
    >>292
    本屋も田舎も都会もないから安心汁 

299 デフォルトの名無しさん [sage] 2009/10/18(日) 21:33:55 ID: Be:
    でも都会の本屋はテーブルやベンチがあってそこでゆっくり読めたりする・・・
    工学書の棚でも小奇麗なねえちゃんも居る時あるし・・・
    田舎は立ち読みしてるとおっさんにハタキでハタハタされたりするんだろ・・・ 

300 デフォルトの名無しさん [sage] 2009/10/18(日) 21:36:31 ID: Be:
    椅子があるのにはカルチャーショックを覚えた
    やっぱ凄いよ都会(といってもそこは都会という程でもないけど)!! 

302 デフォルトの名無しさん [sage] 2009/10/18(日) 21:41:45 ID: Be:
    >>277
    やっぱ横浜出るのが確実だろーな
    西口ダイエー内のあおい書店がおすすめ 

304 デフォルトの名無しさん [sage] 2009/10/18(日) 21:59:04 ID: Be:
    >>277
    >>302
    おとなり藤沢の
    ジュンク堂が(・∀・)イイ!!
    有隣堂も(゚з゚)イインデネーノ? 

305 デフォルトの名無しさん [sage] 2009/10/18(日) 22:08:13 ID: Be:
    大型書店じゃないと、判型大きい本にかけるカバーが無いと言われたり
    これから作るからで待ってと言われたり
    ぎりぎりの大きさのしかないと言われて「無理やり付けて下さい」と頼んだり。
    あと大型書店でもカバーかけるの嫌がって、無断でカバーかけずに袋に入れようとする。
    すかさず「カバーかけて下さい」と突っ込んで、
    その後に簡易包装に協力するため「袋いりません」「手下げ袋もいりません」と言う。
    俺って嫌な客か?
    電車の中で電話帳みたいな本読んでるの、プログラマしかいないよな。 

306 デフォルトの名無しさん [sage] 2009/10/18(日) 22:10:18 ID: Be:
    嫌な客 

307 デフォルトの名無しさん [sage] 2009/10/18(日) 22:21:53 ID: Be:
    板違いな嫌なレス 

308 デフォルトの名無しさん [sage] 2009/10/18(日) 22:30:53 ID: Be:
    >電車の中で電話帳みたいな本読んでるの、プログラマしかいないよな。

    確かに・・・というか自分以外でそんな分厚い本を読んでいる人を見たことがないかもw
    電車の中を見回すと8割ぐらい携帯弄ってるしな.

    上の方で出ていたGTK+の本を買うかどうか悩む.
    買った人いるかな 

309 デフォルトの名無しさん [sage] 2009/10/18(日) 22:38:55 ID: Be:
    書籍スレじゃなくて書店スレみたいになってるなw 

310 デフォルトの名無しさん [sage] 2009/10/18(日) 22:41:35 ID: Be:
    本って、トイレでウンコしながら読むものだろ? 

313 デフォルトの名無しさん [sage] 2009/10/18(日) 22:49:52 ID: Be:
    地方のジュンク堂が品揃え豊富かつ空いてて最強
    東京の大型書店は読みたい本の前に誰か立ってていつまでたっても読めないとか
    立ち読みしてたら人が近づいてきて邪魔そうにされたりするし
    レジの行列も異常 

314 デフォルトの名無しさん [] 2009/10/18(日) 22:58:36 ID: Be:
    地方なら、平日の昼間いけば、すいてて読み放題。 

315 デフォルトの名無しさん [sage] 2009/10/18(日) 23:00:41 ID: Be:
    東京の人間がいう地方なんて神戸とか京都とかそんなレベルだろ 

316 デフォルトの名無しさん [sage] 2009/10/18(日) 23:32:53 ID: Be:
    田舎の本屋なんて、Vistaの本の横に「ふつうのコンパイラをつくろう」が
    置かれてたりするからなw 

317 デフォルトの名無しさん [sage] 2009/10/18(日) 23:35:31 ID: Be:
    ワードとエクセルとエロゲ雑誌しかないorz 

318 デフォルトの名無しさん [] 2009/10/18(日) 23:39:54 ID: Be:
    「Railsレシピブック183の技」がゲームの攻略本のコーナーにあった。
    田舎の地方都市の大型書店・・・「技」ってついてるからなのかな 

319 デフォルトの名無しさん [sage] 2009/10/18(日) 23:44:42 ID: Be:
    カーニハン&プローガーのソフトウェア作法が編み物のコーナーにあった 

電話帳みたいなプログラミングの本を電車の中で読む。ああ @uskz センセのことかw

Rubyについて Part 37
825 デフォルトの名無しさん [sage] 2009/10/17(土) 23:58:05 ID: Be:
    我らの武器は三つ!
      オブジェクト指向!
        ガーベジコレクション!
          教祖への妄信!
            それから素敵な赤い色!

    ……テンポ悪いな。 

826 デフォルトの名無しさん [sage] 2009/10/18(日) 00:04:30 ID: Be:
    タダ-ン!!
    ... nobody expects the Spanish Inquisition!

827 デフォルトの名無しさん [sage] 2009/10/18(日) 00:08:55 ID: Be:
    なぜ唐突にそんなおっホイねたをw 

828 デフォルトの名無しさん [sage] 2009/10/18(日) 02:14:49 ID: Be:
    元ネタ知らないのに大笑いしてしまった 

829 デフォルトの名無しさん [sage] 2009/10/18(日) 02:34:57 ID: Be:
    モンティパイソンは"Communist Quiz"も応用が利くよね。
    マルクス => RMS
    レーニン => ケイ
    チェ => PG
    毛沢東 => Matz
    とかでサッカーネタ => M$ APIネタ にすればいろいろ遊べそう。 

830 デフォルトの名無しさん [sage] 2009/10/18(日) 03:22:40 ID: Be:
    ゲートから12人のYuguiさんが一斉に出馬、
    先頭YuguiさんYuguiさん、一馬身遅れてYuguiさん、続いてYuguiさん、
    追い上げるYuguiさん、とかそういう 

■_ 直交性だっけ?



小さな発見 on x86-64 - ひげぽん OSとか作っちゃうかMona-
小さな発見 on x86-64CommentsAdd Star

mona

Mosh の Jit のために gcc (x86-64) の出力するコードを見ている。何となく発見や疑問があるので書いてみる。

    * 見ている範囲では r8-r12 をあまり使わないように見える
          o がんばって rax, rdx 辺りを使い回している印象
          o どのみち 64bit レジスタ使うなら rex prefix の関係で、ほぼ同じ命令長のはずなんだけど速度が違うんだろうか
    * cmpq $12344567, %rax というコードをアセンブルしようと思たら rax 決めうちの opcode がある事を知り。面白かった

「rax, rdx辺り を頑張って使いまわしている」というのは、 8086 → (省略) → 80386 で、 大分「レジスタごとの固有の役割」 (loop 命令ではカウンタが cx に決めうちとか、 string 命令で siとdiが使われるとか) が薄くなってるはずですけどそれでも特に eax (32bitレジスターの場合) なんかは「特別扱い」されるきらいがあるのでその辺の癖を引きずっているのかなあという気も。

たとえば 8086や8080だと、即値と論理演算できるのは AXレジスター(相当)しかできなかったり。 あ、8086はそうでもなかったか?

■_

2009年10月17日

■_

・高円寺
目的の書店見つけられず○| ̄|_ 竹書房も書店名だけじゃなくて簡単な地図くらい用意してくれたって…

・同じ入門書なのに…
C++ for Dummies という、~ for Dummies というシリーズものの一冊を見かけたんですが、 日本でよく見かける「入門書」とだいぶ違いますね。 このシリーズ 「Dummies」向けというタイトルの通り、 かなり手取り足取り教えるタイプの入門書です。 ざっと目を通しただけなので詳しく見ていったらまた違う感想になるかもしれませんが、 終盤の章では「Boostを使おう」とかでそれなりにページ数を割いてました。 厚さの問題などもあるでしょうけど、日本の「入門書」とどんだけ違うのかと 頭を抱えたくなりました。

ものは、 これかな? C++ For Dummies, 6th Edition:Book Information - For Dummies

■_



Perlについての質問箱 41箱目
844 デフォルトの名無しさん [] 2009/10/17(土) 08:40:05 ID: Be:
    すいません超初歩的な質問だと思うんですが
    $val が 1か4か9の時
    という風な条件文を書くとき
    $val == (1|4|9){
    では間違っていますか?
    初歩的過ぎるのかネットでの調べ方もいまいち掴めませんので教えて下さい。 

845 デフォルトの名無しさん [sage] 2009/10/17(土) 08:45:40 ID: Be:
    いやがらせ 

846 デフォルトの名無しさん [sage] 2009/10/17(土) 09:19:21 ID: Be:
    1 = 0001b
    4 = 0100b
    9 = 1001b
    つまり (1|4|9) は 1101b なので 13

    $val が 1か4か9の時はこう書く
    if($val == 1 || $val == 4 || $val == 9){} 

847 デフォルトの名無しさん [sage] 2009/10/17(土) 09:26:40 ID: Be:
    >>844
    その書式に極力合わせるなら、

    $val =~ /^(1|4|7)$/ and do{ 

848 デフォルトの名無しさん [sage] 2009/10/17(土) 09:48:47 ID: Be:
    >>844
    ジャンクションですね、わかります 

849 844 [sage] 2009/10/17(土) 10:25:03 ID: Be:
    お早い回答ありがとうございます。
    やはり間違ってたんですね。どうも上手く行かない理由がやっとわかりました。
    とりあえず地道に>>846の書き方で頑張ろうと思います。
    >>847の方はまだ微妙に理解できないので、もっと精進しようと思います。

    >>848も意味がどうにもわかりません。 

851 デフォルトの名無しさん [sage] 2009/10/17(土) 12:39:07  ID: Be:
    http://www.kcrt.net/program/perl6/14junctive.html
    なるほどPerl6にはそんな機能があるのか
    じゃあビット演算はどうするのよと思ったらこう書くのか・・・
    1 +| 2 # == 3
    5 +& 3 # == 1

やっぱりこういう比較したくなるもんなんだなあ。あと、 lower < var < upper みたいなのとか。

■_ あとで(ry

ずいぶんと伸びてるなあ

What do you wish someone had taught you when you first learned to program? : programming

I'm currently mentoring a high school student taking AP Computer Science (java). I 
don't have much of a formal background in CS, but I enjoy it enormously and am trying 
to communicate some sense of the passion and tradition of programming while we plod 
through the more mundane things. The class itself seems to leave much to be desired, 
so I've been augmenting the curriculum with Project Euler and little projects to 
refactor and extend the example code from his book, which is often pretty poor.

I have two goals, I think. The first is to clear as much of the mental overhead out of 
his way so he can just write code with a non-trivial chance of compiling. By this I 
mean answering a lot of noobish but essential questions and postponing some 
inessential points until he's ready for them (e.g. "what is the machine doing in 
an expression like 2 + 2.0" or "is public static void main(String[] args) a 
magic incantation or does it mean something?")

The second goal is to find things he feels challenged to explore and push himself into. 
A lot of Goal 1 deep-background-type-stuff is prerequisite to this, naturally, so I 
don't expect him to be motivated to go home and gin up a browser yet. I know that he's 
ultimately the one who has to grok it himself, and am mainly concerned with having him 
read and write as much code as realistically possible. But I also worry sometimes 
whether the things I'm showing him are "taking," and would be interested to 
know what first hooked you, redditors, when you started out, and what aha! moments 
helped you along, especially at the very beginning.

So: what do wish someone had taught you when you first began to program? Corollary: 
what would he wish someone had told me when I first began to teach someone to program?
C++ is frequently reviled both by those who never use and by those who use it all the time : programming

I want to highlight Ken Thompson's quote:

    [C++] certainly has its good points. But by and large I think it's a bad language. 
    It does a lot of things half well and it's just a garbage heap of ideas that are 
    mutually exclusive. ... It's way too big, way too complex. And it's obviously built 
    by a committee.

This entirely sums up my feelings about C++, as a developer who uses it every day.

built by a committee だからて。

■_ 本日の巡回から

2009年10月16日

■_

・むう
書きかけの原稿を置いてきてしまった。 気力が失せたので短縮バージョンで。 アクセスできないときに登録開始されたんで某勉強会 はまるきり蚊帳の外だったしな。

■_ おや、こんなところに

GNU Smalltalk のソースを眺めてたんですが

/* Definitions for data structures and routines for the regular
   expression library, version 0.12.
   Copyright (C) 1985,89,90,91,92,93,95,96,97,98 Free Software Foundation, Inc.

   This file is part of the GNU C Library.  Its master source is NOT part of
   the C library, however.  The master source lives in /gd/gnu/lib.

   The GNU C Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public License as
   published by the Free Software Foundation; either version 2 of the
   License, or (at your option) any later version.

   The GNU C Library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public
   License along with the GNU C Library; see the file COPYING.LIB.  If not,
   write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.  */

/* modified for Ruby by matz@netlab.co.jp */

#ifndef __REGEXP_LIBRARY
#define __REGEXP_LIBRARY

/* Extended regular expression matching and search library.
   Copyright (C) 1993, 94, 95, 96, 97, 98 Free Software Foundation, Inc.

   The GNU C Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public License as
   published by the Free Software Foundation; either version 2 of the
   License, or (at your option) any later version.

   The GNU C Library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public
   License along with the GNU C Library; see the file COPYING.LIB.  If not,
   write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.  */

/* removed gapped buffer support, multiple syntax support by matz <matz@nts.co.jp> */
/* Perl5 extension added by matz <matz@caelum.co.jp> */
/* Removed Ruby dependencies by Paolo Bonzini <bonzini@gnu.org> */

見覚えのある名前がw まあ、マルチバイト文字対応はずしたってのはある意味妥当なのかな。

■_ 本日の巡回から

■_ 七つの

どういう経緯で決めたものか良くわからんのですが

The Pragmatic Bookshelf | Core Data in print; Seven Languages
Seven Languages

Author Bruce Tate reports on the selection of Seven Languages:

“I just wanted to take the opportunity to thank all of the readers who contributed to 
the Seven Languages in Seven Weeks poll.

It's remarkable that so many of the languages that made my original list showed up 
here. Five of my original choices made the top 10. It's also cool to see that Haskell 
showed up on the top of the list. I had a few of my own rules based on interviewing a 
bunch of potential readers. There could be only one pure OO language; there could be 
only one Lisp; I probably shouldn't do both JavaScript and Ruby.

So based on everyone's voting and my rules, here's my final list of Seven Languages:

皆さんの投票とわたしのルールによって、以下のように最終的に七言語 (Seven Languages)
のリストができました。

    * Haskell—Static Typing as if you meant it and functional programming at its purest
    * Erlang—Concurrency made easy
    * Clojure—It's like Lisp, only better
    * Ruby—Simple and elegant, the way O-O was meant to be
    * Scala—All the buzz at JavaCon this year
    * Prolog—It'll blow your mind (if you can understand it)
    * IO—The minimalist prototype language

All of the top 5 made it in; I struck Python as a second object oriented language. I 
struck Lisp as being too close to Clojure, and I included IO as a JavaScript 
alternative because both are prototype-based languages.”

Python は第二のオブジェクト指向言語として
Lisp は Clojure に近すぎるもののため
JavaScriptの代わりに IO。どちらもプロトタイプベースの言語である

Thanks to all of you who helped Bruce choose the seven languages. We're looking 
forward to more feedback once the book goes beta.

Enjoy!

さりげなーーーく、Prolog があるのがひじょーーーーに気になるんですが(笑)

■_ そーいや

軌道の幅を変えた例があったのだった。

京成電鉄 - Wikipedia

改軌工事

1956年8月、運輸省(現・国土交通省)が「東京およびその周辺における都市交通に関する第1次
答申」策定する。この答申は東京のターミナル駅における混雑の緩和を狙ったもので、11の地下
鉄を整備し、一部での相互直通運転を行うというものだった。この「相互直通運転」の対象とな
ったのは都営地下鉄1号線(現・都営地下鉄浅草線)及び京成電鉄・京浜急行電鉄である。これ
により3者による規格統一に向けての議論が行われるが、規格統一の際に浮かび上がった大きな
難題が軌間の違いである。

当時、京成電鉄は軌間1372mmの「馬車軌」、それに対して京浜急行電鉄は軌間1435mmの標準軌を
採用していたが、相互直通運転に際して当然ながら統一する必要があった。ともに運転頻度の高
い路線だが、議論の結果京成電鉄が対策をとることとなった。この時1372mmと1435mmの三線軌条
や四線軌条とする案も挙がったが、車輪やレール同士の干渉など物理的な問題により、結局全線
改軌の方針となった。

まず、改軌のテストも合わせて1959年(昭和34年)8月18日 - 11月30日に同じく軌間1372mmの新
京成電鉄新京成線の改軌を実施し、この成果を見て改軌工事計画を立案した。

まず、同年春に犬釘をレールの外側に仮打ちする工事を行い、改軌工事のスムーズ化を図った。
そして同年10月9日 - 12月1日に改軌工事を行うこととした。

改軌工事の工程は、

   1. 1959年10月9日・10日:千葉線 京成幕張 - 京成千葉(現・千葉中央)間 8.8km
   2. 1959年10月13日・14日:本線 宗吾参道 - 京成成田間 4.2km、千葉線 京成津田沼 - 京成幕張間 4.0km
   3. 1959年10月17日・18日:本線 鹿島川専用乗継場(一般には京成臼井 - 京成佐倉間仮駅と案内されていた) - 宗吾参道間 8.0km
   4. 1959年10月20日・21日:本線 京成大和田 - 鹿島川専用乗継場間 10.5km
   5. 1959年10月24日・25日:本線 京成津田沼 - 京成大和田間 9.0km
   6. 1959年10月28日・29日:本線 東中山 - 京成津田沼間 8.1km
   7. 1959年11月4日・5日:本線 京成高砂 - 東中山間 8.9km
   8. 1959年11月10日・11日:押上線 押上 - 青砥間(全線) 5.7km
   9. 1959年11月16日・17日:本線 お花茶屋 - 京成高砂間 2.8km、金町線 京成高砂 - 京成金町間(全線) 2.5km
  10. 1959年11月22日・23日:本線 日暮里 - お花茶屋間 7.8km
  11. 1959年11月30日・12月1日:本線 京成上野 - 日暮里間 2.1km

となっており、1工程終了後2日以上の準備期間を設けて行うというものであった。

そして準備が整った10月9日に改軌の第1工程となる千葉線京成幕張 - 京成千葉間の改軌を開始、
翌10日に予定通りに終了し、同区間で最新鋭の3050形による始発列車が運転された。その後改軌
工事は順調に進み、11月30日に最終13工区の京成上野 - 日暮里間の改軌を予定より2日前倒しし
て終了、これを以って京成電鉄全線の改軌が終了した。

これと並行して、京成電鉄は軌間1372mmの旧型車両の改軌と東武鉄道の協力を得て押上駅の地下
化も行い、1960年11月29日に同駅の地下化を以ってすべて終了した。翌月12月4日に都営浅草線
浅草橋 - 押上間が開業し、浅草橋 - 東中山間で日本初の民鉄・地下鉄の相互直通運転が開始さ
れた。

でもまあ 1067→1435 だとまた事情が変わる面もあるだろうし、 JR以外でも関東圏の私鉄は大部分が 1067mm なのだった 違うのは京王線(とそれに乗り入れている都営地下鉄)くらい?。 あー、銀座線と丸の内線も違うか。

2009年10月15日

■_

・あさりよしとお新刊
みつからね~~♪

・ムダヅモ
副将があの方だとすると、大将誰?

・IBM → HAL
日経ソフトウエアの11月号を読み返していたら、 2001年宇宙の旅に出てきたHAL(HAL9000)はIBMの各文字を一つずつ前にずらしたものである (H→I、A→B、L→M)という話がさらっと書いてあったけど、これって関係者 (クラークだったかキューブリックだったか)に否定されてたような気がするんだけどなあ



HAL 9000 - Wikipedia
語源と由来 [編集]

HALはIBMを1文字ずつ前にずらして命名されたとする説が根強いが、監督のスタンリー・キュー
ブリックや、共同脚本のアーサー・C・クラークはそれを否定している。小説『2010年宇宙の旅』
では、チャンドラー博士自らIBM説を否定するくだりがある。しかし、アーサー・C・クラークは
後年になってからIBM社がこの説を迷惑がっているどころか半ば自慢しているらしいと聞き及び、
著書「3001年終局への旅」のあとがきで「今後はこの説の間違いを正す試みを放棄する」と述べ
ている。

ふむ。

・shibuya.lisp
Shibuya.lisp ≫ Blog Archive ≫ Shibuya.lisp テクニカルトーク#4 で。 17:00 Lispのココロ (竹内郁雄/東京大学)|USTREAM中継:×|保存動画公開:× なんと!?

■_ XX is Love

{ End Bracket }: Scheme Is Love

{ End Bracket }
Scheme Is Love (Scheme は愛)

Don Box

For the past few years, it has become fashionable to embrace a dynamic language such 
as Perl, PHP, Python, or Ruby. While I'll admit to having a short but pleasurable 
tryst with Ruby, I believe I have found true love in the dialect of Lisp called Scheme.

過去数年に渡り、PerlやPHP、Python、Rubyのような動的言語をembrace するために 
fashionable なものになってきました。わたしは Ruby に対して短いけれども  pleasureble 
tryst (楽しい密会?) をすることを認める一方で、わたしは自分がScheme と呼ばれている Lisp 
の dialectにtrue love を見つけたと確信しています。

In writing Scheme programs, I've learned a lot about coding, design, architecture, and 
aesthetics. On this front, Eric S. Raymond got it right in his essay, "How to 
Become a Hacker":

Scheme プログラムを書いているときに、わたしはコーディングや設計、アーキテクチャ、
aesthetics といったものを学びました。
On this front, Eric S. Raymond got it right in his essay, "How to Become a Hacker":

    Lisp is worth learning for a different reason - the profound enlightenment 
    experience you will have when you finally get it. That experience will make you 
    a better programmer for the rest of your days, even if you never actually use 
    Lisp itself a lot.

Everyone gets something different from their travels with Lisp. Here's what I saw 
along the way.

Lisp とともに旅をするすべての人が異なるものを得ます。
わたしの場合はこうでした。


Small is beautiful. Scheme is a great example of a micro-kernel design style. Scheme 
defines a very small number of base mechanisms as part of the core language/runtime 
specification. For example, Scheme defines only one conditional in its base: the if 
special form. The if form works like the ? : operator from C/C++/C#:

Small is beautiful. Scheme は micro-kernel 設計スタイルの素晴らしい実例です。Scheme は
非常に少ない数の base mechanisms をコア言語およびランタイムの仕様の一部として定義して
いますたとえば Scheme ではその base においてただ一つの  conditionalしか定義されていま
せん。if フォーム がそれです。この if フォームは CやC++、C#の ? : 演算子のように動作し
ます:

(if abc "yes" "no")

This is equivalent to the following C expression:

これは次の Cでの式と等価です。

abc ? "yes" : "no"

But Scheme and the C languages depart at this point. C defines a number of logical 
operators (&&, ||, !) and control flow statements (if, if/else, while, 
do/while) as language primitives. In contrast, Scheme defines all of these constructs 
as either procedures or macros. Does Scheme have the moral equivalent of C's basic 
conditionals and control constructs? Absolutely. What's interesting about Scheme is 
that these are all defined purely in terms of Scheme.

しかし Scheme と C とはこの点で違いがあります、C では言語のプリミティブなものとして論
理演算子 (&&, ||, !) や制御文  (if, if/else, while, do/while) を定義しています。
対照的に、Scheme ではこれらの constructs すべてを手続きかマクロとして定義しています。
Scheme には C の basic conditionals や control constructs と moral equivalent なものが
あるのでしょうか?もちろんあります。Scheme で興味深いのは、こういったものすべてが純粋に 
Scheme の terms で定義されているということです。

Lambda is more powerful than you think. Scheme programs are defined largely in terms 
of the lambda special form. Scheme lambdas are used to define functions. What's 
noteworthy about lambda is that functions are values just like integers are values. 
For example, the following Scheme code

lambda はあなたが考えているよりもずっと強力なものです、Shceme プログラムは概ね lambda 
特殊形式 で定義されますScheme の lambda は関数を定義するために使われています。lambda 
に関して注目すべきことは、関数が、整数が値であるというのと全く同じように値であるという
ことです。たとえば次のような Scheme コードを例にとると

(define s (lambda (y) (+ y 1)))

defines a new variable named s whose value is the function that calculates the 
successor of its argument. Here's the equivalent C#:

s という名前を持った新しい変数を定義しています与えられた引数の successsor を計算するこ
れと等価なC#のコードは次のようになります

Converter<int,ingt;> s = delegate(int y){ return y + 1; };

In both C# and Scheme, lambdas form lexical closures that capture the in-scope 
variables that are used by the newly defined function.

C# とScheme の両方ともで、lambada は新しく定義された関数によって使われる in-scope 
variables をキャプチャーするレキシカルクロージャー (lexical closure) を形成します。

Consider this C# code:

Converter<int,int> MakeAccumulator() {
  int total = 0;
  return delegate (int y) { return total += y; };
}

What I love about this approach versus defining a class is that I didn't need to go 
through the standard 20 questions one typically asks themselves when writing a new 
class. No class versus struct, interface versus abstract base, or other analysis was 
necessary. Instead I wrote a program that did what I wanted it to do. Period.

What I love about this approach versus defining a class is that
クラス定義とくらべたときにこのアプローチをわたしが好きなのは
新しいクラスを記述するときに
go through the standard 20 questions one typically asks themselves
する必要ないということです。
class と struct の違いもありませんし、
インターフェースと抽象基底の違いもありません。
さもなければ、other analysis  が必要でした。
Instead I wrote a program that did what I wanted it to do.
Period.


The difference between code and data is highly overrated. One thing all Lisp dialects 
have in common is that they build on a very simple mechanism (lists) that are used to 
build composite data structures. For example, the following Scheme expression

コードとデータとの違いとは  highly overrated です。すべての Lisp dialects が持っている
共通なのは、それらが複雑なデータ構造を構築するのに非常に単純なメカニズム(リスト) が使
われているということです。例として次の Scheme の式を考えてみましょう

(list 1 2 3 4 5)

results in a five-element list containing the integers 1 through 5. In this case, list 
is a variable that is bound to a lambda that constructs a list out of its arguments.

これは 1から 5までの整数からなる 5つの要素を持つリストです。
このケースでは、リストはその引数群からリストを構築する lambda に束縛されている変数です。

In Lisp dialects, expressions themselves can be viewed as lists. Consider this simple 
Scheme expression:

Lisp の dialects では式はそれ自身をリストとしてみることが可能です。
次のような単純な Scheme の式を考えてみましょう:

(+ 1 2 3 4 5)

When evaluated, this expression results in the number 15. To turn off evaluation and 
keep this expression as plain, uninterpreted data, you can use the quote special form 
like this

この式を評価するとその結果は数値の15となります。評価をオフにし、この式をそのまま (as 
plain) にしておくには次のようにクォート特殊フォーム (quote special form)を使うことがで
きます。

(quote (+ 1 2 3 4 5))

which is longhand for:

'(+ 1 2 3 4 5)

Both of these expressions result in a six-element list, which begins with the symbol + 
followed by the integers 1 through 5. The ability to treat code as data allows me to 
apply general query and data manipulation techniques to my programs. To go back to the 
world of interpretation, I can ask the system to evaluate a data structure as if it is 
a legal Scheme expression like this:

これらの式の両方ともがその結果は+ というシンボルで始まり、その後に整数の1から5までが続
く 6個の要素を持つリストです。コードをデータとして扱う能力はわたしが自分のプログラムに
対してgeneral query とデータ操作のテクニックを適用することを可能にします。To go back 
to the world of interpretation,次の例のようにして、わたしはシステムに対してあるデータ
構造をそれがlegal なScheme の式であるかのように評価することを依頼できます。

(eval '(+ 1 2 3 4 5) (scheme-report-environment 5))

This melding of code and data is central to all dialects of Lisp, and is fundamental 
to the way Microsoft is integrating multiple expression languages (most notably SQL) 
in future versions of the MicrosoftR .NET Framework.

このコードとデータの melding はすべての Lisp の dialects にとってに対する central であ
り、Microsoft が将来の Microsoft .NET Framework で複数の expression languages (most 
notably SQL)を統合するであろう手法の fundamental です。


Don Box is an architect on the Indigo project at Microsoft, working on next-generation 
Web service protocols and plumbing. His latest book is Essential .NET Volume 1: The 
Common Language Runtime (Addison-Wesley, 2002).

c 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement

■_

最も美しいプログラミング言語は? Part3
449 デフォルトの名無しさん [sage] 2009/10/15(木) 09:34:53 ID: Be:
    ちんこ神はなんでrubyが嫌いなんですか?
    使ってみて、あるいは調べてみてこれは駄目だということがあったら語ってみてくださいな 

450 ちんこ ◆GbXlaaQNk. [sage] 2009/10/15(木) 09:44:28 ID: Be:
    型がなくて可読性が低い。
    自分では分かってるつもりかも知れないけど、他人が読んだ時の不愉快さが異常。
    コードは他人に読ませるために書くものなので、型がない時点で論外。
    人類に残された選択肢はJavaかScalaしかない。 

451 ちんこ ◆GbXlaaQNk. [sage] 2009/10/15(木) 09:50:27 ID: Be:
    あと、世界的にユーザが少ないこともデメリットだ。
    Python VS Rubyはよく言われることだが、
    おれの中ではPythonが存在するのにRubyが存在するメリットがよく分からない。

    今、javaのエスケープ解析なるものを使ってみた。
    射精した。なんだこれ。
    エスケープ解析考えたやつは世界に千人くらい子供残せ。
    おれが許す。 

452 デフォルトの名無しさん [sage] 2009/10/15(木) 09:52:06 ID: Be:
    まつもとゆきひろに謝れ 

453 デフォルトの名無しさん [sage] 2009/10/15(木) 10:01:23 ID: Be:
    おれはJavaが嫌いなので、Javaのコードなど貼らないでください。
    そして、山に帰ってください。二度と人里には降りてこないでください。

    まぁ冗談はともかくJavaなんて仕事でもなければあんな醜いもん使いたくねーよ
    Rubyが糞なのは同意だがMatzもお前には言われたくないだろうな 

454 390 [sage] 2009/10/15(木) 10:28:10 ID: Be:
    >>447
    >(前略).... なので評価のしようがないし、「評価」というのがあやふやなので何をしようもない。

    了解しました。

    >おれはRubyが嫌いなので、Rubyのコードなど貼らないでください。

    こちらも了解。コピペは取り止めます。 

455 デフォルトの名無しさん [sage] 2009/10/15(木) 10:29:23 ID: Be:
    コンパイラをキッチリと理解していないチンコに明日はない 

456 デフォルトの名無しさん [sage] 2009/10/15(木) 10:33:17 ID: Be:
    上の書き込みとは関係ないけど
    美しさではPrologが一番。
    この言語が一番フラットに書ける。 

457 デフォルトの名無しさん [sage] 2009/10/15(木) 10:34:39 ID: Be:
    フラットとは?
    シンプルでなくてフラット? 

458 デフォルトの名無しさん [sage] 2009/10/15(木) 10:42:12 ID: Be:
    リスト以外に構造体を使わない 

459 デフォルトの名無しさん [sage] 2009/10/15(木) 10:50:05 ID: Be:
    >>450
    >型がなくて可読性が低い。

    これはJava vs. Rubyを指していると思うんだけど、だとしたら同感だね。
    Rubyでのプログラミングは楽しいけど、人の作ったRubyスクリプトの多くは読みたくネエ。

    >>451
    >あと、世界的にユーザが少ないこともデメリットだ。

    Webアプリの世界ではPHP/Ruby(Rails)がメジャーで、Phyton(Zope)は超マイナーな存在じゃないかな。
    つまり、一概にはユーザが多い/少ないは言えないのではないかと。

    >ython VS Rubyはよく言われることだが、
    >おれの中ではPythonが存在するのにRubyが存在するメリットがよく分からない。

    両者は設計思想がまるで違うよ。
    Phytonは教育用途も意識し、簡潔な言語体系(simple is best)を目標に設計された。
    だから、コードは冗長だけど、可読性が高いという利点がある。
    Rubyは、なんかPerl/Smalltalk/Clu/Lispの良いところを、もうこれでもかと積極的に取り入れた。
    だから、プログラミングは楽しいけど、可読性は低いという欠点がある。

    プログラマが目的に応じて使い分ければいいんじゃないかな。
    業務で開発するとして、両者からの選択権がもらえたなら、漏れは、まず間違いなくPhytonを選ぶけどね。 

460 デフォルトの名無しさん [sage] 2009/10/15(木) 10:54:34 ID: Be:
    >>458
    引数に構造体がこないという意味だと思うけれど、
    本体に現れる副目標は構造体そのものだけどねw
    制御構造としては確かにフラットでPythonのインデントを嘲笑いたくなるね。 

461 デフォルトの名無しさん [sage] 2009/10/15(木) 10:56:08 ID: Be:
    >>459
    ふぃとん? 

462 459 [sage] 2009/10/15(木) 11:04:19 ID: Be:
    [訂正] X: Phyton --> O:Python

    指摘アリガト >>461 

463 デフォルトの名無しさん [sage] 2009/10/15(木) 11:20:32 ID: Be:
    制御構造?構文ではなくて?
    制御構造がフラットというと逐次とジャンプしかないasmみたいなものを連想するのだが 

464 デフォルトの名無しさん [sage] 2009/10/15(木) 11:21:49 ID: Be:
    >>458

    >>390だけど、漏れも意味がよく分からんw
    もう少し具体的に書いておくれ

    少なくとも、>>402のコードの最終行では「リスト以外に構造体(attr/4)を使っている」ヨ。 

476 デフォルトの名無しさん [sage] 2009/10/15(木) 20:00:34 ID: Be:
    型がないのがそんなに可読性低いか?
    とりあえず、具体例を出してみてくれ
    俺はそんなに可読性が低いとは思えないので 

477 デフォルトの名無しさん [sage] 2009/10/15(木) 20:09:18 ID: Be:
    動的言語に型がないというのはやめてくれ。型が実行時(動的)にしかわからないだけで型はある。
    型宣言がないだけだ。 

478 デフォルトの名無しさん [sage] 2009/10/15(木) 20:21:48 ID: Be:
    ここでいう型がないとは、変数に型がないということだから、
    そういう風に解釈してくれ
    ちんこもそういう意味で言ってるし 

Ruby やら Python みたいな言語を「型がない言語」っつっちゃうのは混乱するよなあ。

■_ インデックスソート

どもです。


2009-10-14 - うっくつさん本を読む。 あるにはあるけど

http://www.kt.rim.or.jp/~kbk/zakkicho/09/zakkicho0910b.html#D20091013-2の話。

一応、インデックスソート(タグソート)というものはある。が、Javaではまったく意味がない
し、C言語でもほとんど意味がない。Fortranなら少しは意味があるかも。

要するにポインタや参照がない言語では配列とインデックスを代用に使う、というだけの話では
ないかと思う。むしろインデックスソートが必要な時点で表現力の乏しい言語なのかも。

そんなものよりsort_by@rubyを標準に入れて欲しい。

技法としては存在しているのは知っていますし、たぶんBASICあたりで自分でもやったことが あると思います。ただ技法の名前として「インデックスソート」もしくは「タグソート」と 呼ぶのはどうかなあというのが一つですね。もう一つは、Java でなんのためにその 「インデックスソート」をそんなに強く求めるのかという。 あー、Perl 4時代にも同じようなことをやったような。 @sorted_index = sort {$var[$a] <=> $var[$b] } 0 .. $#var のようなやつ。

sort_by のようなのが欲しいというのはありますね。はい。

■_ あとで

日本でも話題に上るかと思ったらかけらも気配がないなあ。 ちょっと時間切れっぽいので余裕があれば週末に改めて。



Observations from Uppsala » Joel Spolsky: You cannot program parallel in C, period
Joel Spolsky: You cannot program parallel in C, period
October 11th, 2009 | Categories: uncategorized | Tags: C/C++, Joel Spolsky, stackoverflow.com

stackoverflowlogo250hq2I found this quote in Stackoverflow Podcast #68 quite funny in 
its extreme dislike of parallel programming in C…

Thanks to the community transcripts wiki:

    Spolsky: Quite probably. I mean C is a car, it’s very dangerous – it doesn’t 
have seatbelts, but it’s very powerful because it goes very fast. In fact, I’d go so 
far as to say, unless some people are gonna punch me about this one, but you cannot 
write multi-threaded code in the C programming language. You just can’t. Although 
technically all the capabilities are there, it is beyond the capability of mortal 
humans – and I know, some of you out there are very smart and you think that you have 
the capability of writing multi-threaded code in the C programming language, because 
you’re hot shit. Well, let me tell you, it is beyond the capability of humans on this 
planet, for their brains are just not adequate to the task of writing multi-threaded 
code in most languages, least of all low-level languages like C. It’s just not gonna 
work, it’s just not gonna make you happy. So there.

The only problem with this statement is that it means we are all doomed: since all 
operating systems are written in C, and all low-level libraries, it means that we have 
no way to build the first level of abstraction needed to provide the higher-level 
primitives for C# and Python and everything else higher up the stack.

But in general, I think this is a fairly true statement for volume programming.

まあその主張もわからんでもないんだけど。

■_ 本日の巡回から

2009年10月14日

■_

・鉄道記念日
でしたよと。汽笛一声新橋を♪

・絶望先生 DJCD
14日配信の絶望放送だと10/21にDJCDが出るようなことを言ってるのだけど、 それは11/6じゃないのかなあ? 10/21 って音楽集のような気がするんだけど。 Amazon.co.jp: DJCD さよなら絶望放送 特別版 血裂撰~けっさくせん~(DVD付): ラジオ・サントラ: 音楽 Amazon.co.jp: 懺・絶望劇伴撰集: TVサントラ, 大槻ケンヂと絶望少女達, 絶望少女達, 神谷浩史, 小林ゆう: 音楽

・GNU Smalltalk
白熊さんの力を借りてやってみるか。 前に Windows で動かそうとちょっとだけいじったんだよなw もちろん GUI 部分は完全に後回しで。 PowerOfWhiteBear シロクマの力を使えば簡単にGNU Smalltalkを試すことができます。入門用にどうぞ。

■_ Javaプログラマーのための~


Don't Quit Your Day Job: Erlang for Java Programmers

Tuesday, September 08, 2009

Erlang for Java Programmers (Javaプログラマーのための Erlang)

In a previous post I declared the end of my monogamous relationship with Java. I
really played the field for a little while, but it did not take long for an
infatuation with Erlang to take hold. Clojure was the runner up, and something I
intend to explore more soon, but two languages at a time was a bit too much.

直前のポストでわたしは end of my monogamous relationship with Java (自分が Java だけ使
うことの終わり) を宣言しました。わたしはその分野で実際に play したのはちょっとの期間だ
ったのですが、Erlang への興味を長いこと逸らせるようなことはありませんでした。Clojure 
が二番目の候補にあってこれはすぐに調査しようと思っていたものなのですが、しかし二つの言
語を一度にやるのは多すぎたのです。

Erlang is a functional language, but as a Java developer it did not scare me off.
While the syntax is a little out there, the concepts map pretty neatly:

Erlang は関数型言語ですが、Java デベロッパーのわたしを scare しませんでした。
構文は少々 out there でしたが、そのコンセプトはとても素晴らしいものです:

Immutability (不変性)

I have always erred on the naughty side with Java when it comes to the use of objects.
I tend to have fairly struct like domain objects with getters and setters, and leave
the business logic to manager type classes. I was never comfortable tying business
logic to something I read out of the db and pass around and which may have different
requirements in different apps. So the switch to a functional language was pretty easy,
the main difference is instead of using setters, updating an object is a bit more like
a clone/set combo. It feels a little like wasting memory, but you get over it.

わたしは、(Javaで)オブジェクトを使おうとしたときにはいつもJava の naughty side に直面
していました。ゲッター (getter) と セッター (setter) を持ったドメインオブジェクトのよ
うなfairly struct を使う傾向があって、ビジネスロジックをマネージャータイプクラス 
(manager type classes) に置いていました。自分がdbから読み出して、順に処理していき違う
アプリにおいては異なる要求をする可能性があるなにかをビジネスロジックと束ねる (tying) 
ことにわたしは満足しませんでしたですから、関数型言語に切り替えるのはとても簡単なことで、
主な違いはオブジェクトのアップデートをセッターを使って行うのではなくclone/set の組み合
わせのようなもので行う点です。これはメモリの浪費をしているのではないかとも感じるかもし
れませんがそれ以上のものが手に入れられます。


Conditionals vs Pattern Matching (条件式とパターンマッチング)

In Java my methods tend to end up littered with if/then/else tests on the state of 
various objects. In Erlang the case statement is occasionally used to make sure a 
function did not return an error, but not much else. Instead, Erlang takes the idea of 
an overloaded method to a whole new level. Pattern matching is pretty easy to 
understand, and impossibly powerful. Each function input can be used to direct flow in 
to this or another version of the function. This sounds like it might lead to a bunch 
of copy paste, but instead it results in a few succinct versions of a function that 
are far easier to reason about.

Java ではわたしのメソッドはif/then/else テストが様々なオブジェクトの状態に対して撒き散
らされたものとなる傾向がありました。Erlang の case 文はエラーを返さない関数を使うこと
もありましたがそれほど多くはありません。代わりに Erlang ではオーバーロードされたメソッ
ドの考えを新しいレベルに引き上げました。パターンマッチング (pattern matching) はとても
理解しやすい上にありえそうもないほど強力なものです。各関数に対する入力はその関数もしく
は関数のもう一つのバージョンに対するdirect flow として使うことができます。これはコピペ
の塊を招きかねないように聞こえるかもしれませんがそうはならずに少数の、何故かということ
がわかりやすい succinct versions of a functionの結果となります。

Objects are Processes (オブジェクトはプロセスである)

One of the main reasons I picked Erlang over a more traditional functional language
like Haskell is the idea of processes. I didn't quite understand how anything could
happen in a side effect free, stateless world, but Erlang keeps state all neatly
wrapped up inside processes. Erlang processes are instantiated functions. You heard
that right, unlike in Java, where an object is an instantiated class, in Erlang you
run a function in a recursive loop forever. Weird right? Well the only real trick to
this is now that the loop is going infinitely, passing its own state back in to itself,
it needs a way to talk to the outside world. This is accomplished through messages. By
putting a receive block inside the function, it will sleep until another process sends
it a message. It will then wake, handle the message, loop and go back to sleep.

わたしが Haskellのような、より伝統的な関数型言語ではなく Erlang を取り上げた主な理由の
一つが、そのプロセスの考え方です。副作用をなくし、状態のない世界にすることで何がどのよ
うにできるのかわたしはよくわかりませんが、Erlang は wrapped up されたプロセスの内側に
状態をすべて neatly に保持します。Erlang のプロセスはインスタンス化された関数です。
You heard that right,
オブジェクトがインスタンス化されたクラスであるようなJavaとは違って
Erlang では関数を永遠に再帰ループで実行します。
Weird right?
これを行うためのトリックとして今きちんとできるのはループを無限にして自分の状態を自分自
身に送り返すことで、これ外側の世界に対して tolk するために必要な方法なのです。これはメ
ッセージを使って実現されています。receive block を関数の内部に putting することにより
そのプロセスは別のプロセスがメッセージを送ってくるまでスリープします。そのメッセージに
よってプロセスが復帰し、送られたメッセージを処理してからまたスリープに戻ります。

There are of course many more concepts to consider, and I did not touch on OTP, but
these were the main hurdles I encountered when reading my first Erlang book. I think
Joe Armstrong's book is fantastic, and the new O'Reilly book is solid as well.

もちろん、注目すべきコンセプトはまだたくさんありますし、OTP にもまだ言及していません。
けれどもそれらはわたしが最初の Erlang 本を読んだときに遭遇した main hurdles  だったの
です。わたしは Joe Armstrong の本はすばらしい出来だと思いますし新しく出るオライリーの
本も同様のことでしょう。

There is a new online tutorial for beginners:
ビギナー向けの新しいオンラインチュートリアル
http://learnyousomeerlang.com/

For a solid 6 part intro to OTP check out Mitchell Hashimoto's blog:
http://spawnlink.com/articles/an-introduction-to-gen_server-erlybank/

A good searchable API site (though seemingly lacking the bifs):
http://erlapi.prepor.ru/docs/

If you are in Chicago, be sure to check out our user group:
http://groups.google.com/group/ceug?hl=en

And if you are interested, my first Erlang project:
http://github.com/chrisduesing/simmoa/tree/master

■_ まだやってるよ

馬構造体w

インデックスソート -OKWave
回答

//サンプルデータ
int[] a = {24,16,12,11,18,16};
//----- ここから本体 -----
//並べ替え用TreeMap
TreeMap<Integer, Integer> t = new TreeMap<Integer, Integer>();
//値と位置(インデックス)を仕込む
for ( int i = 0 ; i < a.length ; i++ ) t.put(a[i],i);
//インデックス用の配列(★結果の配列)
int[] r = new int[a.length];
int i = 0;
//TreeMapから値順に位置(インデックス)を受け取る
for ( Integer x : t.keySet() ) r[i++] = t.get(x);
//----- ここまで本体 -----

独自にクラスを作るまでの必要は無いと思うんですけどね。
この回答への補足
インデックスソート対象の配列がユニークで無い場合、
Mapを使うと所望の結果は得られないでしょう。

そういう意味で、当初例示した配列の中に 16 を2つ入れているんですが...

実行して見られましたか?
確かに重複を見落としてました。そういう場合は下記で如何でしょう。
//サンプル配列
int[] a = {24,16,12,11,18,16};
//---- ここから本体 ----
TreeMap<Integer, List<Integer>> t = new TreeMap<Integer, List<Integer>>();
for ( int i = 0 ; i < a.length ; i++ ) {
  List<Integer> v = t.get(a[i]);
  if ( v == null ) v = new ArrayList<Integer>();
  v.add(i);
  t.put(a[i],v);
}
//結果の配列
int[] r = new int[a.length];
int i = 0;
for ( Integer x : t.keySet() ) {
  for ( Integer y : t.get(x) ) r[i++] = y;
}
//---- ここまで本体 ----
これは、あまりにも。言いにくいのですが、技巧的な上に実行効率もよくありません。

私が、N0.1の回答のところに書いたプログラムよりも、
何が優れていると思われているのでしょうか?

Comparable でがんばればうまくいきそうな気がするけど気のせいかなあ。 Javaはあまりつかっとらんから(苦笑)

■_ なるほど


Route 477 - (Ruby 1.9の)Hashが順序を保持するのは自然か , GNU Smalltalkなら、コマンドラインでSmalltalkを試せる

(Ruby 1.9の)Hashが順序を保持するのは自然か

という話がありましたが:

    * ときどきの雑記帖 i戦士篇 2009年10月(中旬)

Rubyは、ArrayがStackやQueueを含んでいるように、大クラス主義の言語です。 Hashが順序を保
持するようになったというよりは、 「HashがOrderedHashを含むようになった」と考えると自然
かなぁと思います。

そういう考え方もありですね。うん。納得納得。

とはいえ、Perlでセキュリティ上の理由でどうのってのがちょっと引っかかります。 時間があったら調べてみよう。

■_ 本日の巡回から

2009年10月13日

■_

・今日読み終わった新書は正直はずれだった。 ので何も書かないw

そういや一昨日昨日と紹介したのとは別に、また新書(出版社忘れた)で 生命保険がどうのってのが出てたような。

某所。

並列プログラミングの効率的なデバッグを実現する「Parallel Inspector」(1/3):CodeZine

(略)

 また、よしんば新人であっても、マルチスレッドの注意点さえ知っていれば、このようなコー
ドは避けます。実際、私が最初にマルチスレッドなプログラムを作ったときは、このような、ロ
ーカル変数に保存した変数を操作するようなことは避けました。新人が作ったことを想定したな
ど、他人を馬鹿にする言動です。

 情報処理技術者であるなら、情報を軽々しく扱うのはやめてください。発信する/発信した情
報に、責任を持ってください。

さてさて。 新作も出てるようだけど、この筆者さんは(以下略

■_ うは

すげーすれ違い

インデックスソート -OKWave
インデックスソート

Javaに、インデックスソートを実行するライブラリーはありますか?

例えば、
 {24,16,12,11,18,16}
の入力に対して、昇順ソートしたときのインデックス位置
 {3,2,1,5,4,0}
を出力してくれるようなライブラリを探しています。

どなたか、ご存じないでしょうか?
以上、よろしくお願いいたします。
回答
TreeMap じゃダメ?
http://java.sun.com/javase/ja/6/docs/ja/api/​

この回答への補足
とりあえず、ネイティブなライブラリが見つからなかったので、
自分で書いてみましたが、本当に無いのでしょうか?

こういう基本的なアルゴリズムに関するようなクラスを
自力で実装する必要があるというのも気色悪いですよね...


ネイティブなライブラリの存在をご存知の方がおられましたらご教授ください。


import java.util.Arrays;

/**
 * 配列をインデックスソートするためのクラスです。
 */
public class ArrayIndexSorter {

(略)

}

この回答へのお礼
Number インターフェースが Comparable インターフェースを extends してなかったので、補足
のように IndexedNumber クラスを書く必要があるかと思いましたが、Numberの具象クラスで
Comparableはimplementsされてました。この不自然な仕様はなぜでしょう?

というわけで、ある程度簡略化はされましたが、自力でこんなことを書く必要があるかどうかは、
未だに疑問です。

import java.util.Arrays;

public class ArrayIndexSorter {

    public static Integer[] toObject(int[] a) {
        Integer[] v = new Integer[a.length];
        for (int i=0, n=a.length; i<n; i++) {
            v[i] = a[i];
        }
        return v;
    }

(略)

    private static class IndexedObject implements Comparable<IndexedObject> {
        private int index;
        private Object object;
        public IndexedObject(int index, Object object) {
            this.index = index;
            this.object = object;
        }
        public int getIndex() {
            return index;
        }
        @SuppressWarnings("unchecked")
            public int compareTo(IndexedObject o) {
                return ((Comparable<Object>)object).compareTo(o.object);
            }
    }
}
回答
質問への直接の回答ではなく、むしろ議論の範疇になりそうなので、役に立たな
いと思ったら無視してください。

私はインデックスソートなる機能を持つネイティブクラスがあるかどうか知りま
せん。ただ、

> こういう基本的なアルゴリズムに関するようなクラスを
> 自力で実装する必要があるというのも気色悪いですよね...

この考え方に興味を持ちました。私は学生時代も含めると10年以上、プログラミングを扱う世
界にいますが、インデックスソート、というものを扱ったことも、それが必要とされる場面も知
らないのです。もちろんいろいろな業界・分野がありますし、私の知識や経験が万全だとはまっ
たく思っていないので、ご質問に対して否定的な考えは持っていません。ただ、お考えになって
いる機能について、必要な人がいるかもしれないなとは思うものの、基本的な機能だから標準と
して実装されるべきだ、とまでは思えないのです。

試しに「インデックスソート」という単語でgoogleで検索をかけてみましたが、この質問も含め
600件弱しか引っかからず、有効でない結果を差し引いたらその半分もなさそうです。それらを
読む限りでは主にデータベース操作に関連して使われるアルゴリズムのようですが、それより検
索結果の量が気になります。この「インデックスソート」という呼び名自体は「基本的」と呼べ
るくらいメジャーなものなのでしょうか? もし別の呼び名があるなら、それとjavaという検索
ワードで探してみてはいかがでしょうか。

以上、少しでも参考になればと思います。
この回答への補足
>インデックスソート、というものを扱ったことも、
>それが必要とされる場面も知らないのです。

例えば、

  MATLAB Function Reference
  sort
  ​http://www.mathworks.com/access/helpdesk_archive_ja_JP/r13/help/too...​
  
  [B,INDEX] = sort(A)

こんな感じです。
戻り値が複数ある時点で、多くの人はMATLABの関数に違和感を感じるかもしれませんが、構造体
(Javaのクラス)を定義してそのポインタ(オブジェクト)を1つ返すのと全く同等なことです。
MATLABには、実用的なライブラリが沢山存在するので、独自にクラスを設計する場合にも、非常
に有益だと思われます。

具体的な使用例としては、
 競馬のあるレースの3番人気の馬の馬体重は
 何キログラムですか?
という解を求めるプログラミングを書くとしましょう。

こんな場合に、
 オッズ配列だけをインデックスソートして、
 3番人気の馬を特定して、その馬体重を取り出す。
といった使い方をするということです。

それならば、馬構造体(オブジェクト)を馬体重をキーにしてソートすれば良いのではと思われ
るかもしれませんが、馬構造体のサイズが非常に大きいときに、最終的に必要とされないデータ
を含めてソートすることはヒープの無駄といえます。また、この競馬の例では、馬番(馬名)と
いうユニークなキーがあるのでわざわざ新たにインデックスを生成してソートすることに無駄が
あるのではと思われるかもしれませんが、この方法の利点はユニークなキーを持っていないデー
タ構造でも、その中身を一切気にせずに一意な方法でソート出来るということです。

ここまでの話では、いかにもオブジェクト指向的でないと思われるかもしれませんが、その観点
から言えば、
 オブジェクト自体を並べ替えないで、ある項目でソートした
 任意番目のオブジェクトを取り出したい
という場合にインデックスソートが威力を発揮します。日常的に、こういう要求もあるのではな
いでしょうか?


>この「インデックスソート」という呼び名自体は「基本的」と
>呼べるくらいメジャーなものなのでしょうか?

日常的な用語の名詞結合なので、なかなか目的の内容が探しにくくなっています。タグソートと
も言いますが、こちらもGUIのタグばかりがヒットして大変です。mooter検索が登場したとき
には検索エンジンの世界も様変わりするかと思われましたが、全く羊頭狗肉で使い物にならない
し。

Copyright © OKWave. All rights reserved.Powered by OKWave

要するに「オレ様用語」? >インデックスソート (タグソート) もちろんこの種の手法は以前からあったのは確かだけど、 クラスライブラリで用意すべきものかというと… あとJavaだから、 馬構造体のサイズが非常に大きいときに、最終的に必要とされないデータを含めてソートすることはヒープの無駄といえます。 は違うような。ソートの途中で要素の交換が起きてもJavaのオブジェクトの管理方法を 考えればそのでかい馬構造体のデータそのものがあっち行ったりこっち行ったりはしないですよね。 「ラベル」が入れ替わるだけ。

■_ なぜHaskellをつかうのか


Why we use Haskell - lablog

Why we use Haskell

haskell September 22, 2009 15:42

As a newly started company, we have a lot of technical decisions to make. One of the
important ones is the choice of a programming language. Since we're building a web
application, this goes for both the client (i.e. the web browser) and the server.

newly started companyとして決定すべき technical decisions がわたしたちにはありました。
重要なものの一つがプログラミング言語の選択でした。わたしたちは web アプリケーションを
構築していたので選択するプログラミング言語はクライアント (webブラウザー) とサーバーの
両方になりました。

On the client, there wasn't much discussion. Javascript is the only viable choice,
unless you want to use Flash or similar plugin-based models. But on the server, we had
more freedom. Popular choices for web applications are dynamically typed languages
like Ruby, Python and PHP, and statically typed languages like Java and C#.

クライアント側では議論はそれほどありませんでした。Flash や同様のプラグインベースモデル
のものを使おうとしない限りJavascript は唯一の viable choice でありました。しかしサーバ
ー側ではわたしたちはより多くの自由があったのです。webアプリケーション向けの Popular
choices には、Ruby やPython、PHP のような動的型付け言語とJavaやC#のような静的型付け言
語がありました。

However, there was another option. Two of us (me and Sebas) are enrolled in the
Software Technology master program at Utrecht University, where we often use the
programming language Haskell. Haskell is a functional programming language, which
means that a program is composed of expressions instead of statements, as is the case
in an imperative programming language.

しかし、もう一つ別の選択肢があったのです。わたしたちのうち二人 (わたしと Sebas)は 
Utrecht University でSoftware Technology master program に enroll していました。そこで
はしばしばHaskellというプログラミング言語を使っています。Haskell は関数型プログラミン
グ言語で、命令型言語での文 (statements) の代わりに式 (expressions) を組み合わせてプロ
グラムを組み立てます。

As you might have guessed from the title of this post, we decided to use Haskell for
our server side programming. What are the features that made us choose Haskell?

このポストのタイトルを見てあなたも薄々感づいているでしょうが、わたしたちは自分たちのサ
ーバーサイドプログラミングに Haskell を使うことを決めたのです。さて、わたしたちに 
Haskell を選択させた機能とはなんでしょうか?

First, we like the functional programming model. Modeling programs based on what
values are, instead of what bits to move where, is much closer to the way we think. We
write down what we mean, and let the compiler figure out how to calculate it. This
also leads to shorter code: Haskell is often surprisingly concise.

第一に、わたしたちは関数型プログラミングモデルを好んでいたと言うことがあります。ビット
をどこかに動かすということではなく、値 (values) に基づいてプログラムをモデリングするこ
とはわたしたちの思考法により近いものです。わたしたちはわたしたちの意図するところを書き
下し (We write down what we mean)、コンパイラーにそれをどのように計算するのかを figure
out させます。このことはコードをより短くすることにも繋がりました。Haskell はしばしば
驚くほど簡潔なのです。

Another important consideration is the strong type system that Haskell has. It has
powerful features that prevent you from running incorrect programs, while not getting
in the way, as is often the case in traditional statically typed languages like Java
or C#. This is due to the fact that Haskell has type inference: it can deduce the
types of variables and functions without programmer specifications.

もう一つ重要な consideration は Haskell が持つ強い型システムです、これはJava やC# のよ
うな伝統的な静的型付け言語においてしばしば見られるような while not getting in the way 
となったときに正しくないプログラムを実行することを防ぐ強力な機能です。これは Haskell 
が型 inference (type inference) を持つことによるもので、プログラマーの指定がなくても変
数や関数の型を deduce することが可能です。

Something that sets Haskell apart from almost all other programming languages, is its
purity: an expression in Haskell is not allowed to do anything on evaluation other
than return its value (functions are not allowed to have side-effects). This has many
implications. For example, data is immutable: if you modify a list, for example, you
create a new copy (although smart compilers share duplicate parts for efficiency).
This means that you never have to think about other parts of the code changing your
data: you can always reason locally. Another implication is that your language can be
lazy (and in fact, Haskell is). This means that expressions are not evaluated unless
their results are needed. This can lead to performance improvements, and allows you to
use infinite data structures.

Haskell とそれ以外のほぼすべてのプログラミング言語とをわけるもの、それは Haskell の
purity (純粋性)です:Haskell における式は評価の際にその値を返すこと以外のことを行うこと
が許されません(関数が副作用を持つことが許されない)。これは多くの implication を持って
います:たとえばデータは immutable (変更不可能)であり、あなたがリストを変更したとする
と、新しいコピーを作ることになります(とはいえ賢いコンパイラーであれば効率を上げるため
に重複した部分を共有させるでしょう)。データが immutable であるとはコードのほかの部分が
自分のデータを変更してしまうことをあなたは考慮する必要がなく、常に局所的に判断できると
いうことを意味します。もうひとつの implication はあなたの使う言語が lazy になれるかも
しれない(事実、Haskellはそうです)ということです。lazy とはその結果が必要とされるまでは
式が評価されることがないということです。これはパフォーマンスの改良に繋がる可能性があり、
無限を含んだデータ構造 (infinite data strecture) を使うことを可能にします。

If we disallow side effects, how do we perform I/O, for example? Haskell uses an
abstraction called a monad to do this. A monad shows up in the type, indicating that
we are performing side effects. The I/O monad allows us to force an ordering on
actions, allowing us to safely perform the actions in a lazy setting. We can also use
monads to keep state, have mutable variables, and many other things.

副作用を禁止したとすると、たとえば入出力(I/O)の実行はどのように行うのでしょうか?
Haskell ではモナドと呼ばれる abstraction を使ってこれを行います。モナドは型に現れるも
ので、ユーザーが副作用を起こすことを示しますI/O モナドはアクションにおける順序をユーザ
ーが強制することを許可し、lazy setting におけるアクションを安全に実行することを可能に
します。ユーザーはモナドを状態を保持するため (use monads to keep state)や変更可能な変
数 (mutable variables) を持ったりその他諸々(many other things)  のために使うこともでき
ます。

Purity also makes concurrency a lot easier: if data is immutable, there is no risk in
sharing it between different threads. If you need to share mutable data between
different threads, Haskell offers a few ways of dealing with this, the most
interesting of which is software transactional memory (STM), a lock-free way of
building composable atomic actions.

purity は concurrency も大幅に簡単化します:データが変更不可 (immutable) であれば異なる
スレッド間でのデータの共有をリスクなしに行えます。異なるスレッド間で変更可能 (mutable)
なデータを共有する必要がある場合にも、幾通りかのそういったデータを扱うための手段を
Haskell は offer しています。その中で最も興味深いのは software transactional memory
(STM) で、これはcomposable な atomic actions を構築する lock-free な方法です。

Since Haskell is a functional language, functions are first class: you can create them
on the fly, pass them as arguments, return them as results, store them in a data
structure, etc. This allows you to easily create powerful abstractions. For example,
one often-used Haskell function is map. It takes an argument that turns a value of
type a into a value of type b, and uses this to transform a list of a's into a list of
b's by applying it to each element. This function abstracts away looping over a list.
In a similar way we can create our own abstractions. This often leads to the creation
of lightweight EDSLs (embedded domain specific languages), especially since Haskell
allows the creation of (infix) operators as well.

Haskell は関数型言語なので関数は first class であり、関数を on the fly (その場) で作る
ことができますし、引数として渡すこともできます。また、関数の結果として返すことも、ある
データ構造に格納すると言った諸々のことも可能です。Haskell で頻繁に使われる関数に map
というものがありますが、これは型 a の値を 型 bの値へと変換する引数を一つ取るもので、a
のリストを b のリストへ変形 (transform) するためにその引数をリストの要素ごとに適用しま
す。この関数 (map) は、リストに対する looping over の方法を抽象化します。同様の方法を
使って、ユーザーは自分たちの abstractions を生成することができます。特に Haskell が中
値演算子も作り出すことができることから、これはしばしば lightweight EDSL (EDSL →
embedded domain specific languages組み込みのドメイン特化言語) を作ることにつながります

The combination of conciseness, locality of data, strong types and explicit
side-effects has a very important consequence: it makes refactoring easy and risk-free.
You can change your code, and if it still type checks, you can often be sure that it
still works. Combined with the power of abstraction this means we can quickly develop
programs that can be easily understood and modified by others.

combination of conciseness やデータの局所性、強い型付け、明確な形の副作用は非常に重要
な conseqence を持っています:リファクタリングを容易にし、リスクから解放します。コード
の変更が可能で、型チェックを行いつづけていればほとんどの場合に変更後も動作することが保
証されます。Combined with the power of abstraction this  はわたしたちがすばやくプログ
ラムを開発することができるということです

Finally, another positive aspect of Haskell is its community. There is an active blog
community, a large and helpful IRC channel (#haskell) and an online package repository.
There is an industrial strength compiler, a dependency tracking package manager and
built-in tools like code coverage.

最後の、もう一つの Haskellに関する positive aspect はそのコミュニティです。アクティブ
なblogコミュニティ、大規模かつ親切な IRCチャネル (#haskell)、オンラインパッケージリポ
ジトリがあります。industrial strength な コンパイラーがあり、dependency tracking 
package manager や code coverage のような built-in tools もあります。

Of course, there are also a few risks involved in choosing a language like Haskell.
Since it doesn't have a user base as large as some other languages, there are less
libraries available. This is alleviated in part by a strong C interface that Haskell
provides. Because of laziness, performance problems can be harder to diagnose and fix.
And of course, there are less programmers who have experience with Haskell, so finding
people to help you can be harder.

もちろん、Haskellのような言語を選択するのにいくつかのリスクも同時にあります。他の言語
と比べたときにユーザーベースがそれほど大きくはないので使えるライブラリの数も少ないので
す。この点は Haskell が提供している強力な Cインターフェースによって軽減 (alleviated) 
されています。遅延評価を行っているので、パフォーマンスに関する問題は調べたり修正するこ
とが難しくなる可能性があります。そしてもちろん、Haskell について経験のあるプログラマー
は他の言語に比べると少数ですからあなたを助けてくれる人物を見つけ出すのは困難なことかも
しれません。

But all in all, we feel that the benefits Haskell can bring us outweigh the risks. And
most of all, Haskell makes programming fun!

しかし全体としてわたしたちは Haskell が bring us outweigh the risks できることの
benefits を感じています。
And most of all, Haskell はプログラミングを楽しくしてくれるのです!

good luck, guys! :)

Jordan
September 23, 2009 1:07

■_ 本日の巡回から

2009年10月12日

■_

・生命保険の罠
えっと、一部で誤解されてる気配があるんですが、生命保険が不必要というのではなくて、 どういう契約にするのがいいのか考えましょうということです。 たとえば貯蓄型といわれるような生命保険があるんですけど、本当にそれでいいのかとか。

・ラベル
ついったで、プログラミング言語での最初の大きな飛躍は「ラベル」の発明にあるんじゃないか とかつぶやいていた人が。んで、自分は変数にあたるものを番地ではなく名前(ラベル)で 扱えるようなことがポイントだろうと思ってたのですが、その人が言うには 分岐命令(や手続き、関数)のラベルに注目していたのですね。 ハンドアセンブル(や直接機械語で記述)のときに手計算しなければならなかったのが 自動化できるようになったとか。 記憶だけで書いているのではなはだまとまりにかけますが、まあそういうことで。

付け加えておくと、「サブルーチン」の発明(or 発見)のほうが重要じゃないかなあと いう気がしますが、まあそれもそれ。

■_ ハッシュ(連想配列)の性質



Perlについての質問箱 41箱目 
796 デフォルトの名無しさん [] 2009/10/11(日) 23:57:04 ID: Be:
    連想配列について質問です。
    たとえばkeysでとりだしたハッシュの順序は一定ではないそうですが、
    何回もperl *.plで実行しても同じ順序でキーが取り出されます。
    ハッシュの順序はOS依存なんですか?それともperlのバージョン依存なんですか?
    同じ環境のもとで同じプログラムにした場合はkeysでとりだされるキーも同じ順序になるのですか? 

797 デフォルトの名無しさん [sage] 2009/10/12(月) 00:12:59 ID: Be:
    ハッシュ依存じゃないの? 

798 デフォルトの名無しさん [sage] 2009/10/12(月) 00:17:12 ID: Be:
    >一定ではないそうですが

    これは誰から聞いたの? 

799 デフォルトの名無しさん [sage] 2009/10/12(月) 00:35:34 ID: Be:
    別に乱数は使ってないよ 

800 デフォルトの名無しさん [sage] 2009/10/12(月) 00:51:45 ID: Be:
    一定ではないというのは環境によるんだろうが
    ハッシュに順序の保障を求めるべきではないとは思う
    順序の保障が欲しければリストを利用/併用すべきだろうな 

801 デフォルトの名無しさん [sage] 2009/10/12(月) 01:24:16 ID: Be:
    perlのバージョン依存。

    perl5.10.0のperldoc -f keysでは、
    ===========
    超訳。
    perl5.8.1までは、セキュリティー上の理由から、
    keysはプログラムを実行する度に違う順序で取り出されてた。
    (順番自体は見た目上ランダムに決定されてる。ただし、
    同一プロセス内で、hashに変更が無いならeach, valuesでも
    keysと同じ順である事は保証される。)
    ===========
    暗に「より新しいperlではkeysはhashに変更が無いなら
    プログラムを複数回実行しても同じ順に取り出される。」
    と言ってはいるが、それをkeysのperldocでは明文化は
    してない。
    ここまで調べて面倒になった。

    俺も>>800氏と同じ見解だし。

802 デフォルトの名無しさん [sage] 2009/10/12(月) 01:32:14 ID: Be:
    うそっ
    わざわざランダムにしてたんだ

    for (keys
    っていう処理はするけど、大抵はsortとセットだから気にしたこともなかった 

803 デフォルトの名無しさん [sage] 2009/10/12(月) 02:52:49 ID: Be:
    >>801
    逆だ。5.8.0までは特定の順序で取り出されていたのを、
    5.8.1以降で変わるようにしたんだ。

    http://perldoc.perl.org/functions/keys.html
    > Since Perl 5.8.1 the ordering is different even between different runs of Perl
    > for security reasons (see "Algorithmic Complexity Attacks" in perlsec).

    http://perldoc.perl.org/perlsec.html#Algorithmic-Complexity-Attacks
    http://perldoc.jp/docs/perl/5.10.0/perlsec.pod 

804 デフォルトの名無しさん [sage] 2009/10/12(月) 03:59:09 ID: Be:
    セキュリティが理由なら、止めてしまう訳ないしな 

Ruby のハッシュを orderd hash にするときも確か書いてたけど、 ハッシュテーブルから要素を列挙するときに放り込んだ順に取り出せると考えるのは自然なんかなあ。 んーむ。実装を先に知ったせいか、ランダム(のようにに見える)で当然だと納得してたんだけど。 んで、同じものを何度か列挙するとそれぞれは同じ順序であると。 それが現状のPerl ではセキュリティ上の理由で変わっていると。

■_ プログラミングスタイル

ねくすとじぇねれーしょんとか言われてもねえ。


Go Ahead: Next Generation Java Programming Style | Code Monkeyism

by Stephan Schmidt
Written on August 10, 2009 by Stephan Schmidt

Go Ahead: Next Generation Java Programming Style
次世代の Javaプログラミングスタイル

Many companies and developers move away from Java to new languages: Ruby, Python, 
Groovy, Erlang, Scala. You might be trapped with Java.

多くの企業と開発者が JavaからRuby や Python、Groovy、Erlang、Scala といった新しい言語
へと移行しています。あなたは Java に引っかかっているかもしれませんが。

Even if you've trapped, you can change your programming style and reap some of the 
benefits of those new languages. In the last 15 years Java programming style has 
changed significantly:

仮にあなたが Java に囚われたままであったとしても、あなたは自分のプログラミングスタイル
を変えることができますし先に挙げたような新しい言語の benefits の一部を享受することがで
きます。過去十五年の間、Java のプログラミングスタイルは大きく変わってきたのです:

   1. Final is your new love: More and more Java developers in the teams I've worked 
      with, started to use final. Making variables final prevents changing those values. 
      Most often, if you reasign a value, it's a bug or you should use a new variable. 
      Final prevents bugs and makes code easier to read and understand. Make everything 
      immutable.

      final はあなたの新しい愛: わたしが働いていたチームのJava開発者たちはだんだんと
      finalを使い始めるようになりました。変数を final にすることで値の変更をできない
      ようになります。ほとんどの場合、ある値を再代入するということはバグであるか、
      新しい変数を使うべき局面であるかのいずれかです。final はバグの混入を防ぎ、
      コードを平易で読みやすく理解できるものにします。すべてを immutable (変更不能な
      もの)にしましょう。

      final Foo bar = new Foo();

      I've written more about this topic in “All variables in Java must be final”.

      このトピックについては、“All variables in Java must be final”
      でさらに詳しく書きました。


   2. No setters. Many Java developers automatically - sometimes with the evil help of an
      IDE - write setters for all fields in their classes. You should not use setters. 
      Think about each setter you want to write, are they really necessary for your fields? 
      Better create new copies of your objects if values change. And try to write code 
      without getters either. Tell, don't ask tells you more about the concept.

      セッターを作らない。多くの Java開発者が自動的に、ときに IDEのジャアクな力を借りつつ
      クラスのフィールドのセッターを記述しています。セッターは使うべきではありません。
      あなたが記述したいと思ったセッターの一つ一つについて、それが本当にそのフィールドに
      必要なものなのかを良く考えてみてください。もし値を変更するのなら、オブジェクトの
      新しいコピーを作るのがより良いやり方です。そして、ゲッターも作らずにコードを書くこ
      とに挑戦してみてください。Tell, don't ask tells you more about the concept.

   3. Do not use loops for list operations. Learning from functional languages, looping
      isn't the best way to work on collections. Suppose we want to filter a list of
      persons to those who can drink beer.  The loop versions looks like:

      リスト操作でループを使わないこと。ループがコレクションに対する操作としてはベスト
      のものではないということを関数型言語から学びました。人物リストからお酒が飲める人を
      フィルタリングしたいとしましょう。ループを使ったバージョンはこんな感じになります:

      List<Person> beerDrinkers = new ArrayList<Person>();
      for (Person p: persons) {
          if (p.getAge() > 16) {
      	    beerDrinkers.add(p);
          }
      }

      This can - even in Java - be rewritten to a more a functional programming style. 
      For example using Google collections filter:

      これはJavaでさえ、より関数型のプログラミングスタイルで書き直すことができます。
      例として、Google collections の filterを使ってみましょう:

      Predicate<HasAge> canDrinkBeer = new Predicate<HasAge>() {
          public boolean apply(HasAge hasAge) {
              return hasAge.getAge() > 16;
          }
      };

      List<Person> beerDrinkers = filter(persons, canDrinkBeer);

      As remarked by Dave Jarvis, I should have dropped the getter, and he's right ;-)

      Dave Jarvis が指摘したように、getter を取り除くべきですね。 彼は正しい ;-)

      Predicate canDrinkBeer = new Predicate() {
           public boolean apply(HasAge hasAge) {
               return hasAge.isOlderThan( 16 );
          }
      };

      which would lead to better code down the road:

      Predicate canDrinkBeer = new Predicate() {
          public boolean apply( HasAge hasAge, HasAge otherAge ) {
              return hasAge.isOlderThan( otherAge );
          }
      }

      The predicate version is slightly larger, but consists of two parts. Each one is 
      easier to understand. While the loop version gets unreadable fast with new 
      requirements, the functional version can easily be combined,

      predicate version は大きくはなっていますが二つのパーツに分かれていて、それぞれは
      理解するのが簡単です。ループバージョンは new requirements つきでさっと読むことが
      できないのに対して、関数型バージョンは組み合わせるのも簡単です。

      List beerDrinkers = filter(filter(persons, canDrinkBeer), isMale);

      More on this at the Metaphysical Developer.

   4. Use one liners: Write concise code. Java is a noisy language. But don't make it 
      noiser as it needs to be. Instead of

      ワンライナーを使う: 簡潔なコードを書きましょう。Javaは noisy な言語です。それでも
      必要以上に noiser にしないようにしましょう。

      public int add(int a, int b)
      {
        int result = a + b;
        return result;
      }

      write

      とするのではなく次のように書きましょう

      public int add(int a, int b) { return a + b; }

      IDEA and possibly other IDEs can keep oneliners formatted as oneliners, if you 
      tell them so.

      IDEA やおそらくほかの IDE も、指示しておけばワンライナーをワンライナーとして
      整形しておけるでしょう

   5. Use many, many objects with many interfaces. Domain driven design currently makes
      a big splash. A class should be splitted into many roles, implementing many 
      interfaces. This way the class is reusable.

      多くのインターフェスと共にたくさんのオブジェクトを使う。
      Domain driven design (ドメイン駆動設計) currently makes a big splash.
      一つのクラスは多くの role に分割して多くのインターフェースを実装すべきです。
      このようなやり方はクラスを再利用可能にします。

      public class Person implements Nameable, Hireable, LivesAt {
         ...
      }

      public interface Nameable {
        String getName();
      }

      can work on more objects. Another benefit is lower coupling.
      Methods should be written to only work on roles, not classes. This way methods 

      メソッドはrolesに対してのみ動作するように書くべきであり、クラスに対してで
      はありません。このやり方によるメソッドはより多くのオブジェクトに対して動作
      します。もう一つの利益は lower coupling だということです。

      public void print(Nameable name) {
        System.out.println(name.getName());
      }

      I've written more about that in “Never, never, never use String in Java ”.

      “Never, never, never use String in Java ” により詳しいことを書きました。

   6. Use Erlang-Style Concurrency. The Java concurrency primitives like locks and 
      synchronized have been proven to be too low level and often to hard to use. There
      are better ways to write concurrent code. Erlang Style concurrency is one of them
      - in Java there are many ways to achive this in Java - I've written about them here.
      Newer ones are Akka and Actorom. You can also use Join/Fork or the myriad of data
      structures in java.util.concurrent.

      Erlangスタイルの並列性を使う。Java の  concurrency primitives  は低レベルすぎて使い
      辛いことがしばしばあります。concurrent なコードを書くためのよりよい方法があります。
      Erlangスタイルの concurrency はその一つで
      - in Java there are many ways to achive this in Java -
      I've written about them here.
      Newer ones are Akka and Actorom.
      You can also use Join/Fork or the myriad of data structures in java.util.concurrent.

   7. Use Fluent Interfaces. Fluent interfaces can make your code much more readable and
      shorter. A very good example is the MapMaker API in Google Collections:

      fluent インターフェースを使う。fluent インターフェースはあなたのコードを格段に読み
      やすくまた短いものにします。これのよい例は Google Collections の MapMaker API です:

       ConcurrentMap graphs = new MapMaker()
             .concurrencyLevel(32)
             .softKeys()
             .weakValues()
             .expiration(30, TimeUnit.MINUTES)
             .makeComputingMap(
                 new Function() {
                   public Graph apply(Key key) {
                     return createExpensiveGraph(key);
                   }
                 });

   8. Data Transfer Objects without setters and getters. If you have simple data holders
      or data transfer objects, don't write boiler plate code with getters and setters.
      I know this is heresy in Java, but just use public fields. Instead of

      セッターやゲッターを使わないデータ転送オブジェクト (Data Transfer Object)
      もしあなたが単純なデータホルダー (data holder) か データ転送オブジェクトゲッターや
      セッターを伴った boiler plate なコードを書かないでください。わたしはこれが Javaに
      おけるheresyであるということを知っていますが、パブリックフィールドを使います。

      public class Point {
         private int x;
         private int y;

         pulic Point(int x, int y) {
            this.x = x;
            this.y = y;
         }
         public int setX(int newX) {
            x = newX;
         }
         public int getX() {
           return x;
         }
         ...
      }
      ...
      int x = p.getX();
      int y= p.getY();

      write

のようなコードは次のようにします

      public class Point {
         public final int x;
         public final int y;

         pulic Point(int x, int y) {
            this.x = x;
            this.y = y;
         }
      }
      ...
      int x = p.x;
      int y = p.y;

      Refactoring is easy, should you need it. If you do not control all the code and 
      it's usage, you might need to be more careful though. 

      リファクタリングは簡単で、あなたが必要とすべきものです。もしあなたがコードすべてや
      その使い方の制御をしていないのなら、さらに注意深くなる必要があるかもしれません。

This tips lead to better Java code. Try them in your next Java class. What do you 
think? I'd like to hear how your Java coding style has changed in the last 10 years.

このtipsはよりよいJavaコードにつながります。あなたの次のJava classで試してみてくださ
い。どうですか?あなたのJavaのコーディングスタイルがこの十年でどのように変わったのか訊
きたいと思います。

Of course, you should follow me on twitter here.

You can share this post!

Do you want to tell others about this article? Use the social bookmark icons to submit 
this artice to the service of your choice. Thanks.


Code Monkeyism Copyright 2009 , content and design by Stephan Schmidt. Monkey is from 
the Tango Project and is available under the Creative Commons Attribution Share Alike 
license. Icons from FamFamFam, images from Flickr and iStockPhoto.

■_

今回は思い切りハードに。



The A-Z of Programming Languages: Arduino's Tom Igoe - Arduino, a-z of programming languages, software development, Tom Igoe - Computerworld
Do you have any advice for up-and-coming hardware hackers?

Patience. Persistence. And frequent showers. I get my best problem solving done in the shower. 

■_ 本日の巡回から

2009年10月11日

■_

・読んだ
クラウドの象徴 セールスフォース 生命保険の「罠」 (講談社+α新書)
クラウドがなんちゃらはたくさんでてるんでよくわからん。 まあこれまでも確か2冊くらい読んでるはずだけど。 この本の場合は、セールスフォースという会社のシステムを使ったクラウドコンピューティングの事例 というのがあったのでそこは良かった。定額給付金のためのシステム構築の話もしっかり載ってたし。 しかし港区だかのシステム請け負ったのはどこで、どういったものだったんだろうか。 生命保険の「罠」のほうは、まあこのぐらい知っておかないとだめよ。ということでしょう。 わたし個人に関しては知るのが遅すぎた嫌いがありますが(笑)。 たとえば、ある生命保険の契約をして、何年かたったところで 「このままですと掛け金が2倍になりますけど、これを機会に契約内容を見直しませんか」 なんて話があったりしたんですが、そのへんの理由が良くわかりました。 保険(生命保険)というものがどういったもので、何のために契約するのかをそれぞれが考えたほうが良いと思います。

・見た
PASMO 対応コインロッカー。確かに便利かもねん。 普通のロッカーと比べてどのくらい高くつくもんなんだろう?

・中央モノローグ線
こういうことされてもなあ。 とりあえず高円寺だけがんばるか(笑) ライオリ11月号から。

各街キャラ描き下ろしPOP展示&単行本をお買い上げくださった方に先着で
各街キャラ描き下ろしペーパーをプレゼント(各店舗1種・全8種)!!
開催状況および時期は書店様によって異なります
(開催店舗は下記の書店様リストをご参照ください)
  
  中野 あおい書店 中野本店
  高円寺 高円寺文庫センター
  阿佐ヶ谷 書原 阿佐谷店
  荻窪 ブックセンター荻窪
  西荻窪 NET21今野西荻窪店
  吉祥寺 ブックスルーエ 啓文堂書店吉祥寺店
  三鷹 文教堂 三鷹駅店
  武蔵境 WILDFLAG 武蔵境店
  立川 オリオン書房ルミネ店
  八王子 くまざわ書店コミックランド・ビーワン
  

竹書房4コママンガ誌オフィシャルサイト | 4コマ堂» » 10月17日「中央モノローグ線」発売! お店のblogかな? 高円寺書林 -creator's ark-

■_ ヲチ

推薦図書/必読書のためのスレッド 52 
72 デフォルトの名無しさん [] 2009/10/10(土) 23:27:43 ID: Be:
    いきなりプログラムソース提示してちょこっと解説して、はい動いたね。おしまい。
    てな初心者向け書籍が散見されてて、本屋で何も買えずに帰ってきてしまった。
    要件定義や設計ドキュメントからしっかり練られてて実践的内容な脱初心者向け
    VB2008の書籍って何かお勧めありますか? 

73 デフォルトの名無しさん [sage] 2009/10/10(土) 23:30:56 ID: Be:
    俺も>>72みたいな本を探してます
    初心者からの壁は薄いけどそこから中級者までの壁が異様に厚くて到達できない… 

74 デフォルトの名無しさん [sage] 2009/10/10(土) 23:42:20 ID: Be:
    ひと目でわかるMicrosoftVisualBasic2008アプリケーション開発入門
    http://www.amazon.co.jp/dp/4891005750/

    この内容を把握出来てればあとは実践だけかと。 

76 デフォルトの名無しさん [sage] 2009/10/11(日) 02:04:23 ID: Be:
    要件定義や設計ドキュメントからしっかり練られてて実践的内容な脱初心者向け
    と来て
    「VB2008」
    をつけるから見つからないんじゃねえかな 

77 デフォルトの名無しさん [sage] 2009/10/11(日) 02:12:48 ID: Be:
    >>74それは
    ○○という子供だましな陳腐なソフトを作ってみよう(先ずここで読者の気力を削ぐ)
    フォームにコレとソレとアレを貼り付けよう。著者の都合と気分により仕様は後で説明する。
    やっぱ紙面の都合により、説明はない。とにかく言われるがまま文字を写せ。
    紙面勿体無いからコメントも省略ね。
    ボタンクリックイベントに処理をベタベタ書いてはいおしまい。
    ね。動いたでしょ? ならコントロールの使い方もわかったわよね?ではおしまい。
    という典型的悪例だと思うが。
    二等兵からせめて伍長や軍曹レベルに引き上げてやる本って無いものか。
    個人だと相談する人も少なく壁が高いんだよな。
    実践経験も職場の内容じゃ胃の中の蛙だし。

    組み込みソフトウェア開発のためのオブジェクト指向モデリング
    話題沸騰ポットttp://www.sessame.jp/workinggroup/WorkingGroup2/POT_Specification.htm
    を題材に設計していく内容なんだが、組み込みソフトウェアって書いてあるけれど、
    内容は別に組み込みに特化してる物でもなし、汎用可能と思われ。
    たいして厚みもないし一度読んでみては?VBじゃないけど。 

78 デフォルトの名無しさん [sage] 2009/10/11(日) 02:38:49 ID: Be:
    > 胃の中の蛙
    もう助からない・・・ 

79 デフォルトの名無しさん [sage] 2009/10/11(日) 02:49:06 ID: Be:
    大海を知らず。どころの騒ぎじゃねぇなw
    今すぐ飛び出せ!じゃないと死ぬる
    でも、なんだか笑えない。自分も今、なにかの胃の中にいるんじゃないかな
    明日はせっかくの休暇だし朝まで寝るか。 

80 デフォルトの名無しさん [sage] 2009/10/11(日) 03:27:16 ID: Be:
    >>78,79
    久々に大爆笑させてもらったよwww 

■_ method out?

「メソッドアウト」って聞き覚えがないんですが、起源などご存知の方がいらしたら教えてください。 どーも「eat in」と同じにおいを感じてなりません。


コメントの必要性
コメントの必要性

コメントが必要かどうかを問われれば、僕は「不要」と言います。

でも、それは二者択一な回答を期待されたときの話で、ドキュメントコメントのような、クラス
や各メンバのドキュメントは書くべきだと思います。

僕が不要だと思うのは、メンバの実装部分に記述されているコメントです。

(略)

例えば、次のようなコードをコメントを書くように命じられたら、反発するのは僕だけではないでしょう。

void Method() {
  // コンソールウィンドウにユーザー名を表示する
  Console.WriteLine(_username);
}

そして、どうしてもコメントが必要だと言われたら、僕は、以下のように書き直すことを提案します。

void Method() {
  ShowUsername();
}

/// <summary>
///   コンソールウィンドウにユーザー名を表示する
/// </summary>
void ShowUsername() {
  Console.WriteLine(_username);
}

結果的にコードは長くなります。

しかし、先に書いたとおり、メンバのドキュメントコメントと、処理に対するコメントは別のものです。
もし、処理にコメントが必要だとするなら、それはメソッドアウトが必要であることと同じ意味だと思っています。
逆に、メソッドアウトの必要がないなら、コメントも必要ないと思ってます。

"メソッドアウト - Google 検索 "method out - Google 検索

「method」 って名詞だからその後ろに in だと out だのくっつけるのはなんか変な気がするんですよね。 あーでも、「garbage in, garbage out」 とかいうか。 Comment out - Wikipedia, the free encyclopedia だと comment は動詞でもあるし。 Comment Definition | Definition of Comment at Dictionary.com んで jargon file。 comment out

■_ memo

もうちょっとスレ? が伸びるのを待ちます。 まあこの話題も以前に出たはずのものではあるんですが。 Ask Proggit: what do you dislike in Smalltalk? : programming

■_ けんろん!

こっちもちょっと様子見。 Abstract Absurdities: How to teach Category Theory? : programming Abstract Absurdities: How to teach Category Theory?

■_ 本日の巡回から

■_

シリーズものなんですがそこから。

The ascent of scripting languages

The ascent of scripting languages

When you say “scripting language” these days, most programmers think of Perl, Python, 
Ruby, PHP, ASP, or JavaScript.  But the history of scripting languages starts much 
earlier than any of these.

今日、“スクリプティング言語” (scripting langauge) といったとき、大部分のプログラマー
は Perl や Python、Ruby、PHP、ASP、JavaScript といったものを思い浮かべるでしょう。しか
しスクリプティング言語の歴史はこういった言語よりもはるかに昔に始まっていたのです。

The Early Days: JCL

At least as early as 1964, programmers realized that having to do everything in code, 
including copying files, was too tedious.  So IBM introduced a “job control language” 
(JCL)  on the OS/360.  In this language, you could copy a file from one location to 
another using only 9 lines (punched on cards, of course), as compared to writing a 
Fortran programming that would be much more complex.  JCL was also used to run 
programs in batch mode, specify their parameters, and branch based on their result.

少なくとも1964年の初めには、プログラマーたちはファイルのコピーも含めたすべてのことをコ
ードで行う必要があることがとてもうんざりすることなのを認識していました。そこで IBM は 
OS/360 で “job control language” (JCL ジョブ制御言語)を導入しました。この言語ではよ
り複雑なフォートランプログラムを書くのに比べると、たった9行だけでファイルをある場所か
ら別の場所へコピーすることが可能でした(もちろんカードにパンチします)。JCL はバッチモー
ドでのプログラムの実行にも使われましたプログラムに対するパラメータを指定し、その実行結
果に基づいて分岐するといったことを行いました。

I remember when I was a lowly operator on a Data General Eclipse system, and I needed 
to load the contents of a tape into a file on an IBM 4331 in another department.  I 
strolled over to their operations window with the tape in hand.  When I finally got an 
operator's attention, I asked him to “please run this tape into a disk file for me.” 
 He stared at me and said, “Where's your JCL?”  I replied, “JC who? On the DG, I 
can just enter a command on the console to do that.”  He looked smug and said, “
That's impossible.  You can't read a tape without JCL.”  So, I had to research the 
required JCL and punch the cards.  Which goes to show how command line interpreters on 
minicomputers had already advanced beyond mainframe batch jobs by the late seventies.

わたしは自分が Data General Eclipse system の下っ端オペレーターであったときにあるテー
プの内容を別の部署にあった IBM 4331 のファイルにロードしなければならなかったときのこと
が忘れられません。わたしはそのマシンの操作ウィンドウの前をテープを抱えてうろうろしてい
たのですが、ようやくのことで一人のオペレータの注意をひいて彼に尋ねました。「申し訳ない
のですが、このテープをファイルに移してもらえないでしょうか」彼はわたしをにらんでこう言
いました「あなたの JCL はどこですか?」わたしはそれにこう答えました「JC 誰ですって? DG 
では、コンソールでコマンドを入力するだけでできることなんですけど」彼は勝ち誇った風な様
子で言いました「そんなことは不可能ですね。JCLがなければテープを読むことはできませんよ」
ということで、わたしは必要なJCL を調べて、その内容をカードにパンチしなければならなかっ
たのでした。1970年代の終盤には、ミニコンピューター上のコマンドラインインタープリターは
メインフレームのバッチジョブをすでに凌駕するものであったのです。

Scripting Command Line Interpreters

Command line interpreters, such as DG's CLI, DEC's MCR and DCL, and more famously 
Unix's Bourne Shell not only accepted simple commands to perform (what at the time 
seemed like) complex operations, they also provided a way to execute a series of those 
commands stored in a file.  DG called them “macros”, DEC called them “command files”, 
and Unix called them “shell scripts”.  These early scripting languages also provided 
local variables and flow control mechanisms, so it wasn't long before they began to be 
used for even more complex operations that used to require compiled programs.

DG の CLI、DEC の MCR やDCL、そしてさらに有名な Unix の Bourne Shell などといったコマ
ンドラインインタープリターは(当時としては、ですが)複雑なオペレーションをこなすための単
純なコマンドを受け付けるだけでなくそういったコマンドの並びを格納したファイルを実行する
方法も提供していました。DG はそういったファイルを「マクロ」(“macros”) と呼び、DEC で
は「コマンドファイル」(“command files”) と呼び、そして Unixでは 「シェルスクリプト」
(“shell scripts”) と呼んでいました。これら初期のスクリプティング言語はローカル変数や
フロー制御機構も備えていましたから、それらの言語がコンパイルされたプログラムを必要とす
るようなより一層複雑なオペレーションに使われるようになるのにもそれほど時間が必要ではあ
りませんでした。

When I was first introduced to Unix systems back in 1984, I was thrilled with the C 
language, the Bourne shell, and powerful utilities like awk and sed.  But there was 
one thing that bothered me:  their syntaxes were similar, but not identical - and the 
overlap in problem domain was significant.  I thought, wouldn't it be cool if you 
could have one language that addressed the combined problem domain in a consistent 
syntax?  But I was too busy to do anything about it.

わたしが最初にUnixシステムを導入した頃の1984年に戻りましょう。わたしは C や Bourne 
shell、そして強力なユーティリティである awk やsed を楽しんでいました。けれどもわたしを
うんざりさせるような一つのことがらがあったのです:これらの構文はどれも似たようなものな
のに、どうして全く同じではないのだろう -そして、問題領域でそれぞれがオーバーラップし
ていることも明白でした。わたしは考えました。一貫した構文でもって結びついた問題領域 
(combined problem domain) に対処できる言語が一つあれば、それは cool じゃないだろうかと。
But I was too busy to do anything about it.けれどもそのときそこで何かをするにはわたし
はとても忙しかったのです。

Perl

A few years later, Larry Wall found the time to do something about it: the Perl 
language.  Perl combines the ease of shell scripting with powerful features borrowed 
from C and various Unix utilities.  Immediate and easy access to regular expressions, 
lists, associative arrays, the ability to treat any value as a string, no need for 
scaffolding (not even a “main()” declaration), automatic resource management, eval 
(the ability to execute a string as code at runtime), and the ability to combine 
different programming paradigms freely are some of the language's strengths that 
combine to make “easy things easy and hard things possible.”  And you can choose 
from a number of ways to do the same thing, a principle known as TIMTOWTDI (There Is 
More Than One Way To Do It).

数年ののち、
Larry Wall found the time to do something about it: the Perl language.
Perl は C や各種のUnixユーティリティから拝借した強力な機能を備えたシェルスクリプトを簡
単に使えるように組み合わせました。正規表現やリスト、連想配列 (associative arrays) にす
ばやく簡単にアクセスでき、任意の値を文字列として扱えて、scaffolding の必要はなく
(main() の宣言すらありません)、自動的にリソース管理を行い、eval (実行時にコードとして
文字列を実行する能力) があり,異なるプログラミングパラダイムを自由に組み合わせる能力は
“easy things easy and hard things possible” (簡単なことは簡単に、難しいことを可能に)
するために combine する Perl という言語の強み (strengths) です。
そしてあなたは TIMTOWTDI (There Is More Than One Way To Do It)
として知られる原則に則って、同じ事を行う複数のやり方の中から選択することができます。

Object-orientation can be a good approach for managing complexity, but languages that 
force the use of object-oriented notation usually add unnecessary complexity to almost 
every project.  When Perl added support for objects, it did so in an optional way that 
can be freely mixed with non-OO code so that complex modeling can be achieved when 
needed, but otherwise not required.  The syntax for objects was initially a bit of a 
kludge, but that seems sufficiently remedied in Perl 6.

オブジェクト指向は複雑さを管理できる優れた手法ですが、オブジェクト指向的記述を強制する
言語は一般的にはほとんどすべてのプロジェクトに対して不必要な複雑さを追加するようなもの
でした。Perl にオブジェクトのサポートが追加されたとき、非オブジェクト指向コードと自由
に混ぜることができるようなこのため、オブジェクト指向なコードが必要となったときには複雑
なモデリングを achived 可能でしたがそれ以外のものは要求されませんでした。オブジェクト
のための構文は当初は少々見づらいものでしたが、Perl 6 で一新されたようです。

Tcl

About the same time (late 1980's), John Ousterhout created the TCL scripting language. 
It's an interesting functional language in its own right, but its enduring 
contribution to scripting languages has been the Tk, a framework for enabling 
cross-platform graphical user interfaces that can be used from within many popular 
scripting languages.

時を同じくして(1980年代終わり)、John Ousterhout は TCL というスクリプティング言語を作
り出しました。Tcl はそれ自体が interesting functional language ですが、スクリプティン
グ言語が Tk を得ることに貢献しています。Tk はクロスプラットフォームなグラフィカルユー
ザーインターフェースを可能とし他のポピュラーなスクリプティング言語の中で使うことができ
るフレームワークです。

Python

Guido van Rossum was also at work in the late 1980's on a new scripting language: 
Python.  Unlike Perl, Python's philosophy is that there should be only one clear way 
to do something.  This philosophical rigidity is reflected in the language's syntax.  
Rather than curly braces to group statements, indentation (significant white space)  
is used.   Rather than a semicolon to terminate statements, the end of line is used.  
These rules may prevent clever programmers from writing code that is easily 
misunderstood, but they also limit flexibility of coding style.

Guido van Rossum も1980年代の終わりに新しいスクリプティング言語 Python の作業を進めて
いました。Perl とは異なり、Python の哲学は there should be only one clear way to do 
something (何かを行う明快な手段はただ一つあればよい) です。この哲学は言語の構文に 
rigidity に反映されています。複数の文をまとめるのにカーリーブレースではなくインデント 
(空白を使って表されます) を用います。文を終端するのにはセミコロンではなく行末を使いま
す。これらの規則は clever なプログラマーたちが誤解されやすいコードを書いてしまうことか
ら守ります。しかしそれらの規則はまた、コーディングスタイルの柔軟性を制限することにもな
りました。

On the other hand, Python does not limit the choice of programming paradigm.  It 
readily supports structured, functional, object-oriented, and aspect-oriented 
programming - and allows you to mix those styles.

一方で、Python はプログラミングパラダイムの選択を制限していません。構造化プログラミン
グ、関数型プログラミング、オブジェクト指向プログラミング、そしてアスペクト指向プログラ
ミングを readily にサポートしていて、さらにこれらのスタイルを混ぜることも許しています。

Python gave us the term duck typing (although some earlier languages also provided 
forms of this).  If a class provides the methods expected for an interface, then it 
meets the requirements for that interface - whether or not it is derived from any base 
class of that interface.  The name comes from the duck test:  “if it looks like a 
duck, swims like a duck, and quacks like duck, then it probably is a duck”.  In 
Python, if an object implements the methods we want to call, then it qualifies as a 
receiver.  This seemingly simplistic form of typing easily enables polymorphism 
without requiring inheritance - thus eliminating the need for complex inheritance 
hierarchies.

Python はダックタイピング (duck typing。ただし一部の言語にはPythonよりも早くにこれを提
供していたものがありました)という用語をわたしたちにもたらしました。あるクラスがあるイ
ンターフェースで期待されるメソッドを提供しているのならば、そのインターフェースのベース
クラスから派生しているかどうかには関係なくインターフェースに対する要求を満たしていると
するものです。ダックタイピングと言う名前はダックテスト (duck test) から来ています:“if 
it looks like a duck, swims like a duck, and quacks like duck, then it probably is a 
duck”. (もしそれがアヒルような外見で、アヒルのように泳ぎ、アヒルのように鳴くのなら、
それはおそらくアヒルだろう) Python では、あるオブジェクトがわたしたちが呼び出したいメ
ソッドを実装していたならばそのオブジェクトはレシーバーとなることが許されます。これは継
承を要求することなしに、つまり複雑な継承の階層の必要性を取り除いて多態 (polymorphism) 
を簡単に可能にする simplistic form のようなものです。

Ruby

I may not be qualified to write objectively about Ruby, because it's currently my most 
favorite programming language.  Yukihiro Matsumoto, affectionately known to the Ruby 
community as “Matz”, released Ruby to the public in 1995.  His design philosophy 
focuses on creating a language for human programmers, rather than for the machine.  
The result is based largely on Perl and SmallTalk, with nods to other languages.  It 
follows the POLS (“Principle of Least Surprise”) - so where it may be minutely 
inconsistent, it usually does what the programmer expects.  Ruby also embraces Perl's 
concept of TIMTOWTDI - you can probably find eight or more ways to perform even the 
simplest operation.

Ruby は現時点でのわたしの一番好きなプログラミング言語であるので、Ruby について 
objectively に書くことができないかもしれません。Ruby コミュニティでは“Matz”として親
しまれている まつもとゆきひろ氏は1995年に Ruby を公にリリースしました。彼の設計哲学は、
プログラマーである人間のための言語を作るのであって機械のために作るのではないということ
に焦点を当てています。その結果は (nods to other languages しつつ) Perl と Smalltalk に
大きく影響を受けたものです。POLS (“Principle of Least Surprise” 驚き最小の原則) に従
い(そのために細かいところで一貫性を欠くこともありますが)、通常はプログラマーが予期した
ことを行います。Ruby は Perlのコンセプトの TIMTOWTDI も embrace しますあなたは単純な操
作一つに対してさえ八種類以上のやり方を見つけることができるでしょう。

Ruby is one of the more thoroughly object-oriented languages around.  Almost anything 
can be treated as an object, even literals - which provides amazing expressiveness.  
Nevertheless, you aren't required to explicitly use classes at all, unless you want to. 
If you define a function that isn't in a class, it actually extends the global Object 
class.  You don't have to be aware of that, and yet you can also use that fact to your 
advantage.

Ruby はとことんオブジェクト指向をつきつめた言語の一つで、リテラルすらも含むほとんどす
べてのものをオブジェクトとして扱うことが可能です。これは amazing expressiveness をもた
らします。それでいて、あなたが望まない限りにおいてクラスの使用を強制されることはありま
せん。クラスに属さない関数を定義したとき、それは実際にはグローバルな Object クラスを 
extend しています。あなたはそれを気にする必要はなく、それをあなたの advantage として使
うこともできます。

Ruby uses duck typing, like Python.  Ruby also allows any class to be reopened and 
extended.  For instance, you can add your own methods to String and Integer, or 
override the ones that are predefined.  This makes most OO purists wet their pants.  
Potentially it's a truly dangerous capability, but in the right hands at the right 
time it can be amazingly powerful.

Ruby は Python と同様にダックタイピングを使っています。Ruby では任意のクラスを reopen 
したりextend できます。たとえば、String クラスや Integer クラスにあなたの書いたメソッ
ドを追加することができますし、すでに定義されているものをオーバーライドすることも可能で
す。これはオブジェクト指向 purists を wet their pants させるものです。潜在的にこれはと
ても危険な機能ではあるのですが、正しい時と場所で使えば信じられないほど強力なものになり
ます。

Because of its great flexibility, Ruby is inherently multi-paradigmatic.  It's 
possible to write Ruby code that reads like Lisp, Java, or even Pascal.  You can tune 
for readability, performance, minimum code, cleverness, or just about any other 
emphasis you'd like to achieve.

その great な柔軟性故に、Ruby はその本質からマルチパラダイム的です。そしてそれにより、
Lisp のように読める Ruby のコード、Java のように読める Ruby のコード、さらには Pascal 
のように読める Ruby のコードすら書くことが可能です。あなたはこの能力で 読みやすさ 
(readability) を向上させることができますし、パフォーマンスの向上やコードの最小化 
(minimum code)、cleverness (巧妙さ?) を増すため、あるいはその他あなたが強調する 
achieve したいものについて。

And since we've been talking about Ruby, now might be a good time to throw in a 
continuation (pardon the pun).

わたしたちは Ruby についてはすでに述べましたから、


To be continued…
つづく。

There is so much more ground to cover, and I've probably already exhausted your 
attention span.  So, I'll continue this thread in a later post on the use of scripting 
languages and the web.  I have also neglected to talk about scripting languages 
embedded in applications.  There are many scripting languages that I won't be able to 
cover, and many distinguishing features and capabilities that I won't have space to 
discuss.  But I hope you'll find this overview helpful.

This post is part three of a series on the history of programming languages.  For the 
first two parts, see:

    * The Early History of Programming Languages
    * An introduction to object oriented languages


一つ前へ 2009年10月(旬)
一つ後へ 2009年10月(旬)

ホームへ


Copyright (C) 2009 KIMURA Koichi (木村浩一)
この文書の無断転載はご遠慮ください(リンクはご自由にどうぞ)。

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