■_
・年俸
まあ例によって東スポの紙面から。
ファイターズのダルビッシュが契約更改して、史上最年少の3億円プレイヤーとか。
ほかにも同じくらいの高給取りが二人ほどいて、総額で23億円という枠があるのを
突破しそうだとか何とか。メジャーはもっと高い年俸がという話はあるだろうけど、
向こうは収入も桁が違うしねえ。さて、どこまであがるのやら。
タイガースの赤星が引退だそうで。
一つ前へ
2009年11月(下旬)
一つ後へ
2009年12月(中旬)
・年俸
まあ例によって東スポの紙面から。
ファイターズのダルビッシュが契約更改して、史上最年少の3億円プレイヤーとか。
ほかにも同じくらいの高給取りが二人ほどいて、総額で23億円という枠があるのを
突破しそうだとか何とか。メジャーはもっと高い年俸がという話はあるだろうけど、
向こうは収入も桁が違うしねえ。さて、どこまであがるのやら。
タイガースの赤星が引退だそうで。
OCaml internals part 2: Strings and other types OCaml internals part 2: Strings and other types (文字列などの型) In part 1 we saw how integers and some integer-like things are represented at runtime in OCaml. part 1 では整数やいくつかの整数のようなものが OCmal ランタイムでどのように表現されてい るかを見てきました。 Objects which are large or more complex than simple integers are stored in OCaml blocks. An OCaml block consists of a header followed by an array of words. Word in this context means a 4 or 8 byte quantity (for 32 and 64 bit platforms respectively) which can contain a value or something else. 単純な整数よりも大きかったり複雑であるようなオブジェクトは OCmal ブロックとして格納さ れます。ひとつの OCmal ブロックはヘッダーとそれに続くワードの配列から構成されます。こ こでは、ワードは値もしくはなにがしか (value or somthing else) を格納できる4バイト (32 ビットプラットフォームの場合) か8バイト(64ビットプラットフォームの場合) の大きさになり ます。 Actually if you have a value which is a pointer to an OCaml block, then (for performance reasons) it points to the zeroth element of the array, and the header is at a negative offset, -4 or -8. 実際には、ある OCaml ブロックへのポインターである値があったとき、それは性能上の理由で配列 の第 0 要素を指していて、ヘッダーはそこから負のオフセット(-4 もしくは -8) が掛かった所 にあります。 +---------------+---------------+---------------+- - - - - | header | word[0] | word[1] | .... +---------------+---------------+---------------+- - - - - ^ | pointer (a value) What we've described so far (values and blocks) turns out to be a complete description of how everything is stored in an OCaml program. [OK, not 100% true: you can also have pointers to C structs] わたしたちはこれまで、説明してきたこと (values と blocks) は、OCaml プログラムで全てがど のように格納されるのかの完全な記述を目指していたものです。 [OK, not 100% true: you can also have pointers to C structs] So how do all the OCaml types map to values and blocks? At the end of this part you'll find a comprehensive table showing the mapping for every type. Let's start with some easy ones first. それではすべての OCaml の型はどのようにして値とブロックとにマップされているのでしょう か? この回の最後ですべての型に対するマッピングを show している comprehensive table を 見ることになるでしょう。 Let's start with some easy ones first. 簡単なものから見ていくことにしましょう。 An OCaml string is just stored as a byte array, with enough words allocated for the required size of the string: OCaml の文字列は、その文字列を格納するのに必要な大きさを満たすだけの領域を割り当てられ ている単なるバイト配列として格納されます +---------------+----------------+------------------+ | header | 'a' 'b' 'c' 'd' 'e' 'f' '\O' '\1' | +---------------+----------------+------------------+ ^ | an OCaml string (There's a bit of extra cleverness with strings described here). An array is just stored as an array of values, with each word corresponding to one value: 配列は単純に、各ワードが一つの値を表現している値のならびとして格納されます。 +---------------+---------------+---------------+- - - - - | header | value[0] | value[1] | .... +---------------+---------------+---------------+- - - - - ^ | an OCaml array As I described in the previous part, simple variants are just stored as integers, but if a variant has any parameter, then it's stored as a block: 前回説明したように単純な値は単なる整数として格納されますが、ある variant がなんらかの パラメータを持っている場合にはそれはブロックとして格納されます: +---------------+---------------+ | header | arg[0] | +---------------+---------------+ ^ | a variant with one arg (引数一つを持った variant) Let's take a closer look at the header: ヘッダーをより詳しく見てみましょう: +---------------+---------------+----------+--+--+---------------+ | size of the block in words | col | tag byte | +---------------+---------------+----------+--+--+---------------+ ^ <- 2b-><--- 8 bits ---> | offset -4 or -8 The size part is simple enough - it just records the number of words in the block, eg. the length of the array. Note on 32 bit platforms, this is 22 bits long, which is the reason for the annoying 16 MByte limit on strings (16 MBytes = 4 M-words = 222 words). Solution: use a 64 bit platform for serious OCaml. size の部分はとても単純で、ただ単に該当のブロックにあるワードの数、つまりその配列の長 さが記録されています。32ビットプラットフォームでの size part の長さは22ビットであり、 これが文字列の長さの限界が 16Mバイト (16 MBytes = 4 M-words = 222 words) になっている 理由です。 解決策: 64ビットプラットフォームを使う The tag byte is multipurpose. For example, in the variant-with-parameter example above, it tells you which variant it is. In the string case, it contains a little bit of runtime type information (it's a string). In other cases it can tell the garbage collector that it's a lazy value, or opaque data that the garbage collector shouldn't scan. タグバイトは多目的です。たとえば上の例のようなパラメータつきの variant であった場合に はタグバイトはその variant がどの種の variant なのかを示します。文字列の場合には variant はちょっとした実行時型情報 (文字列になっている) を保持します。その他にも、その variant が lazy value であるとかガーベジコレクターがスキャンすべきでない opaque データ であることをガーベジコレクターに対して教えることができます。 “col” (color) is two bits used by the garbage collector which I won't go into, but you can find out about coloring algorithms in any good book on garbage collection. “col” (color) はガーベジコレクターによって使用される 2ビットです。ここでは深入りしま せんが、ガーベジコレクションについてのどの良書ででもカラーリングアルゴリズムを見つける ことができるでしょう。 One interesting little optimization that OCaml does is for arrays of floating point numbers. So that OCaml does well at numeric programs, arrays of floats are stored inline like this: OCaml が浮動小数点数の配列に対して行う興味深いちょっとした最適化がひとつあります。 OCaml は数値計算プログラムでも力を発揮するので、浮動小数点数の配列は以下のように inline で格納されます: +---------------+---------------+---------------+- - - - - | header | float[0] | .... +---------------+---------------+---------------+- - - - - ^ | an OCaml float array Where do these OCaml blocks live? That's the subject of part 3 … OCaml のブロックはどこで生存しているのでしょうか? それは part 3 の主題です。 Reference table (参照テーブル) Chapter 18 of the OCaml manual describes the representation of blocks in some detail, but not very clearly, so here is a table showing how OCaml objects map into values and blocks. OCaml マニュアルの第18章ではブロックの表現を多少詳しく記述していますが、それは単純明快 なものではないので、OCaml がどのようにオブジェクトを値とブロックにマップしているかを表 すテーブルを以下に示します。 OCaml Representation (OCmal での表現) any int, char stored directly as a value, shifted left by 1 bit, with LSB = 1 値として直接格納されます。1ビット左シフトし、LSBを 1にします。 (), [], false stored as OCaml int 0 (native int 1) OCaml の int 0 (native int の 0) として格納 true stored as OCaml int 1 (native int 3) OCaml の int 1 (native int の 3) として格納 variant type t = Foo | Bar | Baz (no parameters) stored as OCaml int 0, 1, 2 OCaml int 0, 1, 2 として格納されます variant type t = Foo | Bar of int The variants with no parameters are stored as OCaml int 0, 1, 2, etc. counting from the leftmost, counting just the variants that have no parameters. パラメータを持たない variants は OCaml int の 0, 1, 2, … のように格納されます。最も左 のものから数え始めてパラメータを持たない variants を数えます。 The variants with parameters are stored as blocks, with tag 0, 1, 2, etc. counting from leftmost, counting just the variants with parameters. The parameters are stored as words in the block itself. パラメータを伴う variants は tag 0, 1, 2, … と共にブロックとして格納されます左端を先 頭にパラメーターを持った variants だけを数えます。パラメーターはそのブロック自信の中に ワードとして格納されます。 Note there is a limit around 240 variants with parameters that applies to each type, but no limit on the number of variants without parameters you can have. This limit arises because of the size of the tag byte and the fact that some of the high numbered tags are reserved. 型ごとに適用されるパラメータつきの variants は 240個前後に制限されることに注意してくだ さい。ただし、パラメータを持たない variants の数に制限はありません。この制限は、タグバイ トのサイズとタグの表せる範囲の最高値近辺の幾つかが予約されていることに起因しています。 list [1; 2; 3] This is represented as 1 :: 2 :: 3 :: [] where [] is a value OCaml int 0, and h :: t is a block with tag 0 and two parameters. This representation is exactly the same as if list was a variant. これは 1 :: 2 :: 3 :: [] のように表現されます。このとき [] は OCmal int 0 の値であり、 h :: t はタグ 0 を持ち、二つのパラメータを伴っています。この表現はリストが variant で あった場合でも全く同一です tuples, struct and array (タプル、構造体、配列) These are all represented identically, as a simple array of values. The tag is 0. The only difference is that an array can be allocated with variable size, but structs and tuples always have a fixed size. これら (タプル、構造体、配列) はすべて値の単純な並びとして identically に表現されます。 そのタグは 0 です。唯一異なるのは、配列が可変サイズの割り当てができるのに対して、 struct やタプルは常に固定サイズであるという点です。 struct or array where every element is a float (すべての要素が float であるような struct や 配列) These are treated as a special case, as described above. The tag has the special value Double_array_tag (254) so that the garbage collector knows how to deal with these. これらは前述したように、特殊なケースとして取り扱われます。タグは Double_array_tag (254) という特殊な値を持っていて、ガーベジコレクターはどのようにこれらを扱うかを知っています。 Note this exception does not apply to tuples that contain floats. Beware anyone who would declare a vector as (1.0, 2.0). この例外は float の要素を持つタプルに対しては適用されないことに注意してください。 誰かが (1.0, 2.0) のようなベクターを宣言していないか気をつけてください。 any string (任意の文字列) Strings are byte arrays in OCaml, but they have quite a clever representation to make it very efficient to get their length, and at the same time make them directly compatible with C strings. The tag is set to String_tag (252). 文字列は OCaml ではバイトの並びですが、効率よく文字列の長さを得られるようなとても賢い 表現になっていてなおかつ同時に C 形式の文字列と直接の互換が取れるようになっています。 タグには String_tag (252) がセットされます。 For full details of blocks, read the comments in the <caml/mlvalues.h> C header file that comes with OCaml. ブロックについての完全な説明は、OCmal についてくる C のヘッダーファイル <caml/mlvalues.h> にあるコメントを読んでください。
会社のホームページがなぜかYAHOOにだけアップされません。GOOGOLEとMSNにはあっぷされています。もちろんエンジンはかけています。
ちまちまいじってるんですが。
input()
{
register c;
extern char *lexprog;
if (yysptr > yysbuf)
c = U(*--yysptr);
else if (yyin == NULL)
c = *lexprog++;
else
c = getc(yyin);
if (c == '\n')
yylineno++;
else if (c == EOF)
c = 0;
return(c);
}
やはりこれと同じようなことをしてやらないといけないという結論に。 yyin == NULL とのとこと、その直後の else 節の getc(yyin) はわかるんだけど、 if 節で使っている yypstr とか yysbuf とかはどういう素性の変数なのか良くわからず。 U ってマクロ(たぶん)もわからんしなあ。あー unsigned char へのキャストかなあ。 んで、flex では #undef input /* defeat lex */ というのはやってはいけないらしいので、 YY_INPUT の定義でがんばるよりない?
・いろいろありました
お察しください(笑)
とあるところで 3rd cache という記述を見かけ、 primary → secondary と来るんだから、3rd はないだろうとぐぐる先生に尋ねてみたら、 どうも AMD では third cache とか呼ばれるものが本当にあるらしいと言うことを知って びっくり仰天。 AMD 64bit CPU Guide - Fab51 とはいうものの、こっちで検索した方が "third cache"よりもそれらしい結果になっていると思うんですが ”tertiary cache - Google 検索 安西先生、英語はよくわからんとです。
推薦図書/必読書のためのスレッド 53 186 デフォルトの名無しさん [sage] 2009/12/09(水) 01:33:36 ID: Be: プログラムはなぜ動くのかという本はプログラミングの役に立つのでしょうか 評価はされていますがその類の本を読んだことが無いのであまり想像出来ないのですが 187 デフォルトの名無しさん [sage] 2009/12/09(水) 01:38:04 ID: Be: プログラミング経験ゼロでプログラミングに憧れがあって いきなり勉強はきついからまずプログラミングの雰囲気だけ感じてみたい・・ という人限定ならいいかも 188 デフォルトの名無しさん [sage] 2009/12/09(水) 01:41:45 ID: Be: 学校で習ってますけど、なぜ動くかは知りませんね 189 デフォルトの名無しさん [sage] 2009/12/09(水) 02:17:45 ID: Be: >>186 よりあえず読んで後悔はしない 190 デフォルトの名無しさん [sage] 2009/12/09(水) 02:29:19 ID: Be: そうですか。気になってたんでやっぱり読んでみます 191 デフォルトの名無しさん [sage] 2009/12/09(水) 05:19:38 ID: Be: あんまりコンピュータを知らない人が、プログラムを書く必要があったりする時にとりあえず読んで欲しい本だな。 俺の後輩が独習CでCを覚えたので、適当な数値を解析するプログラム作らせたら 最初に2Gbytesくらいの巨大配列を作り、文法通りに書いたのに動かないと嘆いていた。 そんなにメモリないんだよ。 192 デフォルトの名無しさん [sage] 2009/12/09(水) 05:52:05 ID: Be: プログラムはなぜ動くのか の著者評判悪いよ 馬鹿向けの本 193 デフォルトの名無しさん [sage] 2009/12/09(水) 06:28:39 ID: Be: 世の中には君が思うよりバカが一杯いるんだよ。 194 デフォルトの名無しさん [sage] 2009/12/09(水) 11:08:15 ID: Be: 呼ばれた気がした 195 デフォルトの名無しさん [sage] 2009/12/09(水) 11:53:36 ID: Be: >>192 ググってみたら矢沢って人の本か。 一時期、俺が見てたブログ周辺でその人の本の間違い探しがはやったことがあったな。 196 デフォルトの名無しさん [sage] 2009/12/09(水) 12:25:50 ID: Be: 矢沢さんはマーケティングのプロ。 どういう本が読み手にいい読後感を与えるか知り尽くしてる感がある。 難しいところ(えてして重要なところでもあることが多い)は全部飛ばして 表面だけをさらっと広くなぞることで読者に 「こんな短時間であれもこれも全部理解できた!」と満足させる。 エンターテイメントは客をどれだけ満足させられるかが重要だから そういう意味では良本なのかもしれない。 197 デフォルトの名無しさん [sage] 2009/12/09(水) 13:18:26 ID: Be: >>192 評判悪いと馬鹿向けの本なのか? まぁ、困ったらフローチャート描けとか書いてあるけどな 198 デフォルトの名無しさん [sage] 2009/12/09(水) 15:43:04 ID: Be: えてして、素人が書いた間違った文章の方が 素人受けはいいからねえ 199 デフォルトの名無しさん [sage] 2009/12/09(水) 17:20:24 ID: Be: 著者の自慰のために書かれた本が多すぎる あれで出版社が利益が出てるのかとても不思議 コスるエネルギーの1%くらいはマーケティングに剥けてください
このあと、ここのURLがでてたりしてびっくりw
blog | Perlgeek.de :: Perl 6: Failing Softly with Unthrown Exceptions Perl 6: Failing Softly with Unthrown Exceptions Most programming languages handle failures with either of two paradigms: failing routines return special values, or they throw exceptions. 大部分のプログラミング言語は、失敗したルーチンが特別な値を返すかもしくは例外を送出する かの二つのパラダイムのいずれかを使って失敗を扱います。 Either way has its severe problems: in languages like C it can be very simple to forget to catch such a return value, and very tedious to propagate them to the caller; on the other hand throwing exceptions often clutters the code with way too many try blocks, and it's generally unfriendly if you try to automatically parallelize expressions. いずれのやり方であっても severe な問題があります。C のような言語では、そういった戻り値 を受け取ることを忘れてしまうことはとても起こしやすいことです。また呼び出し元に対してそ の特殊な戻り値を伝えるのがとても面倒です。その一方で例外の送出にしても、しばしば多すぎ る try ブロックによって コードを clutters してしまいますし、automatically parallelize expressions を試みても一般的には unfriendly です。 So Perl 6 offers a middle ground: soft or unthrown exceptions. If a routine calls fail("message"), a new Exception object is created and returned from the current routine. That object behaves as an undefined value, which stores the message, file and line information of the fail() location, a backtrace and so on. そこで Perl 6 ではその中間点を offer します: soft exception もしくは unthrown exception というのがそれです。 If a routine calls fail("message"), 新しい例外オブジェクトが作成されてカレントルーチンから戻ります。 That object behaves as an undefined value, which stores the message, file and line information of the fail() location, a backtrace and so on. そのようなオブジェクトは undefined 値のように振舞いますが、fail() の位置についてのファ イルと行の情報やバックトレースの情報などのメッセージを抱えています。 When you ask such an object whether it's true or false, or defined or undefined, you'll get a correct answer, and the exception is marked as handled. そういったオブジェクトに対してそれが true と false のいずれなのかやdefined と undefined のいずれなのかを尋ねた場合には正しい答えが得られます。 However if you try to use it as an ordinary value, it turns into an (ordinary) fatal exception. So both of these work: しかし通常の値のように使おうとすると(通常通りの) fatal exception が発生します。その結 果、以下の二つのやり方のどちらでもうまく行くのです。 # Variant 1: no exception thrown 例外を送出しない my $handle = open('nonexistingfile'); if $handle { .say for $handle.lines; } else { # do something else } # Variant 2 my $handle = open('nonexistingfile'); # throws a fatal exception while calling $handle.lines # $handle.lines の呼び出し時に fatal exception が送出される .say for $handle.lines; Now if you do some automatically parallelized operations, a single failure doesn't have to abort the whole operation, and neither is information lost 現時点では、some 自動並列化操作 (automatically parallelized operations) を行うと、 その操作全体を中断すべきではないsingle failure が起きてしまって、 先に挙げたようないずれの情報も失われてしまいます。 # divide @a1 by @a2 element-wise, a division by zero might occur: @a1 »/« @a2; The API for accessing the Exception objects isn't very mature yet, but the concept stands. See S04/Exceptions for the gory details, as they stand today. The API for accessing the Exception objects isn't very mature yet, 例外オブジェクトへのアクセスのためのAPIはまだ very mature ではありませんが but the concept stands. コンセプトは決まっています。 See S04/Exceptions for the gory details, as they stand today.
今回はMATLAB。
The A-Z of Programming Languages: MATLAB - a-z of programming languages, computer science, engineers, mathmatics - Computerworld Do you have any advice for today's maths, science and engineering students? Stay in school. I'm serious, it's very tempting for these guys [to leave early], particularly in the computer business. It’s so attractive and they get such good jobs. They can go out and be a web designer, they’re attracted by computer graphics, games, the film industry. That’s exciting, attractive work and these students leave school [university] to go get those good jobs. For the long term, they should stay in school and learn a little bit more math and a little more engineering before they succumb to all the attractive industries.
中身、読んだことはありませんが…
・Lua開発読本 B5 ??p 300円
・契約更改
昨日うっちー(内川)で、今日はむらたん(村田)。
二人ともFAで出て行きそうだなあ(苦笑)
東スポの記事では、
内川はメジャー志向があるとかあったけど正直厳しいと思うけどねえ。
メジャー行ってそこそこでも成功した野手って少ないし、
WBCのときとメジャーのスカウトの評価もそれほど高くなかったんじゃないかな。
ベイスターズのチーム事情からうっちーは守るところがころころ変わっちゃうけど、
外野やファーストだと打力がもっとないとだめだろうし、
セカンドショートだと…
年俸の額についてはまあいろいろあるしにんともかんとも。
ただ、チームの状況を考えれば3億とか4億なんてのはむりぽたんだろうねえ。
・入団発表
新入団の選手のお披露目があったらしい。
筒香(つつごう)ぐらいしかTVには映してもらえなかったけど、
「ハマのゴジラ」と呼ばれるのは嫌だ。と堂々と主張するのはいいねえ。
spaghetthi だけが pasta だけではないということかw
What is the Pasta Theory of Programming? What is the Pasta Theory of Programming? (プログラミングのパスタ理論とは何か?) The pasta theory of programming has to do with the complexity of various programming structures. Just as pasta comes in many different sizes and shapes, the same is true with programming code. With a pasta theory, a particular type of pasta is used as a colorful illustration to identify some aspects associated with a particular set of programming protocols. プログラミングにおけるパスタ理論は様々なプログラミング構造の複雑さと一緒に使わなければ なりません。パスタには様々な大きさや形のものがあるようにプログラムコードにもいろいろな ものがあります。パスタ理論ではパスタの特定の型はプログラミングプロトコルのある partcilar set に結び付けられた幾つかの aspects を識別するためのカラフルなイラストとし て使われています。 One excellent example of a pasta theory of programming is the spaghetti code. Cooked spaghetti is often served as a collection of strands that cross over and intertwine with one another. It is practically impossible to extract one strand of spaghetti without causing some degree of disturbance to the other strands. プログラミングにおけるパスタ理論のとても良い例がスパゲティコードです。調理されたスパゲ ッティはしばしばごちゃごちゃに絡まりあった麺の集まりとして供されます。他の麺に影響を及 ぼさずにスパゲッティの麺一本だけを取り出すことは現実には不可能です。 With this type of pasta theory, it is understood that the programming effort is somewhat happenstance and chaotic. There is little or no real structure to the programming code. The end result is that attempting to modify the code associated with one portion of the sequence often creates unanticipated problems with another part of the code. As a result, a spaghetti code is extremely hard to understand in terms of logical progression and equally difficult to modify without creating new problems. happenstace (良い)偶然のできごと chaotic 混乱 無秩序 このパスタ理論によって、プログラミングの努力は somewhat happenstance and chaoticだと理 解されました。プログラミングコードには real structure が少数だったり、全くなかったりす る場合すらあります。その結果として、one portion of the sequence に結びついているコード を修正しようとしたときに、しばしば予期しなかった問題がコードの別の部分で発生するという 事態が生じます。最終的に、スパゲッティコードは terms of logical progression において理 解するのがとんでもなく困難なものになり、新しい問題を引き起こさずに修正を行うことも同様 に難しくなります。 By contrast, the pasta theory of programming can also refer to programming that is highly structured. One example of this type of theory is known as the lasagna code. Lasagna is a layered pasta dish, with ingredients placed deliberately and consistently between the layers of lasagna noodles. The end result is a pasta dish that is uniform throughout and is easily broken down into identifiable components. それとは対照的に、プログラミングのパスタ理論は高度に構造化されたプログラミングを表すこ ともできます。このタイプの理論の一例はラザニアコード (lasagna code) として知られていま す。ラザニアは lasagna noodles の層の間に意識的かつ一貫性を持って材料が置かれたものが 積み重なった pasta dish です最終的には全体が統一されていてなおかつ容易に識別可能なコン ポーネントに分解できる pasta dish となります。 When the pasta theory or programming uses the term lasagna code to refer to a programming effort, it is spotlighting the logic and order that appears to govern the entire structure of the code involved. It is possible to modify sections of the code without creating an unanticipated reaction somewhere later in the code processing. Logical progression and sequencing are hallmarks of a lasagna code, making it an opposite of the more chaotic spaghetti code. パスタ理論 やパスタプログラミングにおいて、プログラミングでの努力をあらわすためにラザ ニアコード(lasagna code) という言葉を使ったとき、そこではコードの構造全体の統治を可能 であることを示すロジックと命令にスポットを当てています。あとでそのコードのどこかを処理 したときに予期しない反応を起こさずにコードのあるセクションを修正することが可能です。 Logical progression と Logical sequencing はラザニアコードの特徴 (hallmakrs) であり、 よりカオス的なスパゲッティコードの対極なものにするものです。 The concept of the pasta theory of programming is typically attributed to Raymond Rubey. In a letter he wrote to a trade magazine in 1992, Rubey used terminology related to ravioli and spaghetti to refer to programming strategies and situations. The general idea of a pasta theory of programming caught on and soon various programming methods began to be labeled by many programmers using various types of pasta. In some cases, the selection of pasta names pointed toward beneficial attributes of a given programming code approach, while others referred to programming methods that were considered to be less efficient and structured プログラミングにおけるパスタ理論 のコンセプトは典型的な attributed to Raymond Rubey で す。1992 年に trade magazine に宛てて書いた手紙の中で、Rubey はラビオリやスパゲッティ に関連する用語をプログラミングの戦略 (strategies) やシチュエーションを表すために使いま した。プログラミングに関するパスタ理論の一般的な考え方が受け入れられ、すぐに様々なプロ グラミング手法が多くのプログラマーによっていろいろなパスタを使ってラベリングされ始めま した。パスタの名前は与えられたプログラミングコードのアプローチの beneficial attributes を反映させるものが選択されることもありましたが、そのほかの他のものは効率が悪く構造化の 度合いも低いとみなされるプログラミング手法を表していました。
ほとんどのソフトはJavaやCなので書かれていると思いますが、SchemeやPrologを使うべきである時はありますか?
大阪府の電子入札や電子申請に使う端末には、「Internet Explorer 6 SP3」「Internet Explorer 7(以下 IE7)」 「Internet Explorer 8(以下 IE8)」並びに「Windows XP SP3」「Windows Vista(以下 Vista)」「Windows 7」を使用しないでください。
What you need are * magic comments, * String#encode. You don't need to use String#force_encoding in your application.
自分は以前から、パソコンや情報技術に関することに興味を持っていて、いろんなことに挑戦してたんですが、それはあくまで趣味の範囲内でやっていたことなんです。 自分のペースでやるからこそ、趣味といえるし、興味も持てると思いました。
どこで"インテルC++コンパイラの機能を体験"しているのでしょうか。
コマンドラインから起動されたときはコマンドラインアプリケーションとして動作させたい - 葉っぱ日記 CMD.EXEから起動したときにはそのアプリケーションをコマンドラインアプリケーションとして、 それ以外の例えばExplorerなどから起動した場合にはGUIアプリケーションとして動作するよう なものを組みたいと思っていろいろ調べたのですが、あまりうまい方法がなく、その場しのぎ的 な方法であきらめよう…というメモです。 まず、起動元が CMD.EXE なのかそれ以外なのかの判断には、TH32CS_SNAPPROCESS を指定して CreateToolhelp32Snapshot を呼び出し、PROCESSENTRY32.szExeFile を見て自分の親プロセスが "cmd.exe" かどうかを確認することで判断できます。 (略)
自分を起動したのが cmd.exe かどうかの判定は悩んでいたりしたのでこの情報はありがたい。 が、この情報を使っていじる余裕ないなw
本文もちゃっちゃと訳すかねえ。 とりあえず項目だけ。 Twelve Tips to Master Programming Faster
Do you want to become a great coder? Do you have a passion for computers but not a thorough understanding of them? If so, this post is for you. (略) The 12 Tips 1. Get started. 2. Don’t worry. 3. Silicon Valley. 4. Read books. 5. Get mentors. 6. Object Oriented. 7. Publish code. 8. Use github. 9. Treat yourself. 10. Write English. 11. Be prolific. 12. Learn Linux. That's it, go get started! Actually, I'll give you one bonus tip:
この場合に "cond" って名前はどうだろうか。
そういえばピンポン出来てたのを忘れてた #include <iostream> using namespace std; template<int first, int last> struct ping_pong_value { private: template<bool b> struct bool_ {}; static const bool has_range = first != last; static const bool cond = first < last; static const int low = cond ? first : last; static const int range = cond ? last - first : first - last; int v;
switch (cond) ならわからんでもないけど。
これも余裕があれば。
The Best C++ Interview Question – Ever! - Windward Wrocks The Best C++ Interview Question – Ever! There is no one magical question that can determine if someone is the right candidate. There isn't even one that will determine if their technical knowledge is up to par. But there are those occasional questions that provide a lot of bang for the buck – simple questions that give you a lot of feedback about the candidate. If I could ask a C++ programmer just one technical question, this would be it. Why? Because the correct answer feels wrong and the initial answer is generally wrong. So seeing how they work through the explanation is very illustrative of not just their knowledge of C++, but their willingness to not get locked in to their initial answer. もしわたしがとある C++プログラマーにひとつだけ技術的な質問ができるとしたら、 この質問をするでしょう。なぜか? それは、この質問に対する正しい答えは間違っているように 感じられるものであり、最初の回答は間違っていることが一般的なのです。 Q: Can you call "delete this;" inside a member function? (以下略)
・読んだ
どうも今ひとつすっきりとしない読後感。
説得力があるようでなんか納得いかない部分もあり、
「ふんふん。それで?」てな感じかなあ。
昨日の、大小文字無視で文字列比較するときにどうのこうの(ただしASCII限定) というやつの続き。
#include <stdio.h>
int
main()
{
int ch;
printf("bitwise and\n");
printf("upper case\n");
for (ch='A'; ch<='Z'; ch++) {
printf("%c %c \n" , ch, ch & ~('A' ^ 'a'));
}
printf("lower case\n");
for (ch='a'; ch<='z'; ch++) {
printf("%c %c \n" , ch, ch & ~('A' ^ 'a'));
}
printf("bitwise or\n");
printf("upper case\n");
for (ch='A'; ch<='Z'; ch++) {
printf("%c %c \n" , ch, ch | ('A' ^ 'a'));
}
printf("lower case\n");
for (ch='a'; ch<='z'; ch++) {
printf("%c %c \n" , ch, ch | ('A' ^ 'a'));
}
return 0;
}
これを実行すると、結果はこんな感じ。
bitwise and upper case A A B B C C D D E E F F G G H H I I J J K K L L M M N N O O P P Q Q R R S S T T U U V V W W X X Y Y Z Z lower case a A b B c C d D e E f F g G h H i I j J k K l L m M n N o O p P q Q r R s S t T u U v V w W x X y Y z Z bitwise or upper case A a B b C c D d E e F f G g H h I i J j K k L l M m N n O o P p Q q R r S s T t U u V v W w X x Y y Z z lower case a a b b c c d d e e f f g g h h i i j j k k l l m m n n o o p p q q r r s s t t u u v v w w x x y y z z
ASCII コード表を見るとわかりますが、大文字と小文字の関係って 上から3ビット目が立ってるか立ってないかだけの違いなんですね (数値で表現すれば 0x20)。ということで、xor やら or やら and でごにょると どうにかできると。
今ひとつ日本語にならないところがあるけど、そろそろ時間切れ(なんの)ということで。
State of Ruby VMs: Ruby Renaissance - igvita.com State of Ruby VMs: Ruby Renaissance Ruby is commonly associated with the frameworks (Rails, RSpec, and many others) that it enabled, but it is much more then that. The same ideology and design principles that popularized the language at the start are also the reason why it is being currently ported to a variety of alternative platforms: JVM, Objective-C, Smalltalk VM and Microsoft's DLR. Technical details aside, few will disagree that Matz's focus on “how we feel while programming” and the objective of “making the programmer happy” has resonated with the larger community. Ruby は (Rails, RSpec, その他もろもろの) フレームワークと結び付けられることが一般的ですが、 but it is much more then that. 開始時に言語を popularized した同じイデオロギーとデザインの原則は現時点で JVM, Objective-C, Smalltalk VM、Microsoft DLRといった様々な alternative platforms に移植されている理由でもあります:技術的な詳細はさておいて、Matz が “how we feel while programming” (わたしたちがプログラミング中にどのように感じているか) にフォーカスし、 “making the programmer happy” (プログラマーを幸福にする)という目的を設定したことが 大きなコミュニティと resonate (共鳴) したということに反対する人はそれほどいないでしょう。 In a short span of just a couple of years, the Ruby VM space has evolved to more than just a handful of choices: MRI, JRuby, IronRuby, MacRuby, Rubinius, MagLev, REE and BlueRuby. In fact, keeping up with all of the most recent developments within each VM is now easily a full-time job. For that reason, and with RubyConf ‘09 in full swing, let's take a quick survey of the space and where it's taking us. 二、三年という短いスパンでは Ruby VM 空間は just a handful of choices という範囲を越え、 MRI, JRuby, IronRuby, MacRuby, Rubinius, MagLev, REE、BlueRuby と広がっています。事実、 最近の各 VM についての開発のほとんどすべてが容易にフルタイムの仕事になっています。 For that reason, and with RubyConf ‘09 in full swing, let's take a quick survey of the space and where it's taking us. 2010: Year of Ruby Renaissance (Ruby の Renaissance の年) Observing the trends and acceleration of development amongst all the VM's, it is clear that 2010 is going to be an exciting year for the language. While more than a few developers have proclaimed Ruby (and more often, Rails) as dead within the past year, likely due to it loosing the initial novelty angle, in reality the language is at the cusp of becoming available to a much broader community. Within the next year, MacRuby, Rubinius, IronRuby, and MagLev should all hit the 1.0 status, effectively making all the things we love about Ruby available to entirely new communities of programmers. HotCocoa with MacRuby makes writing Mac apps a breeze, IronRuby will bring Ruby scripting to the .NET crowd, Rubinius will become a viable deployment platform, and MagLev will give us the distributed persistence model offered by their Smalltalk VM. All of this without even mentioning the growing adoption of JRuby, which marries the best of JVM with Ruby, or the rising popularity of REE fork of Matz's Ruby which offers significant performance and memory improvements. すべての VM の開発に関するトレンド (trends) と acceleration (加速) を見渡してみると、 2010年を Ruby という言語にとっての exciting year にしようとしていることは明白です。少 なからぬ数の開発者たちは Ruby (と、より頻繁に Rails) を、initial novelty angle を失っ ているという理由で昨年中に死んでいた (dead within the past year) と proclaim (宣言、 公言)しているのにも関わらず実際には言語は一段と広範なコミュニティになるのを可能にする 尖端にあるのです。来年中には、MacRuby, Rubinius, IronRuby, MagLev のすべてがバージョン 1.0 に到達して、 effectively making all the things we love about Ruby available to entirely new communities of programmers. HotCocoa with MacRuby は Mac 用アプリの記述を breeze し、IronRuby は .NET クラウドのた めの Ruby scripting へ誘(いざな)い、Rubinius は viable な開発プラットフォームになり、 そして MagLev は彼らの Smalltalk VM によって offer される分散型永続モデル (distributed persistence model) をわたしたちに提供することでしょう。これらすべてのことは JVM と Ruby との best の組み合わせである JRuby の growing adoption にまったく言及していません し、顕著なパフォーマンスやメモリ管理の改良を提供している REE によって fork された 改造 Matz 版 Ruby の popularity が 増加していることにも触れていません。 In other words, if the “Ruby revolution is over”, then the next year is likely to be the first year of its Renaissance. It won't happen overnight, but slowly and surely we will see the same idioms, tools, and DSL's we are all accustomed to in Ruby make their way to adjacent platforms. Many projects and companies are already using RSpec and WebRat to test their non-Ruby code. Likewise, why not use Ruby for DOM manipulation via Silverlight (Gestalt), or abstract Java or Cocoa API's into concise DSL's? It's an exciting time to be a Rubyist. 言葉を変えると、もし “Ruby 革命が終わった”なら、その次にくる年はルネサンス (Renaissance) の最初の年でしょうということです。それは突然起こるものではありませんが、 ゆっくりとしかし確実に、わたしたちは同じイディオム、同じツール、同じDSLを見ることにな るでしょう。すでに多くのプロジェクトと企業が RSpec と WebRat を Ruby 以外のコードのテ ストに使っています。さらには、なぜ Silverlight (Gestalt) 経由の DOM 操作に Ruby を使わ なかったり、abscract Java や Cocoa API の一貫性を持った DSL のために Ruby を使わないの でしょうか? それは Rubyist にとってのエキサイティングな時間なのです。 MRI: Matz's Ruby (1.8.x / 1.9.x) MRI Ruby, which is the original and the default platform for the vast majority of Ruby users have been making steady progress throughout the past year. First, we saw the 1.9.1 release at the beginning of the year, which made Ruby 1.9 a viable deployment platform, although the overall pickup has remained relatively low. In mid July, Ruby 1.9.2 preview 1 hit the shelves, and the original schedule planned for the final 1.9.2 release on December 25th. However, Yuki Sonoda (release manager) recently indicated that the schedule will be canceled in favor of making Ruby 1.9.2 compatible with the RubySpec suite prior to the final release - this is great news for everyone and well worth the wait. MRI Ruby は Ruby ユーザーの vast majority にとっての original かつ default のプラット フォームであり、この一年で大きな進歩をしました。第一に、overall pickup has remained relatively low であったにもかかわらず今年の初めに Ruby 1.9 を使い物になる開発プラット フォーム (viable deployment platform)にした 1.9.1 のリリースを目にしました。7月の半ば には Ruby 1.9.2 preview 1 が hit the shelves し、そして1.9.2 の最終的なリリースが12月 25日という original schedule が立てられました。しかしながらリリースマネージャーである Yuki Sonoda は最近になって、 Ruby 1.9.2 に以前の final release に対する RubySpec との 互換性を持たせることを優先するので当初のスケジュールはキャンセルされるだろうことを示唆 しています - これはすべての人にとっての great news であり、待つべき価値のあるものです。 Sitting in the audience at RubyKaigi in Tokyo earlier this year, it was clear that the focus of the development team is on Ruby 1.9. Moving forward, there will be one more release within the 1.8.x branch (Ruby 1.8.8), and it will serve as a bridge between 1.8 and 1.9. If you haven't already, you should investigate migrating your code to Ruby 1.9 - most of the critical gems, and all popular frameworks work out of the box, not to mention the numerous performance improvements. 今年東京で行われた RubyKaigi の席上で開発チームが Ruby 1.9 にフォーカスしていることが 明確になりました。 Moving forward, 1.8.x についてはあともう一つのリリースが予定されていて(Ruby 1.8.8)、それは 1.8 と 1.9 との間の橋渡しを勤めることになるでしょう。あなたがまだ移行を済ませていないのなら、あな たのコードの Ruby 1.9 への移行の調査をすべきでしょう重要な gems の大半とすべての ポピュラーなフレームワークは数多くのパフォーマンスの改良を mention するためではなく work out of the box しています In the coming year, we may even see a Ruby 2.0, and in all likelihood a continual improvement in speed and library support. Matz showed off a number of experimental branches at RubyKaigi, and Koichi Sasada indicated that many of the performance optimizations are yet to be turned on for Ruby 1.9 - to date the focus has been on compatibility and feature completeness. 来る年にはわたしたちは Ruby 2.0 すら見る可能性があり、そしてスピードとライブラリサポー トにおける継続的な改良の見込みがあります。Matz は RubyKaigi で数多くの実験的なブランチ を見せてくれましたし、Koichi Sasada は 1.9 でまだ trun on されていない、現在までの互換 性と feature completeness に焦点の当てられた性能に関する最適化の数々を indicate しまし た JRuby: Ruby on the JVM (JVM 上の Ruby) Out of all the “alternative” Ruby VM's, JRuby is by far the most mature project both in terms of compatibility and community coverage. By combining the best of the JVM platform - generational GC, true concurrency (no GIL), and transparent interop with any Java library - with Ruby syntax, it is no surprise that JRuby has been quietly gaining market share in the community. It is fast, it runs Rails, and it will soon be compatible with Ruby 1.9. “alternative”な Ruby VM 群の外にあって JRuby は互換性とコミュニティのカバレージの両 方において最も成熟したプロジェクト (mature project) です。世代別 GC (generational GC) や (GILのない) 真の並列性を備えた最高の JVM プラットフォームと、Ruby 構文とすべての Java ライブラリとの等価な interop をする組みあわせによって、JRuby がコミュニティの中で 目に見えてマーケットシェアを獲得していることになんの不思議もなくなりました。JRuby は高 速で Rails を実行でき、まもなく Ruby1.9との互換性も持つでしょう。 Within the past year the JRuby team, which consists of 7 active committers (3 of whom migrated from Sun to Engine Yard earlier this year) , and dozens of intermittent contributors has fixed more user reported issues than in all previous releases combined. JRuby 1.4.0 is a good indicator of the health of the project: a large collection of new features, and over 307 bug fixes since JRuby 1.3.1. 七人のアクティブなコミッター (その内の三人は Sun から Engine Yard へ今年初めに移籍しま した) と数十人の intermittent contributorsから構成される JRuby チームは昨年、以前のリ リースにあったバグよりも多くの user reported issues を修正しました。JRuby 1.4.0 はこの プロジェクトの健全さ具合の良い指標になっています: 新機能の大きなコレクションと JRuby 1.3.1 以降に修正された 307を越えるバグ。 Tickets for JRubyConf were sold out in a matter of hours following the announcement, and in all likelihood serve as a good indicator that JRuby is the platform to watch in the coming year. The combination of the JVM optimizations and its widescale deployment within the enterprise world will definitely make it an appealing Ruby VM. JRubyConf のチケットはアナウンスがあってから瞬く間に売切れてしまい、JRuby が来る年には 注目すべきプラットフォームであることの good indicator として可能性を秘めています。にあ ります。enterprise world における JVM の最適化とその widescale な開発の組み合わせは、 Ruby VM を決定的にアピールすることでしょう。 MacRuby: Objective-C, LLVM and Ruby (Objective-C と LLVM と Ruby) Want to mix and match Cocoa API's or access OSX system libraries all within a Ruby VM? Then MacRuby is the answer and the VM is picking up steam fast. On March 9th, MacRuby 0.4 shipped with a threaded GC, full 64-bit support, DTrace probes, and many improvements to the HotCocoa API's. Since then, the project has switched from YARV to a completely new VM based on LLVM compiler infrastructure (shipped in 0.5 beta 1), and the benefits are numerous: machine code compilation, true concurrency (no GIL), a working JIT, and even ahead of time compilation (AOT)! Ruby VM とCocoa API とを一緒に使ったり match させるだとか、OSX のシステムライブラリを Ruby VMの中で使ったりしたいですか? であれば、MacRuby はそれに対する回答であり、その VM は picking up steam fast です。3月9日、スレッド対応の GC、完全な64ビットサポート、 DTrace probes、そして HotCocoa APIに対する多く改良と共に MacRuby 0.4 がリリースされま したその後、プロジェクトは YARV から LLVM コンパイラー infrastructure に基づく新しい VM へと完全に移行しました (shipped in 0.5 beta 1)。それによる恩恵は様々です: 機械語コ ード (machine code) へのコンパイル、GILなしの本物の並列性、動作する JIT、そして AOT (ahead of time compilation:即時コンパイル。というか定訳あり?事前コンパイル) さえも! In other words, MacRuby is now a true Ruby compiler. You can write a HotCocoa app, leverage native POSIX threads, or even take advantage of Apple's Grand Central Dispatch (GCD) and then compile your program and distribute it as a binary to any OSX user. 言い換えれば、MacRuby は今や本物の Ruby コンパイラーとなったのです。あなたは (MacRuby を使って) HotCocoa アプリを書くことができますしネイティブ POSIX スレッドを leverage す ることや、あるいは Apple の GCD (Grand Central Dispatch) の advantage を得ること、さら にあなたのプログラムをコンパイルしてその結果をバイナリとして任意の OSX ユーザーに配布 することが可能です。 With 7 members on the team and a growing community (RubyOnOSX), MacRuby is quickly becoming one of the most promising open-source projects for Apple - it would be great to see them officially embrace it in the coming year. With the new VM and numerous performance improvements, MacRuby has the potential to bring Ruby to all the Objective-C developers and open up an entirely new market for Ruby. In theory, we could even see MacRuby on the IPhone, that is, if we overcome a few minor snags, like a missing GC. Definitely a project to watch in the coming year as it edges towards the 1.0 status. チームの七人のメンバーと拡大するコミュニティ (RubyOnOSX) と一緒に、MacRuby はたちまち のうちに Aplle にとっての one of the most promising なオープンソースプロジェクトとなり ました。 - it would be great to see them officially embrace it in the coming year. 新しい VM と数々のパフォーマンスの改善によって、MacRuby はすべての Objective-C 開発者 を Ruby にひきつけ、Ruby のための完全に新規の市場を open up する可能性を秘めています。 GC の欠如のような幾つかの重大ではない障害 (minor snags) を克服できれば、理論的にはわた したちには iPhone 用 MacRuby すら目にする可能性があります。 Definitely a project to watch in the coming year as it edges towards the 1.0 status. MagLev: Smalltalk VM and Ruby (Smalltalk VM と Ruby) The GemStone team has been quietly making steady progress with MagLev over the past year. The development is being done in parallel with work on their upcoming GemStone 3.0 VM and is promising to bring Ruby to their 64-bit Smalltalk VM, which offers a JIT, years of VM optimizations, and most importantly, a built-in persistence and distribution layer. In other words, you could think of Maglev as a distributed database that runs Ruby code internally - thousands of concurrent VM's can be spread across hundreds of nodes, all accessing the same data with ACID semantics. GemStone チームは昨年、MagLev でもって steady progress (確固とした進歩) を果たしました。 MagLev の開発は彼らの upcoming な GemStone 3.0 VM での作業と並行して行われました。それ は Ruby を64ビット Smalltalk VM へ導くものであり、JIT を提供し VM の最適化に時間をかけ ています。そして最も重要なのは組み込みの永続レイヤーと分散レイヤーです。言葉を換えれば、 あなたは Maglev を Ruby のコードを内部的に実行する分散型データベースと見なせるというこ とです。数千の並列 VM を数百個のノードを横断して spread し、それらすべてがACID 特性を 持った同じデータにアクセスできます。 At RailsConf this year the team showed off a working Sinatra app, and since then they have gone from passing 2000 to nearly 28000 RubySpecs. Rack, Sinatra, MiniTest and a few others already run unmodified on the VM and the tentative plan is for the project to hit 1.0 sometime in the upcoming year. At the moment, there is a closed alpha test in progress, but soon it will be opened to the larger public. 今年の RailsConf において、このチームは動作する Sinatra アプリケーションを披露しました。 そして RubyScpecs も2000個パスするところから28000近いところをまで合格するようになって います。Rack、Sinatra、MiniTest、そのほかいくつかのものが既に修正なしでこのVM上で動作 しています and the tentative plan is for the project to hit 1.0 sometime in the upcoming year. 現時点ではクローズドなαテストが進行中ですが、 時をおかず大規模でパブリックなものとしてオープンになるでしょう。 The persistence layer offered by the VM is definitely one of the most interesting features, but the team has also indicated that MagLev will support other persistence models as well - you'll be able to use ActiveRecord with MySQL, etc. Keep an eye out for the beta! この VM によって提案されている永続レイヤーは疑いなく one of the most interesting features です。その一方で開発チームはActiveRecord と MySQL の組み合わせのような別の永 続モデルも同様にサポートするだろうことも indicate しています。βに注目です! Ruby Enterprise Edition Launched in mid 2008, REE is a fork of Ruby 1.8.6 optimized for server and production deployments of MRI Ruby. Combination of MBARI patches, improvements in thread and scheduling overhead by Joe Damato and Aman Gupta, a copy-on-write (COW) fork model, and a tunable GC all contribute to a measurable difference in the amount of used memory and overall performance. Earlier this year Twitter switched their infrastructure to REE and reported a 30% improvement in throughput! REE は Ruby 1.8.6 をサーバー向けに最適化した、MRI Ruby の production deployments とし て fork したもので2008年の中ごろに立ち上げられました。MBARIパッチと、Joe Damato と Aman Gupta による スレッドとスケジューリングのオーバーヘッドに関する改良や、コピーオンライ ト (copy-on-write, COW) を使った fork モデル、tunable GC といったものを組みあわせるこ とで、使用メモリや全般的なパフォーマンスにおいて measuable difference な性能向上を見まし た。今年初めに Twitter はそのインフラを REE に切り替え、それによってスループットが 30% 改善されたと報告しています! Phusion Passenger, developed by the same team, has also seen a good pickup in the community within the past year, but it remains to be seen if REE adoption will continue to grow in light of all the progress by alternative VM's. 同じチームによって開発されていた Phusion Passenger もまた昨年コミュニティのなかで seen a good pickup しましたが、しかし altanative な VM 群 によるすべての進化の観点から REE が成長しつづけることが許されるのならばこれもまた残ることでしょう。 IronRuby: Ruby on .NET (.NET 上の Ruby) IronRuby is a .NET implementation of the Ruby VM which leverages Microsoft's Dynamic Language Runtime (DLR), and hence enables an entire host of interesting use cases for Ruby. For example, not only is there seamless integration with all the .NET libraries and infrastructure, but running on top of the DLR also means that Ruby can be run within Silverlight (yep, right in your browser - check out Gestalt). IronRuby は Microsoft の DLR (Dynamic Language Runtime) を leverages し、それにより Ruby に対して entire host of interesting use cases が可能にした Ruby VM の .NET での実 装です。これはすべての .NET ライブラリとそのインフラとのシームレスな統合 (seamless integration) というだけに留まらず、DLR 上で動作するということは同時にRuby が Silverlight と一緒にその中で実行できるということも意味しています (yep, right in your browser - check out Gestalt). The 1.0 release is looming on the horizon and the team has been making great progress. IronRuby now passes over 92% of all the RubySpecs and the adaptive compiler, combined with the optimized DLR also means much lower VM startup times, as well as significant performance improvements over MRI. 1.0 のリリースは looming on the horizon で、開発チームは大きな進捗を果たしました。 IronRuby は現状で RubySpecs の 92 % 以上にパスし、最適化 DLR と組み合わせた adaptive compiler はVM の起動時間を大幅に減少させて MRI のそれを越えるほどの大幅な性能改善をして います。 It remains to be seen if the .NET community will embrace IronRuby, but it sounds like tool support (Visual Studio, Intellisense, etc) might be the next big hurdle for the project. .NET コミュニティが IronRuby を embrace するのなら、(Visual Studio や Intellisense な どの) ツールのサポートがこのプロジェクトに対する next big hurdle になったとしても IronRuby は変わらずに残るでしょう。 Rubinius: Ruby written in (mostly) Ruby ((ほとんどが) Ruby で書かれた Ruby) Rubinius is an initiative to implement as much of Ruby as possible via Ruby code itself - turtles all the way down. In the works since 2006, the Rubinius team lost a few developers early this year, but the project is alive and healthy. The VM has been rewritten in C++, a JIT compiler has been added, and you can now run mongrel, thin, rack, amqp, and a number of other gems all unmodified. The roadmap shows 1.0RC in the works, and a focus on enabling real-world application deployments (packaging, distribution, etc). Rubinius は Ruby を可能な限り Ruby 自身で書かれたコードで実装するという initiative で す- turtles all the way down. 2006 年以来の活動で、Rubinius チームは今年初頭に数人の開 発者を失いはしたもののプロジェクトは健在です(alive and healthy)。VM は C++ で書き直さ れ、そしてJIT コンパイラーが追加され、現状で mongrel, thin, rack, amqp,そのほか数多く の gems を修正することなしに実行することが可能です。ロードマップは 1.0RC が作業中であ り、(パッケージングや配布などの) real-world application deployments の enabling にフォ ーカスが当てられていることを示しています。 It is too early to talk about performance, but the combination of the JIT and LLVM infrastructure means that Rubinius will have true concurrency (no GIL), and plenty of opportunities for introspection and optimization of your code - an inherent benefit of rewriting Ruby in Ruby itself. 現時点でパフォーマンスについて言及することは早すぎますが、JIT と LLVM インフラとの組み 合わせはRubinius が (GILが存在しない)本物の並列性とあなたのコードに対する (Ruby自身で Ruby を書き直したということによって自然に得られる) introspection (内省) と最適化のため の機会を数多く手に入れるだろうことを意味しています Both FFI and RubySpecs, which are now used by virtually every other VM are a direct result of the project, so all things considered, Rubinius can already be called a resounding success. However, with 1.0 on the horizon, it remains to be seen how and if the community will react to the release. Getting a few production deployments under the belt, as well as building a larger user community, are likely to be the big challenges for the year ahead. 現在では実質的にほかのすべての VM で使われている FFI と RubyScpecs の両方ともがこのプ ロジェクトの直接の成果であるので、すべてのことを考慮すれば Rubinius はすでに完全に成功 していると言えます。とはいうものの with 1.0 on the horizon ということから、 it remains to be seen how and if the community will react to the release. 幾つかの production deployments を完成させるのはより大きなユーザーコミュニティを構築す るのと同じように来る年の big challenges になるでしょう。 BlueRuby: Ruby on ABAP VM (ABAP VM 上の Ruby) An exploratory research project form SAP Labs, BlueRuby is an initiative to bring the Ruby runtime to the ABAP VM powering the AP NetWeaver and SAP ERP 6.0 products. It is already passing 75.5% of all the RubySpecs and is being pushed by SAP as a way to adopt TDD practices within their products. At this point, there is no known release schedule or public roadmap for BlueRuby, so don't expect Rails apps on top of SAP NetWeaver anytime soon, but it does have the potential to bring Ruby and all the best practices enabled by it to thousands of enterprise developers. SAP Labs の exploratory な研究プロジェクトである BlueRuby は Ruby ランタイムを AP NetWeaver による ABAP VMと SAP ERP 6.0 products に bring するための initiative です。 すでに RubySpcecs の 75.5 % に合格しており、彼らの製品での TDD practice を適用する手段 として SAP からプッシュされています。現時点では BlueRuby のリリーススケジュールや公の ロードマップは知られていませんのですぐにでも SAP NetWeaver 上の Rails アプリケーション がでるようなことは期待できません。しかし BlueRuby には Ruby とRubyによって可能とされた best practices のすべてを数千人の enterprise developers にとどける可能性があるのです。 Rubies everywhere! Talking to the developers of all of the alternative VM's you can't help but to feel excited about the future of Ruby. There is a clear pattern emerging: using Ruby to go beyond Ruby, and as a bridge to other communities. Halfway through RubyConf, it is a clear theme here as well - several serialization talks, code generation, and an entire evening of presentations on all the Ruby VM's.
いつの間にこんなに増えたんだろう(^^;
・読んだ
「野村克也は本当に名将か」。や、ノムさん誉める本ばっかの中でめだってたのでw
んでまあ、特に「ヤクルト時代の再生工場の実態」(つーかどれだけの選手が「再生」されたか)
とか、「投球分析」で打率が上がったのは古田だけとか、
川崎、西村、岡林、伊藤智仁 といった投手を使い潰しているとか
数字で見ると説得力あるねえ。
・フォネティックコード
昨日、ケーブルテレビの工事がありまして。
その作業中に作業してたお兄さんが会社? Niなにやら連絡して B-CAS の設定をいろいろ
やる場面があって、そのときに数字とアルファベットの組み合わせのなにかの
コードを電話でやり取りしたんですが、
A → America
B → Brazil
C → Canada
D → Denmark
てな感じでアルファベットの聞き間違いを防いでました。
E以降も国名を使うとどんな感じになるんだろうか。
Wataru's memo(2009-12-05) 本物を探せ 機械語はなぜ難しいのか 先日「"割り込み処理" は既に死語と化している」と書きましたが、若い人達はアセ ンブリ言語や機械語の学習を放棄している訳ではありません。数は少ないかもしれませんが、ス クリプト言語からプログラミングに目覚め、やがてコンピュータ内部の仕組みに興味を持ち、つ いには機械語を学ぼうとする人達は間違いなく存在します。だからこそ、専門雑誌は定期的に 「コンピュータの仕組み」に関する特集を組んできましたし、関連する書籍も多数出版されてき たのでしょう。 それでは、このような特集が組まれ書籍が出版されるたびに、彼らの疑問は解消し、コンピュー タ内部への理解は深まったのでしょうか?残念ながら、そうではないようです。"理解 " するということは、単純に知識が増えることではありません。ある "閾値" を超える必要がある。閾値を超えて、初めて新しい "視界" が開ける。私自身がそう でしたが、閾値に満たない学習をいくら重ねても、OUTPUT は HIGH にはならない、LOW レベル のままなのです。 次の世代のために樹は植えられているのか "閾値" を超えることができる教材や書籍が存在しない環境で、若い人達が「機械語 がわからない」と嘆くのは、至極当然でしょう。「わからない」ことが正しい、自らを卑下する 必要もない。しかし、疎外感は残る。その疎外感にかこつけて、金太郎飴のような特集記事や書 籍が、寄せては消える。波のように。 ローマの詩人、スタティウスは「次の世代のために樹を植える」という詩句を残していますが、 こと "機械語" に関しては、団塊の世代を始めとする日本の大人達は植樹を怠ってき たと言って良いでしょう。 そして、このような大人達は「プログラマーたるもの機械語を知らずしてコーディングすること なかれ」と説教を垂れる訳です。私が、若い人の立場であれば「アホか」と言い返すでしょう。 「学ぶための環境を整えず、教える労もとらずして、偉そうなこと言うな」と。 機械語の理解は必要か (以下略)
ついったでわたしがフォローしている人の中で、一生懸命独学で情報関連の 勉強やってるっぽい人がいるんですけど、そのつぶやきを見ていると、 たとえばマイクロプロセッサとかOSの一番ハードよりの動作なんかのところで、 IA-32 とかを題材にしているせいか無用に寄り道しているというか 変な勘違いしているんじゃないかと思う場面がよくあるんですよね。 と微妙に斜め上の感想を残しつつ結論も考察もありませんw
おさかなラボ - 低レイヤの文字列操作 低レイヤの文字列操作 ちょっとC書いてて、あるファイルがWindowsのスクリーンセーバーかどうか拡張子(.scr)で判別 するロジックで、拡張子に大文字小文字がことがあることが判明したあと、ものすごくロジック 書くのが面倒くさくなってきた俺はイラっときて次のように書いた。 char *p = filename + strlen(filename); char lc = 'a' - 'A'; if((*--p|lc) == 'r' &&(*--p|lc) == 'c' && (*--p|lc) == 's' && *--p == '.'){ // みつかったよ! } Perlに限らずLL書いてる人ってこういう発想はさすがに出てこないんじゃないだろか。こういう いじり方してると、最低限この程度のCは書けるようにしておくべきなんじゃないかなーとは思 う。 たとえ世の中からポインタが消え去ったとしてもだ。 ちなみにこの技、基本的にASCIIにしか通用しません。低レイヤの人はよくその辺突っ込んでく るので念のため。 (*)あと、このプログラム、厳密にはif(len < 5) return false;みたいの噛ませないと危険です。
strncasecmp あたりで済ませちゃうような気がする(汗 で、仮に自分でこの種のコードを書くのなら、 引き算じゃなくてビット演算使うかな (ASCII限定なのは一緒) ヒント: 'A' xor 'a' → ? まあ同じ機械語になると思いますが。
これはどうなんですかねえ。
WB-VRTにおけるLinuxとμITRONの関係およびGPLに関して -OKWave 困り度: * すぐに回答を! Linuxでの開発経験ゼロの者です。 某企業からWB-VRTという製品が出ています。 ハイパーバイザコールを使ってLinux上のドライバからITRONが 用意したドライバを呼び出せばGPLを回避できるとなっています。 とありますが、よく意味がわかりません。 GPLのドライバを使ってLinux上で動くアプリを作成した場合、 ITRONが用意したドライバがなんだろうとGPLには関係ないと 思うのですが。 申し訳ないですが、かなり混乱しております。 できれば細かくご説明いただけると助かります。
製品名を出しているのに「某企業」もないだろうと思うがねえ。
とはいえちょっとぐぐる先生にお尋ね申し上げてみると、
株式会社 ウェルビーン | 製品・サービス - 取扱製品 - WB-VRT
株式会社 ウェルビーン | 製品・サービス - 技術情報・導入事例
Linux と、ITRON が別々に動作していて、このソフトがその間を取り持つといった感じ?
詳しくは二つ目のリンクにある図なんかを参照してください。
確かに通常のリンクではないけれども、うーん、どうなんだろう。
WB-VRT 技術資料(306KB) [要ユーザ登録] (PDF)
も参照しないとわからないかなあ。
がんがんいくなあ。まあまだαですが。
Python 2.7 Release Python 2.7 alpha 1 was released on December 5th, 2009. Python 2.7 is scheduled to be the last major version in the 2.x series before it moves into 5 years of bugfix-only mode. This release contains many of the features that were first released in Python 3.1. Improvements in this release include: * An ordered dictionary type * New unittest features including test skipping and new assert methods. * A much faster io module * Automatic numbering of fields in the str.format() method * Float repr improvements backported from 3.x. * Tile support for Tkinter * A backport of the memoryview object from 3.x * New syntax for nested with statements
assosiative array → hash への改称の理由の一次資料探してんですけど どこなんだろうか。青ラクダの最初のやつかなあ。 でも電子的なテキストで読んだような気もするんだけど、勘違いかも。
Perlについての質問箱 42箱目 167 デフォルトの名無しさん [sage] 2009/12/03(木) 19:38:02 ID: Be: 初心者です。 $ARGV[1]が巨大なファイルなので内容を配列に押し込むとやたらに時間がか かるのとメモリが一杯一杯になるので、以下のようなコードになってしまいました。 whileループ内でファイルのopen/closeを繰り返す以外に、メモリに負担をかけない 解決策が無いでしょうか? open(IN0,"<$ARGV[0]"); while(<IN0>){ 処理; open(IN1,"<$ARGV[1]"); while(<IN1>){ if(条件){処理; last; } } close(IN1); } close(IN2); 168 デフォルトの名無しさん [sage] 2009/12/03(木) 20:47:58 ID: Be: ねえよ、帰れ 169 155 [sage] 2009/12/03(木) 20:55:20 ID: Be: >>165 ありがとうございます。あきらめてDevel::Peekを使うことにします 170 デフォルトの名無しさん [sage] 2009/12/03(木) 23:55:00 ID: Be: $^Nは、正規表現パターン内では 使えないの? \数字のかわりに、/(.).+?$^N/とか 書けたら、括弧をいちいち数えなくても よくなってウマー、と試したけど、なんか うまくいかない。orz 171 デフォルトの名無しさん [sage] 2009/12/04(金) 03:19:47 ID: Be: >>167 どんな処理してるか/ファイルサイズにもよるけど、いちいちopenするのではなく、 seek(IN1, 0, 0)でファイルポインタを戻してみるとか。 早く処理できるようなデータの持ち方に変えた方がよいのでは。 172 デフォルトの名無しさん [sage] 2009/12/04(金) 09:14:52 ID: Be: open/closeをなくしてseekにかえても、メモリに抱えられないぐらい でかいファイル$ARGV[1]を毎回頭から読んでたら負けだと思う。 インデックス的なものを用意して全部読まなくていいように工夫する しかないんじゃないかなぁ。 173 デフォルトの名無しさん [sage] 2009/12/04(金) 12:28:51 ID: Be: >>167 ファイルシステム版KVSとか使え 速度を問わないならdbopenとかでもいいからさ。 ただこの2つはシーケンシャルな読み出しにめっぽう弱い。 ので固定長ファイルに変換してseekで読み出すのも手。 それか>>172のようにファイルに直接インデックス張っちゃうか。 perldoc界隈がなんか騒がしいな。 174 デフォルトの名無しさん [sage] 2009/12/05(土) 15:04:50 ID: Be: >>172>>173 一度だけハッシュを作ってそれを利用するという方法で高速化が出来ました。 >>173がインデックス的なと言ってくれたので思いつきました。 感謝です。 175 デフォルトの名無しさん [sage] 2009/12/05(土) 15:06:28 ID: Be: perlはメモリ喰いと批判されるけど64ビット版なら好きなだけメモリ喰っても良いんじゃないの? 実際のところどうなんだろ? 176 デフォルトの名無しさん [sage] 2009/12/05(土) 16:58:38 ID: Be: 64bit版のperlあるの? 177 デフォルトの名無しさん [sage] 2009/12/05(土) 17:11:24 ID: Be: 64bit linuxにデフォで入っていない? 178 デフォルトの名無しさん [sage] 2009/12/05(土) 17:13:13 ID: Be: そんなの5.8.0からとっくに対応になっとるやろボケ 179 デフォルトの名無しさん [sage] 2009/12/05(土) 17:57:17 ID: Be: 知るかクズが 180 デフォルトの名無しさん [sage] 2009/12/05(土) 20:23:18 ID: Be: やかましわボケ 181 デフォルトの名無しさん [sage] 2009/12/05(土) 23:37:42 ID: Be: 死ねカス 182 デフォルトの名無しさん [sage] 2009/12/05(土) 23:51:04 ID: Be: さっさとdual coreに対応しる 183 デフォルトの名無しさん [sage] 2009/12/06(日) 16:10:36 ID: Be: >>174 むしろKVSやdbopenがハッシュ関数を積極的に利用する方なんだがな。 ハッシュって言葉の意味と、DB系の話で何でハッシュって言葉がでてくるのか ちゃんと勉強しとかないと恥かくぞ。 184 デフォルトの名無しさん [sage] 2009/12/06(日) 18:09:07 ID: Be: ハッシュテーブルを略してハッシュって言ってるんだろ。 ハードディスクを略してハードと言うのと同じ。 185 デフォルトの名無しさん [sage] 2009/12/06(日) 18:59:21 ID: Be: >>183 プ 186 デフォルトの名無しさん [sage] 2009/12/06(日) 21:17:00 ID: Be: >>ハードディスクを略してハードと言うのと同じ それはねーよ 187 デフォルトの名無しさん [sage] 2009/12/06(日) 21:51:31 ID: Be: ハードはハードウェアの略だろ、普通は 188 デフォルトの名無しさん [sage] 2009/12/06(日) 21:59:39 ID: Be: ハードディスクをハードと略するのはあり得ないな。 他の板ならそれでも許されるかもしれんが、少なくともプログラム板では無理。 189 デフォルトの名無しさん [] 2009/12/06(日) 22:06:17 ID: Be: つまらん 190 デフォルトの名無しさん [sage] 2009/12/06(日) 23:05:57 ID: Be: Perlのハッシュは連想配列と呼ぶべきなんだが 「%」→パーシュ(?)ってことでハッシュにしてるんだろう 191 デフォルトの名無しさん [sage] 2009/12/06(日) 23:12:29 ID: Be: 4の頃は実際「連想配列」だったべ 5になったときにassociative arrayとかじゃなげーから呼び名を hashにしたんじゃなかったか 単に内部実装がhash tableだからhashのはず 192 デフォルトの名無しさん [sage] 2009/12/06(日) 23:56:28 ID: Be: 「連想」という誤訳が好きだったのに 193 デフォルトの名無しさん [sage] 2009/12/06(日) 23:58:59 ID: Be: お前らハッシュという言葉が何で、なんでハッシュテーブルって呼ぶのか 全然わかってないだろ・・・。 194 デフォルトの名無しさん [sage] 2009/12/07(月) 00:22:25 ID: Be: 日本語でおk
…誤訳?
あるわけありません。専攻分野と全く違うので。
Already know some Scala, but want to take the next step and make practical use of modern monadic design patterns? This is the book for you.
ということで、私は勝手に eZ430 Chronos を "programmable training watch" と命名した次第。
まえがき 『はじめなければ、はじまらないのです。』
要するにですね、文章をパソコンのキーボートとマウスで書くことが出来るWord というソフトがありますよね。 そのような、アルゴリズムをパソコンのキーボートとマウスで作れる(書ける?)ソフトウェアを探しているのです。
国内の総発電量を9200億kWh/年と仮定、総量に変化がないとした場合、2001年の総発電量に対するルーターの消費電力は0.008%だが、 2020年には48.7%(トラフィック量が年率40%で増加すると、2001年時の597倍に相当。電子技術に変化がないとした場合)になる。
・ブログ手当て?
毎度おなじみ東スポから。
プロ野球選手の契約更改の時期ですが、とある球団のとある選手が
(ベイスターズの選手ではない)、「ブログ手当て」なるものを契約更改の席上で
要求したとかしないとか。まあ上げ幅だか下げ幅が納得いかなかったので
交渉材料のひとつとして出したのでしょうけど、に、してもだなあ。
【Perl,PHP】LLバトルロワイヤル8【Ruby,Python】 85 デフォルトの名無しさん [sage] 2009/12/05(土) 10:52:56 ID: Be: 今日、札幌RubyKaigiだけどustだれかしらない? 86 デフォルトの名無しさん [sage] 2009/12/05(土) 11:00:39 ID: Be: ごめんなさい誤爆でした 87 デフォルトの名無しさん [sage] 2009/12/05(土) 11:45:44 ID: Be: >>84 比の要素数が合わなくて訳判らん 88 デフォルトの名無しさん [sage] 2009/12/05(土) 11:58:24 ID: Be: >>85 http://ruby-sapporo.org/live 89 デフォルトの名無しさん [sage] 2009/12/05(土) 12:38:29 ID: Be: 一番関数型を取り入れてるのは何? JavaScript? 90 デフォルトの名無しさん [sage] 2009/12/05(土) 13:58:29 ID: Be: >>88 Thansk 91 デフォルトの名無しさん [sage] 2009/12/05(土) 15:25:26 ID: Be: なんでこんなクソ寒い時期に札幌でやるんだ 92 デフォルトの名無しさん [sage] 2009/12/05(土) 15:26:27 ID: Be: カニが美味しいとかそういった理由と見た 93 デフォルトの名無しさん [sage] 2009/12/05(土) 15:34:28 ID: Be: >>88 LighningTalkみてて面白かったんだが、 こういうのってPythonとかPHPとかの日本のコミニティではやってないんですかね? 見てみたいっす ustreamとかでも見られるキボン 94 デフォルトの名無しさん [sage] 2009/12/05(土) 16:03:47 ID: Be: >>93 やってると思うお。 ustは、Ruby札幌の場合、好きでやってるチーム(KaigiFreaks)の存在 が大きいと思う。 95 デフォルトの名無しさん [sage] 2009/12/05(土) 16:09:23 ID: Be: 今朝の北海道 ttp://tv2ch.com/jlab-10s/s/10s175544.jpg 96 デフォルトの名無しさん [sage] 2009/12/05(土) 19:20:14 ID: Be: >>92 そういうのは大事だね。 97 デフォルトの名無しさん [sage] 2009/12/05(土) 19:28:55 ID: Be: RegionalRubyKaigiの一環なのかな?? > 札幌
プログラミングの下手な奴の特徴 0x01 176 仕様書無しさん [sage] 2009/12/03(木) 12:52:54 ID: Be: プログラミングが下手なやつって俺のこと? 大学時代C++で挫折して卒業後はシステム部門で運用監視系に入ろうと思ったら バリバリの開発系(基幹システム内製)で1年くらいでやめてしまったよ。 もう、あんなとこ行きたくない・・・ キーボードすら触れなくなって、マジ辛かった。 深夜まで開発作業に没頭なんて嫌だ・・・。 みんな忙しくて誰も助けてくれなかった。 今は運用監視系ですけどね。 あのキツイ教訓のおかげで、無理や我慢はしなくなってしまった。 177 仕様書無しさん [sage] 2009/12/03(木) 17:28:59 ID: Be: 運用監視ってただサーバーをぼーーーっと眺めてるの? 178 うゆ ◆e6.oHu1j.o [sage] 2009/12/03(木) 17:34:22 ID: Be: 言語習得の段階で挫折したならやめろよっ 世の中にはな、 C++が初めから読める人間もいるんだ 179 仕様書無しさん [sage] 2009/12/03(木) 19:30:22 ID: Be: LISP如きで頭痛に苦しむアホも居るけどね 180 仕様書無しさん [sage] 2009/12/03(木) 20:24:22 ID: Be: C++読める奴が羨ましいわ ちょっと複雑なテンプレートが使われてるともう何がなにやら 181 仕様書無しさん [sage] 2009/12/03(木) 21:23:41 ID: Be: ソースの読解力は場数で決まる 182 仕様書無しさん [sage] 2009/12/03(木) 21:32:19 ID: Be: きれいなもん見ないと 183 仕様書無しさん [sage] 2009/12/03(木) 23:06:38 ID: Be: >>181 だな ぶっちゃけ読解力は汚いソースもたくさんみないと上がらない スクラッチ開発しかしない奴とかは 総じて読解力が低い 184 仕様書無しさん [sage] 2009/12/04(金) 01:11:37 ID: Be: >183 そんなに俺を責めないでくれ・・・ 185 仕様書無しさん [sage] 2009/12/04(金) 12:32:53 ID: Be: C++スクラッチか・・・ 趣味も業務もC++はまともに書いたこと無いからな 186 仕様書無しさん [sage] 2009/12/04(金) 12:37:04 ID: Be: そんなにたくさん機能なくてもソフトは作れるからな テンプレートとかイラネ 187 仕様書無しさん [sage] 2009/12/04(金) 14:24:46 ID: Be: >>186 C++のテンプレートなら、プログラムが下手な奴でも マクロとしては使えるんで 使うといいよ マクロすら使わずコピペしまくりなら まあ残業頑張れ位しか言う事はないがw 188 仕様書無しさん [sage] 2009/12/04(金) 14:54:21 ID: Be: たまたま別プロジェクトのC++のテンプレートを作った人のコード見た時に 面白そうだから説明受けて、聞いた時は非常に便利そうだなとは思えたんだ 聞いた後に読んでみたんだけど、 でもループすらテンプレート化されてたんで 経験の無い俺には意味不明だった 189 仕様書無しさん [] 2009/12/04(金) 23:16:32 ID: Be: >>187 初心者がテンプレ使うのはやめてくれ! 190 仕様書無しさん [sage] 2009/12/05(土) 01:14:31 ID: Be: >>189 マクロ代わりに使われたテンプレートのソースも読めない奴は マクロでも読めないから無問題 まあテンプレートを極めたソースは 必ず最適化を狙って書いてあるから読解は 多少困難になるけどな つーか、本来そのための機能でもあるし 191 仕様書無しさん [sage] 2009/12/05(土) 01:38:57 ID: Be: テンプレートを ・仕組みを理解した上で使う → 素質あり ・仕組みを十分理解せず使う → 馬鹿 ・使わない → 並 192 仕様書無しさん [sage] 2009/12/05(土) 02:04:18 ID: Be: >>191 テンプレートなんてここ数年間だけでも 機能が拡張され続けてるんだが にわか丸出しだな 193 仕様書無しさん [] 2009/12/05(土) 02:15:57 ID: Be: テンプレートとは関係ないが、プログラムの下手な奴は すぐに自分で把握出来ない量や質のプログラムを書いてバグの海に沈む ってのはある プログラムが下手な奴は まず書かない努力から始めよう 203 仕様書無しさん [sage] 2009/12/05(土) 08:36:13 ID: Be: 会社ではゴリゴリcobol、 家では趣味としてC++で小物作り。 まわりにC++できる人いないから 情報源はネットと本だけ。 完全に独学だから仕事としてなら 使い物にならないだろうな・・・ 例えばaが0のときの書き方は !aって書くよりa==0って書いた方がいいよね? 204 仕様書無しさん [sage] 2009/12/05(土) 09:36:05 ID: Be: >>203 その選択肢、 signed a; a==0 or 0 == a 以外に何があるっていうんだ。 てか、プログラミングに独学以外ってあるのか? 純粋に仕事で覚えるのは独学に付け加える程度の知識だと思う。 逆に言えば、独学でウンコみたいな知識をつけていない限り、 仕事では独学してる人のほうが使えることが多い気がする。 ウンコみたいな知識ってのは、 コード書いてるそばから無用な速度や最適化のこと 考えはじめるとかね。 205 仕様書無しさん [sage] 2009/12/05(土) 11:57:30 ID: Be: >>204 独学only馬鹿の独演会とかいらないよ? しかも自分は速度がきわめて重要な処理は書いた事がありません って自白してるし ただ>>203のコードは今どきなら 最適化がされて同じコードを吐くから 気にする事はないけどな 206 仕様書無しさん [sage] 2009/12/05(土) 12:11:56 ID: Be: ネットや本だけって、十分すぎるだろう。大抵の仕事はネットや本で片付く 問題はその内容だが 207 仕様書無しさん [sage] 2009/12/05(土) 14:49:15 ID: Be: >>205 速度が重要な処理は書いた事は… とりあえずはあると思う。 (文字のマッピング変換処理) 俺が言っているのは、たとえば VB6でSelectステートメントが遅いから使うなとか、そういう類の。 そのステートメントが100万回呼ばれていて、 明らかにSelectステートメントのせいでシステムが遅いっていうなら、 Selectステートメントを使わないように直すに値するが、 そうじゃない限りは可読性のために使用を控えるべきじゃないっていう ごくごく当たり前のこと。 ちなみに独学onlyバカってのはどういうことを言っているんだ? 208 仕様書無しさん [sage] 2009/12/05(土) 14:51:54 ID: Be: if (!strcmp(a, b)) 209 仕様書無しさん [] 2009/12/05(土) 16:52:21 ID: Be: チェック系の処理でbooleanのt/f使わず Stringで"OK"とか"NG"とか返してた。 210 仕様書無しさん [sage] 2009/12/05(土) 20:11:51 ID: Be: if (!!!a)
いけがみさんが LL温泉会場から OCmalがどうたらいうつぶやきをしていたので なんとなく思い出した。
A beginners guide to OCaml internals ≪ Richard WM Jones In this 6 part series, I'm going to introduce the internals of the OCaml programming language (tutorial and other references here). This isn't going to be very comprehensive or in-depth. It's more of a digest of the readily available information that I found by reading the manual, header files, and some of the compiler code. It's definitely pitched at beginners, not experts. この6回のシリーズではOCamlというプログラミング言語の内部についての説明をしたいと思いま す(チュートリアルとその他のリファレンスはこちら)。これは comprehensive なものでも in-depth なものでもありません。マニュアルやヘッダーファイル、そしていくつかのコンパイ ラーのコード(compiler code. 出力したコードのことか?)からわたしが気づいた readily available な情報のダイジェストです。完全に初心者を対象にしたものであり、エキスパート向 けのものではありません。 By the end of it, you should be able to look at small pieces of OCaml and work out in your head how they get translated into machine code. By the end of it, OCaml の小さなコード片を見られるようにしておき、 どのように機械語に変換されるのかを確かめられるようにすべきでしょう。 I'm definitely not a great expert on the internals of OCaml. This means a couple of things:(a) I've probably made some mistakes (post a comment if you see any). (b) I might “reveal too much” of the specifics of the current implementation:anything could change in a future version of OCaml, although the internals described here have been pretty stable for a long time. わたしは決して OCmal 内部の great expert ではありません。 どういうことかというと: (a) 多分どこかに間違いがあるでしょう (もし見つけたらコメント欄に書いてください)。 (b) I might “reveal too much” of the specifics of the current implementation: ここで書かれた内部の詳細は長いこと安定しているものではありますが、 将来の OCmal では変更されることがあるかもしれません。 Without further ado … 宣伝はこれくらいにしましょう Part 1: Values (値) In a running OCaml program, a value is either an “integer-like thing” or a pointer. OCaml プログラムを実行しているとき、 値は 整数のようななにか (“integer-like thing”)かポインターのいずれかになります。 What's an “integer-like thing”? Any OCaml int or char, or some things which are stored like integers for speed, which include the constants true and false, the empty list [], unit (), and some (but not all) variants. “integer-like thing”(整数のような何か)というのは一体なんなのでしょうか? Any OCaml int or char, or some things which are stored like integers for speed, which include the constants true and false, the empty list [], unit (), and some (but not all) variants. For reasons that I'll explain later, OCaml stores values which are integer-like and values which are pointers differently. 後述する理由により、OCaml は整数のような値とポインターとを異なる形で格納します。 7A value containing a pointer is just stored as the pointer. Because addresses are always word-aligned, the bottom 2 bits of every pointer are always 0 0 (the bottom 3 bits are 0 0 0 for a 64 bit machine). OCaml therefore stores integers by setting the bottom bit to 1 and shifting the integer over 1 place: ポインターを含む 7A という値はポインターとして格納されています。アドレスは常にワード境 界に置かれているので、すべてのポインターの最下位 2ビットは常に 0 0 になります(64ビット マシンでは最下位 3ビットが 0 0 0 となります) OCaml therefore stores integers by setting the bottom bit to 1 and shifting the integer over 1 place: OCaml は整数を、1ビットシフトして場所を空けた上で最下位ビットを立てた形で格納します +----------------------------------------+---+---+ | ポインター | 0 | 0 | +----------------------------------------+---+---+ +--------------------------------------------+---+ | 整数 (31 or 63 bits) | 1 | +--------------------------------------------+---+ You can quickly tell if a value is an integer-like thing (ie. is the bottom bit 1?). これであなたはある値が整数のようなものかを即座に判定できるようになります (最下位ビットが1かどうかを見ればよい)。 OCaml gives you some C macros and OCaml functions you can use on values. The C macros are Is_long (is it an integer?) and Is_block (is it a pointer?) in the header file <caml/mlvalues.h>. The OCaml functions are is_int and is_block (for pointers) in the “infamous” Obj module. OCmal は値に対して使うことのできるいくつかの C マクロと OCmal 関数を提供しています。C マクロ Is_long (整数かどうか判定) と Is_block (ポインターかどうか判定) がヘッダーファ イル<caml/mlvalues.h> にあります。OCmal 関数 is_int と is_block (ポインター用) が“悪名高い”(infamous) なObj モジュールにあります。 # let what_is_it foo = let foo_repr = Obj.repr foo in if Obj.is_int foo_repr then "integer-like" else "pointer" ;; val what_is_it : 'a -> string = <fun> # what_is_it 42 ;; - : string = "integer-like" # what_is_it () ;; - : string = "integer-like" # what_is_it [1;2;3] ;; - : string = "pointer" # type bar = Bar | Baz of int ;; type bar = Bar | Baz of int # what_is_it Bar ;; - : string = "integer-like" # what_is_it (Baz 5) ;; - : string = "pointer" Are ints slow? After all it seems like you have to do a lot of bit shifting to do any arithmetic with them. 整数演算は遅いのでしょうか?整数に対してなんらかの算術演算を行うためにはたくさんのビッ トシフトの実行が必要になるので実行速度が遅くなるように思われます。 It turns out that they are a little bit slower, but not by very much. The OCaml compiler can perform most arithmetic operations in between one and four machine instructions, and usually just one or two, making it the same or fractionally slower than a straight native integer. (Of course, there is a more serious penalty in the cases where you really need the full width of a 32 or 64 bit integer, for example in crypto or compression algorithms). ビットシフト操作が入ることで多少遅く (little bit slower) なりますが、それほどおおきな ものではありません。OCmal コンパイラーはほとんどの算術演算を一つから四つの命令 (instruction) で実行することが可能ですが、大抵は一つか二つの命令で済みます。これによっ て straight native integer の場合よりも多少遅くはなります(もちろん、暗号化だとか圧縮ア ルゴリズムのように32ビットなり64ビットの幅を丸ごと使った整数が必要な場合にはより serious penalty が掛かる場合もあります)。 Increment addl $2, %eax インクリメント Add a constant addl (constant*2), %eax 定数の加算 Add two values lea -1(%eax, %ebx), %eax 二つの値の加算 Subtract subl %ebx, %eax 減算 incl %eax That these are equivalent isn't totally obvious, but this post explains why. これらが等価なものであることは一目ではっきりとわかるものではありませんが、 ここではなぜなのかの説明はしません。 That concludes part 1. Tune in tomorrow for part 2, or if you're reading this in the future, use this handy table of contents: * Part 2: Strings and other types (文字列とそれ以外の型) * Part 3: The minor heap (マイナーヒープ) * Part 4: The major heap (メジャーヒープ) * Part 5: Garbage collection (ガーベジコレクション) * Part 6: Conclusion, further reading (結論とあわせて読みたい) Update This guide is discussed on reddit here. Also on Hacker News here.
つづく。
書店員の情報交換スレ42 812 マロン名無しさん [sage] 2009/12/05(土) 00:45:28 ID:??? Be: そして出版不況の中今回もオマケの力でヤングエースは瞬殺されるのだった はえー 813 マロン名無しさん [sage] 2009/12/05(土) 00:47:42 ID:??? Be: おまけ付かないと全く売れないがなw 814 マロン名無しさん [sage] 2009/12/05(土) 02:11:16 ID:??? Be: もうおまけだけで売ればいいんじゃ 815 マロン名無しさん [sage] 2009/12/05(土) 12:41:37 ID:??? Be: お願いだから定期改正をちゃんと反映してくれ YA40冊で足りる道理がないだろ あ、来月は4冊でもいいよ
先月号は、今月号発売の二日前くらいでも目撃したなあw
私はアラン・ケイのOSプロジェクトこそが工学だと思う*1。あれはシステムの複雑さをソースコード量=情報量の下限値として探る実験だ。.
"どうやら、Google日本語入力の予測変換を気に入らぬ人がいるようだ。"
・ふるえるなひとみこらせよふっかーつーのーとーきー♪
先日復刊ドットコムで復刊がアナウンスされたJava並行処理プログラミングです。 いつかあなたの住む町へ行くかもしれません♪
奥付はこの通り
一体、初版一刷をどれだけ刷っていたのかという。
【Perl,PHP】LLバトルロワイヤル8【Ruby,Python】 67 デフォルトの名無しさん [sage] 2009/12/04(金) 13:32:02 ID: Be: はい、Perl厨です。 >>11 Encodeはもうちょいなんとかならんかったのかとは思う。コガイダン、あんだのことだよ。 文字列とバイト列は違うこと、それによって得られるメリットが分かればねえ。 しかしPHPerのかく日本語正規表現とかもはやギークコードにしかみえんぞ。ああいうのから 脱出したいとは思わないのかね? まあアレが嫌ならuse utf8やuse Encodeは絶対せずにJcode.pmで凌ぐというソリューションだってあるんだぜ。 >>16 PHPの思いつき実装は有名だし、コミッタやベンダが間違いを認めないのでも有名だし (だからバグとしか思えない挙動や機能が山のように残ってる)、その辺は叩かれてしかたない。 完全なセキュリティホールを「事前に○○しないのが悪い」で一蹴だからな。ビビったわ。 Perlはその点Larryが人間できてるから「あれはPerl使いに迷惑掛けた。悪かった」とか素直に認める。 Webフレームワークと親和性が悪いのが今のところ一番のネックだなPHPは。 >>27 Catalystはその辺柔軟性高い。昔のDBIやTemplateがそのまま使えるからな。オレオレでもおk。 逆にDBICやTTでバリバリ書くことも当然できるし。 >>36 PHPでRESTfulなフレームワーク書こうとして挫折するのはむしろ正常。Rubyが優れてる傍証にはならん。 >>40 アメリカでは去年から求人数でPerlがPHPを抜き、引き離しつつあります。Javaにはまだ敵いません。Rubyって何ですか? 68 デフォルトの名無しさん [sage] 2009/12/04(金) 14:32:03 ID: Be: >>67 | アメリカでは去年から求人数でPerlがPHPを抜き、引き離しつつあります。 まじすか。Perl好きとしてはうれしいなぁ。 ソースはどこですか? 69 デフォルトの名無しさん [sage] 2009/12/04(金) 14:32:49 ID: Be: アメリカではpythonとperlではどっちが求人数があれなん? 70 デフォルトの名無しさん [sage] 2009/12/04(金) 14:50:10 ID: Be: >>68 >>69 http://www.indeed.com/jobtrends?q=perl,php,python,ruby ほらよ。ちなみにindeedは求職サイト。だから実際のニーズが ダイレクトにグラフに出てる。 三文ニュースサイトが聞いたこともない調査会社に依頼したのとは訳が違う。 ちなみにjavaは今雲の上あたり。検索エリアに色々入れてみるといい。 71 デフォルトの名無しさん [sage] 2009/12/04(金) 14:54:29 ID: Be: Scale: Relative 72 デフォルトの名無しさん [sage] 2009/12/04(金) 15:05:03 ID: Be: PHPの方が伸びてね? 73 デフォルトの名無しさん [sage] 2009/12/04(金) 15:12:13 ID: Be: >>70 ソースありがと。 Perlだと23,828、PHPだと13,289だね。 monster.comでもPerlは2065で、PHPは1535。 おー。確かにアメリカはそんな感じなんだな。 74 デフォルトの名無しさん [sage] 2009/12/04(金) 17:10:42 ID: Be: Perl はプログラマが見つからず、いつまでも求人。 PHP は流動性が高い、という可能性も。 75 デフォルトの名無しさん [sage] 2009/12/04(金) 17:42:46 ID: Be: LLでの仕事ってWeb系しかないのかな? 外国だとPythonは普通のアプリ開発があるんかな? 76 11 [sage] 2009/12/04(金) 20:05:53 ID: Be: >>67 PHP使ってて日本語正規表現使う場面はなかったな。 というか、PerlやRuby使ってても日本語正規表現使う場面がない俺は 多分幸せなんだろうな。 Perlって、最早Moose必須な感じだよね? 他の言語では言語自体でカバー出来る事が、CPANありきなところがどうもなぁ。 でも、MooseのRecipeだなんだ読んでて、触ってるとだんだん楽しくなってくる不思議。 pmの1;や、my $self = shift; は猛烈にダサいと思うけどね。 >>70 Javaすげーな。その流れだと、PHPは二年後くらいにはPerlに追いつくね。 Perlは遺産が多いからかな。伸び率も悪そうだし。 COBOL入れるとおもしろい。もうちょい生きていけそうだな。 77 デフォルトの名無しさん [sage] 2009/12/04(金) 20:51:59 ID: Be: COBOLは滅びぬ。何度でもよみがえるさ。COBOLの力こそ人類の夢だからだ http://itpro.nikkeibp.co.jp/article/Interview/20091127/341216/
今回はどうにかなってもこの先どうなるのかねえ。
C言語でのCSVソートとデータ抽出について -OKWave 皆様、はじめまして。 この度、急ぎでプログラムをC言語で作成するように命じられました。 C言語は経験が無いと断ったのですが、要員確保が出来ない為、何とかしてくれとのこと。 本来なら自分で学習しながら、作成すべきなのですが、超短納期の為、その時間が取れません。 今回は誠に申し訳ないのですが、皆様のお力をお借り出来ないでしょうか。 宜しくお願いいたします。 仕様概要 ・CSVファイルを読み込み、2カラム目の項目(文字型)で昇順ソート(qsort)を行う。 ・ソートされた2カラム目の同一値毎に1カラム目(数値型)が最大値となるレコードを抽出する。 ・抽出されたレコードを新規CSVファイルに出力する。 入力CSV概要 ・レコード件数は日によって変わる ・カラム数は8つ ・各カラムの項目長は可変長 ・上記に伴いレコード長も可変長 (略)「超短納期」で「C言語は経験が無い」人にやらせるって, この時点ですでに無理筋だよなぁ.... さておき, どうしても C じゃないとダメなの? ほかのスクリプト系言語ならもっと簡単にで きるはずなのに. 各カラムのデータにカンマ (,) がないなら Perl では %records; while (<>l) { $data = [split /,/]; next if exist $records{$data->[1]} && $records{$data->[1]}->[0] > $data->[0]; $records{$data->[1]} = $data; } for (sort { $a <=> $b; } keys %records) { print join(',', @{$records{$_}}); } くらいで終わりなのに.こんばんは。回答有難うございます。 確認したところ、C以外は却下と言われました。 ソースを提示頂いたのに申し訳ないです。とりあえず、昇順に並び替える所まで挑戦してみた。 -------- #include <stdio.h> #include <string.h> #include <stdlib.> (以下略)> ・各カラムの項目長は可変長 この「可変長」の部分がひっかかります。 可変長でもかまいませんが、長さの上限はあるのでしょうか? 上限が設定されていないのであれば、reallocでバッファを拡張しながら読み込まないといけませんので、 未経験者がいますぐ取り組むのは絶望的です。こんばんは。 仕様を再確認しました。 各カラムの項目長は決まってないらしいのですが、 レコード長の上限は2048らしいです。 つまりカラムの項目長上限も決まってるようなものですね! レコード的に2048を超えるレコードが存在した場合、 そのレコードは処理対象外とするそうです。 おいおい、最初と話が違うだろ・・・と言いたかったです。> 皆様のお力をお借り出来ないでしょうか。 で、なにが問題なんですか?こんにちは。 処理の概略手順だけ考えてみました。 ※下記は一例です。 1)入力元CSVファイルをオープンする。 2)入力元のCSVファイルを行単位に読み込み、その行数のみ取得する。 ・fgets関数で、最大バッファ長を (2048+4)ぐらいとして、行単位に[EOF] になるまで読み込んで(※ここでは文字列バッファに読み込むのみ)、 行数(レコード数)をカウントする。 ・読み込んだ1行分の文字列の末尾の改行文字('\n')を除いた文字数が 2048文字を超えた行は無視する。(※カウントしない) <行数(レコード数)を格納する変数の例> long nRecCnt; ← 取得した行数(レコード数)を格納する。 3)取得した行数分の、データ構造体(1レコード相当)の配列を確保する。 (略)
釣りのにおいがぷんぷんするけど、本当に業務でこういうことやれとか いってくるようなところなら良く考えたほうがいいじゃないか?
もいっこ
CGIについて -OKWave 会社から以下のようなcgiを作ってくれと言われましたが、初心者の為皆目見当つかない状態です perl,c,c++のうちなんでもいいそうですが、perlが入っているので、それを使おうかと思っています。 <図書管理サイト(CGIプログラム)要求仕様> rental.cgi 1.登録社員がアクセス、セレクトボックスから自分を選択し、パスワードを入力。 (パスワードは当面、社員番号と同じでよいと思われる) 2.認証に成功すると図書リスト画面が出る。図書リスト画面は、 「図書テーブル」の内容がリスト表示される。表示は「登録日が新しい順」。 本が増えることを想定すると、図書名による「検索」ができるとなおよい。 3.「貸し出し中ではない」本は、「借りる」といるリンクがつく。「借りる」を クリックすると、JavaScriptによるアラートで「本XXXXを借りますか?」と出す。 OKがクリックされたら、貸し出し登録。 データベースの更新等貸し出し処理が無事終了したら 該当の本を「貸し出し中」とし、図書リストを更新表示。 なお、この時プログラム内部で「履歴テーブル」にデータを追加しておくこと。 4.図書リスト画面において、該当社員が借りている本の場合は「借りる」ではなく 「返却する」リンクとなる。 クリックすると、JavaScriptによるアラートで「本XXXXを返却しますか?」と出す。 OKがクリックされたら、図書返却登録。3.と逆のステップになる。 データベースの更新等返却処理が無事終了したら 該当の本を「貸し出し中」では無くし、図書リストを更新表示。 なお、この時成功画面に「本は棚に忘れず返却してください」などと出す。 データベースの方はpostgreSQLで下のような感じで作ってあります。 データベース名…bookmanagement (以下略)> 作ってくれと言われましたが、初心者の為皆目見当つかない状態です 断るべきです。そういうわけにもいかないんですむむむ、すごい会社ですね^^; とりあえず、Perl、CGI、JavaScript、SQLの知識が必要そうです。 まず、これらに関する書籍を読むことから始めることになると思います。 JavaScriptはWebだけで何とかなりそうです。 完全な初心者がそれなりのものを作るとしたら、勉強から始め、半年ぐらいはかかるでしょうか?そうですね^^ でも、しかも納期今月末って言われてます…orz 明日、書店へ行って少し本をあさってきます。 何かいいのありますでしょうか?
「EDSAC(Electronic Delay Storage Automatic Calculator,エドサック)」という名前をご存じだろうか。
こんだけ伸びたから、ちょっとまとめてみるか?
Why does everyone here seem to dislike C++? (self.programming)
# 744個のコメント
とか。
Why Perl Lost It : programmingWhy Perl Lost It (martin.drashkov.com)
526個のコメント
学研のおばちゃんまだかな~♪
『学習』『科学』休刊のお知らせ | 学研ホールディングス
ついに。というか。
実は一年間だけどだけど、わたしの母が「学研のおばちゃん」やってましたw
年末だよ!のら犬兄弟のギョーカイ時事放談スペシャル -のら犬兄弟のギョーカイ時事放談!-
んーむ、チケット取れるかしらん。
・伸びてる
Why Perl Lost It : programming
Why does everyone here seem to dislike C++? : programming
結構良くできてると思います。リンク先のチートシート。
Moving from Python 2 to Python 3: A 4 page "cheat sheet" - Rhinocerus Moving from Python 2 to Python 3: A 4 page "cheat sheet" I've produced a 4 page document that provides a very concise summary of Python 2<->3 differences plus the most commonly used new Python 3 features. It is aimed at existing Python 2 programmers who want to start writing Python 3 programs and want to use Python 3 idioms rather than those from Python 2 where the idioms differ. It uses Python 3.1 syntax since that looks like being the standard for a few years in view of the language moratorium. The document is U.S. Letter size but will also print fine on A4 printers. It is available as a free PDF download (no registration or anything) from InformIT's website. Here's the direct link: http://ptgmedia.pearsoncmg.com/impri...on2python3.pdf And of course, if you want more on Python 3, there's always the documentation---or my book:-) "Programming in Python 3 (Second Edition)" ISBN-10: 0321680561.
Matz Q&A - 角谷HTML化計画(2009-11-21) Matz Q&ACommentsAdd Star Matzに訊け!のコーナー。 (印象に殘った質問) Q: Ruby 2.0はいつ出ますか? Matz: いつ出すかなんてさっぱりわからないけれど、1.9.2のリリース後に着手します。 (これはRubyWorld Conference 2009と同じ答えなので、どうやら本気みたい) Q: 5年後どうなっててほしいですか? Matz: RubyConf 2014で笑顔のみんなに会いたいね。 Q: 1.9.2 に __DIR__ 入れてほしいんですが? Matz: (Yuguiさんの顔色をうかがった後に)いいよ
ほう。1.9.2 リリースのあとに着手。
こういうことをいう奴は、どういう神経をしてるんだろうな。相当、面の皮が厚いのか。
zOSの品質をなめちゃいけません。マシン語レベルまで管理されてるんですから。
すんません。いろいろ余裕がががが。
・やるのかw
さよなら絶望放送・ラジオイベント≪レッツ!きよ彦ナイト≫
読んだ
ドラフト物語
なかなか面白い見方をするなーと思った。
確かにチームの方針とかが透けて見えたりして興味深い。
競合してくじで負けたときの指名をどのようにしているとか。
Odd rounding problem using the ruby printf-format-specifier - Stack Overflow Has anybody got any ideas on this one? When we run: printf("%.0f", 40.5) On a windows box the return is "41" but on our production ubuntu server we're getting "40"Looks like a simple case of binary floating point imprecision. On one machine you get 40.499999999 which rounds to 40; on the other machine you get 40.500000000001 which rounds to 41. If you need exact numbers then you should not use binary floating point. You can use fixed point decimal, or decimal floating point. Edit: you're using BigDecimal, you say. Why not avoid any conversion to float by using #round and then #to_i? (Or #floor or #ceil instead of #round... it's not clear what your goal is.) b = BigDecimal.new("40.5") print b.round.to_i # => 41
リテラルの 40.5 を使っているんだから、40.4999.... とか 40.500...1 の可能性はないでしょう (2 が基数の浮動小数点数でも誤差なく表現できるはずの数値)。 これって単に bankers' rounding しているけのような気がするけどなあ。 あれ、これって ruby の話か。
めんどい。
>make cmp -s y.tab.h awk.h || cp y.tab.h awk.h cc -O -c -o awk.lx.o awk.lx.c awk.lx.l: In function `yylex': awk.lx.l:67: warning: assignment makes integer from pointer without a cast awk.lx.l:75: warning: assignment makes integer from pointer without a cast awk.lx.l:77: warning: assignment makes integer from pointer without a cast awk.lx.l:102: warning: assignment makes integer from pointer without a cast awk.lx.l:132: warning: assignment makes integer from pointer without a cast awk.lx.l:141: warning: assignment makes integer from pointer without a cast awk.lx.l: At top level: awk.lx.l:151: error: redefinition of 'input' lex.yy.c:1738: error: previous definition of 'input' was here awk.lx.l: In function `input': awk.lx.l:155: error: `yysptr' undeclared (first use in this function) awk.lx.l:155: error: (Each undeclared identifier is reported only once awk.lx.l:155: error: for each function it appears in.) awk.lx.l:155: error: `yysbuf' undeclared (first use in this function) make: *** [awk.lx.o] Error 1
この lex ソースだと、input()を自前で書いちゃっているのだけど、 flex 的にはそれは許されないっぽいのでとりあえずコメントにしちゃって続行。 yyptr や yysbuf も調べてないけど、たぶん yybginとかと同類のものだろう。
>make cmp -s y.tab.h awk.h || cp y.tab.h awk.h cc -O -c -o proctab.o proctab.c cc -i -s -O awk.g.o awk.lx.o b.o main.o token.o tran.o lib.o run.o parse.o proctab.o -lm -o awk main.o:main.c:(.text+0x472): undefined reference to `_errno' run.o:run.c:(.text+0x90): undefined reference to `_proctab' run.o:run.c:(.text+0xc0): undefined reference to `_proctab' collect2: ld returned 1 exit status make: *** [awk] Error 1
proctab はソースアーカイブの中にある proc.c をコンパイルしてできる 実行ファイルを実行して作成するもの。 例によって、初期化時の = がなかったりしたので、= つきで生成するように proc.c を修正したり。errono は include <errno.h> せずに 直接 extern int errno とかしてたのを修正。
そんなこんなでなんとか awk の実行ファイルはできたのですが
>echo hello, world | awk 1
awk: syntax error near line 1
awk: bailing out near line 1
>echo hello, world | awk "{print}"
awk: syntax error near line 1
awk: bailing out near line 1
んーむ、たぶん awk.lx.l をちゃんとしないとだめなんだろうなあ。
この度、12月23日に発売を予定しておりました、Blu-ray&DVD「第四巻 / なでこスネイク」につきまして、制作上の都合により、発売日を2010年1月27日に変更させていただく事となりました。
だが、私はこれを「コマンド プロンプト」と呼ぶのがどうにも気にくわないのだ。
「カーソルって何?」と聞かれたときにうまく説明できません。 カーソルとはどのようなものなのでしょうか?
ドラフト仕様は341ページのPDF文書で、Rubyの文法や組み込みモジュールの仕様が記載されている。
C++0x以前では、関数オブジェクトは、お世辞にも、活用されているとは言い難かった。既存の関数ポインタより圧倒的に便利なのだが、如何せん、その文法が汚い。
文章を読まずに、訳の質を判断するには、カタカナの量を見るといい。カタカナばかりの訳本は買う価値はありません。英語で読んだ方がましです。
紙のサイズも、欧米ではA3/A4/A5が主流だそうです。B3/B4/B5は日本ローカル仕様のようです。
中途半端な状態の訳がいくつか。 げしょ。
・ひぐらし
近代麻雀に「ひぐらしの哭く頃に 燕返し編」とかいうのが掲載されててふいた。
読みきりかと思ったら、月一(近代麻雀は月二回刊)での連載らしい。
・そしてムダヅモ
もうわけわからんw(というのは前にも書いたような気が)
ところで、この作品の作者さんがついった始められたようです。
大和田秀樹 (hideki6809) on Twitter
6809 って「究極の8ビットCPU」のあれでしょうかw
UNIX V7 の awk の話なんですが、いくつか引っかかってます。 簡単に修正できるものもあるんですが、ひとつ修正方法がよくわからないものが。
%Start A str chc sc reg comment
%{
#include "awk.h"
#include "awk.def"
#undef input /* defeat lex */
extern int yylval;
extern int mustfld;
int lineno 1;
#ifdef DEBUG
# define RETURN(x) {if (dbg) ptoken(x); return(x); }
#else
# define RETURN(x) return(x)
#endif
#define CADD cbuf[clen++]=yytext[0]; if(clen>=CBUFLEN-1) {yyerror("string too long", cbuf); BEGIN A;}
#define CBUFLEN 150
char cbuf[CBUFLEN];
int clen, cflag;
/* extern struct yysvf yysvec[], *yybgin; */
%}
A [a-zA-Z]
B [a-zA-Z0-9]
D [0-9]
WS [ \t]
%%
switch (yybgin-yysvec-1) { /* witchcraft */
case 0:
BEGIN A;
break;
case sc:
BEGIN A;
RETURN('}');
}
<A>^\n lineno++;
int lineno 1; というのは元のコードがそうなっています。 @alohakkun の調査だと、古いCではこういう記述がありと書かれていたような記憶が。 まあそれはさておき、= 追加しておしまい。 んで困っているのが、%% の直後の switch 文。いろいろ調べてみるとこれは lex と flex の非互換性のひとつのようです。
unnamed-faq-98 - Lexical Analysis With Flex unnamed-faq-98 To: daniel@synchrods.synchrods.COM (Daniel Senderowicz) Subject: Re: lex In-reply-to: Your message of Mon, 22 Nov 1999 11:19:04 PST. Date: Tue, 23 Nov 1999 15:54:30 PST From: Vern Paxson <vern> Well, your problem is the switch (yybgin-yysvec-1) { /* witchcraft */ at the beginning of lex rules. "witchcraft" == "non-portable". It's assuming knowledge of the AT&T lex's internal variables. For flex, you can probably do the equivalent using a switch on YYSTATE. Vern
switch (YYSTATE) でいいのかなあ。
このほか気になったのが、stdio.h が <> じゃなくて "" で 囲まれているということ。
run.c #include "awk.def" #include "math.h" #define RECSIZE 512 #include "awk.h" #include "stdio.h"
gcc + flex でコンパイルを試みているので、asprintf なんていうのは見事に名前が衝突します。
run.c
obj asprintf(a,n) node **a;
{
obj x;
node *y;
char *s;
y = a[0]->nnext;
x = execute(a[0]);
s = format(getsval(x.optr), y);
tempfree(x);
x = gettemp();
x.optr->sval = s;
x.optr->tval = STR;
return(x);
}
=====
obj aprintf(a,n) node **a;
{
obj x;
x = asprintf(a,n);
if (a[1]==NULL) {
printf(x.optr->sval);
tempfree(x);
return(true);
}
redirprint(x.optr->sval, (int)a[1], a[2]);
return(x);
}
びっくりしたのがこれ。
tran.c
cell **makesymtab()
{
int i;
cell **cp;
cp = (char *) malloc(MAXSYM * sizeof(cell *));
if (cp == NULL)
error(FATAL, "out of space in makesymtab");
for (i = 0; i < MAXSYM; i++)
*((cell **) cp + i) = 0;
return(cp);
}
malloc の戻り値を char * でキャストしてそれを cell ** な変数に代入しようとしています。 gcc ではここでエラーになりました。 なぜ cell ** でキャストしないで char * でキャストなのかよくわかりません。
知らない間に mb_なんちゃら もいろいろ芸が増えているのだねえ。
Alexey Zakhlestins blog » ode to mb_ereg functions PHP has some sets of functions, which are not known to the wide audience. One of those is mb_ereg_* family of functions. PHP は広くは知られていない関数群のセットを幾つか持っています。 mb_ereg_* ファミリーの関数群はその一つです There is a common misunderstanding, that mb_ereg_* functions are just unicode counterparts of ereg_* functions: slow and non-powerful. That's as far from truth as it can be. mb_ereg_* 関数群は ereg_* 関数群のUnicodeバージョンであり、遅くて非力なものだというのは よくある誤解です。 That's as far from truth as it can be. mb_ereg_* functions are based on oniguruma regular expressions library. And oniguruma is one of the fastest and most capable regular expression libraries out there. Couple of years ago I made a little speed-test. mb_ereg_* 関数群は oniguruma という正規表現ライブラリを基礎に使ったものです。 この oniguruma は、正規表現ライブラリの中でも最も高速かつ capable なものの一つです。 二年ほど前にわたしはちょっとしたスピードのテストをしました。 Anyway, this time, I was going to tell about it's usage. PHP-documentation isn't telling much. いずれにしても、今回は PHP のドキュメントではあまり触れられていない使い方について お話しましょう。 Let's start with the basic fact: you don't need to put additional delimeters around your regular exprsssions, when you use mb_ereg_* funcitons. For example: まずは基本的な事実から始めましょう。 mb_ereg_* 関数群を使うときには、 正規表現の周りを囲むデリミターを追加する必要はありません。 例を挙げましょう: // find first substring consisting of letters from 'a' to 'c' in 'abcdabc' string. mb_ereg('[a-c]+', 'abcdabc', $res); To execute same search, but in case-insensitive fashion, you should use mb_eregi() mb_ereg(), mb_eregi() and mb_split() functions use pre-set options in their work. You can check current options and set the new ones using mb_regex_set_options() function. This function is parametrized by string, each letter of which means something. mb_ereg()、 mb_eregi()、mb_split() といった関数は その動作時に pre-set されたオプションを使用します。 mb_regex_set_options() 関数を使って カレントのオプションを確かめたりセットすることができます。 この関数は文字列によってパラメーター指定され、 その文字列のそれぞれの文字がなんらかの意味を持っています。 There are parameters (you can specify several of these at the same time): パラメーターには以下のものがあります (一度に複数の指定ができます): * ‘i': ONIG_OPTION_IGNORECASE; * ‘x': ONIG_OPTION_EXTEND; * ‘m': ONIG_OPTION_MULTILINE; * ‘s': ONIG_OPTION_SINGLELINE; * ‘p': ONIG_OPTION_MULTILINE | ONIG_OPTION_SINGLELINE; * ‘l': ONIG_OPTION_FIND_LONGEST; * ‘n': ONIG_OPTION_FIND_NOT_EMPTY; * ‘e': eval() resulting code And there are “modes” (if you specify several of these, the LAST one will be used): さらに“モード”もあります (これらを複数個使って指定した場合、文字列の最後にあるものだけが使われます): * ‘j': ONIG_SYNTAX_JAVA; * ‘u': ONIG_SYNTAX_GNU_REGEX; * ‘g': ONIG_SYNTAX_GREP; * ‘c': ONIG_SYNTAX_EMACS; * ‘r': ONIG_SYNTAX_RUBY; * ‘z': ONIG_SYNTAX_PERL; * ‘b': ONIG_SYNTAX_POSIX_BASIC; * ‘d': ONIG_SYNTAX_POSIX_EXTENDED; Descriptions of these constants are available in this document: API.txt これらの定数の説明は鬼車の APIX.txt というドキュメントで説明されています。 So, for example, mb_regex_set_options('pr') is equivalent to mb_regex_set_options('msr') and means: たとえば mb_regex_set_options('pr') は mb_regex_set_options('msr') と等価であり * . should include \n (aka “multiline-match”) . は \n も含むようにする(複数行マッチ) * ^ is equivalent to \A, $ is equivalent to \Z (aka “strings are single-lined”) ^ が \A と、$ が \Z と等価になるようにする (単一行として扱う) * using RUBY-mode RUBYモードの使用 By the way, that is the default setting for mb_ereg_* functions. And, mb_ereg_match and mb_ereg_search families of functions take options-parameter explicitly. ところでこれは mb_erge_* 関数群のデフォルトの設定です。 また、mb_ereg_match と mb_ereg_search の関数ファミリーは オプションパラメーターを explicitly に取ります。 So, back to functions: さて関数の説明に戻りましょう: // make sure, that the whole string matches the regexp: mb_ereg_match('[a-c]+', $user_string, 'pz'); // 'pz' specifies options for this operation // (multiline perl-mode in this case) // replace any of letters from 'a' to 'c' range with 'Z' $output = mb_ereg_replace('[a-c]', 'Z', $user_string, 'b'); // use basic POSIX mode Ok, these were easy and similar to what you've seen in preg_* functions. Now, to something more powerful. The real strength lies in mb_ereg_search_* functions. The idea is, that you can let oniguruma preparse and cache text and/or regexp in its internal buffers. If you do, matching will work a lot faster. これらの関数はpreg_* 関数群に見られるものと同様のものですがさらに強力になっている部分 があります。その real strength は mb_ereg_search_* 関数群にあります。使われているアイ デアは oniguruma にテキストや正規表現をあらかじめ与えておいてその内部バッファーに保存 させるというもので、これを行うとマッチングが格段に高速化されます。 mb_ereg_search_init($some_long_text); // preparse text mb_ereg_search('[a-c]'); // execute search while ($r = mb_ereg_search_getregs()) { // get next result // work with matched result } mb_ereg_search('[d-e]'); // execute different search on the same text mb_ereg_search_init($some_other_text); // preparse another text mb_ereg_search(); // execute search using previous (already preparsed) regexp This is the fastest way of parsing large documents in php, as far as I know. これは、わたしの知る限りでは PHP を使って大きなドキュメントを解析するときの 最速な方法です。 Notes on charsets. Though, it is often mentioned, that mb_ereg_* functions are “unicode”, it would be more practical to say, that they are encoding-aware. It is a good idea to specify, which encoding you use beore calling oniguruma. キャラクターセットには注意してください。 mb_ereg_* 関数群は “Unicode”であるとしばしば言及されているのですが、 より実情に沿って言えば、encoding-aware の関数群なのです。 oniguruma を呼び出す前にあなたの使うエンコーディングを指定するのは良い考えです。 Some options: mb_regex_encoding('UTF-8'); mb_regex_encoding('CP1251'); // windows cyrillic encoding mb_regex_encoding('Shift_JIS'); // japanese Check the full list of supported encodings.
grep には、マッチした場合にその行を出力するのではなくファイル名を出力させる -l オプション(ファイル名の出力はファイルごとに一回まで)や、 検索パターンが見つからなかったときに行を出力させる -v オプションがあります。 んで、「特定のパターンを含む行が存在しないファイルのファイル名」を出力させるには というお話なんですが、-l と -v を組みあわせて指定しても期待通りには動きません。
Re: Using grep to search for files that do not contain a string On Wed, 25 Nov 2009, ewgoforth wrote: I know that I can search for lines that do not contain a string. However, the -v option doesn't appear to work with the -l option. Is this possible. It works perfectly. Please read the manual. You probably want "-L", rather than "-vl". Matthew -- Psychotics are consistently inconsistent. The essence of sanity is to be inconsistently inconsistent.
GNU grep だと -L というそれを実行させるオプションがあります。 ほかの環境にもあるのかな。
今は日本も人口がどんどん減っているけれど、今生まれてくる子供たちは、数が少ないが故に明らかに将来、恵まれた生活を享受できるだろうし。 彼らはその時代に即した生き延びる術を身につけて、ちゃんと生き延びていくはず。
一つ前へ
2009年11月(下旬)
一つ後へ
2009年12月(中旬)
メールの宛先はこちら