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

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

一つ前へ 2008年11月(下旬)
一つ後へ 2008年12月(中旬)

ホームへ

2008年12月10日

■_

・訂正
The Ruby Way と The Rails Wayを取り違えていた模様。

・比較
String#equals(Object) 問題 - BOOLEANLABEL String の空文字判定 - YoshioriのBlog [vacant lot] : binary method …仁鶴? 笑福亭仁鶴 (3代目) - Wikipedia

■_



推薦図書/必読書のためのスレッド 43

113 デフォルトの名無しさん [sage] Date:2008/12/10(水) 12:28:14  ID: Be:
    憂鬱なプログラマのためのオブジェクト思考開発講座
    わかりやすいと思ったんだけど、駄作って本当? 

114 デフォルトの名無しさん [sage] Date:2008/12/10(水) 12:55:49  ID: Be:
    駄本じゃない
    でも今ありがたがる本でもない 

115 デフォルトの名無しさん [sage] Date:2008/12/10(水) 12:59:55  ID: Be:
    >>114
    なんか、間違ったこと書いてるって言う人がいるんだけど 

116 デフォルトの名無しさん [sage] Date:2008/12/10(水) 13:00:26  ID: Be:
    子細そいつに聞けよ 

117 デフォルトの名無しさん [sage] Date:2008/12/10(水) 15:17:00  ID: Be:
    いや、ネット上で見たので
    2ちゃんでは絶賛されてるけど糞だとか何とか 

119 デフォルトの名無しさん [sage] Date:2008/12/10(水) 15:30:30  ID: Be:
    糞の部分について具体的に言ってるならまだしも
    ホントに糞としか言ってないなら便所のラクガキレベルだな 

120 デフォルトの名無しさん [sage] Date:2008/12/10(水) 16:26:29  ID: Be:
    >>113
    今更読む本ではない、とは言えるかと

    >>119
    検索してみたら、この辺りが特にボコボコに叩いてる
    http://d.hatena.ne.jp/uskz/20070726/p1
    http://d.hatena.ne.jp/iltc/20080428/1209382705
    http://d.hatena.ne.jp/minekoa/20080503/1209799681
    http://d.hatena.ne.jp/JavaBlack/20070805/p2
    http://d.hatena.ne.jp/JavaBlack/20080824
    http://d.hatena.ne.jp/JavaBlack/20080401/p1
    http://d.hatena.ne.jp/JavaBlack/20070806/p1

    最後のやつは、
    「憂鬱本の間違い箇所は全部。だから説明する必要が無い。
    どこが違うか分からないやつは馬鹿だからそもそも話にならない。
    間違っていない正しい本を読め。
    http://d.hatena.ne.jp/JavaBlack/20070825/p1
    が最適。」
    と言う立場を取っているみたいだ。
    あと皆「犬わんわん、猫にゃーにゃー」を嫌ってるっぽい。
    あれは説明を間違えるととんでもない誤解を与える例だけど
    それ自体が悪いとかいうのとはちょっと違うと思うんだが…。 


Lisp Scheme Part24 [bbs2chreader]
748 デフォルトの名無しさん [sage] Date:2008/12/08(月) 15:19:34  ID: Be:
    論理否定が理解できるなら継続も理解できる筈って言われたんだけどマジですか? 

749 デフォルトの名無しさん [sage] Date:2008/12/08(月) 15:24:00  ID: Be:
    カリー、ハワードの対応とかいうあれ? 

750 デフォルトの名無しさん [sage] Date:2008/12/08(月) 15:36:40  ID: Be:
    論理否定も継続も理解してるつもりだが、相関はわからん。
    カリー・ハワードを勉強すればわかるの? 

752 デフォルトの名無しさん [sage] Date:2008/12/08(月) 23:23:32  ID: Be:
    Curry-Howard の概観なら、これとか判り易かった。
    http://www.kmonos.net/wlog/61.html#_0538060508 

753 デフォルトの名無しさん [sage] Date:2008/12/08(月) 23:30:15  ID: Be:
    という用語を作り、SF ファンとして有名なフォレスト・J・アッカーマン氏が
    12 月 4 日に 92 歳で死去したそうだ 

754 デフォルトの名無しさん [sage] Date:2008/12/08(月) 23:35:19  ID: Be:
    アッカーマン関数の? 

757 デフォルトの名無しさん [sage] Date:2008/12/09(火) 11:15:05  ID: Be:
    >>754
    そっちはヴィルヘルム・アッカーマン。 

そうかあ、アッカーマン関数の人じゃなかったんだ(^^:



Perlについての質問箱 38箱目
661 デフォルトの名無しさん [sage] Date:2008/12/08(月) 19:40:05  ID: Be:
    "$var" って書く奴、文字列比較と数値比較が分ってない奴。
    自称回答者でも初心者スレにすら値しない。
    質問者共々、みんな纏めてこっち行け。

    くだすれPerl(超初心者用)2
    ttp://pc11.2ch.net/test/read.cgi/php/1204488452/


662 デフォルトの名無しさん [sage] Date:2008/12/08(月) 19:48:21  ID: Be:
    >print "$a".".txt\n";

    これのことか。これはひどいな。

673 デフォルトの名無しさん [sage] Date:2008/12/09(火) 05:03:10  ID: Be:
    モダンパールとやらはどこにいったら覚えられるのでしょうか

    http://perl-users.jp/modern_introduction_perl/
    ここもいくら待っても目次しかないんだけど 

674 デフォルトの名無しさん [sage] Date:2008/12/09(火) 06:06:55  ID: Be:
    >>673
    そこはね、おまえが書くために用意されているんだよ。 

675 デフォルトの名無しさん [sage] Date:2008/12/09(火) 11:32:04  ID: Be:
    >>673
    この辺からたぐってみるといいかもね。
    http://b.hatena.ne.jp/entrylist?url=http://perl-users.jp/ 

【初心者】Java質問・相談スレッド121【歓迎】 

777 デフォルトの名無しさん [sage] Date:2008/12/08(月) 20:56:25  ID: Be:
    Javaは配列辺りまで理解して今はクラスの基礎を勉強してる俺が
    SJC-A受けてみようと思う。
    今日、Amazonで参考書買った、
    Sun教科書とか言うドッチカト言うと青本では無く紫本と
    徹底攻略とか言う通称黒本の二冊をお急ぎ便で頼んだ。



    受かると思いますか?… 

779 デフォルトの名無しさん [sage] Date:2008/12/08(月) 21:27:50  ID: Be:
    >>777
    おまえみたいな奴はもし受かっても会社では通用しないな。rubyにしとけw 

783 デフォルトの名無しさん [sage] Date:2008/12/08(月) 22:02:38  ID: Be:
    資格持ってるからといって期待させといて、実際に仕事任せて出来なかったら逆にうらまれるだけだしな・・・
    それよか、英語の文献読むことが多いだろうしtoeic受けたほうがいいよw 

789 デフォルトの名無しさん [sage] Date:2008/12/08(月) 22:49:12  ID: Be:
    とにかくさ~>>777に受かるか受からないか
    受かるとしたらどの位か答えてあげてよ 

791 デフォルトの名無しさん [sage] Date:2008/12/08(月) 22:54:30  ID: Be:
    Aは受けたことないからわかんね

    http://suned.sun.co.jp/JPN/certification/sjcaobj.html

    主な出題範囲を見る感じ100%受からないとおもた 

802 デフォルトの名無しさん [sage] Date:2008/12/08(月) 23:55:21  ID: Be:
    資格とか持ってる奴の方が実際は役に立たないのがおおいよね。 

803 デフォルトの名無しさん [sage] Date:2008/12/09(火) 00:00:59  ID: Be:
    数えたことが無いので知らん 

804 デフォルトの名無しさん [sage] Date:2008/12/09(火) 00:01:47  ID: Be:
    テストは満点、適応能力は0点なんて昔からいるだろ。 

806 デフォルトの名無しさん [] Date:2008/12/09(火) 00:08:52  ID: Be:
    >>793は、テストは0点、協調性0点ってことですかw 

809 デフォルトの名無しさん [] Date:2008/12/09(火) 00:26:22  ID: Be:
    >>806
    どうせ古い知識とか昔の小技とかこだわってるオッサンだろw
    もう化石だしほっといていいんじゃね? 

810 デフォルトの名無しさん [sage] Date:2008/12/09(火) 00:38:01  ID: Be:
    森田スクロールは今のコンシューマ開発でも使われている。
    とか言ってみるw 

812 デフォルトの名無しさん [sage] Date:2008/12/09(火) 10:10:36  ID: Be:
    プログラミングの資格を誇示するやつってろくなやついないから、 >>777 には受かって欲しいなぁ。 

813 デフォルトの名無しさん [sage] Date:2008/12/09(火) 10:40:00  ID: Be:
    古い情報ニ種を持ってて古い一種に英語が分からずに落ちて他何も持ってない俺でも
    ボソボソとだがやってけるんだから、資格なんて…資格なんてっ!

    でも資格もってると実際には使えんヤツでも手当て出たりするんだよな…もったいねぇ。 

814 デフォルトの名無しさん [sage] Date:2008/12/09(火) 10:49:00  ID: Be:
    資格というのは手当てのために取るもんだから、持ってるからといって凄腕なわけでない。
    トーイックとかもってないと上に上がれない職種も多いでしょ。
    警察と同じで一種の昇給試験にちかい。
    それよりも仕事もってくる嗅覚(営業)の特技が合った方が先々でやってけるw 

815 デフォルトの名無しさん [sage] Date:2008/12/09(火) 12:34:12  ID: Be:
    情報二種とか懐かしすぎるだろ、持ってる事忘れてたわ
    取得当時はまだ高校生になったばかりだったなあ(遠い目 

816 デフォルトの名無しさん [sage] Date:2008/12/09(火) 12:39:27  ID: Be:
    資格なんてとって遊んでる暇があったら、仕事しなさい 

817 デフォルトの名無しさん [sage] Date:2008/12/09(火) 12:45:40  ID: Be:
    法的に有利にならない資格は取っても無駄 



くだすれFORTRAN(超初心者用)その3
773 デフォルトの名無しさん [] Date:2008/12/08(月) 05:30:57  ID: Be:
    gfortran(win32)でコンパイルすると,次のようなエラーが出てしまいます,
    解決策はありますでしょうか。
    DATAN2が使えないというようなことだとおもうのですが。
    (linux版のifortではコンパイルできています)

    amp32.f:79.72:

    ZATAN(ZD,ZE) = DATAN2(ZD,ZE)
    1
    Error: Unexpected STATEMENT FUNCTION statement at (1)


    なお,gfortran -vは次のとおりです。

    Using built-in specs.
    Target: i586-pc-mingw32
    Configured with: ../trunk/configure --prefix=/mingw --enable-languages=c,fortran
    --with-gmp=/home/FX/local --with-ld=/mingw/bin/ld --with-as=/mingw/bin/as --dis
    able-werror --enable-bootstrap --enable-threads --disable-nls --build=i586-pc-mi
    ngw32 --enable-libgomp --disable-shared
    Thread model: win32
    gcc version 4.4.0 20080603 (experimental) [trunk revision 136333] (GCC) 

774 デフォルトの名無しさん [sage] Date:2008/12/08(月) 07:13:07  ID: Be:
    文関数っぽいところでエラーが・・・・・
    zatanを複素数のatanだったきがするから、予約語をそれ以外で使ったことで怒られたのか?

    gfortranが手元で使えないから分からんけど、zatanの名前を変えてみたら?

776 デフォルトの名無しさん [] Date:2008/12/08(月) 14:05:16  ID: Be:
    774 のコメント見てgoogleでzatanを引いたらこのスレが出てきたw

    zatan(x) で引数一つの関数だから773のは多分 774のとおり
    予約語を代入文の右側で呼んでるから怒られたっぽいな。
    上の方で書いてあるけど変数名を決めるのは難しい。 

777 773 [] Date:2008/12/08(月) 18:01:20  ID: Be:
    >>774,776
    ありがとうございます。
    名前を決めるのはなかなか難しいですね。

    ほかのサブルーチンの場合,問題なくコンパイルできていて,
    できる場合とできない場合があるようです。
    エラー込みでコンパイルということなんでしょうかね。

    なお,g77ではスルーできるようなので,
    とりあえずこれでしのいで,
    あとで考えようと思います。 

778 デフォルトの名無しさん [sage] Date:2008/12/08(月) 20:24:47  ID: Be:
    予約語?なにそれ、食えるの?

    PROGRAM PROGRAM
    REAL REAL(8), THEN, END
    IF(N) = N * 2
    WRITE(I, A) = I + A
    SIN(X) = COS(X)

    THEN = 3.
    REAL(4) = 1.2
    END = 0.

    WRITE(*,*) IF (1 + 2), THEN
    WRITE(6,*) WRITE(6, 2.3), REAL(4), SIN(END)
    STOP
    END

779 773 [] Date:2008/12/08(月) 21:54:37  ID: Be:
    >>778

    なるほど,そういうことなんですね。
    これがヒントになり,解決しました。
    どうもありがとうございました。 

780 デフォルトの名無しさん [sage] Date:2008/12/08(月) 23:12:11  ID: Be:
    ほかの言語から来た人がよく誤解しているが、FORTRANには予約語というものは無い。
    文法書をよく読むと書いてある。

784 デフォルトの名無しさん [sage] Date:2008/12/09(火) 00:45:54  ID: Be:
    πぐらい予約語にしたらいいのに 

785 デフォルトの名無しさん [sage] Date:2008/12/09(火) 01:09:56  ID: Be:
    >>784
    過去互換が崩れるのでまずい気がする
    INTRINSIC MODULEとして数学常数を与えることも可能だが、
    それはそれで変数名のバッティングが起きそうで、自分で常数MODULE作れという事になる。

    まぁFortran2008では
    REAL, PARMETER :: pi = 4.0d0 * ATAN(1.0d0)
    というコンパイル時の関数評価も可能になったし、まぁいらねんでね?

786 785 [sage] Date:2008/12/09(火) 01:10:54  ID: Be:
    訂正:Fortran2008では⇒Fortran2003では

787 デフォルトの名無しさん [sage] Date:2008/12/09(火) 03:13:57  ID: Be:
    >>780
    文法書にはpreserved wordがあるので予約語は「ある」。英語で読もうね。
    もっとも、あとでユーザーのoverrideできる仕様になっとる点で他の言語とは違うが。
    >>778 がちょっぴりまぬけな得意気まんまんに例を出したが、
    そんなことわざわざすまでもなく773のがそういうことになっとるのだな。
    んで、IntelはそのOverrideを出来るようにしており、gfortranでは禁止しているだけのお話。
    ややこしいのはそのOverrideをメイン階層でしてしまった場合に
    下層の副プログラムにも反映されてしまう場合がある。されない場合もある。

    PI は 785 のやりかたが推奨されてるね。 

788 デフォルトの名無しさん [sage] Date:2008/12/09(火) 05:04:50  ID: Be:
    >>787
    ん?どの文法書の話だ?
    Fortran に preserved word は無いぞ。
    この文脈で overide なんて用語を待ちだしてくるのは、生粋の Fortran 使いでは無いわなw

    gfortran なんて使ったこと無いが、それは Fortran と呼べる代物では無い。


    ANSI規格書はFORTRAN77しか持ってないが、2.2 Syntactic Itemsのところで
    "There is no sequence of characters that is reserved in all contexts in FORTRAN."
    とある。

    また、Fortran95/2003Explained の 2.7 Names のところによれば
    "There are no other restrictions on the names; in particular there are no
    reserved words in Fortran."
    とある。







789 デフォルトの名無しさん [sage] Date:2008/12/09(火) 11:23:48  ID: Be:
    >>787
    >文法書にはpreserved wordがあるので予約語は「ある」。英語で読もうね。

    >>>778 がちょっぴりまぬけな得意気まんまんに例を出したが、

    挑発的なわりに・・・・なんなの?
    アホ? 

790 デフォルトの名無しさん [sage] Date:2008/12/09(火) 14:52:19  ID: Be:
    おまえらおちつけ 

PL/I が予約語持ってないというのはよく覚えているんだけど、 FORTRANもそうだったっけ?

■_

A simple Operator Precedence parser
http://www.hokstad.com/operator-precedence-parser.html

Functional Programming and the J Programming Language
http://www.cs.trinity.edu/~jhowland/math-talk/functional1/


Conal Elliott » Why classic FRP does not fit interactive behavior
http://conal.net/blog/posts/why-classic-frp-does-not-fit-interactive-behavior/

2008年12月09日

■_

・「もやしもん」7巻
また特装版があるのかっ!? Amazon.co.jp: もやしもん 7―TALES OF AGRICULTURE (7) (イブニングKC): 石川 雅之: 本 (これは特装版へのリンクではありません)

Rails WayThe Ruby Way(第2版)
中身をちょっと書店で立ち読みさせてもらったのですが (雨が降ってたし重いので買ってません><)、 正規表現の章? のあたりでカッコが正しくペアになっているかどうかチェックするという 正規表現の解説をしているところがあったと思うのですが、 そこの文章で「(記述した正規表現の中に)左再帰があると無限後退が生じる」 とかなんとかいう記述を見つけました(文章は正確ではありませんが、 左再帰、後退という単語は間違いなくあったと思います)。 この「後退」って正規表現エンジンの動作の「バックトラック」のことだったり? だとするとbacktrack → 後退 としちゃうのはここではあまりよろしくないような。 訳者はどなたなのだろう? The Ruby Way第2版の第3章でした。

・[お察しください]
まあ、イロイロあったわけですよ。

■_ super

super() について - methaneの日記2008-12-09 - JBuilt-in Functions Python v3.0 documentation

Built-in Functions — Python v3.0 documentation
super([type[, object-or-type]])¶

    Return a “super” object that acts like the superclass of type.
    型が superclassであるかのように振舞うオブジェクト "super"を返します。

    If the second argument is omitted the super object returned is unbound. If the 
    second argument is an object, isinstance(obj, type) must be true. If the second 
    argument is a type, issubclass(type2, type) must be true. Calling super() without 
    arguments is equivalent to super(this_class, first_arg).
    第二引数が省略された場合、戻り値として返された super オブジェクトは束縛されていません。
    第二引数がなんらかのオブジェクトであったとき、isinstance(obj, type)は trueに
    ならなければなりません。(第二引数が)型 (type)であった場合には issubclass(type2, type)
    は trueにならなければなりません。引数なしで super() を呼び出した場合、それは
    super(this_class, first_arg)と等価になります。

    There are two typical use cases for “super”. In a class hierarchy with single 
    inheritance, “super” can be used to refer to parent classes without naming them 
     explicitly, thus making the code more maintainable. This use closely parallels the use 
    of “super” in other programming languages.
    “super”の使い方には典型的な二つのものがあります。単一継承であるクラス階層において
     “super”は(自分の親クラスの)名前を知らなくても親クララスを参照することを可能に
     させるので、コードをより保守しやすいもの (more maintainable)なものにします。
     この使い方は他のプログラミング言語における “super”の使い方に類似しています。

    The second use case is to support cooperative multiple inheritence in a dynamic 
    execution environment. This use case is unique to Python and is not found in
    statically compiled languages or languages that only support single inheritance. This 
    makes in possible to implement “diamond diagrams” where multiple base classes 
    implement the same method. Good design dictates that this method have the same calling 
    signature in every case (because the order of parent calls is determined at runtime 
    and because that order adapts to changes in the class hierarchy).
    二種類目の使い方というのは、動的実行環境 (dynamic execution environment)において
    協調型多重継承 (cooperative multiple inheritence) をサポートするというものです。
    この使い方はPython固有のものであり、静的コンパイル型言語 (statically compiled languages )
    や単一継承だけをサポートする言語にはみられないものです。この使い方により同じメソッドを
    実装している複数のベースクラスが存在する“ダイヤモンドダイヤグラム”(diamond diagrams)
    の実装が可能になります。このメソッドを持つ Good design dictates はすべてのケースにおいて
    同じ calling signature を持ちます(これは order of parent calls が実行時に決まることと
    そのような order がクラス階層中での変更に追随するからです)。

    For both use cases, a typical superclass call looks like this:
    どちらの場合でも、superclassの典型的な使い方は次のようになります:

    class C(B):
        def method(self, arg):
            super().method(arg)    # This does the same thing as: super(C, self).method(arg)

    Note that super() is implemented as part of the binding process for explicit dotted
    attribute lookups such as super().__getitem__(name). It does so by implementing its
    own __getattribute__() method for searching parent classes in a predictable order 
    that supports cooperative multiple inheritance. Accordingly, super() is undefined for 
    implicit lookups using statements or operators such as super()[name]. Also, super() is 
    not limited to use inside methods: under the hood it searches the stack frame for the 
    class (__class__) and the first argument.
    super()が、super().__getitem__(name)のようにドット付き属性 (dotted attribute)
    であることがはっきりとしているものに対する binding process の一部として実装されている
    ということに注意してください。

へえ。

■_ スタイル

2008-12-08 - きしだのはてな 実用を考えると、文字列リテラルとの比較は文字列リテラルが先のほうが見やすい

2008-12-08 - きしだのはてな
もう落ち着いた話題だけど、SwingWorkerのサンプル書いて思い出した。

文字列リテラルの比較の話だけど、"リテラル".equals(s)よりもs.equals("リ
テラル")のほうが見やすいとか意味を反映しているとかあった。

けど、実際にJavaで文字列リテラルの比較などという無粋なことをする場合は、select~case的
な使い方をすることがほとんどであるような気がする。

(略)

意味としても、methodと"GET"の比較、methodと"POST"の比較、という気
持ちではなくて、"GET"の場合、"POST"の場合、という気持ちで書いてい
るのだから、methodとかequalsとか、ごちゃごちゃしたものは後ろにまわしてしまいたい。
equalsIgonoreCaseを使うほうが多かったりするしね。

で、このとき、methodがnullでもそれなりに動いて問題の発現が遅れて困るとかいう意見は、
「ん~なんのこと?」という感じになる。まあそういう可能性がある場合もあるのだろうけど、
少なくともぼくの書いてるコードの場合は、nullならほっとけばいいことがほとんどなので、関
係ないことが多い。それより、nullとかどうかじゃなく、該当がない場合はすべからくエラーと
いう処理のほうが多い。

"リテラル".equals(s)は嫌がらせとしか思えないという意見もあったけど、実のとこ
ろそれは、文字列の比較を行っていること自体が嫌がらせだったりするんじゃないだろうか?と
思ったりもする。

まあ、こういう書き方がいいとか悪いとかで意見が割れるときは、だいたいどっちも正しいのだ
から、どういう使い方を前提にしてるか明確にすると議論しやすいね。

if (false)はちょっと勘弁していただきたいというのはおいといて、 "".equals(なんとか) に比べると "GET".equals(method)なんかはあまり違和感を覚えないな。 見た目の問題だろうか? あれ、大本の記事で問題にされたのって空文字列判定限定だったっけ? 面倒だから調べないw

■_ Microsoft will support CPAN authors with free access to Windows machines

Microsoft will support CPAN authors with free access to Windows machines - Perlbuzz

Adam Kennedy's announcement tells the long story, but the short version is this: 
Microsoft will be providing every CPAN author with free access to a centrally-hosted 
virtual machine environment containing every major version of Windows.

It will be interesting to see how this plays out. Will CPAN authors use the resources 
from Microsoft to make sure that our modules work on Windows? I know that I'm 
especially interested because I want ack to be transparently cross-platform. Anything 
I can do to help get ack out on Windows boxen, to help Windows programmers know that 
the command-line can be better than an IDE, is a win.

This is pretty big, and I'm glad to see Microsoft providing this service. I'm 
especially thankful for Adam putting what I'm sure was a huge number of hours making 
this happen. I'm glad we have him on our side.

(時差があるけど)6日付というとほかが多くてボツにした日の分か。 Microsoftがどうこうというのはわかったけど、 Microsoft will be providing every CPAN author with free access to a centrally-hosted virtual machine environment containing every major version of Windows. だったか。あー、それで記事の途中にWindowsのバージョンがずらずら並んでいる所があったのかっ。 自分の英語流し読み能力の低さに絶望した○| ̄|_

■_

そして自分の英語力のなさを痛感するものをもう一つ。

Laurence Tratt: How can C Programs be so Reliable?
http://tratt.net/laurie/tech_articles/articles/how_can_c_programs_be_so_reliable

How can C Programs be so Reliable?

どうすればCプログラムを信頼できるものにできるだろうか?

C is, today, a unique programming language. Surprisingly few people can really program 
in C and yet many of us have quite strong opinions about it. Buffer overflows, stack 
smashing, integer overflows - C has many well publicised flaws, and these terms are 
often bandied about confidently, even by those unfamiliar with C. Personally I shied 
away from C for a decade, for one reason or another: originally, compilers were 
expensive (this being the days before free UNIX clones were readily available) and 
slow; the culture was intimidatory; and, of course, all the C scare stories made me 
think that a mere mortal programmer such as myself would never be able to write a 
reliable C program.

今日にあって、Cは特異なプログラミング言語です。
驚くほどの少数の人だけが本当にCを使って  プログラムすることができ、
Cを使ってプログラムできるのは驚くほどの少数に過ぎず、
yet many of us have quite strong opinions about it.
バッファーオーバーフロー、スタックの破壊、整数オーバーフローなどなど、Cには多くの非常に
良く知られている欠点があります。そしてこれらの用語はCに馴染みのない人たちによってさえも
しばしば喧伝されています。わたし個人はもう十年も前からCからは離れてしまっています。
for one reason or another: 第一には、コンパイラーがとても高価だったこと
(無料配布されているUNIXクローンが簡単に手に入るようになる以前のことです)、
そしてコンパイラが(コンパイル速度や生成したコードの速度の面で)遅かったということです。
(Cに関連した)文化はとても威嚇的なもので、すべての C scare stries(Cの怪談 and/or 怖い話?)
はわたしに、自分のような平凡なプログラマー (mere mortal programmer)には
信頼性のあるCプログラムを書くことは決してできないのではないのかと思わせるものだったのです。

# intimidatory
# → 態度などが〕威嚇的な, 恫喝(どうかつ)的な.


Discounting a couple of tiny C modules that I created largely by blindly cutting and 
pasting from other places, the first C program I wrote was the Converge VM. Two things 
from this experience surprised me. First, writing C programs turned out not to be that 
difficult. With hindsight, I should have realised that a youth misspent writing 
programs in assembler gave me nearly all the mental tools I needed - after all, C is 
little more than a high-level assembly language. Once one has understood a concept 
such as pointers (arguably the trickiest concept in low-level languages, having no 
simple real-world analogy) in one language, one has understood it in every language. 
Second, the Converge VM hasn't been riddled with bugs as I expected.

大部分をどこか別の場所から闇雲にコピペしてきたもので作ったいくつかの小さなCのモジュールを
除けば、わたしが最初に書いたCプログラムというのは Converge VM でした。
それによって経験した二つのことがわたしを仰天させたのです。
まず第一に、Cでプログラムを書くことは難しいことではないということ。
あとから考えてみると (With hindsight)、わたしは
a youth misspent writing programs in assembler gave me nearly all the mental tools I needed 
#misspent→浪費した(過去分詞)
#若い時分にアセンブリ言語でプログラムを書きちらかしまくったのは良い経験だったとか?
だということを明確にはっきりと理解しておくべきだったのです。
結局のところ、Cとはアセンブリ言語よりもちょっとだけ(プログラミング言語としての)水準が
高いものにすぎなかったのです。ある言語における(ほぼ間違いなく 現実世界で単純に analogy
を探すことのできない低水準言語におけるtrickiest concept であろう)
ポインターのようなコンセプトを理解できてしまえば、すべての言語の同様なものも理解できたのです。
第二に、Converge VM でわたしが考えていたほどにはバグに悩まされることがなかったということです。


In fact, ignoring logic errors that would have happened in any language, only two 
C-specific errors have thus far caused any real problem in the Converge VM (please 
note, I'm sure there are lots of bugs lurking - but I'm happy not to have hit too many 
of them yet). One was a list which wasn't correctly NULL terminated (a classic C error); 
that took a while to track down. The other was much more subtle, and took several days, 
spread over a couple of months, to solve. The Converge garbage collector can 
"conservatively" garbage collect arbitrary malloc'd chunks of memory, looking for 
pointers. In all modern architectures, pointers have to live on word-aligned 
boundaries. However, malloc'd chunks of memory are often not word-aligned in length. 
Thus sometimes the garbage collector would try and read the 4 bytes of memory starting 
at position 4 in a chunk - even if that chunk that was only 5 bytes long. In other 
words, the garbage collector tried to read in 1 byte of proper data and 3 bytes of 
possibly random stuff in an area of memory it didn't theoretically have access to. The 
rare, and subtle, errors this led to were almost impossible to reason about. But let's 
be honest - in how many languages can one retrospectively add a garbage collector?

事実、どんな言語でも起こりうるロジックのエラーを無視すれば、Cに固有のエラーのたったの
二種類だけが Converge VMでの深刻な問題のすべてを引き起こす原因となったのです
(注意していただきたいのは、たくさんのバグが潜んでいるであろうことをわたしが確信していた
というこです。とはいえ、I'm happy not to have hit too many of them yet)。
バグのひとつはリストが正しくNULLで終端されていなかったという
Cでは古典的ともいえるエラーでした。これはすぐに追跡することができました。
もうひとつは、much more subtle (NULL終端に比べるとほとんど発生しないような?)で
took several days, spread over a couple of months, to solve.
(再現するのに数日?、)解決するのには数ヶ月を要しました。
Converge のガーベジコレクターは mallocによって割り当てられたメモリのチャンクを
任意に "conservatively"  にポインターを検索してガーベジコレクトできるものでした。
# conservatively
# →保守的、控えめ、
すべての modern architectures ではポインターはワード境界に置かれなければなりません。
しかし mallocされたメモリーのチャンクはしばしばワード境界から外れた所にあったのです。
そうした場合、ガーベジコレクターは対象となっているチャンクに対して、
たとえそのチャンクがたったの5バイトしかなかったとしてもposition 4から始まる4バイトを
読み込もうとするのです。言葉を換えると、ガーベジコレクターは一バイトの正しいデータと
(理論的にはアクセスする必要がない領域でおそらく内容がランダムであろう)
三バイトのゴミデータとを読もうとしていたのです。
The rare, and subtle, errors this led to were almost impossible to reason about.
#滅多に起きないようなエラーで理由を把握することがほとんどできなかった?
しかし正直に言って、一体どれほどの言語がガーベジコレクターを
retrospectively に追加することができるのでしょうか?
#retrospectively
# →回顧的な?

My experience with the Converge VM didn't really fit my previous prejudices. I had 
implicitly bought into the idea that C programs segfault at random, eat data, and 
generally act like Vikings on a day trip to Lindisfarne; in contrast, programs written 
in "higher level" languages supposedly fail in nice, predictable patterns. Gradually 
it occurred to me that virtually all of the software that I use on a daily a basis - 
that to which I entrust my most important data - is written in C. And I can't remember 
the last time there was a major problem with any of this software - it's reliable in 
the sense that it doesn't crash, and also reliable in the sense that it handles minor 
failures gracefully. Granted, I am extremely fussy about the software I use (I've been 
an OpenBSD user for 9 years or so, and software doesn't get much better than that), 
and there are some obvious reasons as to why it might be so reliable: it's used by 
(relatively) large numbers of people, who help shake out bugs; the software has been 
developed over a long period of time, so previous generations bore the brunt of the 
bugs; and, if we're being brutally honest, only fairly competent programmers tend to 
use C in the first place. But still, the fundamental question remained: why is so much 
of the software I use in C so reliable?

Converge VMに関するわたしの経験はわたしの previous prejdices とは違ったものでした。
わたしはCプログラムの、ランダムにsegfaultし、データを食い、Lindisfarneへ向かう在りし日の
ヴァイキングのように振舞うという考えを暗黙のうちに受け入れていたのです。対照的に、
“高水準の”プログラミング言語で書かれたプログラムはうまいこと予測したパターンで
失敗することを期待できます。
Gradually it occurred to me that virtually all of the software that I use on a daily a basis
- that to which I entrust my most important data - is written in C. And I can't remember
the last time there was a major problem with any of this software - it's reliable in 
the sense that it doesn't crash, and also reliable in the sense that it handles minor 
failures gracefully.
#自分が日々使っていたソフトウェアのすべて(自分の大事なデータを任せていたような)が
#Cで書かれていたこと。
#それらのソフトウェアは、いつ大きな問題を起こすようなことがあったのか思い出せないくらい
#信頼できるものだった。
#クラッシュもしないし、小さな問題があっても対処できた云々。
なるほどわたしは自分が使っているソフトウェアについてとんでもなく神経質(fussy)でしたし
(わたしはもう9年かそこいらの間 OpenBSDユーザーです。
and software doesn't get much better than that)、
信頼性が高いということのいくつかの明白な理由が存在していました。
そういったソフトウェアは(相対的に)多くの、それもバグを炙り出すのを手助けできるような
人たちに使われたものであったのです。
ソフトウェアというものは長い時間をかけて開発されるものであったので
previous generations (先の年代の開発者たち?)はバグと対面することに
うんざりしていたのです。また率直に言ってしまえば(if we're being brutally honest)、
only fairly competent programmers tend to use C in the first place.
#十分卓越した力量を持ったプログラマーたちだけが first place にあるCを
#使おうとすることになるでしょう。
しかしまだ、根本的な疑問が残されています。なぜそんなにもたくさんのわたしが使っていた
Cによって書かれたソフトウェアはあれほどまでに信頼できるものであったのでしょうか?

#Lindisfarne → http://en.wikipedia.org/wiki/Lindisfarne
#In A.D. 793 (796 per some authorities), a Viking raid on Lindisfarne caused much 
#consternation throughout the Christian west, and is now often taken as the beginning 
#of the Viking Age. The Anglo-Saxon Chronicle records:
#
#    In this year fierce, foreboding omens came over the land of Northumbria. There 
#    were excessive whirlwinds, lightning storms, and fiery dragons were seen flying in the 
#    sky. These signs were followed by great famine, and on January 8th the ravaging of 
#    heathen men destroyed God's church at Lindesfarne.
#
#The more popularly accepted date for the Viking raid on Lindisfarne is June 8; Michael 
#Swanton, editor of Routledge's edition of the Anglo-Saxon Chronicle, writes "vi id 
#Ianr, presumably [is] an error for vi id Iun (June 8) which is the date given by the 
#Annals of Lindisfarne (p. 505), when better sailing weather would favour coastal raids."
#Alcuin, an English monk of that period, noted:
#
#    Never before has such terror appeared in Britain as we have now suffered from a 
#    pagan race. . . .The heathens poured out the blood of saints around the altar, and 
#    trampled on the bodies of saints in the temple of God, like dung in the streets.



After a dark period of paper writing, I've recently been doing a little bit of C 
programming. As someone who, at some points, spends far too much time away from home, 
reliably sending e-mail has always been an issue. For several years I have sent e-mail 
by piping messages to a sendmail process on a remote machine via ssh. While this 
solves several problems (e.g. blacklisting), it has the problem that on many networks 
(particularly wireless networks) a surprising number of network connections get 
dropped. Checking that each e-mail has been sent is a frustrating process. So, having 
mulled on its design for a little while, I decided to create a simple utility to 
robustly send e-mail via ssh. The resulting program - extsmail - has more features 
than I'd originally expected, but the basic idea is simply to retry sending messages 
via an external command such as ssh, until the message has been successfully sent. I 
also wanted the utility to be as frugal with resources as practical, and to be as 
portable as possible. This inevitably led to extsmail being written in C. I then 
decided, as an experiment, to try and write this, as far as possible, in the 
"traditional" UNIX way: only to rely on features found in all sensible UNIX clones and 
to be robust against failure. In so doing, I made two observations, new to me, about 
writing software in C.

After a dark period of paper writing, I've recently been doing a little bit of C 
programming. As someone who, at some points, spends far too much time away from home, 
それぞれのe-mailがすでに送信されたかどうかを調べることはフラストレーションが溜まる手続きです。
ですから、
having mulled on its design for a little while,
わたしはssh経由でrobustly にe-mailを送るための単純なユーティリティを作ることにしたのです。
その結果できたプログラム(extsmail といいます)は最初にわたしが見込んだよりも多くの機能を
持っていますが、基本的な考えかたはsshのような外部コマンドを経由してただ単にメッセージの
送信のリトライをするというものです。わたしはまた、現実的なレベルでリソースを節約しつつ
可能な限り可搬性のあるようなユーティリティであることを欲していました。
こういったことから必然的に extsmail はCで書かかれることになったのです。

The first observation is semi-obvious. Because software written in C can fail in so 
many ways, I was much more careful than normal when writing it. In particular, 
anything involved in manipulating chunks of memory raises the prospect of off-by-one 
type errors - which are particularly dangerous in C. Whereas in a higher-level 
language I might be lazy and think "hmm, do I need to subtract 1 from this value when 
I index into the array? Let's run it and find out", in C I thought "OK, let's sit down 
and reason about this". Ironically, the time taken to run-and-discover often seems not 
to be much different to sit-down-and-think - except the latter is a lot more mentally 
draining.

最初の observation はややはっきりしたもので、Cで書かれたソフトウェアはあまりにも多くの原因で
failする可能性があるということです。わたしは通常よりも非常に注意深くプログラムを書きました。
特に、off-by-one type error (一個ハズレエラー)の類が予想される
メモリのチャンクを操作する箇所がそうでした。一個ハズレエラーはCにおいては特に危険な代物です。
高水準言語であれば 
“うん? 配列の添え字を指定するときにはこの値から1引かないといけないのかな?
じゃあ走らせて調べてみようか”と怠けることができます。
Cの場合わたしはこう考えました
"OK, let's sit down and reason about this"
#座ってからこれについて論じてみよう?
皮肉なことですが、run-and-discover に費やされる時間というのはほとんどの場合において
sit-down-and-think のときとそう変わるものでもないのです。
後者の方がより精神的に消耗するということを除けば。ですが。



The second observation is something I had not previously considered. In C there is no 
exception handling. If, as in the case of extsmail, one wants to be robust against 
errors, one has to handle all possible error paths oneself. This is extremely painful 
in one way - a huge proportion (I would guess at least 40%) of extsmail is dedicated 
to detecting and recovering from errors - although made easier by the fact that UNIX 
functions always carefully detail how and when they will fail. In other words, when 
one calls a function like stat in C, the documentation lists all the failure 
conditions; the user can then easily choose which errors conditions he wishes his 
program to recover from, and which are fatal to further execution (in extsmail, out of 
memory errors are about the only fatal errors). This is a huge difference in mind-set 
from exception based languages, where the typical philosophy is to write code as 
normal, only rarely inserting try ... catch blocks to recover from specific errors 
(which are only sporadically documented). Java, with its checked exceptions, takes a 
different approach telling the user "you must try and catch these specific exceptions 
when you call this function".


二番目の意見はわたしがそれまで考えたことがなかったようなことです。
Cには例外処理機構がありません。extsmail がそうだったように、
ある人はエラーに対して robust (頑丈、頑強)であろうとするでしょうし
またある人は可能性のあるすべてのエラーを自分の手で処理する必要があるでしょう。
たった一つの方法でエラー処理を行ってしまうということはとても痛みを伴うものです。
extsmailのかなりの部分(少なくとも40%はあると思います)が
エラーを検出とリカバリに費やされていました。
これはUNIXの関数がどのようなときにどうやって失敗するかについて
常に事細かに決まっているにも関わらず。です。
言い換えると、Cの statのような関数を誰かが呼び出したとき、
そのドキュメントはその関数での失敗条件 (failure condtions)をリストアップしているということです。
ユーザーはそうした後にエラーの状況(errors conditions)に応じて選択を容易に行うことができるのです。
プログラムをエラーから復帰させるのか、あるいはそれ以上の実行が不可能なのか
(extsmailではメモリーの確保失敗だけが実行中断となるエラーでした)などなど。
これは例外ベースの言語から来る mind-set とは非常に異なったものです。
checked exceptions を持ったJavaはユーザーに対して
"you must try and catch these specific exceptions when you call this function".
(あなたがこの関数を呼び出すときには特定の例外に対する try と catch を行わなければならない)
と通知するという異なるアプローチを取っています。


What I realised is that neither exception-based approach is appropriate when one 
wishes to make software as robust as possible. What one needs is to know exactly which 
errors / exceptions a function can return / raise, and then deal with each on a 
case-by-case basis. While it is possible that modern IDEs could (indeed, they may well 
do, for all I know) automatically show you some of the exceptions that a given 
function can raise, this can only go so far. Theoretically speaking, sub-classing and 
polymorphism in OO languages means that pre-compiled libraries can not be sure what 
exceptions a given function call may raise (since subclasses may overload functions, 
which can then raise different exceptions). From a practical point of view, I suspect 
that many functions would claim to raise so many different exceptions that the user 
would be overwhelmed: in contrast, the UNIX functions are very aware that they need to 
minimise the amount of errors that they return to the user, either by recovering from 
internal failure, or by grouping errors. I further suspect that many libraries that 
rely on exception handling would need to be substantially rewritten to reduce the 
number of exceptions they raise to a reasonable number. Furthermore, it is the caller 
of a function who needs to determine which errors are minor and can be recovered from, 
and which cause more fundamental problems, possibly resulting in the program exiting; 
checked exceptions, by forcing the caller to deal with certain exceptions, miss the 
point here.

わたしが理解したのは、例外に基づくアプローチというものがプログラムの作り手がソフトウェアを
可能な限り頑丈 (robust)にすることを望んだときにとられるアプローチであるということでした。
作り手人が必要としていることが errors / exceptions a function can return / raise 
のいずれであるのかを正確に知りたいということであるとき、
それぞれをどのように処理するかはケースバイケースになります。
近代的な IDE では自動的に与えられた関数がどのような例外を発生させるのかを
あなたに教えることも可能です。
this can only go so far.
理論的なことを言えば、オブジェクト指向言語における
サブクラス化 (sub-classing) と多態 (polymorphism) はコンパイル済みのライブラリが
与えられた関数呼び出しがどのような例外を送出する可能性があるかを保証することができません
(サブクラス化によって関数のオーバーロードが行われて異なる例外が送出される可能性がある)。
現実的な観点で言えば、わたしは多くの関数が数多くの異なる例外を送出すると主張 (claim)していて
ユーザーはそれを overwhelmed (制圧する?)しているのではないかと疑っています。
それとは対照的に、UNIXの関数はユーザーに対して返却するエラーの総量を最小限に
することに注意を払っています。それは
either by recovering from internal failure, or by grouping errors. 


Henry Spencer said, "Those who don't understand UNIX are doomed to reinvent it, poorly."
And that's probably why so many of the programs written in C are more 
reliable than our prejudices might suggest - the UNIX culture, the oldest and wisest 
in mainstream computing, has found ways of turning some of C's limitations and flaws 
into advantages. As my experience shows, I am yet another person to slowly realise 
this. All that said, I don't recommend using C unless much thought has been given to 
the decision - the resulting software might be reliable, but it will have taken a 
significant human effort to produce it.

ヘンリー・スペンサーはこう言いました。
「UNIXを理解できない者たちはUNIXを再発明する運命にある。それも劣化した形で」
そしてこれこそがおそらく、あれほど多くのCで書かれたプログラムが
our prejudices might suggest よりも信頼性があるということの理由です。
UNIX文化はコンピューティングのメインストリームにあってもっと古く最も賢いものであり、
いくつかのCの制限と欠点とを利点に転換する手段を見つけ出してきました。
わたしの経験が示すように、わたしは未だ another person to slowly realise this です。
結論を申し上げると、much thought has been given to the decision
#決定を下すのに十分な思考を行うことができる?
でない限りは、Cを使うことをわたしはお奨めしない。ということです。
前提が満たされるのであればソフトウェアは信頼性あるものにできるかもしれません。
しかし、そういった信頼性あるソフトウェアを作り出すためには
多大な労力 (significant human effort) が必要となることでしょう。

  

お願いだから ; とか : とか, とか - とか使いまくって長文にするの止めて○| ̄|_

■_

2008年12月08日

■_

・トライグラフひでえw
melancholic afternoon 12月6日_ いつまでもたたられそうな。

Ruby 1.9 - Bug #830: Encoding::UndefinedConversionError - Ruby Issue Tracking System

・新山さんの長いエントリを読める月曜日の朝。


Brainf*ckとWhitespaceの本を書きましたwwww 正確には、「Brainf*ckとかWhitespaceのような言語の処理系を作りつつ、新しいプログラミング言語を作るところまでを解説した本」ですね。 12/20発売です。 む。チェックせねばw

・Excel
とりあえず140選、他2冊 - 予定は未定Blog版 あれもこれもと揃えると泥沼なのでアレですが、 VBAの辞典(のような体裁のもの)とか逆引きできるようなものがあるといいですよ。 操作全般などの解説本ではこの辺がお薦め。


EXCELビジネス関数・数式 ビジテク

EXCELビジネス関数・数式 ビジテク 2000/2002/2003/2007対応 (ビジテクBUSINESS TECHNIQUE)
EXCELビジネスデータ分析 ビジテク 2007対応

EXCELビジネスデータ分析 ビジテク 2007対応 (ビジテクBUSINESS TECHNIQUE)
EXCELビジネス文書作成 ビジテク 2007 / 2003 / 2002対応 

EXCELビジネス文書作成 ビジテク 2007/2003/2002対応 (ビジテクBUSINESS TECHNIQUE)


Excelの極意

Excelの極意(1) 「データ入力と書式・印刷」を極める Excel 2007/97~2003対応 (Excelの極意 1)

Excelの極意(2) 「数式」を極める Excel 2007/97~2003対応 (Excelの極意 2)

Excelの極意(3) 「関数」を極める Excel 2007/97~2003対応 (Excelの極意 3)

Excelの極意(4) 「魅せるグラフ」を極める Excel 2007/97~2003対応 (Excelの極意 4)

Excelの極意(5) 「データの集計と分析」を極める Excel 2007/97~2003対応 (Excelの極意 5)

Excelの極意(6) 「VBA」を極める Excel 2007/97~2003対応 (Excelの極意 6)

もちろん全部を揃える必要なんてなくて、必要なところを書いているのを買えば十分だと思います。 わたし自身はチャート(グラフ作成)の巻に非常にお世話になりました。 その後お礼の意味も兼ねて他の巻も買ってしまったのですがw

・味付け
なぜみんなあんなに濃い味つけが好きなんだろう。 以前聞いた話では、薄い味付けだと「味がついてない」とクレームをつける人が結構いるからだとか。


それはそれとして、猫、ねぇ。なんで? たぶんそれは 猫でもわかるプログラミング C言語編 第一部 猫でもわかるプログラミング C言語編 第二部 猫でもわかるプログラミング >C++編 第一部 猫でもわかるプログラミング >C++編 第二部 この辺の影響ではないかと。

■_ タイムリー?

PHP5.3.0alpha3のround関数の実装がPHP5.2.6と変わった - hnwの日記 いや、先週後半からの プログラミング質問すれ Part1 で盛り上がってた話題と共通するなあと。

PHP5.3.0alpha3のround関数の実装がPHP5.2.6と変わった - hnwの日記
12月4日付でPHP5.2.7とPHP5.3.0alpha3が同時リリースされましたが、これに関連して毎度おな
じみPHPのround関数の話題です。相変わらず記事は長いので簡単なまとめから。

    * PHP5.3.0alpha3ではこれまでのPHPのいずれとも違うround関数が実装されました。少々疑問
      は残るものの、比較的マシな実装だと僕は考えています。今回は0.50000000001のような不思
      議な数は含まれていませんし、問題が起こる例が以前より減ったように思います。

          o 第3引数で丸め方式を選択できるようになりました。四捨五入(デフォルト)や偶
            数丸めなど、4種類の丸め方式が選択可能です。


背景

以下、現時点での僕の理解を書いていきます。

PHPでは、bugs #24142への対応として、PHP 5.1.0からPHP_ROUND_FUZZという定数が導入されま
した。これは、10進小数で考えれば不思議な丸め結果になることへの防止策として、正の数を丸
める場合であれば0.5を足してから切り捨るはずのところを、一部環境のみ0.50000000001(fuzz)
を足す、というものです(参考:「PHPの奇妙なround関数」)。浮動小数点数への理解度が低い
初心者が混乱するのを防ぐための修正と言っても構わないと思います。

この実装に対し、「俺がもっとマシな実装を考えたぜ!」という人がPHP本家に
http://wiki.php.net/rfc/roundingという文章を送りつけ、提案が採用されてPHP5.3.0alpha3か
ら実装された、というのが今回の変更です。

新しいround関数の実装

(さっくり略)

PHPの新しい実装は素直な実装に比べると複雑な計算をしており、正確な結果が得られるという
よりは、誤差が蓄積しそうな計算に見えます。この意味について説明します。

(略)

良くなった点(1)

今回の実装がfuzzを使った実装より優れている点の1つ目は、整数への丸め(小数点以下第1位で
の四捨五入)で妙な誤差が入らなくなったことです。round(0.49999999999999)は0になるように
なりました。整数への丸めについては、今回の実装は素直な実装(=他の言語のround関数)と
同一です。

良くなった点(2)

ここで、例のfuzzの導入のきっかけになったとも言える「初心者の混乱」について見直してみま
す。実は、これまでのfuzzでは目的を果たせない例があります。

$ php-5.2.6 -r 'var_dump(round(1111111.265, 2));'
float(1111111.26)


浮動小数点数は少し小さくなることがあるから、0.5より少し大きい数を足してしまおう、とい
うのがfuzzの意図だったわけですが、対象の数が大きくなってくると情報落ちが起こってしまい、
fuzzが無視されてしまうのです。

「初心者の混乱」への対策の意味では、PHP5.3.0の実装は完璧です。今回は近い数を同一視する
方針にしたため、大きい数が対象でも目的を果たします。

$ php-5.3.0 -r 'var_dump(round(1111111.265, 2));'
float(1111111.27)


良くなった点(3)

浮動小数レジスタが80bitな環境でも、64bitでroundの計算を行うようになったようです。環境
の差がなくなる方が混乱は小さいでしょう。

良くなった点(4)

round関数が第3引数を受けつけるようになりました。四捨五入(Round half up)だけでなく、
Round half down、偶数丸め(Round half even)、Round half oddのいずれかが選べます。誰が
喜ぶのかは疑問ですけど。

感想など

僕の意見としては、どうせround関数なんて精度を落とす演算なんだから、そこまでひどくなけ
ればどんな実装でもいいと思うんですね。そこまで細かい挙動の差が影響するコードを書く人な
らCのソースコードを流し読みするくらいは神経を使うでしょうから、そんな人たちへの気配り
は無用です。ただ、今までその実装について一切ドキュメントが無かったのがひどい点だという
のがこれまでの僕の主張です。

今回の実装についても、ドキュメントが残るという点について非常に素晴らしいと思います。中
身については、数学的根拠がある実装かと想像していたので少しガッカリしましたが、今までの
実装よりは良い実装だと僕は思っています。

ふむ。まあ結果だけを見て「おかしいだろこれ」と騒ぐ人は一定数はいると思いますから、 莫迦避けにはなるかなあと。 金がらみの計算とかは浮動小数点数使うなつーても通じないでしょうしねえ(苦笑)

■_ stackoverflow で訊いてみた

Are you a self taught programmer or did you take a programming course?

Lots of developers I know were self taught programmers including me.

I was wondering how much of the developer community learned programming by taking a 
course in school or by experimenting, asking questions on forums, reading online 
articles, and just making it up as you go along? Post whether you were self taught or 
took classes, what language you program in, and anything else that may be interesting.

P.S. Books count as self taught.

http://stackoverflow.com/questions/332808/development-cost-of-procedural-programming-vs-oop

Development Cost of Procedural Programming vs. OOP?

I come from a fairly strong OO background, the benefits of OOD & OOP are second nature 
to me, but recently I've found myself in a development shop tied to a procedural 
programming habits. The implementation language has some OOP features, they are not 
used in optimal ways.

Have there been any good comparative studies contrasting the cost of software 
development using procedural programming languages versus Object Oriented languages?
http://stackoverflow.com/questions/346061/did-you-feel-learning-to-program-with-turtle-graphics-was-useful

Did you feel learning to program with turtle graphics was useful?

I'm preparing to teach someone to program. When I learned the course material used 
turtle graphics for the first few exercises. In reading introductory textbooks I have 
not found one that uses the technique. Did others find this approach helpful. If not 
what is a better way to learn to program?
http://stackoverflow.com/questions/348526/programming-by-guessinghoping
Programming by guessing/hoping


The Visual Studio IDE gives the developer almost instant feedback as to whether or not 
a block of code is correct or a program runs correctly. This usually leads to 
programming by guessing... The programmer thinks to themselves, "Maybe the 
intellisense will tell me it's right if I do it like this..." or "Maybe if I change 
this constant to that or change this loop and click play it'll work..."

I usually fall into this mode when I'm tired or have my mind on other issues (i.e. 
just don't care ATM). It's sometimes hard to break out of this "mode of operation" 
because you want to get something done but at the same time you aren't thinking about 
what you're doing. It's a viscous cycle.

What are some causes of this type of programming and how do you recognize (i.e. catch 
yourself) when you've fallen into this trap and correct it? Or perhaps a better 
question, how do you prevent it?

(I'm referring more to writing new code or getting a block of code to work than 
debugging existing code, although it could apply to debugging existing code too.)

Think instant gratification.
Books, tutorials, references on Haskell for experienced functional programmer - Stack Overflow
http://stackoverflow.com/questions/341983/books-tutorials-references-on-haskell-for-experienced-functional-programmer

Is there a good description of the "system call" mechanism used in OSes? - Stack Overflow
http://stackoverflow.com/questions/126976/is-there-a-good-description-of-the-system-call-mechanism-used-in-oses

■_ Python 3.0

3.0がらみでいろいろ発表されてますが、追いかけてる余裕ががががが。

Lucumr Cogitations » Blog Archive » Porting to Python 3: Do's and Don'ts
Porting to Python 3: Do’s and Don’ts

So. Python 3 is here and everybody is happy. Now the community expects everyone who 
wrote a library to port it over to Python 3. So here my experiences so far:

Don'ts

Let’s start with the things you should not do.

    * Use py.test for your testsuite. The developers told me that they do not plan to 
      adapt it to Python 3 in the near future. (略)


    * Forking your library for Python 3. Don’t do that. If you can’t create a 
      version that comes out of 2to3 and passes your testsuite do not try to hand correct 
      the code generated. (略)

    * Drop 2.5 support. I know converting libraries is easier if you can just support 
      2.6 and 3.0 but until Linux distributions / OS X ship up to date Python versions it 
      will take some time. You will only hurt your users with such a decision.

Dos

Now to what you should do

    * Report problems with 2to3 as soon as possible and suggest improvements. From 
      what I saw so far 2to3 is a nice tool but it needs a lot of post-converting fixes 
      which are unacceptable. (略)


That’s it for the moment. Concrete tips for porting specific idoms over will come 
once that is possible :)

2.5も切り落とせ。ですか。

■_

うはは名刺入れじゅーよー。 会社のでない名刺をもっと変えたいんだけど、そっち方面の才能は致命的に欠けてるからなあ(^^;

Perl関連でもなんか一部盛り上がってる気配がある(Perl5 is Dying とかあたりが引き金?) けど、あとで忘れなければまとめる。

DJB様ごめんなさい | Selfkleptomaniac
http://selfkleptomaniac.org/archives/794

Do programmers read books? Or is the book industry dead? - Stack Overflow
http://stackoverflow.com/questions/347821/do-programmers-read-books-or-is-the-book-industry-dead

David McLaughlin » How I learnt to love Perl
http://www.dmclaughlin.com/2008/12/07/how-i-learnt-to-love-perl/

Computerworld - Perl 6 to break compatibility, support other interpreters
http://www.computerworld.com.au/article/269758/perl_6_break_compatibility_support_other_interpreters?eid=-6787

Journal of Ovid (2709)
http://use.perl.org/~Ovid/journal/38018

Journal of Ovid (2709)
http://use.perl.org/~Ovid/journal/38010

CSV Mapper
CSV Mapper
Simple Usage Example

require 'csv-mapper'

include CsvMapper

results = import('/path/to/file.csv') do
  start_at_row 1
  [first_name, last_name, age]
end

results.first.first_name  # John
results.first.last_name   # Doe
results.first.age         # 27

使いやすそうだけど速度面ではどうなんだろうか?

2008年12月07日

■_

http://www.nicovideo.jp/watch/sm5377306

・12/7
12月7日が日曜なのは1941年と一緒(真珠湾奇襲の年)と同じだねえ。 などとついったでつぶやいた。

・散髪
いつも通っている床屋に(美容室はどうも)。 いろいろと景気の悪い話などした。

■_

今週は豊作?で量的にもタイヘン。


【逆立ちしても】使えない新人 0x18
124 仕様書無しさん [sage] Date:2008/12/03(水) 00:48:56  ID: Be:
    ちょっとずれた新人がいるんだが、
    初めて客先につれてくんで、いつもの私服じゃなくて
    フォーマルな格好してこっていったら
    タキシード着てきたorz 

125 仕様書無しさん [sage] Date:2008/12/03(水) 00:51:17  ID: Be:
    かっこいい新人だなぁwww 

126 仕様書無しさん [sage] Date:2008/12/03(水) 01:17:16  ID: Be:
    知らないなりにがんばって解釈しようとするのはむしろ微笑ましかったりするけど、
    考える角度が違ってると・・・・・・ 

127 仕様書無しさん [sage] Date:2008/12/03(水) 04:28:43  ID: Be:
    フォーマルって言われたら普通タキシードだよな。
    「スーツ着てこい」って言わなかった >124 が悪い。 
【逆立ちしても】使えない新人 0x18
138 仕様書無しさん [sage] Date:2008/12/05(金) 00:08:35  ID: Be:
    うちの新人君はパスワードもかけずにつけっぱで帰るな 

139 仕様書無しさん [sage] Date:2008/12/05(金) 09:11:19  ID: Be:
    ロックせずに席を外してる新人には漏れなく勝手に恥ずかしい壁紙に変更の刑

    ってやってたら >>138 みたいなのは無くなった
    ちなみに伝統らしい 

140 仕様書無しさん [sage] Date:2008/12/05(金) 09:50:46  ID: Be:
    >>139
    え?キャプチャーしたスクリーンを壁紙にして、
    画面は全部最小化して、閉じられない画面をニヤニヤするのが伝統だろ? 

141 仕様書無しさん [sage] Date:2008/12/05(金) 10:10:45  ID: Be:
    >>140
    それも含むw

    けっこう時間のかかる処理が固まったと勘違いしてリブートしてたな
    さすがに良心が少し痛んだ

144 仕様書無しさん [sage] Date:2008/12/05(金) 13:47:15  ID: Be:
    >>140-141
    俺は前新人にそれやったら、新人がコンセントを引っこ抜くという暴挙をし、
    そのコンセントがまた島の大元で全員のPCが一瞬で電源落ち、
    大騒ぎになったということがw

    やる方は楽しいが、やる奴を選ばないとこっちがとばっちり食らうので注意 

146 仕様書無しさん [sage] Date:2008/12/06(土) 08:29:11  ID: Be:
    デスクトップをキャプチャして壁紙化。 

147 仕様書無しさん [sage] Date:2008/12/06(土) 12:49:05  ID: Be:
    >>146
    >>140-141,>>144 

148 仕様書無しさん [sage] Date:2008/12/06(土) 15:27:54  ID: Be:
    俺も >>139 はやったことあるけど、みんな結構おもしろい事やってんなぁw
    >>142 とか、専用ツールでも作り込んで配ってみるかw

    >>144
    最近、うちじゃみんなノートを複数台になってきてて、
    それは被害が出ないなw 

149 仕様書無しさん [sage] Date:2008/12/06(土) 17:25:35  ID: Be:
    壁紙とスクリーンセーバーをゆめりあに変えたあげく、ポリシー弄って易々と
    戻せないようにしてやった15の夜 

150 仕様書無しさん [sage] Date:2008/12/06(土) 22:51:40  ID: Be:
    昔、新人のPCのtelnetのサービスをこっそりと自動起動にしといて
    ときどきログインしていたずらしたりしたことはある。 



プログラミング質問すれ Part1

258 名無しさん@お腹いっぱい。 [] Date:2008/12/04(木) 02:14:01  ID: Be:
    C言語で質問なんですが、二つの実数が小数点1ケタまで等しいとき
    に~するみたいにしたいんですけど、
    if(a == b){
    ~
    }
    ってやったら実数が完全に等しくないといけないじゃないですか・・・
    どうやれば上記のようにできますか? 

259 名無しさん@お腹いっぱい。 [sage] Date:2008/12/04(木) 02:25:28  ID: Be:
    丸めろ

260 258 [] Date:2008/12/04(木) 09:07:24  ID: Be:
    丸めるってなんですか?
    初心者なのであまりくわしくないです。 

261 名無しさん@お腹いっぱい。 [sage] Date:2008/12/04(木) 09:56:38  ID: Be:
    珍しいスレが上がってると思ったら
    なんだ、釣りか…… 

262 名無しさん@お腹いっぱい。 [sage] Date:2008/12/04(木) 10:19:18  ID: Be:
    >>259
    引っかけ問題に引っかかったね。

    「小数点1ケタまで等しい」→「小数点1ケタ目までの数字が同じ」
    だから、丸めたら不正解。 

263 名無しさん@お腹いっぱい。 [sage] Date:2008/12/04(木) 10:24:13  ID: Be:
    if (fabs(a - b) < 0.1) 

264 名無しさん@お腹いっぱい。 [sage] Date:2008/12/04(木) 10:27:49  ID: Be:
    >>263
    それだと 1.09 と 1.1 でも一致とみなされる

    >>262 参照 

265 名無しさん@お腹いっぱい。 [sage] Date:2008/12/04(木) 10:31:23  ID: Be:
    >>262 は抜きして、丸める方式でOKだとしても、

    >>263 だと 1.11 と 1.02 が一致と判定されるから駄目だな 

266 名無しさん@お腹いっぱい。 [sage] Date:2008/12/04(木) 10:42:06  ID: Be:
    1.11と1.02は偽
    1.00と1.09は真

    実際はこんな比較を行いたいわけがない。 

267 名無しさん@お腹いっぱい。 [sage] Date:2008/12/04(木) 10:48:37  ID: Be:
    >>266
    数値符号の生成処理なんかだと、
    文字通りの数字の一致を判定したいことがあるよ。

    1.11と1.02は偽
    1.00と1.09は真

    そういう比較を行ないたい。 

268 名無しさん@お腹いっぱい。 [] Date:2008/12/04(木) 11:08:11  ID: Be:
    文字列化シロ

269 名無しさん@お腹いっぱい。 [sage] Date:2008/12/04(木) 11:13:46  ID: Be:
    なんで誰も10倍してfloorしろとアドバイスしてやらないんだ 

270 名無しさん@お腹いっぱい。 [sage] Date:2008/12/04(木) 11:57:36  ID: Be:
    オーバーフローするかもしれんじゃん。 

271 名無しさん@お腹いっぱい。 [sage] Date:2008/12/04(木) 14:18:50  ID: Be:
    そんなでかいdoubleなら、小数点以下は0だから、別チェックを前に入れるだけ 

272 名無しさん@お腹いっぱい。 [] Date:2008/12/04(木) 20:04:28  ID: Be:
    >>269にツッコミを入れるなら floorでなくてIntだろ。
    floorだと-2.0と-2.3が違う値になる。
    だから不正解
    それと実数は10倍してintだと化けることがあることを忘れるな。
    整数部と小数部を分離して
    整数部チェックの後
    小数部の判定をすればいい 

273 名無しさん@お腹いっぱい。 [sage] Date:2008/12/04(木) 20:09:49  ID: Be:
    そろそろ正しいコード書いて見せろよ 

275 名無しさん@お腹いっぱい。 [sage] Date:2008/12/04(木) 22:10:07  ID: Be:
    んじゃ、俺が。

    int compare(double a, double b)
    {
    char s1[512], s2[512], p;

    snprintf(s1, sizeof(s1), "%f", a);
    if ((p = strchr(s1, '.')) && p[1])
    p[2] = 0;

    snprintf(s2, sizeof(s2), "%f", b);
    if ((p = strchr(s2, '.')) && p[1])
    p[2] = 0;
    return !strcmp(s1, s2);
    } 

276 名無しさん@お腹いっぱい。 [sage] Date:2008/12/05(金) 07:10:19  ID: Be:
    >>275
    そんなことしなくても、
    sprintf() で "%.1f" のフォーマットで文字列化すれば
    最初から小数点以下第1位までで文字列カットできる。 

277 名無しさん@お腹いっぱい。 [sage] Date:2008/12/05(金) 07:16:16  ID: Be:
    >>276
    アフォか。"%.1f" だと丸められてしまうだろ。 

278 名無しさん@お腹いっぱい。 [sage] Date:2008/12/05(金) 08:58:20  ID: Be:
    指摘される前になおしておこう。

    int compare(double a, double b)
    {
    char s1[512], s2[512], *p;

    snprintf(s1, sizeof(s1), "%f", a);
    if ((p = strchr(s1, '.')) && p[1])
    p[2] = 0;

    snprintf(s2, sizeof(s2), "%f", b);
    if ((p = strchr(s2, '.')) && p[1])
    p[2] = 0;
    return !strcmp(s1, s2);
    } 

279 名無しさん@お腹いっぱい。 [sage] Date:2008/12/05(金) 09:27:12  ID: Be:
    >>278
    別の指摘するよ。

    "%f" は、デフォで小数以下6桁精度に丸められる。("%.6f"と同じ)
    なので、1.9999999 が、2.0 に丸められてしまう。 

280 名無しさん@お腹いっぱい。 [sage] Date:2008/12/05(金) 10:44:50  ID: Be:
    ふむ、10倍するのも計算誤差で小数点第1位が変わる可能性があるな。
    そもそも、外部表現から浮動小数点に変換した時点で誤差が発生するから、
    BCD使えという結論か。 

281 名無しさん@お腹いっぱい。 [sage] Date:2008/12/05(金) 11:20:41  ID: Be:
    丸め方式はFPUに指定コードを与えれば変えることができる。
    そもそも精度を取り違えている。6桁の精度に対して10桁の演算精度があるなら
    最下位2桁部分の丸めで精度が狂うことはない。
    それは最初の質問者が「文字」で質問していたことでも分かる。

    今回の場合無理に比較するのではなくて
    二つの引き算した結果の符号をとって(絶対値化)
    その値から0.1引いた値が正ならfalse
    というのが一番無難。

282 名無しさん@お腹いっぱい。 [sage] Date:2008/12/05(金) 11:39:11  ID: Be:
    >>281
    それ、>>263 と同じ。
    263は、>>264-265 で否決。 

283 名無しさん@お腹いっぱい。 [sage] Date:2008/12/05(金) 12:04:28  ID: Be:
    IEEE 754 として、10倍して整数部をとったんじゃだめな具体例を誰かプリーズ。

284 名無しさん@お腹いっぱい。 [sage] Date:2008/12/05(金) 13:03:09  ID: Be:
    >>283 仮数部フルにつかってたらだめだろ。
    せめて整数化して小数部だけにしてからからという前提にシロ

285 名無しさん@お腹いっぱい。 [sage] Date:2008/12/05(金) 13:15:16  ID: Be:
    だから、具体例を。

    double f = 0.1;
    f = floor(f*10.0);
    printf("%d\n",f==1.0);

    => 1

    だよ。 

286 名無しさん@お腹いっぱい。 [sage] Date:2008/12/05(金) 14:38:49  ID: Be:
    a = 300000000000000.3125;
    b = 300000000000000.3750;
    printf("%f %f %d\n", a, b, floor(a * 10) == floor(b * 10));

287 名無しさん@お腹いっぱい。 [sage] Date:2008/12/05(金) 17:36:14  ID: Be:
    なるほど。わかったよ。

    正に限ると、
    floor(a) == floor(b) && floor((a-floor(a))*10) == floor((b-floor(b))*10)
    でおけ? 

288 258 [] Date:2008/12/05(金) 23:03:41  ID: Be:
    ちなみに実数は0より小さいです。それで小数点2桁目を四捨五入したいです。
    一応自分で作ったんですが

    double x=0.15;
    int a;
    x+=0.05;
    a=x*10;
    x=(double)a/10.0;

    これで大丈夫ですかね? 

289 258 [] Date:2008/12/05(金) 23:04:35  ID: Be:
    ↑間違えました。0でなく1より小さいです。 

290 名無しさん@お腹いっぱい。 [sage] Date:2008/12/05(金) 23:05:41  ID: Be:
    >>267
    お前らあほだな。


    sprintfとstrncmpで解決だろ。 

296 名無しさん@お腹いっぱい。 [sage] Date:2008/12/06(土) 00:29:52  ID: Be:
    >>288
    0より小さい実数は負なのだが…
    中学数学をやり直せ。 

297 名無しさん@お腹いっぱい。 [sage] Date:2008/12/06(土) 10:16:03  ID: Be:
    >>296
    0より小くて負よりも大きい数oがあるとしたら? 

298 名無しさん@お腹いっぱい。 [sage] Date:2008/12/06(土) 10:40:46  ID: Be:
    >>290
    sprintf()する時に、"%f"の変換で勝手に四捨五入されるから不可。 

299 名無しさん@お腹いっぱい。 [sage] Date:2008/12/06(土) 10:48:11  ID: Be:
    >>297
    そんな実数があるのか? 

300 名無しさん@お腹いっぱい。 [sage] Date:2008/12/06(土) 11:37:11  ID: Be:
    1.0以下なら
    10倍説でいいけれど >>287はかっこが足りないだろ
    それに正が前提と言うならfabsなりabsなりいれればいいじゃないか。

    あとsprintf関連のつっこみは四捨五入(rint)じやなくてroundだろ。
    もちょっと「道具の仕様」はしっておこうよ

    double演算でも特定のライブラリーを使っていると高速化のため「singleモード」に設定していて
    丸め誤差も出やすくなったりしていることもある。もっぱらWinに多いけど
    逆にlong doubleにしておけば丸め精度はでにくい。

    今回の場合しょっぱなの「見た目の数字」なんだからsprintfでの誤差は
    最初に認識した文字列にも反映されているはず

    1以下限定なら文字列の段階で整数として入力するか
    文字列できるほうがいい

    しかしネタとして考えるならばbit比較とかマニアックな関数とか
    論理的に完璧なものとかそういうものの方がおもしろい。

    というかUNIX板なんだからネタとして解を求めるならbc前提にするとか
    仮数部のビット比較してみるとか特定ツールにしぼるか
    FreeBSDでのextendedというかlong doubleでの精度アップとか
    もうちょい下のほうにするとかにシチクリ

301 名無しさん@お腹いっぱい。 [sage] Date:2008/12/06(土) 11:47:11  ID: Be:
    使えるツール、足りないツールを作る。それがプログラミング
    できない人は覚えたい。できる人でも穴はある。
    UNIXはツールが多いようでつなぎも情報もすくないんだから
    貴重なスレをあんまり算数の遊びみたいなんでスレを消費するない。
    やるならせめてbcとかシェルとか局所的なものにしちくれ

302 名無しさん@お腹いっぱい。 [sage] Date:2008/12/06(土) 11:50:30  ID: Be:
    >>300
    > >>287はかっこが足りないだろ

    どこが?

    > それに正が前提と言うならfabsなりabsなりいれればいいじゃないか。

    単純に入れたら、正=負とかいう馬鹿な結果が出るから、めんどうだっただけ。 

303 名無しさん@お腹いっぱい。 [sage] Date:2008/12/06(土) 12:27:28  ID: Be:
    貴重なスレって、長寿スレでも狙ってるのか? w
    実数演算の話題はあまりないので結構楽しかったぞ。 

304 名無しさん@お腹いっぱい。 [sage] Date:2008/12/06(土) 12:45:32  ID: Be:
    板違いと思っていたから参戦しなかったが、
    その辺のことはアメリカ人が詳しくまとめてるよ。
    やつらは実数部でドル、小数部でセントを表すことをよくやるから。
    いろいろな言語にBCD演算を入れる提案がつきないのもそのため。
    exact calculation floating point number あたりでググってくれ。
    IEEE 754を仮定して近似計算で、BCD相当の結果を出すものがたくさんある。
    中にはbit演算で正規化されたIEEE 754表現を扱うものまである。

    現代のCOBOL、Javaのページにもこんなんがあるしな。(単純なものだけ)
    http://java.sun.com/developer/JDCTechTips/2001/tt0807.html 

305 名無しさん@お腹いっぱい。 [sage] Date:2008/12/06(土) 12:46:37  ID: Be:
    今のペースだと、Part1なのに10年以上あるスレってか 

306 名無しさん@お腹いっぱい。 [sage] Date:2008/12/06(土) 12:51:59  ID: Be:
    >>304
    それは、内部表現を固定小数というか、
    全部セントに統一しなかったアメリカ人が馬鹿なだけのような 

307 名無しさん@お腹いっぱい。 [sage] Date:2008/12/06(土) 12:58:41  ID: Be:
    金利計算とかあるからセントが最小単位じゃダメだろ。 

308 名無しさん@お腹いっぱい。 [sage] Date:2008/12/06(土) 13:04:25  ID: Be:
    >>300
    お前は roundのことは四捨五入と言わないのか?

    あと、>>287 に括弧が足りないところなんてないし。

    もうちょっと「日本語」と「道具の仕様」は知っておこうよ 

309 名無しさん@お腹いっぱい。 [sage] Date:2008/12/06(土) 13:17:07  ID: Be:
    >>307
    じゃあやっぱりBCD一択。 

310 名無しさん@お腹いっぱい。 [sage] Date:2008/12/06(土) 13:19:59  ID: Be:
    >>300
    おいおい、(s)printfの "%f" 変換は、round() じゃなくて rint() 方式だよ。
    (確認済み) 

313 名無しさん@お腹いっぱい。 [sage] Date:2008/12/07(日) 00:33:16  ID: Be:
    >>309
    組み込みでBCDがないなら、
    オペレーター多重化がないとプログラム書きづらいな。 

314 名無しさん@お腹いっぱい。 [sage] Date:2008/12/07(日) 07:34:44  ID: Be:
    無知晒した >>300 の釈明まだぁ? 

315 名無しさん@お腹いっぱい。 [sage] Date:2008/12/07(日) 10:39:11  ID: Be:
    sprintfで少数第2位まで出しておいて、strncmpで小数点1桁の文字列と比べれば丸めも減ったくれもどうでもいいだろ。 

316 名無しさん@お腹いっぱい。 [sage] Date:2008/12/07(日) 11:47:04  ID: Be:
    >>315
    だから、sprintf()で小数第2位まで出す際に、sprintf()自体で丸めが起きるんだよ。
    printf("%.2f", 1.099) → 1.10 と表示

    あと、×少数 ○小数な、
    日本語くらい正確に使おうよ。 

317 名無しさん@お腹いっぱい。 [sage] Date:2008/12/07(日) 11:51:42  ID: Be:
    >>315
    sprintfで小数第2位まで出す際に、
    小数第3位が丸められるから、
    その結果、小数第1位に繰り上がってしまうことがある。

    よって、>>315 の言ってることは不正解。 

318 名無しさん@お腹いっぱい。 [sage] Date:2008/12/07(日) 12:41:31  ID: Be:
    doubleの有効桁は15~16なので>>278を改造して17桁とれば良い。

    int compare(double a, double b)
    {
    char s1[512], s2[512], *p;

    snprintf(s1, sizeof(s1), "%.17f", a);
    if ((p = strchr(s1, '.')) && p[1])
    p[2] = 0;

    snprintf(s2, sizeof(s2), "%.17f", b);
    if ((p = strchr(s2, '.')) && p[1])
    p[2] = 0;
    return !strcmp(s1, s2);
    } 

319 名無しさん@お腹いっぱい。 [sage] Date:2008/12/07(日) 12:46:13  ID: Be:
    >>318
    …ネタだよな? 

320 名無しさん@お腹いっぱい。 [sage] Date:2008/12/07(日) 22:48:58  ID: Be:
    >>317
    じゃあ4位まで出すか。 

321 名無しさん@お腹いっぱい。 [sage] Date:2008/12/07(日) 23:05:57  ID: Be:
    >>320
    sprintfで小数第4位まで出す際に、
    小数第5位が丸められるから、
    その結果、小数第1位に繰り上がってしまうことがある。

    よって、>>320 の言ってることは不正解。 

322 名無しさん@お腹いっぱい。 [sage] Date:2008/12/07(日) 23:51:11  ID: Be:
    小数点指定なしでいいな。 

round == 四捨五入じゃないから(四捨五入は丸めを行う手法の一つ)ねえ。 それと実際には単純な四捨五入はまず使われないから要注意。 Bankers' rounding (銀行型丸め。でいいのかな?)を調べるよろし。



C言語なら俺に聞け(入門篇) Part 40

424 デフォルトの名無しさん [sage] Date:2008/12/05(金) 18:23:47  ID: Be:
    mallocでNULLが返ったら、あなたならどう対処しますか?
    私はexit 

425 デフォルトの名無しさん [sage] Date:2008/12/05(金) 18:28:24  ID: Be:
    >>424
    エラー表示して終了 

426 デフォルトの名無しさん [sage] Date:2008/12/05(金) 18:33:06  ID: Be:
    >>424
    そんなもんそのプログラムの内容によるとしか言えんだろ 

427 デフォルトの名無しさん [sage] Date:2008/12/05(金) 18:33:09  ID: Be:
    男ならチェックしない 

428 デフォルトの名無しさん [sage] Date:2008/12/05(金) 18:35:24  ID: Be:
    常にexitはないわー 

429 デフォルトの名無しさん [sage] Date:2008/12/05(金) 18:36:54  ID: Be:
    アンケートがやりたいならマ板でやれ 

430 デフォルトの名無しさん [sage] Date:2008/12/05(金) 18:38:25  ID: Be:
    >>424
    場合による。
    もう一度確保を試みたり、例外処理として代行処理関数呼んだり、
    例外処理として関数内gotoしたり、ポインタを返す関数ならNULLを返したり、
    整数を返す関数ならエラーとして整数定数を返したり、続行不可能と判断して
    エラーを吐いてexit()を呼んだりする。 

431 デフォルトの名無しさん [sage] Date:2008/12/05(金) 18:52:19  ID: Be:
    >>424
    頑張って対処します。 

435 デフォルトの名無しさん [sage] Date:2008/12/05(金) 21:19:52  ID: Be:
    >>431
    なんかできることあるの? 

437 デフォルトの名無しさん [sage] Date:2008/12/05(金) 21:29:33  ID: Be:
    linuxとかだと、リターン値を調べるだけムダって話もあるな > malloc() 

438 デフォルトの名無しさん [sage] Date:2008/12/05(金) 21:30:30  ID: Be:
    >>437
    kwsk 

441 デフォルトの名無しさん [sage] Date:2008/12/05(金) 21:48:03  ID: Be:
    >>438
    malloc()はNULLを返さないらしい。
    メモリ確保に失敗したって分かるのは、メモリにアクセスするとき。 

443 デフォルトの名無しさん [sage] Date:2008/12/05(金) 22:37:32  ID: Be:
    >>441
    kernelに怒られて、強制終了した。 

444 デフォルトの名無しさん [sage] Date:2008/12/05(金) 22:47:43  ID: Be:
    >>441
    設定で、その場で確保してみてエラーを返すようにもできるけどね。 

445 デフォルトの名無しさん [sage] Date:2008/12/05(金) 22:54:17  ID: Be:
    >>428
    NULLぽが返ったらどうせ何も出来ないのだからとっとと終了 

446 デフォルトの名無しさん [sage] Date:2008/12/05(金) 22:56:30  ID: Be:
    >>445
    >>430 

447 デフォルトの名無しさん [sage] Date:2008/12/05(金) 22:58:23  ID: Be:
    >>445
    メモリ確保できるかどうかで使用するアルゴリズムを変えてるぜ 

448 デフォルトの名無しさん [sage] Date:2008/12/05(金) 23:03:53  ID: Be:
    >>441
    それは信じられないなあ。
    セグメントバイオレーションを起こすアドレスを返せば、書き込んだときに強制終了して
    わかるけど。そうでないアドレスを返したら、あちこちをぶっ壊すってこと? 

449 デフォルトの名無しさん [sage] Date:2008/12/05(金) 23:08:21  ID: Be:
    >>448
    Linuxの勉強してきてくれ。
    簡単に言えば、malloc()は仮想メモリ空間のアドレスを返すだけ。
    要は、メモリ使用の予約をしているだけだと思えばいい。
    で、実際に使おうとしたときに実メモリが足りなければスワップしてメモリを空けるのだけれど、
    (GUIが走っていたりして)メモリの奪い合いが頻発し始めると強制終了の憂き目に遭う訳だ。 

450 デフォルトの名無しさん [sage] Date:2008/12/05(金) 23:08:34  ID: Be:
    >>448
    http://www.linux.or.jp/JM/html/LDP_man-pages/man3/malloc.3.html
    このページにはバグって書いてあるけど、どっかで読んだ別の文章では、
    現代的なOSはそういうもんだから、もうmalloc()のリターン値をチェックする
    習慣はいらないんじゃね? みたいなことが書かれてた。 

451 デフォルトの名無しさん [sage] Date:2008/12/05(金) 23:16:10  ID: Be:
    CFAQ 7.14

    質問: オペレーティングシステムによっては malloc したメモリを実際に確保するのを
    プログラムがそのメモリを使おうとするまで先延ばしすると聞いたことがある。
    これは文法上許されるのか。

    回答: これは難しい。規格は、システムはこういう風に振る舞ってもよいと書いていないけれど、
    こういう風に振る舞ってはいけないとはっきり書いてあるわけでもない。
    こういう“先延ばしの失敗”の実装は規格が暗黙に要求しているところに
    従っていないように思える。 …… こうした遅延割り付けをするシステムは通常、
    特別のシグナルを使ってメモリの量が危険なほど少なくなっていることを知らせる仕組みを持つ。
    しかし移植性の高いことを目指したプログラムやタコなプログラムはそういうシグナルを捕まえない。
    遅延割り付けをするシステムの中にはプロセス単位かユーザ単位で遅延割り付けをやめる仕組み
    (昔からの malloc の意味付けに戻る仕組み)を用意しているものもある。
    しかし詳細はシステムによって異なる。

452 デフォルトの名無しさん [sage] Date:2008/12/05(金) 23:25:19  ID: Be:
    malloc呼んだらすぐにチョイと何かテスト書き込みしてみる
    という手を思いついたけどうまく行くかどうかは知らない 

453 デフォルトの名無しさん [sage] Date:2008/12/05(金) 23:41:22  ID: Be:
    余り意味はないな。それが有効な状況では既に破綻は目の前だ。 

454 デフォルトの名無しさん [sage] Date:2008/12/06(土) 00:06:23  ID: Be:
    メモリー不足は個々のプログラムの問題でなくて、運用管理の問題
    運用テストではそういった類のテストをする 

462 デフォルトの名無しさん [] Date:2008/12/06(土) 09:59:53  ID: Be:
    ポインタの書き方で質問があります。

    入門本では、

    int *pA;

    のように宣言すればおk と書いてあるのですが、
    そこら辺に転がっているCのソースを見ると

    float*
    char**

    のようになっているポインタがあるのですが、
    いったい何がどう違うのでしょうか?

463 デフォルトの名無しさん [sage] Date:2008/12/06(土) 10:18:36  ID: Be:
    int *p はint型を指すポインタ
    float *p はfloat型を指すポインタ
    char **p はchar*型(つまりchar型のポインタ)を指すポインタ

    一口にポインタといっても、指す先の型によってポインタの型も変わってくる 

467 デフォルトの名無しさん [sage] Date:2008/12/06(土) 16:47:13  ID: Be:
    ポインタってなんすか? 

468 デフォルトの名無しさん [sage] Date:2008/12/06(土) 17:00:19  ID: Be:
    アドレスを入れる変数
    詳しくはググるか書籍で 

469 デフォルトの名無しさん [sage] Date:2008/12/06(土) 18:05:15  ID: Be:
    アドレスいれてなににつかうんすか? 

470 デフォルトの名無しさん [sage] Date:2008/12/06(土) 18:12:42  ID: Be:
    そのアドレスにある情報を読んだり書いたり。

    釣られてる? 

472 デフォルトの名無しさん [sage] Date:2008/12/06(土) 18:29:13  ID: Be:
    配列や構造体を関数に渡すときに値を全てコピーするのは大変な手間になる
    だからアドレスを渡してやる事で処理を速くする 

474 デフォルトの名無しさん [] Date:2008/12/06(土) 19:24:26  ID: Be:
    必要性を感じるまでは無理に使わなくてよい 

477 デフォルトの名無しさん [sage] Date:2008/12/06(土) 21:30:57  ID: Be:
    >>472
    そこをポインタがないとか言われてるJavaとかC#ではどうやってるの? 

478 デフォルトの名無しさん [sage] Date:2008/12/06(土) 21:33:27  ID: Be:
    >>477
    参照型は、まあ、ポインタだよね。 

480 デフォルトの名無しさん [sage] Date:2008/12/06(土) 21:39:37  ID: Be:
    >>478
    参照型はポインタだ だから、JavaやC#はポインタしかない言語だ

    というのを何かの本で読んだ事あるんだけど、Cのポインタとはまたキャラが違うと思うんだ。
    俺はJavaから入って、Cに挫折したけど、Javaで飯を食って行ってるヘタレPGだから、
    Cを自由自在に操れる人は本気で凄いと思う。
    malloc関数とかfree関数のつっこんだ操作がイミフで仕事先の先輩PGもあんなもん覚えなくていいよー と言うんだが…
    これでいいんだろうか… 

482 デフォルトの名無しさん [sage] Date:2008/12/06(土) 21:43:44  ID: Be:
    Cを使うコツは「なんとなく」わかった気になるというのを排除して
    徹底的に理詰めで理解しようとすることだ 

483 デフォルトの名無しさん [] Date:2008/12/06(土) 21:45:32  ID: Be:
    >>475
    >>482 

484 デフォルトの名無しさん [sage] Date:2008/12/06(土) 21:46:30  ID: Be:
    malloc()やfree()は難しい要素はないと思うが… 

485 デフォルトの名無しさん [sage] Date:2008/12/06(土) 21:51:44  ID: Be:
    >>484
    多次元配列の確保とかでわけわかんなくなる人もいるんだよ 

486 デフォルトの名無しさん [sage] Date:2008/12/06(土) 21:52:38  ID: Be:
    メモリの確保?あーめんどくせー 勝手にやってくれよ

    ATに慣れるとMTに乗れなくなる現象ですね 

487 デフォルトの名無しさん [sage] Date:2008/12/06(土) 21:54:26  ID: Be:
    アセンブラで「CPUの動き」に触れてみるといいんじゃない?
    と思うけど保証はしない。 

488 デフォルトの名無しさん [sage] Date:2008/12/06(土) 21:54:59  ID: Be:
    >>485
    それは、基本ができてないからだろ 

489 デフォルトの名無しさん [sage] Date:2008/12/06(土) 21:56:21  ID: Be:
    アセンブラを学ぶことはより深くCを理解できる可能性がある反面
    誤った思い込みをしてしまう可能性もあるので一長一短 

490 デフォルトの名無しさん [sage] Date:2008/12/06(土) 22:17:57  ID: Be:
    >>488
    基本の定義を教えてくれ 

491 デフォルトの名無しさん [sage] Date:2008/12/06(土) 22:39:05  ID: Be:
    >>490
    ・ポインタ型は、あるオブジェクトへの参照を表す値を持つオブジェクトである。

    そのポインタが何を指してるのかを把握出来ることが、
    ポインタを使う上での基本じゃないかね。 

493 デフォルトの名無しさん [sage] Date:2008/12/06(土) 22:45:28  ID: Be:
             ,. -‐'''''""¨¨¨ヽ
             (.___,,,... -ァァフ|          あ…ありのまま 今 起こった事を話すぜ!
              |i i|    }! }} //|
             |l、{   j} /,,ィ//|       『多次元配列の確保についての基本の定義を尋ねたら
            i|:!ヾ、_ノ/ u {:}//ヘ        ポインタについて当たり前の事を説明された』
            |リ u' }  ,ノ _,!V,ハ |
           /´fト、_{ル{,ィ'eラ , タ人        な… 何を言ってるのか わからねーと思うが
         /'   ヾ|宀| {´,)⌒`/ |<ヽトiゝ        おれも何をされたのかわからなかった
        ,゙  / )ヽ iLレ  u' | | ヾlトハ〉
         |/_/  ハ !ニ⊇ '/:}  V:::::ヽ        頭がどうにかなりそうだった…
        // 二二二7'T'' /u' __ /:::::::/`ヽ
       /'´r -―一ァ‐゙T´ '"´ /::::/-‐  \    超スピードだとか催眠術だとか
       / //   广¨´  /'   /:::::/´ ̄`ヽ ⌒ヽ    そんなチャチなもんじゃあ 断じてねえ
      ノ ' /  ノ:::::`ー-、___/::::://       ヽ  }
    _/`丶 /:::::::::::::::::::::::::: ̄`ー-{:::...       イ  もっと恐ろしいものの片鱗を味わったぜ… 

494 デフォルトの名無しさん [sage] Date:2008/12/06(土) 22:54:46  ID: Be:
    >>493
    本当にポインタについて当たり前のことを理解しているというのなら
    頭を使えよ 

495 デフォルトの名無しさん [sage] Date:2008/12/06(土) 22:59:18  ID: Be:
    まあ、たしかに多次元配列をmalloc()で確保することってあんまりないから、
    10*10*10の三次元の配列を確保するとして、

    p = malloc(sizeof(int) * 10 * 10 * 10);

    とかで、pの型ってどうなるんだっけ、ってちょっと考えちゃうな。

    まあ、でも、そんなCの記法の問題だから調べれば分かる問題だし、
    ポインタの難しさとはちょっと違うよな。


Win32API質問箱 Build73

153 デフォルトの名無しさん [sage] Date:2008/12/02(火) 02:17:05  ID: Be:
    WinAPIとまったく関係ないところで GetMessage とか書いたら、G
    etMessageW に名前変わっちゃうんだけど、どうしようもないの?
    上の方でインライン関数って話出てたけど、こういうのもマクロじゃなくて
    インライン関数にしちゃえばいいのに。 

154 デフォルトの名無しさん [sage] Date:2008/12/02(火) 02:21:31  ID: Be:
    >>153
    別にいいじゃん。何か問題でも? 

155 デフォルトの名無しさん [sage] Date:2008/12/02(火) 03:02:57  ID: Be:
    >>154
    class Hoge
    {
     void GetMessage() { }
     void GetMessageW() { }
    };

    A系とかW系とかAPIとは関係ないつもりで書いたとしても、偶然名前が一致してしまったら
    問答無用で置き換えられて二重定義になってしまう。 

157 デフォルトの名無しさん [sage] Date:2008/12/02(火) 03:45:33  ID: Be:
    マクロundefしとけ 

175 デフォルトの名無しさん [sage] Date:2008/12/02(火) 21:59:23  ID: Be:
    >>153
    #pragma push_macro("hoge")
    #undef hoge
    //hogeを使う
    #pragma pop_macro("hoge")

    これだと最後に再定義しなおさなくて済む 

176 デフォルトの名無しさん [sage] Date:2008/12/02(火) 22:22:21  ID: Be:
    >>175
    Hoge::GetMessageの呼出箇所で毎回そんなの書くなんて馬鹿げているというか馬鹿
    APIと衝突しないような名前を付ければ済むだけだし結論出てる 

おお。そんな機能があったのか> 175

■_

Pythonにコンストラクタなんて構文は無いし、親クラスを呼び出す構文も無い
http://d.hatena.ne.jp/methane/20081204/1228416796
http://d.hatena.ne.jp/methane/20081203/1228330596
http://d.hatena.ne.jp/w_o/20081205

http://kirindave.tumblr.com/post/63237966/erlang-slides

http://www.slideshare.net/jignesh/socket-programming-tutorial/

http://torvalds-family.blogspot.com/2008/12/debugging-hell.html

http://book.mycom.co.jp/book/978-4-8399-2784-4/978-4-8399-2784-4.shtml

2008年12月06日

■_

C++WGアドホック会議終了 - Faith and Brave - C++で遊ぼう
そうとう濃い話をしたっぽいなあ

Debugging inside the Scala Eclipse Interpreter
http://suereth.blogspot.com/2008/12/debugging-inside-scala-eclipse.html

Contributing to open source can be hard and frustrating
http://coderrr.wordpress.com/2008/12/04/contributing-to-open-source-can-be-hard-and-frustrating/

・オライリー本
できるだけ安くて買っていない本ということで悩む。 いまフェアで配布している付箋パッドでこれまで手に入ったのが Perl、Python、sed &awk、Mastering Regular Expressions、DNS &BIND。 全部で十種類くらいあるみたいだけど、このへんであきらめるかなあ。 店にもよるけど、オライリー本を買った上でさらにこちらの希望を出せないというのは辛いw (希望を出せる店もある)

■_ (う)さんに私信

丁稚な日々
◆[mswin32] IO.popen

_ テストの失敗をいくつか解消するために内部実装をそれなりにいじってしまった。
Vista以外で動くかどうか不明なので誰かXPとかでtrunk試してください...
なお、makeの途中でminirubyを作った直後にIO.popenを使うので、もしおかしかったらそもそも
rubyをビルドできません。なのでビルドできればまあOK。

_ ちなみに手元ではtest/ruby/test_process.rbは6 failures, 0 errors, 3 skipsらしい。
6Fのうち4つまでは子プロセス側でエラーが出てるようなので、たぶんテストが悪いんだろう。
そして1Fはumaskなので(後で考えるけど)skipすべきような気がする。
もうひとつはなんだろ。 

Win2kとxpでtrunkをビルドしてみましたが、 あいかわらず例のminiruby.exeが開けない病がでますけどそこで再度 nmake すれば先に進んでビルドを完了します。 nmake test と nmake install は問題なしです。 test-all はまだやってません。

■_ 5分でEmacsをわかった気になる

http://nubyonrails.com/articles/emacs-emacs

Emacs? Emacs. 

Screencast
I've assembled a short screencast of my initial impressions:

http://peepcode.com/system/uploads/2008/peepcode-emacs-in-5-demo.mov


Initial Impressions

The Good Stuff よい点

Here's a short list of what I'm enjoying about it so far:

Efficiently keyboard driven. No need to use the mouse at all.
キーボードを使った操作に特化していて、マウスを使う必要はほとんどない。

Window splits for viewing multiple files (and shells) at once.
一度に複数のファイル(とシェル)を見るためにウィンドウを分割できる。

Powerful editing.
強力なエディット機能。

The ease with which one can work with dozens of files without getting confused.

Super customizable.
強力なカスタマイズ機能。

Easy to keep settings, snippets, plugins, etc. synchronized between desktop and laptop 
with Git.

デスクトップとラップトップとの間での
設定やスニペット、プラグインなどのkeepが
Gitを使った同期で簡単にできる。

Quality plugins from the community.

コミュニティによる質の高いプラグインの数々。


The aha moment when parts of code make more sense given the fact that Emacs was used 
by Matz, Ryan Davis, Nathan Weizenbaum, etc. to author them.

That unidentifiable elitist feeling you get from using a tool that's too difficult or 
awkward for most people.

The Awkward Bits ちょっと残念なところ

No GUI for preferences.

Mac OS X integration is just barely good enough to get by. For example, I can't get 
“Hide Others” to work except by using the mouse.

It's assumed that you'll do most work from within Emacs itself rather than piping text 
to it.

Crashes when trying to switch color themes. This may be a problem with the color theme 
plugin I'm using.

It's difficult to think about content and files instead of icons and buttons.

■_ 今日のム板から

Python 3.0について昨日の続き。

Pythonのお勉強 Part30
396 デフォルトの名無しさん [sage] Date:2008/12/05(金) 01:21:54  ID: Be:
    >>389
    じゃぁお前はprintの変更の影響受けて無いじゃん。

    Python開発者は潔癖症なんかじゃないよ。
    print文の変更も議論の上だよ。 print文でファイルに出力する方法とか、最後に改行しない
    方法とか、その為だけに構文を増やしていたのを、普通の関数呼び出しにして柔軟に
    使えるようになった。

    数タイプを削減するためだけに構文増やしまくってたprint文がキモ過ぎただけで、
    print関数は素直で自然な姿。 

399 デフォルトの名無しさん [sage] Date:2008/12/05(金) 04:52:48  ID: Be:
    Cとの互換性を重視して文法がカオスになってるC++を見てると、
    どこかで切り捨ては必要だなって思う。 

400 デフォルトの名無しさん [sage] Date:2008/12/05(金) 09:11:27  ID: Be:
    printの構文くらいしか噛みつくとこないんですね 

402 デフォルトの名無しさん [sage] Date:2008/12/05(金) 10:32:16  ID: Be:
    >>400
    printの構文くらいしか噛みつくとこないということにする以外に噛み付く方法無いんですね 

403 デフォルトの名無しさん [sage] Date:2008/12/05(金) 10:41:21  ID: Be:
    print以外に互換ない所ってどこ? 

404 デフォルトの名無しさん [sage] Date:2008/12/05(金) 10:44:28  ID: Be:
    そもそも、printの構文なんて存在しなくなったというのが正しい。
    printが関数になって、関数の構文で呼び出せるようになり、
    Pythonの構文がいっそうシンプルになった。 

405 デフォルトの名無しさん [sage] Date:2008/12/05(金) 10:46:27  ID: Be:
    >>400
    ぶっちゃけPython3.0の新機能なんざ、後方互換性の破壊による
    二重保守や移行の手間に見合うほどのもんじゃないよ、どれもこれも

    Python3.0のほうがより良い仕様だということは認めるが、
    別に言語仕様だの性能だのの明白な強化に繋がる仕様じゃないし
    単なる切り落としも多い
    例えば、reduce()がbuiltinから消えて喜ぶ奴がいるか?
    はっきりしているのは、それでスクリプトを書き換える必要が生じる
    ユーザだけは沢山いるということだ

    周辺ライブラリとか作ってる人たち、今後は二重保守やテストを強いられることに
    なんのかね
    当たり前のようにC APIも仕様変わってんだろ
    ぞっとするぜ 

406 デフォルトの名無しさん [sage] Date:2008/12/05(金) 10:47:36  ID: Be:
    >>403
    文字列の扱いは全く完璧に変わった
    例外のハンドリングも構文が変わった

    シンタクスレベルの変更なので、スクリプト内で動的にバージョンを判断して
    分岐することはできない
    バイトコンパイルの時点でシンタクスエラーになるからな 

407 デフォルトの名無しさん [sage] Date:2008/12/05(金) 10:49:24  ID: Be:
    変化に対応できないじじいは史ねってことですね、分かります。 

408 デフォルトの名無しさん [sage] Date:2008/12/05(金) 11:02:43  ID: Be:
    >>405
    移行したくないならどうぞそのまま Python 2.x をお使いください。
    だれもあなたに移行しろと言ってませんし、俺もまだ移行しません。
    1年や2年は様子見で良いよ。
    ライブラリが揃いだしてから、新規のコードは Python3.0 用に書き始めれば良い。 

409 デフォルトの名無しさん [sage] Date:2008/12/05(金) 11:09:44  ID: Be:
    > ライブラリが揃いだしてから、新規のコードは Python3.0 用に書き始めれば良い。

    なるほど、使ってる全部の端末に2種類のPythonインタプリタをインストールして
    二重運用するわけかw
    そして今までのコードベースはそのやり方じゃ、3.0からは使えない、と

    うっかりミスでトラブル続出だな
    boost.pythonとかどうなるのやら 

410 デフォルトの名無しさん [sage] Date:2008/12/05(金) 11:11:52  ID: Be:
   >>409
   俺は1.9、2.4、2.5、2.6、3.0全部入れてるぞ 

411 デフォルトの名無しさん [sage] Date:2008/12/05(金) 11:13:16  ID: Be:
    >>410
    >1.9

    Ruby厨乙(ww 

412 デフォルトの名無しさん [sage] Date:2008/12/05(金) 11:13:56  ID: Be:
    流石反応はええな 

414 デフォルトの名無しさん [] Date:2008/12/05(金) 11:59:32  ID: Be:
    >>405
    C APIについてはどうなのか知らないけど、

    通常のPythonスクリプトのプロジェクトでの2重保守のコストは、
    テストを自動化してるかどうかによると思う。
    変換ユーティリティ 2to3 の利用もテストを前提としてるみたいなので。

    ttp://www.artima.com/weblogs/viewpost.jsp?thread=208549 より、簡単に抜粋すると。

    0. テストを書く。
    1. python 2.6 へ移植。
    2. py3k 警告モードでテスト。
    3. 警告がなくなるまで修正を繰り返す。
    4. 2to3で 3.0 向けに変換。
    5. 3.0 でテスト。
    6. エラーがあれば変換前のコードを修正する。
    7. release

    手作業が必要なところ以外を自動化してしまえば、
    保守コストが2倍掛かるなんてことにはならないはず。

    移植コストは 2to3 がどの程度の変換をサポートしてるかに拠るのかな。
    8割程カバー出来ればいいや、みたいな事言ってたを何処かで読んだけど。ソース失念。 

415 デフォルトの名無しさん [sage] Date:2008/12/05(金) 12:05:31  ID: Be:
    ttp://gihyo.jp/dev/feature/01/python3000/0004
    に2to3の適用範囲についての説明はあるな
    その後もっとマシなものになっているのかどうかは分からんが

    その辺は、要求品質にもよるだろうな
    業務としてやってるようなものなら、テストだって全自動で終わりとかありえねえし

    ゲームの自動テストでも書いてみるか?w

416 デフォルトの名無しさん [sage] Date:2008/12/05(金) 12:32:19  ID: Be:
    C apiの変更はboost.pythonに吸収してもらえないのかねえ 

417 デフォルトの名無しさん [sage] Date:2008/12/05(金) 12:47:45  ID: Be:
    http://docs.python.org/3.0/c-api/concrete.html
    を見ると、Sequence ObjectsからString Objectsの記述は無くなって、
    Bytes ObjectsだのByte Array Objectsだのが登場している。
    Unicode Objectsは残っている。
    strはUnicode Objectsにマップするのだろうか。

    http://docs.python.org/3.0/c-api/arg.html
    を見ると、相変わらずフォーマット"s"が存在し、
    「string or Unicode Objects」とか書いてある。
    そしてそれが「char*に」変換する。
    byteからのフォーマット指定子も追加されているが。

    正直何がしたいんだか良く分からないんだが。
    上っ面だけ整理して、C APIはカオスに見える。
    ドキュメントが追いついていないだけか? 

418 デフォルトの名無しさん [sage] Date:2008/12/05(金) 13:38:36  ID: Be:
    まあ3.0移行とか関係なく、普通にテスト書くだろ。
    テスト書かないハゲは消えろや。 

433 デフォルトの名無しさん [sage] Date:2008/12/05(金) 23:56:09  ID: Be:
    以下の呼び出しはaがアサインされてないよと言われて失敗してしまうんですが
    そういうものなんですかね?

    def maker(a):
      # return lambda(c): a + c
      def f(c):
        a = a + c
        return a
      return f

    f = maker(3)
    print f(4)

    左辺値のaを別の変数にすれば動きます。 

435 デフォルトの名無しさん [sage] Date:2008/12/06(土) 00:08:36  ID: Be:
    Python3.0ならnonlocalで出来たかと 

436 デフォルトの名無しさん [sage] Date:2008/12/06(土) 00:09:04  ID: Be:
    >>433
    http://docs.python.org/reference/executionmodel.html#naming-and-binding

    If a name binding operation occurs anywhere within a code block,
    all uses of the name within the block are treated as references to
    the current block.
    This can lead to errors when a name is used within a block before it is bound.
    This rule is subtle. Python lacks declarations and
    allows name binding operations to occur anywhere within a code block.
    The local variables of a code block can be determined
    by scanning the entire text of the block for name binding operations.

    と書いてあるので、仕様だろう
    結局のところletのような構文は無いのだし、それがPythonなのだと思うしかない

    俺は最近はletだのvarだのmyだのが無いことの不便さのほうを感じることが
    多いな

440 436 [sage] Date:2008/12/06(土) 01:38:31  ID: Be:
    すまん、ちょっと意図を勘違いしていた。
    >>433は左辺も右辺も自由変数を参照したいわけだな?
    ならPython3ではnonlocal文でいいはずだが、
    それ以前のPythonでは、自由変数に代入することはできない。

    global変数にはglobal文を使うことで代入することはできるが
    global変数を使うこと自体稀だろう。

    Schemeなどのlet文では左辺がローカルな束縛で右辺が自由変数という
    ケースも良く出てくるが、それもPythonではできない。
    できない理由は>>436の引用に説明されている通り。

    いずれも変数宣言を持たないことによる帰結だな。 

441 デフォルトの名無しさん [sage] Date:2008/12/06(土) 01:41:19  ID: Be:
    let「文」はおかしいな
    まあいいか 

442 デフォルトの名無しさん [] Date:2008/12/06(土) 01:44:19  ID: Be:
    py3kについてkwskかかれた日本語まだー?w

    viewってなんだよviewって・・・ 

443 デフォルトの名無しさん [sage] Date:2008/12/06(土) 01:54:06  ID: Be:
    >>440
    ありがとうございます!

    エラーもはいてくれるし、ローカル変数を使うつもりが初期化を忘れて
    勝手にネームバインディングされるよりはわかりやすくていいのかな。

444 デフォルトの名無しさん [sage] Date:2008/12/06(土) 01:56:51  ID: Be:
    >>443
    本当はletなどで明示したほうがいい、と俺は思うんだけどね

    まあ、letの3文字をタイプする手間と、それを省くことによる仕様面での制限の
    トレードオフを考えたときに、Pythonは手間を省く方を選んだということだ 

445 デフォルトの名無しさん [sage] Date:2008/12/06(土) 02:33:08  ID: Be:
    >>433
    def maker(a):
      # return lambda(c): a + c
      def f(c, a=a):
        a = a + c
        return a
      return f

    とすればいいと思うよ。

446 デフォルトの名無しさん [sage] Date:2008/12/06(土) 02:45:50  ID: Be:
    a += c でもだめなんかなぁ。。。 

法律相談所inム板 

1 デフォルトの名無しさん [sage] Date:2008/12/04(木) 17:30:08  ID: Be:
    何でも質問してくれ
    誰かが答えてくれるはずだ

4 デフォルトの名無しさん [sage] Date:2008/12/04(木) 18:02:46  ID: Be:
    プログラマー+法律か。
    これは新しいな。 

5 デフォルトの名無しさん [] Date:2008/12/04(木) 19:47:27  ID: Be:
    ライセンスに詳しい人いないの? 

6 デフォルトの名無しさん [sage] Date:2008/12/05(金) 05:29:35  ID: Be:
    >>4
    俺は元プログラマの司法書士だ
    今は趣味でプログラミングやってる 

7 デフォルトの名無しさん [] Date:2008/12/05(金) 17:05:17  ID: Be:
    >>6
    資格取ったの何歳?何年勉強した? 

8 デフォルトの名無しさん [sage] Date:2008/12/06(土) 00:08:30  ID: Be:
    25歳の時に仕事やめて実家に戻って無職のまま2年間くらい勉強して取った 

9 デフォルトの名無しさん [sage] Date:2008/12/06(土) 06:13:04  ID: Be:
    25かぁ・・・
    見切りつける思い切りのよさが羨ましい 

10 ,,・´∀`・,,)っ-●◎○ [sage] Date:2008/12/06(土) 08:15:07  ID: Be:
    技術屋なら司法書士より弁理士だろjk

    会社の金でソフ開とればなお良し 

プログラミングはすでに市場飽和状態にある?

1 デフォルトの名無しさん [] Date:2008/12/02(火) 10:05:18  ID: Be:
    プログラミングを最近勉強して思った。
    プログラミング自体についての知的好奇心から勉強してるが。
    かといってプログラムで何か作りたいものは?と言われれば別に作りたいものが無い。
    パソコンでやりたいことができるソフトなどは、大方すでに作られていて、いまさら
    わざわざプログラミング言語を学んで作る意味がない気がする。
    パソコンでやりたいことがあったら
    パソコンの上で動くソフトはすでに市場飽和状態にあるのでは?
    そう考えると、プログラミングを勉強するモチベーションが下がる。
    C言語C++なんかいまさら学んで何を作るのだろか?
    いまさらわざわざOSを新たに作る?
    VB?.NET?C#?Java?
    なんだかよくわからないね。 

3 デフォルトの名無しさん [sage] Date:2008/12/02(火) 15:33:20  ID: Be:
    >>1
    さらに加えて「オープンソース」の勃興(台頭?)もある。
    レンタルサーバー屋やハードウェアベンダにとっては特だろうが、
    ソフト屋が儲からない。 

6 デフォルトの名無しさん [sage] Date:2008/12/02(火) 19:06:38  ID: Be:
    マ板でやれよバカ共。 

7 デフォルトの名無しさん [sage] Date:2008/12/02(火) 19:33:15  ID: Be:
    「発明されるべきものは、すべて発明されてしまった。」

    --- チャールズ H ドュエル、長官、米国特許庁、1899 

8 デフォルトの名無しさん [sage] Date:2008/12/02(火) 20:00:45  ID: Be:
    まあ、でも素人がおもいつきで参入できる分野ではなくなったのは事実。
    いいところの大学でて研究室で新しいプログラミングしたらいいよ。
    そこまでする気はなくても、とりあえず>>1はHaskellとかやればいい 

9 デフォルトの名無しさん [sage] Date:2008/12/02(火) 20:08:23  ID: Be:
    真正乱数生成に成功するまでプログラミングをやめない 

10 デフォルトの名無しさん [sage] Date:2008/12/02(火) 22:03:20  ID: Be:
    プログラミングのプの字も知らん人が溢れてる分野でしっかり揉まれて来い
    そもそも「プログラミングの技術を生かしてなんかできねーのかな」っていうスタート地点が誤り 

11 デフォルトの名無しさん [sage] Date:2008/12/02(火) 23:58:51  ID: Be:
    >>5
    >情報科学系の論文読んでるとプログラミングなんてまだまだやることは
    >たくさん残されてるし、全然開拓されてないと思うんだけどね。

    例えばどんなことかお願い。 

13 デフォルトの名無しさん [sage] Date:2008/12/03(水) 00:02:20  ID: Be:
    >>8
    新しい言語自体、喜ぶ人が限られるのでは? 

14 デフォルトの名無しさん [sage] Date:2008/12/03(水) 00:15:56  ID: Be:
    新しい言語を作っても、その言語を作って何かを作りたい需要自体がない
    なら意味ない。

    >>1 が言うとおり、かつてと比べればやりたい事は減った。 

15 デフォルトの名無しさん [sage] Date:2008/12/03(水) 00:20:42  ID: Be:
    >>8 は、大学で「新しいプログラミング」をしたらいいと言った。
    しかし、そのプログラミングで、いったい何を作ったらいいかと
    いうのが >>1 の疑問だろう。

    残りの作るべき物が、言語とOSに限られるのだろうか。

    仮に言語を発達させていくとして、肝心の、言語を作って何を作るか
    という問題がついて回る。

    もしかすると、今後は、必要になった時にプログラミングをするという
    スタイルに移って行くのであろうか。 

17 デフォルトの名無しさん [sage] Date:2008/12/03(水) 02:11:14  ID: Be:
    人間が手作業でやってることを自動化するのがプログラムの根本でしょ。
    つまり、今手作業でやってることが全て自動化されるまでプログラムが
    介入する余地はあるんじゃない?

    例えば、音声認識→AI判断→3DCG表示で受け答えの受付嬢とか、
    フロアの上面図とドアの位置、収容人数を入力すると、最適なレイアウトを
    考案するプログラムとか。

    自分の知識や技術、既存のマシンの性能とかで無意識に思考を制限してるんじゃないかなぁ。 

22 デフォルトの名無しさん [sage] Date:2008/12/03(水) 11:34:13  ID: Be:
    >>17
    あと大多数の人間の持つ価値観の問題な

    人本体でも映像でもいいでしょってなる頃には営業が外を走り回る文化は無くなってるだろうし
    移動のコストが無駄だからといってデスクワークは自宅で仕事するようになってる
    会議も映像チャットを使うようになってたりね

    実現するだけの技術はもう十分にあるんだけど、人間の感覚がそれを許さないだけ 

24 デフォルトの名無しさん [sage] Date:2008/12/03(水) 16:36:26  ID: Be:
    やること自体は残っているにしても、人工知能の最先端はどうせ大学
    がオープンソースで公開してしまう。

    音声認識を例に取ると、最初IBMなどが実用化して有料で販売した。
    しかし、最近では京大がオープンソースで公開してしまった。
    このような市場破壊行為が税金を使って行われているのが現状だ。 

25 デフォルトの名無しさん [sage] Date:2008/12/03(水) 17:15:35  ID: Be:
    市場破壊(笑) 

26 デフォルトの名無しさん [sage] Date:2008/12/03(水) 17:16:08  ID: Be:
    昔は棲み分けが出来ていたが、大学の研究が民間企業の製品とかち合うよう
    になった。
    民間企業が先に実用化したのに、10年後に大学が無料で公開しやがった。 

27 デフォルトの名無しさん [sage] Date:2008/12/03(水) 17:19:15  ID: Be:
    このような事をして人が幸せになると思っているなら大きな間違いだ。

    音声認識ソフトを使う側は幸せになるかも知れないが、作る側は全く
    幸せにはならない。アルゴリズムが公にされた時点でメーカー間の
    競争はなくなる。せっかく研究費を回収しようとしても無理になる。
    大学は10年遅れて税金で大変な事をする。 

33 デフォルトの名無しさん [sage] Date:2008/12/03(水) 17:37:51  ID: Be:
    アメリカには大学から給料貰いながら無料ソフトの流行を促している
    有名な人もいる。全く同じ。
    この人の場合、過去に企業とのトラウマ体験があったらしいが。
    人の恨みは恐ろしい。

    全世界のソフト産業を崩壊させてしまった。 

34 デフォルトの名無しさん [sage] Date:2008/12/03(水) 17:42:49  ID: Be:
    今となっては懐しいGNU叩き 

35 デフォルトの名無しさん [] Date:2008/12/03(水) 17:45:07  ID: Be:
    最近Windows並みに使えるフリーのLinuxが出てきたが、これも市場破壊行為?
    オープンソースやフリーソフトって、市場飽和を加速する効果があるのか無いのか
    意味がわからないな。 

36 デフォルトの名無しさん [sage] Date:2008/12/03(水) 17:45:20  ID: Be:
    そうやな
    オープンソースとかあほらしいんやな
    活性化されるといっても使える技術なんてそのうちの僅かなんだし
    コミュニティの視点でもノイズが増えただけなんやな 


45 デフォルトの名無しさん [sage] Date:2008/12/03(水) 18:07:16  ID: Be:
    数学の証明みたいにコードが書けるようなやつ
    コードを書いた時点である条件下で
    バグが無い事が証明されてるようなソフトになるような開発環境 

47 デフォルトの名無しさん [sage] Date:2008/12/03(水) 18:09:26  ID: Be:
    >>45
    やはり、新言語/新開発環境 でっか。すると>>1に戻り、
    それは、大学がオープンソースで学会発表してしまう
    から、なかなか産業にはならないと。 

49 デフォルトの名無しさん [] Date:2008/12/03(水) 18:11:33  ID: Be:
    >>47
    新言語は大学で開発されそうだけど。
    新開発環境ってどっちかと言えば民間企業のものが多くない? 

51 デフォルトの名無しさん [sage] Date:2008/12/03(水) 18:14:26  ID: Be:
    >>49
    多い。

    しかし、Eclipseも、NetBeansもWidwStudio も無料なはず。
    これは如何なる現象? 

52 デフォルトの名無しさん [sage] Date:2008/12/03(水) 18:15:24  ID: Be:
    >>50
    物々交換?

    流通システムも作るの? 

53 デフォルトの名無しさん [] Date:2008/12/03(水) 18:17:02  ID: Be:
    >>52
    だから俺個人には到底無理。ソフトの開発だけで終わらないから。 

60 デフォルトの名無しさん [sage] Date:2008/12/03(水) 18:51:01  ID: Be:
    昔、音楽アンプを設計するのもラジオを設計するのも難しい時代が
    あったが、今は、オペアンプと、ラジオ専用ICがあるので解説書
    さえあれば誰でも出来る。

    それとも似てるかも。 

61 デフォルトの名無しさん [] Date:2008/12/03(水) 18:52:24  ID: Be:
    プログラミング要求が高度になると。
    市場の要求にこたえられなくて失敗するリスクも高まるな。
    市場にあう要求にこたえる能力も高くないといけない。
    そんな人材はそうそういないから、要求があってもシステムを作る側に
    用意が無くて、市場が空洞化するかもしれない。 

62 デフォルトの名無しさん [sage] Date:2008/12/03(水) 18:53:48  ID: Be:
    >>61
    >プログラミング要求が高度になると。

    技術的なことよりも、量的な問題の方が大きいかも。
    既存のソフトの機能を全て網羅しないと競争に勝てないとか。 

63 デフォルトの名無しさん [] Date:2008/12/03(水) 18:54:03  ID: Be:
    >昔、音楽アンプを設計するのもラジオを設計するのも難しい時代が
    >あったが、今は、オペアンプと、ラジオ専用ICがあるので解説書
    >さえあれば誰でも出来る。

    誰でもできるようになるってのは怖い。
    プロが飯を食っていく飯の種が無くなるってことだ。
    プロはさらに高付加価値商品を生み出すため、地獄の鍛錬を積まないといけなくなる。 

64 デフォルトの名無しさん [] Date:2008/12/03(水) 18:56:19  ID: Be:
    何気に恐ろしいスレだな。
    まるで、このスレは資本主義を終わらせるきっかけになりそうだ。
    結論が出るころには世の中で何かが起きるかも。 

スタートダッシュはよかったが、金曜土曜と書き込みがないな。

■_ C++ History

C++ Historical Sources Archive ? Software Preservation Group

Chronology
Sources: "C++ Timeline", D&E, page 4; HOPL-III paper.

1979 April
    Work on C with Classes began

1979 October
    First C with Classes (Cpre) running

1983 August
    First C++ in use at Bell Labs

1984
    C++ named

1985 February
    Cfront Release E (first external C++ release) Come Meet the Author

1985 October
    Cfront Release 1.0 (first commercial release)

    The C++ Programming Language

1986
    First commercial Cfront PC port (Cfront 1.1, Glockenspiel)

1987 February
    Cfront Release 1.2

1987 December
    First GNU C++ release (1.13)

1988
    First Oregon Software C++ release [announcement]; first Zortech C++ release 

1989 June
    Cfront Release 2.0

1989
    The Annotated C++ Reference Manual; ANSI C++ committee (J16) founded (Washington, DC)

1990
    First ANSI X3J16 technical meeting (Somerset, NJ) [see group photograph, courtesy 
    of Andrew Koenig]; templates accepted (Seattle, WA); exceptions accepted (Palo Alto, 
    CA); first Borland C++ release Somerset meeting group portrait

1991
    First ISO WG21 meeting (Lund, Sweden); Cfront Release 3.0 (including templates); 
    The C++ Programming Language (2nd edition)

1992
    First IBM, DEC, and Microsoft C++ releases

1993
    Run-time type identification accepted (Portland, Oregon); namespaces and string 
    (templatized by character type) accepted (Munich, Germany); A History of C++: 
    1979-1991 published at HOPL2

1994
    string (templatized by character type) (San Diego, California); the STL accepted 
    (San Diego, CA and Waterloo, Canada)

1996
    export accepted (Stockholm, Sweden)

1997
    Final committee vote on the complete standard (Morristown, New Jersey)

1998
    ISO C++ standard ratified

2003
    Technical Corrigendum; work on C++0x started

2004
    Performance technical report; Library technical report (hash tables, regular 
    expressions, smart pointers, etc.)

2005
    First votes on features for C++0x (Lillehammer, Norway); auto, static_assert, and 
    rvalue references accepted in principle

2006
    First full committee (official) votes on features for C++0x (Berlin, Germany)

  

へー。DEC製のC++コンパイラとかあったのか。

■_

Let's talk about Python 3.0
http://www.b-list.org/weblog/2008/dec/05/python-3000/

What is your contribution to open source projects? - Stack Overflow
http://stackoverflow.com/questions/346207/what-is-your-contribution-to-open-source-projects

Coding for high reliability/availability/security - what standards do I read? - Stack Overflow
http://stackoverflow.com/questions/142722/coding-for-high-reliabilityavailabilitysecurity-what-standards-do-i-read

Great programming quotes - Stack Overflow
http://stackoverflow.com/questions/58640/great-programming-quotes

The Pragmatic Bookshelf | Stuart Halloway on Programming Clojure
http://pragprog.com/podcasts/show/24
http://podcasts.pragprog.com/2008-12/stuart-halloway-on-programming-clojure.mp3

2008年12月05日

■_

・風姿花伝など読んでいます
でもたぶんそこからネタを拾ったりはしません。
風姿花伝 (岩波文庫)
あ、現代語訳なんてでてたのか。こっちにしたかったw
現代語訳 風姿花伝
次は徒然草か五輪書でも行ってみるか。 新訂 徒然草 (岩波文庫) 現代語訳・徒然草 (河出文庫)
五輪書 (講談社学術文庫) 兵法家伝書―付・新陰流兵法目録事 (岩波文庫)

・どうなったのかなあ
C++WGアドホック会議について - Faith and Brave - C++で遊ぼう

・ふと思ったこと
日本人は個人が突出して目立つことを好まず組織でものごとを進める とかなんとかよく言われるような印象があるけど(たとえばサッカーとか)、 その実、ある特定の個人に非常に依存しているケースって多いような気がする。 時代を問わず。たぶんこの先は書かない(笑)

READOR DIE
めもがき:2008年12月4日分hubertf's NetBSD blog

hubertf's NetBSD blog
The character encoding of death
Following a pretty pointless "discussion" on IRCnet #NetBSD on what the One True Character Encoding is, here's a quote that I liked:

14:24 <TGEN> use UTF-8, US-ASCII or die
14:24 <Mjoellnir> die is a cool charset.
14:25 <Mjoellnir> DEATH SPEAKS IN IT

うはっ(笑)

■_

書こうと思ったけどメモもとらずにいると(実はとってても)、 実際に書く段になったらすっかり忘れていて翌日以降に気がつくということがががが。 シャッフル - てきとうなメモ単純で正しそうなものが正しいとは限らない - Radium Software

単純で正しそうなものが正しいとは限らない - Radium Software

ここで得られる教訓は,単純な―いわゆる「ナイーブな」コードが,正しいとは限らないという
こと。単純さが正しい風を装っているだけで,その中に気付きにくい誤りを潜めていることだっ
てある。

クイックソートの実装もそういうところあるよね。 ということを書きたかったのでした(前にも書いたけどね)。

■_ オススメ

あまり買いたいとは思えない - 予定は未定Blog版
■[Book]あまり買いたいとは思えないCommentsAdd Star
IT言葉はオレに聞け!―日経パソコン用語読本

IT言葉はオレに聞け!―日経パソコン用語読本

    * 作者: 矢沢久雄, カモシタハヤト, 日経パソコン編集
    * 出版社/メーカー: 日経BP社
    * 発売日: 2008/12/08
    * メディア: 単行本(ソフトカバー)


うーん、このタイトルならそこまでひどいことは書けそうにないし、実害なさそうだから今回は
パスかな。

あ、これ平積みになっているところを見つけたのだけど 思いっきりスルーして中身をチェックしてなかったw

Excelやってみるか - 予定は未定Blog版
VSSやSubversionの使い方が全く分かってないのと同じように、実はExcelを使いこなしている人
って結構少ないと言うことが分かった。

誰もが初期設定のまま使ってて、ツールバーのカスタマイズすらしてない。

つーことで、ちょっとだけExcelやってみようかな。

Excel Hacks 第2版― プロが教える究極のテクニック140選 はオススメです。 それと、自分もあまり使いこなせているとはいえませんが、 ピボットテーブルあたりを自由に(あまり操作に悩まずに)使えるようになると、かなり違います。 でも本業にさしさわりが出るくらいのめり込むとアブナイです(苦笑)。

■_ Write Only Language(s)

Write Only Language つーとPerlが真っ先に挙げられるような気がするんですが、 自分としては APLとかその眷属の方がよっぽど「書きっぱなし言語」にふさわしい気がします。 んで、APLの後継? のJの話。



Essays/Knight's Tour - J Wiki

A knight's tour is a traversal by a knight of a chessboard, visiting each square exactly once.

   1. Depth First Search
   2. Warnsdorff's Algorithm

Depth First Search

ktour uses a depth first search strategy, stopping on finding the first solution (or 
on failing to find a solution).

NB. knight moves for each square of a (y,y) board
kmoves=: 3 : 0
 t=. (>,{;~i.y) +"1/ _2]\2 1 2 _1 1 2 1 _2 _1 2 _1 _2 _2 1 _2 _1
 (*./"1 t e. i.y) <@#"1 y#.t
)

ktour=: 3 : 0
 if. 1>:y do. i.,~y return. end.
 m=. kmoves y
 p=. *:y
 stack=. ,&.>|.y (<:/~@] #&, * +/ ]) i.>.-:y
 while. #stack do.
  s=. >{:stack
  if. a: e. (((i.p)-.s){m)-.&.><s do.
   if. (#s)=p-1 do. (,~y)$/:s,(i.p)-.s return. end.
   stack=. }:stack continue. 
  end.
  stack=. (}:stack),(<s),&.>s-.~({:s){::m
 end.
)

For example:

   ktour 8
 0 11  8  5  2 13 16 19
 9  6  1 12 17 20  3 14
30 27 10  7  4 15 18 21
63 24 31 28 35 22 47 44
32 29 26 23 48 45 36 57
25 62 51 34 39 56 43 46
52 33 60 49 54 41 58 37
61 50 53 40 59 38 55 42

s in ktour is a partial tour. Suppose that relative to s there is an unvisited square 
having no unvisited neighbor. Then that square must be the final destination and must 
be one knight move from the last element of s . Otherwise, s can not be the prefix of 
a tour. The lines

  if. a: e. (((i.p)-.s){m)-.&.><s do.
   if. (#s)=p-1 do. (,~y)$/:s,(i.p)-.s return. end.
   stack=. }:stack continue. 
  end.

implements this heuristic. ktour 8  executes 302,701 iterations with these lines and 
17,739,768 iterations without.

The stack in ktour is initialized to be the squares of the upper northwest octant. By 
reflectional and transpositional symmetry an octant covers all possible starting 
positions of a tour.

   y=: 8
   ] i=: y (<:/~@] #&, * +/ ]) i.>.-:y
0 1 2 3 9 10 11 18 19 27
   ] t=: (i.y,y) e. i
1 1 1 1 0 0 0 0
0 1 1 1 0 0 0 0
0 0 1 1 0 0 0 0
0 0 0 1 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
   (+.|:) (+.|.) (+.|."1) t
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1

Warnsdorff's Algorithm

Warnsdorff's heuristic algorithm was invented by H.C. Warnsdorff in 1823. The 
heuristic is to choose a successor having the fewest further moves.

ktourw=: 3 : 0
 M=. >moves y
 p=. k=. 0
 b=. 1 $~ *:y
 for. i.<:*:y do.
  b=. 0 k}b
  p=. p,k=. ((i.<./) +/"1 b{~j{M){j=. ({&b # ]) k{M 
 end.
 assert. ~:p
 (,~y)$/:p
)

For example:

   ktourw 8
 0 25 14 23 28 49 12 31
15 22 27 50 13 30 63 48
26  1 24 29 62 59 32 11
21 16 51 58 43 56 47 60
 2 41 20 55 52 61 10 33
17 38 53 42 57 44  7 46
40  3 36 19 54  5 34  9
37 18 39  4 35  8 45  6

ktourw is very efficient with ktourw 80 running in about 0.1 seconds.

See also

    * [WWW] Wikipedia
    * N Queens Problem
    * 9 Queens Problem
    * 4 Queens Problem
    * Queens and Knights


こういうのを自在に操れる人がうらやましい。

■_


The Merbist ≫ Blog Archive ≫ Merb ♥ Rails

The Merbist
def: A person who is dedicated to the economic or medicinal uses of Merb.

Merbist とは


Merb ♥ Rails

Love is in the air

Yes, it is true and no, I am not being passive aggressive or cynical.

As you might have heard there has been some tension between the Rails team and the 
Merb team in the last few weeks. Sometimes caused by us, sometimes caused by them. I 
already addressed this issue in this blog post, so let's move on.



Without further ado, here is my …
Top 10 reasons why we ♥ Rails:

    * Without Rails, the Ruby language would not be one of the top 10 programming languages
    * Without Rails, we would still be writing thousand-line configuration files in 
      XML to start your small app
    * Without Rails, most developers would not know what MVC stands for
    * Without Rails, I would not be a Ruby web developer
    * Without Rails, we would not have Merb
    * Without Rails, we would not have all the other cool Ruby frameworks
    * Without Rails, testing would be something only the elite would do
    * Without Rails, serving Ruby web apps would be a pain in the neck
    * Without Rails, Zed Shaw would not be famous

Bonus items:

    * Without Matz, there would be no Ruby
    * Without Ruby, there would be no Rails

Next time you think, I'm a Merb or I'm a Rails, think twice :)

■_


Who is your programming hero? - Stack Overflow
http://stackoverflow.com/questions/132983/who-is-your-programming-hero

2mデスクに最新PC!プログラマ垂涎の開発環境を用意!!/Tech総研
http://rikunabi-next.yahoo.co.jp/tech/docs/ct_s03600.jsp?p=001458&vos=dyterssc000000000000

世界初の電子式テレビを発明!高柳健次郎の技術者人生/Tech総研
http://rikunabi-next.yahoo.co.jp/tech/docs/ct_s03600.jsp?p=001308&vos=dyterssc000000000000

キヤノンのSED関連特許訴訟が決着
http://av.watch.impress.co.jp/docs/20081204/canon.htm?ref=rss

ゴスリング氏、Javaの最新動向を説明:JavaFXとWiiの連携アプリも登場 - builder by ZDNet Japan
http://builder.japan.zdnet.com/news/story/0,3800079086,20384785,00.htm?ref=rss

Javaの父:「Javaはレガシーか?」「その表現は妥当ではない」と反論 - builder by ZDNet Japan
http://builder.japan.zdnet.com/news/story/0,3800079086,20384793,00.htm?ref=rss

開発者だけが悪いのか?
http://blogs.wankuma.com/tyappi/archive/2008/12/05/162810.aspx

Windows Vista の非互換性
http://blogs.wankuma.com/tyappi/archive/2008/12/05/162809.aspx

いい加減、user 間で共有するものが基本的にダメなのか理解してほしい
http://blogs.wankuma.com/tyappi/archive/2008/12/05/162806.aspx

なぜ、そんな考え方になるのか。
http://blogs.wankuma.com/madoka/archive/2008/12/04/162781.aspx

なぜ %PROGRAMFILES% に書き込んではいけないか?
http://blogs.wankuma.com/tyappi/archive/2007/07/12/84794.aspx

浸透していないなぁ。。。
http://blogs.wankuma.com/tyappi/archive/2007/09/11/95202.aspx

C/C++ の将来性 その 4
http://blogs.wankuma.com/tyappi/archive/2008/12/05/162802.aspx

『Songbird 1.0』リリースで『iTunes』の勢いは衰える? - japan.internet.com E-コマース
http://japan.internet.com/ecnews/20081205/12.html


Python 3.0 final Released - PLNews: Programming Language News
http://plnews.org/posts/python_30_final_released_20081203_210004.html
Let's discuss the matter further » Blog Archive » Comprehension consistency at last in Python 3.0!
http://rhodesmill.org/brandon/2008/comprehension-consistency-at-last-in-python-30/


eTcl 1.0-rc31 Released - PLNews: Programming Language News
http://plnews.org/posts/etcl_10rc31_released_20081203_205726.html
Qore 0.7.2 Released - PLNews: Programming Language News
http://plnews.org/posts/qore_072_released_20081203_205537.html

OCaml 3.11.0 Released - PLNews: Programming Language News
http://caml.inria.fr/download.en.html

>Binary distributions for Microsoft Windows
>These are not yet available.

しくしくしく…


What kind of programming method do you prefer? Success vs. Freedom - Stack Overflow
http://stackoverflow.com/questions/342169/what-kind-of-programming-method-do-you-prefer-success-vs-freedom

Why does everyone go with Subversion? - Stack Overflow
http://stackoverflow.com/questions/330963/why-does-everyone-go-with-subversion

Cleaning up Legacy Code "header spaghetti" - Stack Overflow
http://stackoverflow.com/questions/110436/cleaning-up-legacy-code-header-spaghetti

What is your favorite esoteric programming language? - Stack Overflow
http://stackoverflow.com/questions/187715/what-is-your-favorite-esoteric-programming-language

Simple but powerful programming language for a hobby software project - Stack Overflow
http://stackoverflow.com/questions/184469/simple-but-powerful-programming-language-for-a-hobby-software-project

Why software engineer are so egoist to learn new languages & stuffs - Stack Overflow
http://stackoverflow.com/questions/342993/why-software-engineer-are-so-egoist-to-learn-new-languages-stuffs


2008年12月04日

■_

・来ました
モノじゃなくてお知らせですが。

Greetings from Amazon.com.

We thought you'd like to know that we shipped your items, and that this 
completes your order.  

You can track the status of this order, and all your orders, online by 
visiting Your Account at http://www.amazon.com/gp/css/history/view.html


(ry


The following items have been shipped to you by Amazon.com: 
--------------------------------------------------------------------
 Qty                           Item    Price         Shipped Subtotal

---------------------------------------------------------------------

Amazon.com items (Sold by Amazon.com, LLC):

   1             Real World Haskell   $44.45               1   $44.45

Shipped via Standard Int'l  Shipping

---------------------------------------------------------------------
                           Item Subtotal:     $44.45
                  Shipping  and handling:      $8.98

                  EB Pre-order Guarantee:      $0.00

                         Books Pre-order:      $0.00

                  EB Pre-order Guarantee:      $0.00

                                   Total:     $53.43

                            Paid by Visa:     $53.43

    --------------------------------------------------------------------

(ry


via Standard Int'l  Shipping (estimated delivery date: January  9,2009).

(ry
  

しまった。航空便にしなかったので年明けになってしまう。 まあいいか(笑) 航空便だと送料が高いしな。って今いくらぐらいになるんだろう?

2008-12-04 - らいおんの隠れ家 http://d.hatena.ne.jp/lionfan/20081204#1228379796

■_ Perl6 ミーティング

Journal of chromatic (983)

The Perl 6 design team met by phone on 19 November 2008. Larry, Allison, Patrick, 
Jerry, Jesse, Will, Nicholas, and chromatic attended.

c:

    * will let someone else discuss the Parrot Developers Summit
    * released Parrot 0.8.1 yesterday
    * mostly smooth, but didn't get in all of the features we wanted
    * looking at the plan for the next few months to figure out my next features

Patrick:

    * even if Parrot 0.8.1 didn't give all of the features we wanted, it was a useful
     deprecation point
    * lots of things merging into trunk today
    * the Parrot Developers Summit went very well this weekend
    * concentrated on bugfixes and getting lexicals to work
    * we were 95% of the way on Saturday
    * then I added one last feature, and everything fell apart
    * reviewing how Parrot manages contexts to figure that out
    * something's wrong with the collection of contexts
    * haven't worked on it much since Sunday, but working on it again today
    * updated the Rakudo roadmap in the Parrot repository
    * that looked pretty good
    * otherwise, little changes here and there
    * closed 10 or 12 tickets yesterday
    * more of the same coming up for me

Jerry:

    * organized the PDS over this weekend
    * most important thing we did was create the roadmap for Parrot 1.0
    * release date will be March 2009
    * it'll be a stable platform for high-level language implementors
    * Allison, chromatic, and I posted more details on use.perl.org and parrot.org
    * the most visible work product is the Parrot roadmap, which lists important and critical tasks for Parrot 1.0 and beyond
    * haven't made much progress on my grant in the past week
    * turning back to that now that the conference is over
    * hope to do a whiteboarding session with a couple of local developers later this week
    * then I'll have a draft for review

Allison:

    * makes a big difference to be able to say that we can deliver 1.0 in March


Larry:

    * switched over to a trie implementation, which is closer to a DFA implementation
    * uses less memory and is faster
    * lexers can now reuse the patterns of the lexers of the parent class if they haven't changed


Nicholas:

    * did someone name S17 from "Threads" to "Concurrency"?

Jesse:

    * the canonical source for the Synopses is going to move to the Pugs repo

Patrick:

    * there will be announcements to the mailing lists

Jerry:

    * will there be any changes to version numbers and date updates?

Patrick:

    * they stay up to date pretty well
    * people can be mindful of that
    * we can put commit hooks on them there too

Jesse:

    * we won't meet next week
    * I'll send mail confirming that

来年3月に1.0つーてもすぐにその先があることがわかってるしねえ。>Parrot

■_

序文だけでも偉い訳しづらかった (ですのでたぶん間違ってます。致命的なものがないといいのですが)○| ̄|_

How to be a Programmer: A Short, Comprehensive, and Personal Summary

Chapter 1. Introduction

Table of Contents

To be a good programmer is difficult and noble. The hardest part of making real a 
collective vision of a software project is dealing with one's coworkers and customers. 
Writing computer programs is important and takes great intelligence and skill. But it 
is really child's play compared to everything else that a good programmer must do to 
make a software system that succeeds for both the customer and myriad colleagues for 
whom she is partially responsible. In this essay I attempt to summarize as concisely 
as possible those things that I wish someone had explained to me when I was twenty-one.

よきプログラマーになるということは、困難で、すばらしい(noble) ことです。
ソフトウェアプロジェクトの collective vision (プロジェクト全体のビジョン?)を
現実化するのに最も難しいのはあるひとの coworker 達と顧客 (customers)を扱うことです。
コンピュータープログラムを書くということは重要なことであり、
優れた知性 (great intelligence)と卓越した技術とが求められます。
しかしそれは良いプログラマーが、
顧客と部分的にでも責任を負っている多くの同僚の両方が引き継ぐソフトウエアシステムに対して
行わなければならないことに比べれば子供のお遊びのようなものです。
 

This is very subjective and, therefore, this essay is doomed to be personal and 
somewhat opinionated. I confine myself to problems that a programmer is very likely to 
have to face in her work. Many of these problems and their solutions are so general to 
the human condition that I will probably seem preachy. I hope in spite of this that 
this essay will be useful.

これはとても sujective なことですから、当然のことながら
このエッセイは個人的かつ独断的(opinionated)なものとなる運命にあります。
わたしはここで、問題を自分の仕事に集中しなければならないようなプログラマーに限定します。
こういった問題の多くとその解決策はhuman condition (人間関係?) に関して非常に一般的です。
とはいえ、このエッセイが有用になることを願っています。

Computer programming is taught in courses. The excellent books: The Pragmatic 
Programmer [Prag99], Code Complete [CodeC93], Rapid Development [RDev96], and Extreme 
Programming Explained [XP99] all teach computer programming and the larger issues of 
being a good programmer. The essays of Paul Graham[PGSite] and Eric Raymond[Hacker] 
should certainly be read before or along with this article. This essay differs from 
those excellent works by emphasizing social problems and comprehensively summarizing 
the entire set of necessary skills as I see them.


Computer programming is taught in courses. The excellent books: 
コンピュータープログラミングは courses (大学の教育課程で、ということでいいのかな?)
で教えられます。

The Pragmatic Programmer [Prag99], 


達人プログラマー―システム開発の職人から名匠への道

達人プログラマー―システム開発の職人から名匠への道 Code Complete [CodeC93], コードコンプリート―完全なプログラミングを目指して (Microsoft PRESS)
コードコンプリート―完全なプログラミングを目指して (Microsoft PRESS) 93年だとこっち。 Code Complete第2版〈上〉―完全なプログラミングを目指して
Code Complete第2版〈上〉―完全なプログラミングを目指して Code Complete第2版〈下〉―完全なプログラミングを目指して
Code Complete第2版〈下〉―完全なプログラミングを目指して Rapid Development [RDev96], 原書 Rapid Development: Taming Wild Software Schedules
Rapid Development: Taming Wild Software Schedules ラピッドデベロップメント―効率的な開発を目指して (MicrosoftPRESS)
ラピッドデベロップメント―効率的な開発を目指して (MicrosoftPRESS) Extreme Programming Explained [XP99] 原書 Extreme Programming Explained
Extreme Programming Explained XPエクストリーム・プログラミング入門―変化を受け入れる
XPエクストリーム・プログラミング入門―変化を受け入れる all teach computer programming and the larger issues of これらの本はコンピュータープログラミングだけでなく 良いプログラマーであるためのより大きな話題を扱っています。 Paul Graham や Eric Raymond の数多のエッセイは この文書を読む前か並行して読んでおくべきものでしょう。 In this essay the term boss to refer to whomever gives you projects to do. I use the words business, company, and tribe, synonymously except that business connotes moneymaking, company connotes the modern workplace and tribe is generally the people you share loyalty with. Welcome to the tribe. Chapter 2. Beginner 続く。 かどうかはわかんないけどボリュームが全体で結構あるからなあ

■_

ふむ。んじゃパーツを貼り付けてみやう。 ぺたり。

■_ 本日の晒し上げ


配列の検索 -OKWave

困り度:

    * すぐに回答を!

今配列の中にIDとsp(speak)というものが入っていて、それのsp部分に入っている言葉検索した
いんですがjavascript初心者のためやり方がわかりません。とりあえずarray配列を使っていれ
て例えばchat_mss[0]にはchat_mss[0].idはidの1がはいっていてchat_mss[0].spにはhelloと
入っています。

このときに入力方の検索でhと打ち込んだらhがつくものを全部出すことができますか

これができないと大学卒業できないのでぜひ力を貸してください。

わかる人はソースなど書いてほしいです。

参考にソースを載せます。english_list.phpはMysqlからIDとspををもらっています。

var chat_mss = new Array();
    function chat_mss_atribute(){
}

(以下略)

魚拓 http://s04.megalodon.jp/2008-1205-0221-44/okwave.jp/qa4529697.html

いやもうなんというかその…(苦笑)

■_



Pythonのお勉強 Part30

350 デフォルトの名無しさん [sage] Date:2008/12/04(木) 11:42:52  ID: Be:
    3.0きたな。 

354 デフォルトの名無しさん [sage] Date:2008/12/04(木) 12:21:56  ID: Be:
    3.0きたけど様子見。
    他のライブラリーが対応してないから 

355 デフォルトの名無しさん [sage] Date:2008/12/04(木) 12:24:11  ID: Be:
    まあクオリティ的には Ruby 1.9 より断然上だよな> Python 3.0
    そういえば、 Perl 6 という vaporware もありました。 

356 デフォルトの名無しさん [sage] Date:2008/12/04(木) 12:30:13  ID: Be:
    まだ2.6にも移行してねえんだが…… 

362 デフォルトの名無しさん [sage] Date:2008/12/04(木) 14:17:33  ID: Be:
    3.0のWhat's Newは短いなぁ 

363 デフォルトの名無しさん [] Date:2008/12/04(木) 14:21:57  ID: Be:
    >>362
    変更点は全て列挙してあると思うけど、例を載せてほしいってこと?

364 デフォルトの名無しさん [sage] Date:2008/12/04(木) 15:05:48  ID: Be:
    2.6に多くの機能が入ったからその分短くなったね 

365 デフォルトの名無しさん [sage] Date:2008/12/04(木) 15:43:10  ID: Be:
    そういう問題なのか???

    ありすぎて書けない… わけじゃなく段差の分結果的に
    "what's new" の項目数は少なくなったって感じ? 

366 デフォルトの名無しさん [] Date:2008/12/04(木) 15:44:05  ID: Be:
    >>365
    いやいや、十分長いがなw
    参考文献へのリンクも含めて読んでみろよ。

372 デフォルトの名無しさん [sage] Date:2008/12/04(木) 19:02:54  ID: Be:
    具体的にはどの段階で3.0にいこうすればいいのかね? 

373 デフォルトの名無しさん [sage] Date:2008/12/04(木) 19:35:22  ID: Be:
    >>372
    お前の使ってるライブラリが対応したときだろ。 

374 デフォルトの名無しさん [] Date:2008/12/04(木) 19:59:37  ID: Be:
    まだ 3.0 リリースせずにユーザーがもうちょっと 2.6 に慣れてから
    リリースすればよかったような気がする。

    でも、3.0は長い移行期間が必要とされるから、逆に早めにリリース
    しておきたかったんだろうね。 

377 デフォルトの名無しさん [sage] Date:2008/12/04(木) 20:57:18  ID: Be:
    printのカッコが地味に面倒だな。
    こっちの方が言語的にいいのは、頭では理解してんだけどさ。
    いままでの癖がなかなか抜けなくて、ぱいそんたんに怒られてばっかりだ。 

378 デフォルトの名無しさん [sage] Date:2008/12/04(木) 21:26:41  ID: Be:
    3.0が出たので入れてみた(Vista)

    早速起動した。
    > help()
    打ってみた。動く。
    そこで出た文章に従って
    > modules spam
    打ってみた。

    エラー出た。
    uft-8 ってエンコーディングが見つからないって。
    ・・・・あたりまえじゃああああ
    どこが間違ってるのかよく分からんです。
    Python30のディレクトリ下をgrepして出てくるのは
    Lib/test/bad_encoding.py だけ。これは想定通りだろうが・・・ 

379 デフォルトの名無しさん [sage] Date:2008/12/04(木) 21:35:52  ID: Be:
    ・・・もしかしてLib/testはインストール後に
    除去するのが正しい使い方?
    別んとこによけておいたら、↑も通った。 

380 デフォルトの名無しさん [sage] Date:2008/12/04(木) 22:38:47  ID: Be:
    print("a%s%s" % ('b', 'c'))

    なんかキモイな… 

381 デフォルトの名無しさん [sage] Date:2008/12/04(木) 22:42:12  ID: Be:
    Py3kはユニコード指定しなくていいのが嬉しい。
    これでフレームワークが対応してくれれば・・・。 

382 デフォルトの名無しさん [sage] Date:2008/12/04(木) 22:52:02  ID: Be:
    つーか2.5とかでも別に

    def printf(fmt, *args): print fmt % args,
    def fprintf(f, fmt, *args): print >>f, fmt % args,

    とか定義すりゃ
    printf("a%s%s\n", 'b', 'c')
    とか書けるわなあ

    print()関数は、%とカッコがC風のprintf()より冗長に見えてしまうね 

383 デフォルトの名無しさん [sage] Date:2008/12/04(木) 23:03:10  ID: Be:
    setuptoolもまだ対応してないのかな? 

384 デフォルトの名無しさん [sage] Date:2008/12/04(木) 23:06:11  ID: Be:
    3.0わしょーい 

385 デフォルトの名無しさん [sage] Date:2008/12/05(金) 00:17:30  ID: Be:
    >>380
    boost::format
    みたいだ 

386 デフォルトの名無しさん [sage] Date:2008/12/05(金) 00:28:39  ID: Be:
    print("a{0}{1}".format('b', 'c'))
    print("a", 'b', 'c', sep="") 

387 デフォルトの名無しさん [sage] Date:2008/12/05(金) 00:32:32  ID: Be:
    >>386
    それもキモいな
    あまり意味の感じられない多様性

    Perlみたい 

388 デフォルトの名無しさん [sage] Date:2008/12/05(金) 00:44:15  ID: Be:
    string template は 

389 デフォルトの名無しさん [sage] Date:2008/12/05(金) 00:53:59  ID: Be:
    print文なんて一発プログラムでしか使わん。
    ちょっと込み入った規模ならファイルオブジェクトにwriteするか
    loggingを使ってる。

    潔癖症にかかってる人は
    変える必要など無い所まで変えやがるから
    迷惑この上ない。

390 デフォルトの名無しさん [sage] Date:2008/12/05(金) 01:03:49  ID: Be:
    一貫性に拘りすぎるのはバカみたいなことを
    Pythonの中の人言ってなかったっけか 

391 デフォルトの名無しさん [sage] Date:2008/12/05(金) 01:06:36  ID: Be:
    >>390
    それは本当にそう思うけど
    print()関数は、後方互換性潰してまで導入したのがこれか、とは思う 

392 デフォルトの名無しさん [sage] Date:2008/12/05(金) 01:07:24  ID: Be:
    printは最初っからキモイ 

393 デフォルトの名無しさん [sage] Date:2008/12/05(金) 01:09:51  ID: Be:
    >>392
    全くだw 

394 デフォルトの名無しさん [sage] Date:2008/12/05(金) 01:12:03  ID: Be:
    自演オワタ 

395 デフォルトの名無しさん [sage] Date:2008/12/05(金) 01:15:56  ID: Be:
    単要素のタプルもキモイ 

396 デフォルトの名無しさん [sage] Date:2008/12/05(金) 01:21:54  ID: Be:
    >>389
    じゃぁお前はprintの変更の影響受けて無いじゃん。

    Python開発者は潔癖症なんかじゃないよ。
    print文の変更も議論の上だよ。 print文でファイルに出力する方法とか、最後に改行しない
    方法とか、その為だけに構文を増やしていたのを、普通の関数呼び出しにして柔軟に
    使えるようになった。

    数タイプを削減するためだけに構文増やしまくってたprint文がキモ過ぎただけで、
    print関数は素直で自然な姿。 

さっそくいれますた。 現状、2.6と3.0が両方入ってます。

推薦図書/必読書のためのスレッド 43 

37 デフォルトの名無しさん [sage] Date:2008/12/04(木) 02:59:28  ID: Be:
    アルゴリズムについて1から勉強しなおそうと思っているのですが、どちらの本のほうががいいですか?。

    「新版 C言語によるアルゴリズムとデータ構造」

    「定本 Cプログラマのためのアルゴリズムとデータ構造」

    他にもオススメがあったら教えてください。 

38 デフォルトの名無しさん [sage] Date:2008/12/04(木) 09:41:46  ID: Be:
    アルゴリズムイントロダクション一択 

39 デフォルトの名無しさん [sage] Date:2008/12/04(木) 09:50:35  ID: Be:
    >>38
    レベルが違いすぎる 

40 デフォルトの名無しさん [sage] Date:2008/12/04(木) 12:34:32  ID: Be:
    >>37
    Cは既に出来るのなら「アルゴリズム in C」にしなよ。
    ポインタ使い等怪しげなら先に「Cパズルブック」
    これで他はやる必要なし。 

41 デフォルトの名無しさん [sage] Date:2008/12/04(木) 12:40:19  ID: Be:
    アルゴリズム・イントロダクションの正誤表って出てる?
    挿入ソートでtimes(回数)を時間って訳してる箇所があって
    それ以来本棚に積みっぱなし 

42 デフォルトの名無しさん [sage] Date:2008/12/04(木) 12:43:19  ID: Be:
    Cアルゴリズム全科―基礎からグラフィクスまで 

43 デフォルトの名無しさん [sage] Date:2008/12/04(木) 15:59:21  ID: Be:
    http://www.pej-hed.jp/washo/2635.html
    『実装パターン』
    著:ケント・ベック(Kent Beck)
    発行:2008年12月20日予定

    おお、よさげな本だな、

    と思ったら、

    監訳:長瀬嘉秀、永田渉
    訳:株式会社テクノロジックアート

    orz 

44 デフォルトの名無しさん [sage] Date:2008/12/04(木) 16:13:12  ID: Be:
    また長。 

45 デフォルトの名無しさん [sage] Date:2008/12/04(木) 16:20:50  ID: Be:
    >>43
    ttp://www.amazon.com/dp/0321413091/

    イマイチな評価だが。 

46 デフォルトの名無しさん [sage] Date:2008/12/04(木) 22:32:08  ID: Be:
    >>43
    原著会社にあるけど
    超上流とかアホみたいな肩書きついてる層
    が読む、空気本だから買わなくていいよ 

47 デフォルトの名無しさん [sage] Date:2008/12/04(木) 23:22:45  ID: Be:
    そんな層いるのか・・・ 

48 デフォルトの名無しさん [sage] Date:2008/12/04(木) 23:43:30  ID: Be:
    >>43
    俺はこれ面白かったよ。
    デザインパターン系の本は、
    あまり難しく考えずに、一通り目を通しておくといいよ。
    せっかく日本語で出るんだから。

49 デフォルトの名無しさん [sage] Date:2008/12/04(木) 23:55:15  ID: Be:
    >>43
    テクノロジックアートの訳書といえば、
    エンタープライズアーキテクチャパターンとアジャイルソフトウエア開発の
    2冊を持ってるけど、たしかにどっちも酷かった。 

50 デフォルトの名無しさん [sage] Date:2008/12/05(金) 00:01:27  ID: Be:
    内容的には買いだと思っていたが
    そんなに訳酷いのか?
    原著読むほど気合は入らないしなぁ・・・ 

51 デフォルトの名無しさん [sage] Date:2008/12/05(金) 00:16:49  ID: Be:
    >>45
    一番上の二つ星の奴、結局自分が買ったときに40$払ったのが許せなかっただけだろ?
    ちょっと前までは、これくらいの価格の本は3800円とかしたんだけど、今回は妙に安いね。 

52 デフォルトの名無しさん [sage] Date:2008/12/05(金) 00:18:11  ID: Be:
    単なる下請けのマなのに
    ・考える技術・書く技術
    ・ライト、ついてますか
    を買ってしまった。どちらから読むべきやら・・・

53 デフォルトの名無しさん [sage] Date:2008/12/05(金) 00:18:29  ID: Be:
    ・・・と思ったら、ペーパーバックで176ページ?
    そりゃ高すぎだわなw 

54 デフォルトの名無しさん [sage] Date:2008/12/05(金) 00:24:40  ID: Be:
    >>44
    同業からあれだけ叩かれてる人も珍しいよな 

55 デフォルトの名無しさん [sage] Date:2008/12/05(金) 00:26:19  ID: Be:
    XPの白本がひどすぎた

2008年12月03日

■_

・ドラゴンブック
以前にもちょっと書いたような気もするのですが、 どうもどの大型書店に行っても(わたしが実際に言った範囲で、ですが) 日本語訳ドラゴンブックのIIのほうが置かれていないような気がします。

・ウォズ本 SFC研究所 上席研究員・増井俊之の書評ブログ : 『アップルを創った怪物―もうひとりの創業者、ウォズニアック自伝』スティーブ・ウォズニアック(ダイヤモンド社) あーさっさと読もう。 埋もれないうちに(^^;

■_

リブログされたこれを見て思い出した (なんで元を読んだときに思い出さなかったのだろう)。 → Hexenkessel - 個人的には,C++ は組み込みでこそ生きる言語だと思っていて,レガシーな C...

GLibつかおーよ。というお勧め。



Want To Program Smartly In C? Use GLib | Shantanu's Technophilic Musings

GLib - An Introduction:

GLib is a utility library for C, which augments the standard C library in several 
purposeful ways to make your life that much easier while programming. GLib has the 
following things to offer you:


  1. Portability:


The main issue that haunts any C developer is the portability of code. One cannot rely 
on the standard C library for this as you may find many functions that work 
differently under different platforms are aren't there at all sometimes. GLib ensures 
that the all the functionality exposed by it remains consistent across platforms, so 
that you can rest assured that your code will work the way its supposed to work 
irrespective of the Operating System it's being used for (Of course, this assumes 
that you have ensured about portability aspects of your non-GLib related source code). 
Moreover, GLib is available for a vast array of contemporary Operating Systems 
including GNU/Linux, Microsoft Windows and Mac OS X.


  2. Security:


Though you still need to be careful about things like freeing allocated memories
properly, etc but GLib does ensure that all its functionality is secure. Moreover,
GLib has a policy of ensuring that all its functions are threadsafe. This saves you
from a lot of checks and balances and locks and scheduling considerations if you
had written all this yourself.



  3. Useful Data Types:


GLib exposes a lot of data types. Some are very basic that maintain portability across 
OS's and 32-bit and 64-bit systems. e.g. you can rest assured that gint32 will always 
be 32 bit and gint64 will always be 64 bit data types.

Apart from this, it also provides a lot of derived data types e.g. singly linked lists, 
doubly linked lists, hash tables, stacks, queues, trees, and much more. It'd 
basically cover most of you data structure needs that you'd have otherwise had to 
implement yourselves. And it also provides helper functions that makes working with 
them so much more easier. If you have ever used Perl, and have wished that C 
programming could be a bit faster like it, you will be pleasantly surprised.


  4. Utility Functions:


GLib also provides various utility functions to ease out your manipulation of data. 
Some of the functions are meant as more secure and portable replacements for those 
provided with standard C library, while rest are meant to provide other useful 
functionality which you earlier had to implement in your code. Some of the major areas 
covered by GLib's utility functions are String manipulation, character set 
manipulation and conversion (including unicode and base64), using regular expressions, 
file manipulation, shell functions, config file parsing (my favourite), etc.

End Note: I can understand that there would be a lot of people who believe that use of 
GLib is dumbing down programming in C. After all, we take pride being in control of 
our code and this is why we love progrmming in C because we have options to do things 
in our own way. Yes, that is all true but there comes a time where you'd like to 
spend more time in developing the core functionality of your app, or focus more on 
giving a rapid shape to your new idea, rather than reinventing the wheel and fumbling 
around with writing the helper functions. So, keeping that in mind I believe GLib is 
wonderful piece of code that has enabled me to churn out new apps that much faster.

End Note に書いてあることが深いな。

■_

■_ token

mixiの某コミュのとあるトピックで、 while (n --> 0) のように書くと n が 0に近づいていく雰囲気が出ていいよねとかいう話がありまして。 まあ確かにそういう見方もあるかとは思うのですが本題はそこではなく、 その後についたコメントで、後置デクリメントの演算子(--)を変数と離して置けるとは 知らなかった(思わなかった)というものがありました。 なるほど前置にしろ後置にしろ演算子とその対象の間に空白を置くなんてことは まずやらないでしょうからそう思うのも不自然ではないというところでしょうか。

んでもうひとつ思い出したことが。 どこで読んだものだか忘れてしまったのですが、 FORTRANとBASICは空白に意味がなくて D O I = 1, 10 とか書いてもコンパイラーは きちんと DO I=1,10 と解析するようになっていて BASICもそうだという趣旨のことが書かれていました。 これ、FORTRANは確かにそうですが(でも90あたりからは非推奨?)、 BASICについては記憶違いではないかと思います。

ただし一部のもの、たとえば Hu-BASICでは 予約語を含んだ変数名を使うことができないという仕様でした。 逆に、FORI=10TO20 NEXTIのように書いても、 そこから予約語をきちんと認識して FOR I = 10 TO 100 とか NEXT I のように解釈してくれました。 これを利用して(悪用?)、ソースコードの容量を1バイト単位で削っていったものも 結構あったようです。 わたしは X-1 使いではなかったのでよく知りませんけどねw Hu-BASIC - Wikipedia あれ、この使用のこと載ってないな。 わたしが勘違いかましたか? (^^;

うは。なんか面白いものが。 Hu-BASIC中間コード表

さすがはくりーんこんぴゅーたーw

■_ ?

参照渡しの危険性? - 将来が不安
■[tech] 参照渡しの危険性? このエントリーを含むブックマークCommentsAdd Startosik

int型の参照渡しの関数があって、そこにdouble型を渡してしまったのでint化された一時変数が
渡されていて、何も処理されない、って事はあるよね。もちろん警告は出てるんだけど……怖い
なぁ。ポインタ渡しは弾かれて安全だなぁ、と思った。テンプレートでも良いけど。

void Test( int& a, int& b )
{
  a /= 2;
  b /= 2;
}

double a = 2;
double b = 2;
Test( a, b ); // aもbも2のまま

コメントを書く

moritamorita 2008/12/03 00:13
正しいコンパイラだとそのコードはエラーになります。新しいコンパイラを使いましょう。

へっぽこへっぽこ 2008/12/03 00:26
はじめまして、いつもROMっております。
正しいコンパイラだと、一時変数は非constな参照として渡せないというのもありますね~。
VCでコンパイルできたアプリをgccに持っていったら、この手のエラーが続出した思い出がありますw

これがエラーにならないコンパイラーってあるの(あったの)? int と double には継承関係もないし、通るほうが変だと思うんだけど。

g++ -c mmm.cpp
mmm.cpp: In function `int main()':
mmm.cpp:12: error: invalid initialization of reference of type 'int&' from expre
ssion of type 'double'
mmm.cpp:2: error: in passing argument 1 of `void Test(int&, int&)'

cl -c mmm.cpp
Microsoft(R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for 80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.

mmm.cpp
mmm.cpp(12) : error C2664: 'Test' : 1 番目の引数を 'double' から 'int &' に変換
できません。
        'const' に対してではない参照は 非左辺値へバインドできません。

さすがに VC++ 4.2 とか Borland C++ 4.x とか引っ張り出して調べる元気はないw

■_ 初期化

"".equals(stringVariable) は改悪だろう - まちゅダイアリー(2008-11-30)
(1) ローカル変数の場合はコンパイラが null チェックをしてくれる

stringVariable がローカルで宣言した変数の場合は、初期化の有無をコンパイラがチェックし
てくれる。 以下のコードは初期化されていない変数に対してメソッドを呼び出しているので、
「変数 stringVariable は初期化されていない可能性があります」というコンパイルエラーにな
る。 なので、わざわざトリッキーな書き方をする必要はない。

    String stringVariable;
    if (stringVariable.equals("")) {   // この行でコンパイルエラー
       // なにか処理をやる
    }
まぁ、このコンパイルエラーに対して、以下のように修正する人がいるんだけどね…。 せっか くの静的チェックが台無し。
    String stringVariable = null;
    if (stringVariable.equals("")) {
      // NullPointerException が発生する
    }
宣言時に null で初期化するのも、 Java では良くない書き方。 まさか、「変数は null で初 期化する」という規約を定めていて、「"".equals(stringVariable) と書くこと」と いう風習ができた…ことはないよね?
"".equals(stringVariable) は改悪だろう - まちゅダイアリー(2008-11-30)
■1 PoohKid (2008-12-01 (月) 01:16)

>宣言時に null で初期化するのも、 Java では良くない書き方
ごめんなさいごめんなさい…><
C/C++で教育された癖が抜けない、というか宣言時に何も入っていないと不安なんですう。
■2 まちゅ (2008-12-01 (月) 08:20)

確かにC/C++に慣れると不安ですよねw 

まあ「適切に判断して初期化せよ」よりは 「とにかく何かしらの値で初期化しとけ」 的なルールはありそうな気がするなあ。

"".equals(stringVariable) は改悪だろう - まちゅダイアリー(2008-11-30)

ちゃんと考えておけば "".equals(stringVariable) なんて書く必要は全くないよ。

いやまったく。

空文字チェック - nullpo.printStackTrace();

■_ stackoverflow で訊いてみた: よいコードの見分け方って?

今日もまた stackoverflowに寄せられたお題からひとつ。

How can we identify "good code"? - Stack Overflow
How can we identify “good code”?

There's already a great long post on identifying bad code (see Code Smells).

I'd like to ask for the reverse. Do you know any good procedures or checks to identify 
good code? Quick pointers such as "the class definition fits on one page together 
with it's documentation", or "the code can be effortlessly re-used" 
would be great, longer thought-through answers about code review or metrics are also 
welcome.

I'd like to get some input on this to build up to a positive-reinforcement code review 
and analysis at my work, because I feel that would be more productive than pure 
criticism (though both will likely be combined in the end).


    * It's easy to tell what functions/classes/variables do based solely on their names.
    * Implementations are expressive -- no space is wasted in getting the semantics of 
      an algorithm through to the reader, and there is very, very little repetition.
    * There is good unit-test coverage.
    * The program builds itself.
    * Comments explain WHY something is done, not WHAT is done.
    * The style of the code is consistent (no matter who is doing the writing)
    * The code performs well.
    * It's not Bad Code. ;-)

1 - It works

2 - It keeps working

3 - You can understand why

Good code is hard to define but I think as rules of thumb a good code is easy for 
maintenance : 1) Anybody can jump on it and modified it, 2) Name convention, good 
cohesion,

But if you want a deeper and less personal answer I suggest to refer to Mc Call (1977) 
and his software attribute about software quality:

    * Maintainability, the ability to find and fix a defect.
    * Flexibility, the ability to make changes required as dictated by the business.
    * Testability, the ability to Validate the software requirements.
    * Portability, the ability to transfer the software from one environment to another.
    * Reusability, the ease of using existing software components in a different context.
    * Interoperability, the extent, or ease, to which software components work together.
    * Correctness, the functionality matches the specification.
    * Reliability, the extent to which the system fails.
    * Efficiency, system resource (including cpu, disk, memory, network) usage.
    * Integrity, protection from unauthorized access.
    * Usability, ease of use.

These are good point to figure out if the whole code (the software) is "good" or "bad".

You can find more information at SQC Software Quality

悪くないコードが良いコードっていってもなあw 「キミが理解できるコード」ってのは皮肉もあるんだろうけど言いえて妙だな。

■_

C#, C♯, C#相談室 Part49

666 デフォルトの名無しさん [] Date:2008/12/01(月) 19:51:25  ID: Be:
    C#のスレッドとネットワークの本をだれか寄付してくれ。
    おいら金がない。 

667 デフォルトの名無しさん [sage] Date:2008/12/01(月) 20:00:01  ID: Be:
    金がない奴ぁおれんとこ来い
    おれもないけど心配するな 

668 デフォルトの名無しさん [sage] Date:2008/12/01(月) 20:03:58  ID: Be:
    青島乙 

初心者のためのプログラミング言語ガイド Part12

125 デフォルトの名無しさん [] Date:2008/12/01(月) 00:05:43  ID: Be:
    初めての人は何から学ぶべきでしょうか? 

126 デフォルトの名無しさん [sage] Date:2008/12/01(月) 00:11:13  ID: Be:
    >>125
    RubyかPython辺りがいいんじゃないかい 

127 デフォルトの名無しさん [sage] Date:2008/12/01(月) 00:11:14  ID: Be:
    そんなに深く考えないで目に付いたのか始めてみたら? 

128 デフォルトの名無しさん [] Date:2008/12/01(月) 00:16:51  ID: Be:
    アドバイスありがとうございます。
    まったくの初心者なので何もわかりません。
    とりあえずアドバイスいただいたものから本でも探してみます 

129 デフォルトの名無しさん [sage] Date:2008/12/01(月) 00:29:21  ID: Be:
    >>125

    GUIにこだわるのならば、C#。 

130 デフォルトの名無しさん [sage] Date:2008/12/01(月) 00:35:13  ID: Be:
    >>125
    ファミベー 

131 デフォルトの名無しさん [sage] Date:2008/12/01(月) 00:50:37  ID: Be:
    言語仕様がタプタプ霜降り贅肉だと初心者向きではない 

132 デフォルトの名無しさん [sage] Date:2008/12/01(月) 00:57:21  ID: Be:
    HQ+の出番だな 

133 デフォルトの名無しさん [sage] Date:2008/12/01(月) 00:57:50  ID: Be:
    >>128
    Apple系限定だけどObjective-Cお勧め。 

134 デフォルトの名無しさん [sage] Date:2008/12/01(月) 03:29:26  ID: Be:
    Obj-Cを進める前にC++を進めてやれよw 

135 デフォルトの名無しさん [sage] Date:2008/12/01(月) 03:44:48  ID: Be:
    >>128
    初めてなんだったら奥までつっこまないCを薦める。
    あまり、プリプロッセッサやポインタとか構造体まで行かない範囲で。

    コンピュータ科学も考えているならLisp系も学ぶ。

    お手軽に何かを書きたいならRubyかPython。 

136 デフォルトの名無しさん [sage] Date:2008/12/01(月) 07:55:30  ID: Be:
    ポインタと構造体まで行かないのなら最初からRuby/Pythonでいいじゃん。 

137 デフォルトの名無しさん [sage] Date:2008/12/01(月) 08:36:27  ID: Be:
    俺はRPGツクールを勧める 

139 デフォルトの名無しさん [sage] Date:2008/12/01(月) 11:44:29  ID: Be:
    Prologを奬めます。 

140 デフォルトの名無しさん [sage] Date:2008/12/01(月) 15:26:31  ID: Be:
    >>132
    HQ9+だろ。

    >>125
    Brainfuckマジおすすめ 

141 デフォルトの名無しさん [] Date:2008/12/01(月) 16:41:37  ID: Be:
    皆さんありがとうございます。色々候補をあげていただいたので、
    一つずつ調べてみます。色々あって大変ですが、頑張ります 

147 デフォルトの名無しさん [sage] Date:2008/12/01(月) 18:48:16  ID: Be:
    >>141
    ネタ回答もけっこう混ざってるので、最終的には自分の判断で
    何がやりたいか決めてないと、もうそれこそ好みの世界になるので十人十色 


    158 デフォルトの名無しさん [sage] Date:2008/12/03(水) 15:05:38  ID: Be:
    プログラミング未経験、全くの初学者です。
    c言語やVBといった言葉は単語としては知っていますが現在まで全く触ったこともありません。

    最近、サウンドの出力に関するツールを探していたのですが自身の希望するような機能を備えたものは見つからず。
    この機会にプログラミングを学んで自力でツールを作成できるようになりたいと考えています。

    作成を目指すツールは
    windowsXP上でGUIで動作する、サウンド出力に関するもの
    具体的にはサウンドのルーティングと、その際に音量の増大や高低の調整など簡単なエフェクトをかけることができるものにしたいです
    また同時にサウンドルーティングの中継点となる仮想オーディオデバイスの作成も希望しています

    現状、全くのずぶの素人であるため、掲げた目標がどの程度先にあるものかも自身には判然としていませんが
    まあ目標は目標としつつ、ゆっくりでもいいので勉強していきたいと思っています。

    希望するツールの作成にはどのような技術が必要なのか、
    初学者ですので基礎から始めることになりますが将来的にはどの言語でツールを作成することになるのかなど、
    学習の方向性に助言をお願いします。

159 デフォルトの名無しさん [sage] Date:2008/12/03(水) 15:24:56  ID: Be:
    とりあえず物理数学だな 

160 デフォルトの名無しさん [sage] Date:2008/12/03(水) 16:11:32  ID: Be:
    国語と言われなくてひとまず安心した 

161 デフォルトの名無しさん [sage] Date:2008/12/03(水) 16:45:11  ID: Be:
    うるせぇよゆとり 

162 デフォルトの名無しさん [] Date:2008/12/03(水) 20:52:27  ID: Be:
    >>158
    DirectXのフィルタを作りたいってこと?
    サウンドデバイスはよーわからんけど。

    ドライバ作成するハメになりそうだったりCOM使わないといけなかったりするなら
    C++ 

2008年12月02日

■_

東京 - 梶本裕介の日記
持っていく物はノートとペンだけで良いのだろうか

faith_and_brave 2008/12/02 11:13

いいんじゃないかと。
コメント一覧は印刷して配布されると思うので。

あ、なんたら会議(忘れた)でいらっしゃるのでしょうか?

・iPhone
先週末に新宿の紀伊國屋書店に行ったときに、意外に思えるくらいiPhone関連の プログラミング本がありました(洋書ですが)。 BlackberryとかWindows Mobileは見かけなかったので、 そっち方面(てどっち?)には本が何冊も出るほどの需要があるのだなあと。 iPhoneネイティブアプリ開発の必読リンク5本 | iPhone 3G Wiki blog iPhoneアプリ開発苦労話ベスト3―伝説の開発者に訊く(その1) - builder by ZDNet Japan iPhoneアプリここがちがうよベスト3―伝説の開発者に訊く(その2) - builder by ZDNet Japan

・スライド
なんかいろいろ見つかったので。

DBIx::Class beginners
View SlideShare presentation or Upload your own. (tags: dbix::class dbic)
Proud To Use Perl
View SlideShare presentation or Upload your own. (tags: community yacpeu2008)
Perl Myths 200802 with notes
View SlideShare presentation or Upload your own. (tags: perl5 cpan)

■_ 新顔さんとか更新とか

まあいろいろと。

WebHome < Helium < TWiki

Helium is a functional programming language (a subset of Haskell) and a compiler 
designed especially for teaching. The main developers and initiators are Arjan van 
IJzendoorn, Rijk Jan van Haaften, Bastiaan Heeren and Daan Leijen. Currently, Jurriaan 
Hage, Bastiaan Heeren and Arie Middelkoop maintain the compiler and associated tools. 
For more information about Helium contact us.

Hekium はHaskellのサブセットである関数型のプログラミング言語で、特に教育を目的として
コンパイラーのデザインが行われています。主な開発者と initiators には、
Arjan van IJzendoorn, Rijk Jan van Haaften, Bastiaan Heeren and Daan Leijen. Currently,
Jurriaan Hage, Bastiaan Heeren といった人たちがいて、
Arie Middelkoop がコンパイラーおよび関連するツールの保守を行っています。
Heliumに関してのより詳しいことはわたしたちに連絡をとってください。

At this moment, version 1.7 is under construction, with a focus on improving the 
usability and consistency of the system. Preliminary versions of the sources can be 
found under Downloads.

現時点では version 1.7 が開発途上にあり、使い勝手の向上とシステムの一貫性に焦点が
あてられています。ソースのPreliminary versions がダウンロード可能です。
→ http://www.cs.uu.nl/wiki/bin/view/Helium/Downloads

The following modifications have been made

    * compiles with GHC 6.8.1 and 6.8.2
    * additional compiler flags
    * after-install tests were developed as bugs in the installation phase were discovered
    * texthint is now improved and supports compiler flags. Same goes for Hint.
    * add configuration files for helium related settings to be used by Hint and texthint
    * support for switching between versions of Helium
    * allow special alert compilations easily from Hint and texthint (--alert or :a options).
    * new documentation consistent with version 1.7 

The schedule for the coming period is:

    * check documentation consistency
    * construct binary installers
    * bug fix type inferencer
    * add type classes in full 

Longer term:

    * and extend Helium further to support full Haskell 98.
    * change the back-end. The LVM has bugs and there is currently no support available.
    * couple Helium to a graphical library, e.g., wxHaskell or GTK2hs. 

If you think you can do something for us on the above, please contact us. 
Thyrd 0.2.0 Released - PLNews: Programming Language News

Thyrd 0.2.0 has been released. It is a visual, postfix concatenative language and 
development environment. 

→
http://thyrd.org/thyrd/

えーとこの言語は前に見たことがあったっけ? postfix がなんちゃらというのも いくつもあるからなあ。

S9fES Update Available - PLNews: Programming Language News

An updated version of Scheme 9 from Empty Space has been released. It is an R4RS 
Scheme interpreter.

This update includes a simpler infrastructure for primitive procedures. 

→
http://www.t3x.org/s9fes/

ディープスペースナイン に掛けた名前? ちがった。リンク先のページに Above artwork is based on the movie "Plan 9 from Outer Space" and used under the assumption of fair use. ってあるわ。

Scheme 9 from Empty Space
Scheme 9 from Empty Space

S9fES is an interpreter for a broad subset of (R4RS) Scheme. It is written in ANSI C 
(C89) and Scheme.

The S9fES code strives to be simple and comprehensible. It is particularly interesting 
to people who want to

    * try Scheme without having to jump through too many hoops (S9fES is very portable);
    * study the implementation of Scheme (in a language other than Scheme). 

Latest update: 2008-11-29

Scheme 9 - The Book

The Scheme 9 book discusses the implementation in detail and covers the theory behind the scenes.

Before you ask

Why in earth write another half-baked implementation of Scheme?
It is better than getting drunk at a bar.

How complete is it?
S9fES implements R4RS modulo a few omissions. See the man page for details.

Why is it only R4RS-compliant?
R4RS is slightly easier to implement than R5RS Scheme. R6RS? Oh, please.

What are its conditions of use?
Don't worry, be happy.

実装するのに簡単だから R4RS を採用してますよ。と。 せっかくだからこいつのソースコードを読んでみようか。

PILS Announced - PLNews: Programming Language News

PILS has been announced. It is a functional programming language and implementation. 

announced とだけあるってことはたぶん一見さんだな。 って、 The PILS programming language and system has been developed by me during the years 1979 to 2008, originally as an attempt to improve on Lisp. 何年やってるんだw

The PILS programming language

The PILS programming language and system has been developed by me during the years 
1979 to 2008, originally as an attempt to improve on Lisp. However, under influence of 
Prolog, C++, XSLT and SQL, and certain features of spoken Danish, it grew into 
something quite different.

Like Lisp, PILS uses a unified data model for programs and data, but whereas Lisp uses 
lists, PILS uses attribute based nodes as the building stones of its data model. For 
brevity, attributes are referred to as legs. The simple functions in Lisp have, by 
Prolog inspiration, given way for pattern matching based rulesets, which – inspired by 
C++ – are treated as objects and can be combined in may ways.

Qu 1.22 Released - PLNews: Programming Language News
Qu 1.22 has been released. Qu is a general-purpose, object-oriented language.

This release includes: the addition of the Node module, the addition of 
String.xmlescape and String.xmlunescape, the addition of Sys.typeof and Sys.subtypeof, 
bug fixes, the addition of Var.istransient, and other changes. 

→
http://www.qu-lang.org/

■_ stackoverflow で訊いてみた: あなたにとっての(プログラミング分野での)ヒーローは誰ですか?

Who is your programming hero? - Stack Overflow
Longer question

Who is most influential in the development of your craft? Who is the person you 
get/got the most from in your programming career?

Notes

    * One person per answer.
    * Up vote answers that you would've put, to reduce duplication.
    * A reason why would be great. If they are still current, a link to their blog 
      would be extra great.
    * They don't have to be well known, but a reason and a link would make the answer 
      much more useful.

Edit

    * This was intended to be asking about you're influences; on a day to day level, 
      Steve Yegge influences me far more than Alan Turing.
    * Thanks for all the great suggestions for blogs to read, and start catching up on. 
      Some of these folks are completely new to me.
    * The requests in the notes were to make the question work in the context of Stack 
      Overflow. The emphasis was added later, by someone else. I appreciate their 
      frustration, and thank them for their edit, but I won't take the credit for that edit.
    * Unless anyone has any objections, I shall close this question.
Donald Knuth deserves a mention among many.
Alan Turing, the father of modern computer science.

Edsger Dijkstra

Martin Fowler

Probably the person with the strongest influence on recent development trends like 
design patterns, agile methodologies.

Steve McConnell

Anders Hejlsberg; Turbo Pascal, Delphi, J++ and not least C# and the Microsoft .NET 
framework.

John Carmack, I daresay.
http://en.wikipedia.org/wiki/John_D._Carmack


Scott Guthrie - He runs several of the dev teams that build the products I use everyday.

Guido van Rossum, Benevolent Dictator for Life, Python.

Bjarne Stroustrup Who created C84 - what we know as C++.

Good Old Bill Gates !!

He wrote the original BASIC compiler for DOS..

Steve Yegge. Worked at Amazon for several years and is now at Google. He wrote an 
internal blog at Amazon that he later made public, I found it educational and also 
extremely inspiring. It had a significant effect on my growth as a developer.

Mark Russinovich
http://en.wikipedia.org/wiki/Mark_Russinovich

Richard Stallman

Why, Jeff and Joel, of course.

Brian Kernighan, through his writing of Software Tools, Elements of Programming Style 
and others.

Larry Wall, because he invented Perl and had so much fun doing it. Laziness, 
impatience, and hubris man. All the way.

Douglas Hofstadter, mainly for writing Godel, Escher, Bach

The Gang of Four, for their design pattern book.
http://en.wikipedia.org/wiki/Gang_of_Four_(software)

Countess Ada Lovelace - 19th century female mathematician. Regarded by many as "the 
first programmer", for devising algorithms for Babbage's theoretical analytical engine. 
Eponym of the Ada programming language.

Steve Wozniak wasn't he the father of the PC (graphical interface, mouse, floppy drive). 
If what I read is correct he did most of the development in his head cos he didn't 
have the money to buy the hardware.

Alan Kay for sure!

John McCarthy, for inventing Lisp...

Yukihiro Matsumoto (aka Matz)

Miguel de Icaza
http://stackoverflow.com/users/16929/migueldeicaza

John von Neumann
http://en.wikipedia.org/wiki/John_von_Neumann

What about Kent Beck?

Peter Molyneux
http://en.wikipedia.org/wiki/Peter_Molyneux

ゲーム方面で名前の挙がってた人、知らなかった(苦笑) しかし、Wikipediaにはちゃんと載ってた。 すごいぞ(ry

もしよろしければ、あなたにとってのヒーローを教えてください。 わたし? ミドリノセロー こと 作者: 田中 良知 さんです。 最近は書いてなかったと思いますが、 是非とも一度なりとお目にかかりたい人です。 98年のPerl Conferenceが最大にして最後のチャンスだったかも。 運営側は serowさんにも参加の打診をされたそうなのですが、 お断りになったそうで残念至極。

■_

An interesting C linked list idiom - Stack Overflow
http://stackoverflow.com/questions/332441/an-interesting-c-linked-list-idiom

チェックのコメントが厳しめw

Is Yacc still used in the industry? - Stack Overflow
http://stackoverflow.com/questions/332734/is-yacc-still-used-in-the-industry

DBIx::Class beginners - SlideShare
http://www.slideshare.net/ranguard/dbixclass-beginners-presentation

Proud To Use Perl - SlideShare
http://www.slideshare.net/davorg/proud-to-use-perl-presentation

Perl Myths 200802 with notes - SlideShare
http://www.slideshare.net/Tim.Bunce/perl-myths-200802-with-notes

Compiler for simple expressions using LLVM and Python
http://code2code.wordpress.com/2008/11/29/code-generation/

2008年12月01日

■_

Inemuri nezumi diary(2008-11-30)
いけがみさんの書き込みを引き出せてとても嬉しいです。 いろいろ勉強になりました。 しかし、やはり英語版のWikipediaは侮れない。 Cycle detection - Wikipedia, the free encyclopedia miura1729の日記 先行者/後続者 - 黎明日記

関数の話をしよう - @IT
まだついて行けるw

・Programming in Haskell
ソフトカバーの方を新宿のジュンク堂と紀伊國屋書店南新宿店の両方で見かけたのですが、 その値段は2000円近く違ってました>< まあ自分はもう買ってしまっているのでどうでもいいといえばどうでもいいのですが、 これは最近の円高の影響?

・msを騙るフィッシングメールがきました
でもリンク先でバレバレw

■_

■_ div

最適化を掛けるのを忘れていました。

int
foo(int x, int y)
{
	extern int q;
	extern int r;
	q = x / y;
	r = x % y;
	return q*r;
}


	.file	"hoge.c"
	.text
	.p2align 4,,15
.globl _foo
	.def	_foo;	.scl	2;	.type	32;	.endef
_foo:
	pushl	%ebp
	movl	%esp, %ebp
	movl	8(%ebp), %eax
	cltd
	idivl	12(%ebp)
	popl	%ebp
	movl	%eax, _q
	imull	%edx, %eax
	movl	%edx, _r
	ret

おお、割り算命令がひとつにまとまった。

melancholic afternoon
・divの存在意義
C99やC++0x(多分)以前のC/C++では負数の%が処理系依存だからdivがあるのは意味があった気がする.

なるほどですが、C99になる前から除数と被除数が異符号のときの振る舞いは 決まっていたんでしょうか?

■_ 正規表現の構文

なんかちょっといいタイミング。

Lisp Scheme Part24

649 デフォルトの名無しさん [sage] Date:2008/11/28(金) 23:04:49  ID: Be:
    Emacs Lispが正規表現を文字列で記述することに対する不満は見かけるのに
    Scheme(除くGauche、PLTScheme)やCommon Lispではさっぱり見かけないのが不思議だったのですが
    Emacs Lispと違ってリーダマクロがあるからだったんですね(たぶん)
    リーダマクロのあるScheme処理系が結構多いということをはじめて知りました 

650 デフォルトの名無しさん [sage] Date:2008/11/28(金) 23:20:15  ID: Be:
    Emacsはギャップバッファに対する正規表現サーチが組み込み関数なんだよ。
    ギャップバッファの性質上、(point)使って実装すると遅い。
    Lisp/Schemeは、pregexpみたいなライブラリを自前で書いても
    それほど速度は落ちない。まともなコンパイラさえあれば。
    ;; むしろpregexpは他言語のライブラリと比べても速い。 

651 649 [sage] Date:2008/11/28(金) 23:44:30  ID: Be:
    あ、速度はともかく「バックスラッシュのお化け」なところです。
    CLでppcreをコンパイルするとperlよりも速いそうですね。

    リーダマクロについて調べてみたら
    Gauche:ない
    PLT, Guile, Chicken:ある
    Gambit-C:リードテーブルはあるがリーダマクロの追加・編集はできない
    のようです 

653 デフォルトの名無しさん [sage] Date:2008/11/29(土) 00:13:08  ID: Be:
    >>651
    たとえばprintf("%d", n);って書くでしょ
    バックスラッシュやめて%を使えば解決
    もしこれがprintf("\\d", n);だと大変だけど、文字列を使うこと自体は問題ない 

657 649 [sage] Date:2008/11/29(土) 11:25:50  ID: Be:
    >>653
    オレ表現とか書式文字列/formatテンプレートならそれでもいいかもしれませんが
    正規表現ってバックスラッシュを多用しますよね?(私だけ?)
    正規表現を文字列で表現するのが問題だというのではなくて
    文字列として評価される時のエスケープシーケンスとしてのバックスラッシュと
    正規表現としてのバックスラッシュが重なって読み辛くなるという話です。
    そしてこれを解消するのはマクロでは無理で、リードマクロの力が必要になるということです。 

658 デフォルトの名無しさん [sage] Date:2008/11/29(土) 11:41:21  ID: Be:
    リーダマクロのないEmacs Lispだから置き換えを勧めているだけでは?
    理解力ゼロ?

659 デフォルトの名無しさん [sage] Date:2008/11/29(土) 12:03:34  ID: Be:
    651の言いたい事はそういう事か、やっと分かった。
    理解力の問題か? 

660 デフォルトの名無しさん [sage] Date:2008/11/29(土) 12:04:15  ID: Be:
    ちがった、653ね 

661 デフォルトの名無しさん [sage] Date:2008/11/29(土) 12:29:08  ID: Be:
    リードマクロに健全なマクロ
    マクロは広大だわ

items.sjbach.com ≫ Clojure's new regex syntax
Clojure's new regex syntax

Last week, Rich Hickey announced a few notable changes to Clojure, including 
ahead-of-time compilation and a cleaner syntax for regular expressions. Both are 
improvements, but the syntax is especially interesting for a reason unrelated to its 
function. First, a quick overview.

先週のことですが、Rich Hickey がClojureにいくつかのnotableな変更をするという
アナウンスをしました。
それにはahead-of-time compilation、正規表現のよりわかりやすい構文が含まれています。
どちらも改良なのですが、構文のほうは特に

ではまずざっと見ることにしましょう。

1. What has changed

In a sentence, fewer backslashes. The notation is now more in line with that of 
scripting languages, where regular expressions are first-class literals, than that of 
general-purpose languages like C++ or Java, where regexes are just specialized strings.

簡単に言うと、バックスラッシュを少なく。です。
表記は、C++やJavaのような汎用言語の単なる特殊な文字列のようなものから
正規表現が first-class リテラルであるようなスクリプティング言語に近いものになりました。

Say we are given a stream including this text:

...
<img  src="images/11/apple1.gif"/>
<img   src="images/2/bulb2.jpeg"/>
<img src="images/354/citrus32_a.png"/>
...

We want to select IMG tags and capture the basename (without extension) of each source 
file. This can be done in many ways; here's a blueprint which is just barely good 
enough:

わたしたちはIMG タグを選択し、そこに含まれるそれぞぞれのソースファイルの
(拡張子を除外した) basenameを取り出したいと考えています。
これは多くのやり方で実現できます。
以下に挙げるのはとりあえずは役目を過不足なく果たす青写真(blueprint)です:

<img [whitespace]+
     src=" [word-char]+ / [digit]+ / ([word-char]+) ...

Converting this to Clojure's old syntax gives us a somewhat unwieldly 
これをClojureの古い構文で(多少不恰好ですが)書き直します

#"<img\\s+src=\"\\w+/\\d+/(\\w+)". A quick test:

(let [lines "...
             <img  src=\"images/11/apple1.gif\"/>
             <img   src=\"images/2/bulb2.jpeg\"/>
             <img src=\"images/354/citrus32_a.png\"/>
             ..."]
  ;; Return only the captures, not the full matches.
  ;;  マッチした全体ではなくキャプチャーしたものを返す
  (map second
       (re-seq #"<img\\s+src=\"\\w+/\\d+/(\\w+)" lines)))
 
=> ("apple1" "bulb2" "citrus32_a")

The new update to the reader allows us to remove the double escaping of the regex 
specials in the literal:

リーダーに対する新しい更新によって、リテラル中にある正規表現の特殊表記に対する
二重エスケープを取り除くことが可能になります:

(map second
     (re-seq #"<img\s+src=\"\w+/\d+/(\w+)" lines)))

2. Clojure vs foo
   Clojure 対 ほげほげ

Since we're on the topic, here's how Clojure's syntax compares to popular languages.

Since we're on the topic,
ここで Clojure の構文と一般的な言語との比較をしてみましょう。

Ruby and Perl 5

# Regular usage 通常の使い方
/<img\s+src="\w+\/\d+\/(\w+)/
 
# Choosing a different delimiter: デリミターとして違うものを使ってみる
 m|<img\s+src="\w+/\d+/(\w+)|     # Perl
%r|<img\s+src="\w+/\d+/(\w+)|     # Ruby

The clearest of all extant languages (at least in this regard), Ruby and Perl can 
avoid some extra escaping by changing the delimiter character from / to |

(少なくとも現在論じている面において)現存する言語の中でもっとも clean である
Ruby と Perl はデリミターとなるキャラクタを / から | と変更することで
余計なエスケープをいくらか取り除くことができます。

Emacs Lisp

"<img\\s-+src=\"\\w+/[[:digit:]]+/\\(\\w+\\)"

Well, the expression is long and ugly. An upside is that because of the quote 
delimiters, forward-slashes need not be escaped.

うーん長くて見づらいですね。
攻めての救いと云えば、クォートをデリミターとして使っているので
フォワードスラッシュにはエスケープは不要だということです。

Java

"<img\\s+src=\"\\w+/\\d+/(\\w+)"

This is the same as Clojure's original syntax. For reference, Clojure and Java share
a regex engine and are equivalent in power.

これはClojureの変更前の構文と同様です。
参考までに書いておくと、ClojureとJavaは同じ正規表現エンジンを共有していて
その力は同じものです。

Common Lisp

Edi Weitz's professional CL-PPCRE package is essentially the standard for dealing with 
regular expressions in CL.

Edi Weitz による professional CL-PPCRE package  はCommon Lispで正規表現を扱うときの
標準といえるものです。

"<img\\s+src=\"\\w+/\\d+/(\\w+)"

Also, Edi's CL-INTERPOL package provides a reader macro which makes regex literals as 
straightforward as Perl's:

また、EdiのCL-INTERPOL パッケージは正規表現リテラルをPerlのそれのようにしてしまう
リーダーマクロを提供しています。

#?r|<img\s+src="\w+/\d+/(\w+)|

Finally, the reader-macro mastery of Doug Hoyte's Let Over Lambda gives a method of 
making clear, functional literals:

最後に、reader-macro のエキスパートである Doug Hoyte 
(reader-macro mastery of Doug Hoyte) の Let Over Lambda にある
明快で関数的なリテラルを作り出すメソッドを紹介しましょう:

#Let Over Lambda
#→

;; This is an executable lambda:
;; これは実行可能な lambda です:
#~m|<img\s+src="\w+/\d+/(\w+)|

3. The real reason this is neat

The modification was proposed by Chris Houser (with a simple patch) on October 7, 
politely debated until October 10, and committed to Clojure in r1070 on October 15.* 
This syntax was better, and the discussion skipped if it should be applied, directly 
to how.

この修正は、10月7日に簡単なパッチを添えて Chris Houser によって提案されました。
10月10日まで politely debate (突っ込んだ議論?) されました。
そして10月15日の r1070 で Clojureにコミットされました。
This syntax was better, and the discussion skipped if it should be applied, directly 
to how.

Turnaround time for a breaking change: one week. You have to respect that velocity.

There is a feeling in the development community that Clojure has a good chance of 
becoming an important language. Now is the brief time when any interested programmer 
could contribute something significant, in an environment which recognizes intelligent 
contribution and lacks ? for the moment ? politics and tradition.

Want to help? The Clojure mailing list is high signal-to-noise, and joining it is a 
good way to get acclimated. Also, communicating realtime with Rich Hickey and other 
Clojure experts is no more difficult than joining an IRC channel: #clojure on freenode.

* There was also a similar discussion in March, but it did not include a patch.

■_ 入門書

マナちゃんのやさしいC++とか - 予定は未定Blog版

■[C++][Book]マナちゃんのやさしいC++とか

同じくときどきの雑記帖さんから、"マナちゃんのやさしいC++*"について。

この本は結構ウソというか、そんな感じの表現が目立つからおすすめはできないなー。

やっぱり初心者にはAccelerated C++がいいと思うな。

ロベールのC++入門講座は持ってないけど、ちょっと立ち読みしたときに「stringクラス」なる
表現があったのが気になった。

まぁ、初心者に対してこの程度のごまかしはありだろうけどね。

高橋麻奈さんがずいぶん手広く入門書を出されているのは知っていたのですが、 中身をチェックしたことはありませんでした。 今回三項演算子/条件演算子を調べるためにちょっと立ち読みさせてもらいましたが。 C++そのものの入門書ではありませんが、もうすぐ出版されるすっぽすっぽ先生の 新刊がどうなるか楽しみです。

■_ Rakudo

Journal of pmichaud (6013)
Today I added in support for the :global/:g flag in the .subst method (S05); now we 
can do things like:

        > my $i = 0; say "There's more than one way".subst(/e/, { ++$i }, :global);
        Th1r2's mor3 than on4 way

Previously the .subst method would only work on the first match in a string. Rakudo 
still doesn't recognize the case where the :global flag is part of the regex, but at 
least we now have at least one concise mechanism for performing global search/replace 
on a string.

Within the closure argument one can use $/, $0, $1, etc. to refer to the matched 
portions of the string in the replacement. Getting that to work meant that we needed 
to fix the binding of $/ within closures -- it turns out the mechanism we were trying 
to use previously (!OUTER) can't really work in Parrot. As a bonus, fixing this 
simplified actions.pm slightly, and removed several internal subroutine calls that 
were being performed at the start of each closure.

Of course, the pattern and replacement arguments to .subst can be simple strings, but 
any variable substitutions in the replacement string then refer to the outer 
environment and not the values from the matched string.

Now we just need to verify and add a few more tests for this. :-)

Pm

.subst(/e/, { ++$i }, :global)の :global って引数(フラグ?)の渡し方が なんとなくLispを連想させる。 しかし S05、しばらく見ていないうちにまーた大分変わっているっぽいな(^^;

■_ Rubyって

Rubyを学習するには -OKWave

全くのプログラミング初学者がRubyを習得するにはどうすればいいのでしょうか。やはり専門学
校にでも行かないとだめなのでしょうか。

まだ多くの専門学校では、Rubyは教育用の言語に入っていないのではないでしょうか?

また個人的な感想ですが、Rubyはいろんな言語の特徴を研究して、開発者である松本氏が作り上
げた言語のようですが、特にラリー・ウォール氏が作られたPerlの影響を強く受けているように
感じます。

で、Perlという言語は、CとかVBが言語の文法が、がっちり決まっていて、「それ、構文エラ
ーだよ!」なんて役所の役人のようにいちいち文句をつけてくるように感じますが、Perlは、プ
ログラマがやりたいことを推測して、「こんな処理がやりたいんだろうから、この命令はこうい
う意味にとるのがいいだろう」ってソースコードの雰囲気をよんでいる「KYじゃない」言語で
す。

「KYじゃあない言語」というと良い意味にとれますが、学ぶ側からすると、「1つの命令が、
いくつもの意味を持つとか、言葉にしないこと(コードに書かれてないこと)を裏でやってくれ
ている」ので、覚えるのがやや困難さを感じさせる面があります。

Rubyは、さすがにPerlよりも「親切心」は弱まっていますが、それでも、他言語に比べると「K
Yじゃない度」は強いです。


また、一見、Rubyの言語構文は、簡単なように見えますけど、それまでのさまざまな言語を研究
した成果が盛り込まれた、「羊の皮をかぶった狼」みたいな言語です。難しいことを言わずに
「使えればいいじゃん!」的に使うならいいのですが、きっちりと学ぼうとすると、いろんなプ
ログラミングの概念を理解していることを要求されます。

RubyonRailsにもいえますが、単に使うだけならいいのですが、ほんとうに理解しようとすると、
どちらも難易度は高い気がします。

Do What I Mean な言語ですか?

■_ SQL

すみません。つい最近まで HAVING と WHEREの違いがよくわかっていませんでした>< オライリーの本だから(ノベルティのためにw) Head First SQLでも買っておこうか…

Which SQL statement is faster? (HAVING vs. WHERE...) - Stack Overflow

どっちのSQL文の方が速い?

SELECT NR_DZIALU, COUNT (NR_DZIALU) AS LICZ_PRAC_DZIALU
    FROM  PRACOWNICY
    GROUP BY NR_DZIALU
    HAVING NR_DZIALU = 30


or

SELECT NR_DZIALU, COUNT (NR_DZIALU) AS LICZ_PRAC_DZIALU
    FROM PRACOWNICY
    WHERE NR_DZIALU = 30
    GROUP BY NR_DZIALU
The theory (by theory I mean SQL Standard) says that WHERE restricts the result set 
before returning rows and HAVING restricts the result set after bringing all the rows. 
So WHERE is faster. On SQL Standard compliant DBMSs in this regard, only use HAVING 
where you cannot put the condition on a WHERE (like computed columns in some RDBMSs.)

You can just see the execution plan for both and check for yourself, nothing will beat 
that (measurement for your specific query in your specific environment with your data.)
The two queries are equivalent and your DBMS query optimiser should recognise this and 
produce produce the same query plan. It may not, but the situation is fairly simple to 
recognise, so I'd expect any modern system - even Sybase - to deal with it.

HAVING clauses should be used to apply conditions on group functions, otherwise they 
can be mvoed into the WHERE condition. For example. if you wanted to restrict your 
query to groups that have COUNT(DZIALU) > 10, say, you would need to put the condition 
into a HAVING because it acts on the groups, not the individual rows.

■_ stackoverflow からもうひとつ

How can I get rich just programming - Stack Overflow
プログラミングでリッチになるにはどうすれば?

Which are the known cases where a programmer (just by programming) get rich.

A programmer that started a company, I think, doesn't count except if he/she was not 
the CEO but the leader programmer.

This question, at first, may seems silly but its so fundamental as anyone else that 
you'll see in this site. In a given moment, a programmer must do the choice between 
crossover to a managerial role or keep programming just for the fun of it. And this 
choice affect everything else.

I was surprised at first not to see this very question being posted by younger 
visitors but it seems that, until today (20080807) everyone is only focused in 
technical facts. I firmly believe that a programmer must develop also "soft" 
skills and this kind of questions will be asked by newbies anyway (soon or later).


I wonder if Joel and Jeff has addressed this topic before... and I question Which is 
the business model for StackOverflow?

(略)
Send me £20 and I will email you the answer.
Here is my 3-step plan:

   1. Learn programming
   2. Become a good programmer
   3. Win the lottery

Personally I think 1. and 2. have the most chance of success.
I guess there aren't may millonarie programmers, but a very famous one is Charles 
Simonyi, the father of Office. He was a programmer at Xerox Labs in Palo Alto before 
going to Microsoft. There he lead the Word and Excel teams.

By the time he quit from Microsoft he was a millonaire (thanks to all the stock 
options he received as a Microsoft employee). Now he is a CEO of his own company, but 
he was rich before doing that.

PS. By the way, he do has enough money to travel to the space station, jeje.
Love what you do.

If you really love what you're doing, the money will follow.

いや、まじめな回答も元記事には結構ありましたから。はい。

■_

HackageDB: HARM-0.1.3
A simple ARM virtual machine designed for teaching assembly
Built on	ghc-6.10

Wiki - Front Page
LHC is an open source, whole-program, highly optimizing compiler for the purely 
functional programming language, Haskell. It is an (active) fork of John Meacham's 
jhc project.


Is Lua, Perl, Python, or Ruby better suited for Unix system automation? - Stack Overflow
http://stackoverflow.com/questions/320116/is-lua-perl-python-or-ruby-better-suited-for-unix-system-automation

http://bc.tech.coop/blog/081201.html
Clojure could be to Concurrency-Oriented Programming what Java was to OOP


一つ前へ 2008年11月(下旬)
一つ後へ 2008年12月(中旬)

ホームへ


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

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