ときどきの雑記帖 濫觴編

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

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

ホームへ

2011年09月10日

■_

東スポで中野渡(以前ベイスターズにいた選手)がベイスターズに毒舌吐きまくり。 いやまあ仰るとおりですってのがちと悲しいのだけど (山口に対するのは辛口すぎる気もしないでもないけど) 中野渡進 - Wikipedia もつ鍋屋行ってみたいw。

なんか目の敵にしているようで申し訳ないんですが 情報工学は面白い! - 週末スペシャル:ITpro のリンクの最後の回

第14回 近代コンピュータ史――「日本人初」はあなたかも,目指せ,チューリング賞 - 矢沢久雄の情報工学...:ITpro

ただし,ハードウエアと比べて,物理的な形がないソフトウエア(プログラム)は,容易に変更
が可能なため,バグを多く残していたり,自分勝手な記述スタイルに陥ってしまう危険がある。
プログラミング技法とコンパイラ構築技法の研究者であり,ALGOLなどいくつかのプログラミン
グ言語の設計に関わっているアラン・J・パーリス(Alan J. Perlis,1966年受賞)は,プログ
ラミングに関する130項目の風刺的な警告「EPIGRAMS IN PROGRAMMING」を発表している。プログ
ラマなら,一度は目を通しておいてほしい。

EPIGRAMS IN PROGRAMMING でぐぐると EPIGRAMS ON PROGRAMMING が先頭に来るし、 ON の多そうなんだけどどっちが正しいんだろう? 二番目の IN としているページもそれっぽいしなあ。

Epigrams on Programming
Epigrams on Programming
Alan J. Perlis
Yale University

This text has been published in SIGPLAN Notices Vol. 17, No. 9, September 1982, pages 
7 - 13. I'm offering it here online until ACM stops me.

The phenomena surrounding computers are diverse and yield a surprisingly rich base for 
launching metaphors at individual and group activities. Conversely, classical human 
endeavors provide an inexhaustible source of metaphor for those of us who are in labor 
within computation. Such relationships between society and device are not new, but the 
incredible growth of the computer's influence (both real and implied) lends this 
symbiotic dependency a vitality like a gangly youth growing out of his clothes within 
an endless puberty.

The epigrams that follow attempt to capture some of the dimensions of this traffic in 
imagery that sharpens, focuses, clarifies, enlarges and beclouds our view of this most 
remarkable of all mans' artifacts, the computer.

   1. One man's constant is another man's variable.
   2. Functions delay binding: data structures induce binding. Moral: Structure data late
      in the programming process.
Perlisisms - "Epigrams in Programming" by Alan J. Perlis

EPIGRAMS IN PROGRAMMING

1. One man's constant is another man's variable.

2. Functions delay binding; data structures induce binding. Moral: Structure data late
   in the programming process.

(略)

From ACM's SIGPLAN publication, (September, 1982), Article "Epigrams in Programming", by Alan J. Perlis of Yale University.

んー、IN でいいのかなあ。英文法的にどっちがどうなのかはわからんw

■_

TAPL読書会

Python 3.2 (r32:88445, Feb 20 2011, 21:29:02) [MSC v.1500 32 bit (Intel)] on win 32
Type "help", "copyright", "credits" or "license" for more information.
>>> l=[1,2,3,4,5]
>>> l[0]
1
>>> l[4]
5
>>> l[-1]
5
>>> l[5]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: list index out of range
>>> l[-5]
1
>>> l[-6]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: list index out of range

irb(main):001:0> RUBY_VERSION
=> "1.9.2"
irb(main):002:0> l=*1..5
=> [1, 2, 3, 4, 5]
irb(main):003:0> l
=> [1, 2, 3, 4, 5]
irb(main):004:0> l[6]
=> nil
irb(main):005:0> l[-5]
=> 1
irb(main):006:0> l[-6]
=> nil
irb(main):007:0> l[-6]=-1
IndexError: index -6 too small for array; minimum: -5
        from (irb):7:in `[]='
        from (irb):7
        from C:/Program Files/Ruby-1.9.2/bin/irb.bat:20:in `<main>'
irb(main):008:0> l[5]=6
=> 6
Loading DB routines from perl5db.pl version 1.3
Editor support available.

Enter h or `h h' for help, or `perldoc perldebug' for more help.

main::(-e:1):   0

  DB<1> $l = (1, 2, 3);


  DB<2> @l=(1,2,3);


  DB<3> $l[1];


  DB<4> $l[1]


  DB<5> print $l[0]
1

  DB<6> print $l[1]
2

  DB<7> print $l[2]
3

  DB<8> print $l[3]


  DB<9> print $l[-1]
3

  DB<10> print $l[-2]
2

  DB<11> print $l[-3]
1

  DB<12> print $l[-4]


  DB<13> q

これがTAPL読書会とどう関係するのか? それは明日以降明らかに! (なるかもしれない)

■_

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

188 デフォルトの名無しさん [sage] 2011/09/10(土) 11:13:18.92 ID: Be:
    このスレでは数学の書籍の紹介とかはしないの?
    最近twitterなんかの情報系の人達の話がどんどん数学寄りになっていってる気がするんだけど。
    お前ら様達におかれましては数理論理学は基礎中の基礎として把握済みのものになっておりますでしょうか?

    あー、あと
    PROLOG Programming for Artificial Intelligence (4th)
    http://www.amazon.co.jp/dp/0321417461/
    の話題って出てないよね。
    「予約して待つ事数年、すっかり忘れてたけど出荷されたとな!」
    の報告が続々みたいだけど。 

189 デフォルトの名無しさん [sage] 2011/09/10(土) 11:20:08.10 ID: Be:
    俺は自分の好きなようにやる
    twitterとか汁か 

190 デフォルトの名無しさん [sage] 2011/09/10(土) 11:21:58.76 ID: Be:
    このスレでは数学の書籍の紹介はしません
    してもスルーされます

    Prolog の話題もすぐに消えます

    ここで語られるのは主に C/C++、たまに Java 関係のそれもほとんど入門書、
    たまにプログラマ系の人間が読むと面白そうな物語やインタビュー集みたいなもの

    それ以上のレベルになると、それくらい能力があるなら論文漁れとあしらわれます 

192 デフォルトの名無しさん [sage] 2011/09/10(土) 11:35:36.47 ID: Be:
    >>190
    えー?最近はどこも
    「Haskellやるんなら圏論は抑えとかなきゃねー」
    「型付きλ計算ぐらい知ってますよね?」
    って勢いじゃないすか。
    中高生も日常的に英文論文読んでて戦々恐々とする。
    おっさんとして彼らにどう向き合えばいいのやら…。

    Prologだと、絶版になってるけど
    Prologによる論理プログラミング入門
    http://www.amazon.co.jp/dp/476651081X/
    が面白かった。査読者のツッコミが付記してあるのでテンポ良く読めた。

    大学図書館は大抵Prolog関係の書籍が充実してて良いので、Prolog好きなら行くべき。
    …まぁ第五世代なんちゃらの遺産なんだろうけど。 

194 デフォルトの名無しさん [sage] 2011/09/10(土) 11:56:04.19 ID: Be:
    >>192
    だから「このスレでは」と言っている

    Haskell 関連の本を詳しく紹介したい・して欲しいのなら
    Haskell スレの方が食いつきがいい

    Plorog 関連なら Prolog のスレで

    数学関連なら(なぜか計算機科学系でも)数学系のスレの方が反応がいい

    なんでかは知らんが C/C++、Java、あと Web 関連だと、
    ここで訊いてもちゃんとまともにレスしてくれる 

201 デフォルトの名無しさん [sage] 2011/09/10(土) 15:11:21.25 ID: Be:
    >>194
    Haskellの本なら答えるんだが、そもそも聞かれる事が少ない。。。

202 デフォルトの名無しさん [sage] 2011/09/10(土) 16:22:54.06 ID: Be:
    >>201
    洋書でも和書でも全く構わないんだが
    Haskell でランクとか kind とか forall とかの意味や役割を
    丁寧に解説している本って何か無いですか?

    ネット上に散らばっている情報から推理するのに疲れ果てた 

203 デフォルトの名無しさん [sage] 2011/09/10(土) 16:35:21.76 ID: Be:
    ないよ
    Haskell WikiとかGHCのドキュメントを読んだりそこからリンクを辿るしかない 

204 デフォルトの名無しさん [sage] 2011/09/10(土) 16:45:19.05 ID: Be:
    >>202
    まだ読んだ事無いけど、これなら載ってそう
    http://www.amazon.co.jp/gp/aw/d/0954300696/

    ただ、普通に数学の論理学の本買った方が無難じゃ無かろうか

205 デフォルトの名無しさん [sage] 2011/09/10(土) 17:42:59.65 ID: Be:
    >>204
    2004年3月の PDF 版
    http://fldit-www.cs.uni-dortmund.de/~peter/PS07/HR.pdf

    これには載ってなかったです

    Google books で書籍版の中をキーワードで検索してみましたが、
    rank や *->* なんてキーワードではヒットせず
    forall や kind も Haskell の意味ではヒットしませんでした 

206 デフォルトの名無しさん [sage] 2011/09/10(土) 18:01:57.08 ID: Be:
    haskellスレで改めて質問してくださいな 

207 デフォルトの名無しさん [sage] 2011/09/10(土) 18:06:02.76 ID: Be:
    >>205
    forallとかはlisp または論理学の言葉だから
    carがhaskellではheadになってるように、別の名前になってる可能性が高い

208 デフォルトの名無しさん [sage] 2011/09/10(土) 18:24:11.32 ID: Be:
    >>206
    やっぱりこうなるんですよね

    わかりました 

■_

もいっちょ。 Lisp スレなのになぜか

【入門】Common Lisp その8【質問よろず】 

121 デフォルトの名無しさん [] 2011/09/07(水) 18:16:43.66 ID: Be:
    リスプの処理系より簡単な演算器もったスタックマシンのほうが簡単なきがしましたよ。
    アセンブラなんて1行1命令で翻訳してだけだから原始的なものならこっちも簡単でした。 

122 デフォルトの名無しさん [sage] 2011/09/07(水) 18:20:18.73 ID: Be:
    言語処理系を作るなら、まずForth処理系でも作ってみるのは、悪くないよね。 

123 デフォルトの名無しさん [sage] 2011/09/08(木) 06:28:12.39 ID: Be:
    Forthのかっこよさは異常 

124 デフォルトの名無しさん [sage] 2011/09/08(木) 08:59:14.97 ID: Be:
    Obi-Wan Kenobi もForthを使えって言ってたしな 

125 デフォルトの名無しさん [] 2011/09/08(木) 11:30:03.13 ID: Be:
    そのネタ聞くのはもう100万遍目だ 

126 デフォルトの名無しさん [sage] 2011/09/08(木) 18:58:27.75 ID: Be:
    >>125
    > そのネタ聞くのはもう100万遍目だ
    (/ (expt 1000.0 2) 365)
    毎日そのネタを平均一回聞けるとして2739.726年かかるよ 

127 デフォルトの名無しさん [sage] 2011/09/08(木) 21:20:54.60 ID: Be:
    今日という一日を100万回繰り返した超能力者である可能性も捨て切れない。 

128 デフォルトの名無しさん [sage] 2011/09/08(木) 21:25:29.10 ID: Be:
    >>127
    > 今日という一日を100万回繰り返した超能力者である可能性も捨て切れない。
    2739.726歳の超能力者か、なんかすごいね。 

129 デフォルトの名無しさん [sage] 2011/09/09(金) 14:27:37.34 ID: Be:
    激しくどうでもいいなwww 

130 デフォルトの名無しさん [sage] 2011/09/09(金) 14:41:31.45 ID: Be:
    まどマギだったら歳とらない 

131 デフォルトの名無しさん [] 2011/09/09(金) 14:47:43.34 ID: Be:
    \オッカリ~ン/でも多分としとらない。 

132 デフォルトの名無しさん [sage] 2011/09/09(金) 17:35:10.00 ID: Be:
    エンドレスビリオン 

133 デフォルトの名無しさん [sage] 2011/09/10(土) 12:57:05.63 ID: Be:
    あんまり面白かったのでループでまわしたのかもしれんぞ。
    (dotimes (n 999998) (print "Forthを使え")) 

■_

■_

人数が少なきゃ少ないで場所探しは面倒…

2011年09月09日

■_

とある記事を読んで深く考えてみたり 大研究シリーズ なぜ僕たちはプロ野球で通用しなかったのか 才能か、努力か、それとも・・・・・・  | スポーツ | 現代ビジネス [講談社] ほぼ全員知ってたなあ。 ここに出てこなかったあの選手やあの選手も気になる。

来週はまた国会図書館に行って調べものをする予定 (つか前回の調査結果を放置しっぱなしだ)。

Don't like my current job, want to leave, how to explain this in a job interview? - Programmers - Stack Exchange

InfoQ: Entity Frameworkでセカンドレベルキャッシュ

セカンドレベルキャッシュは、Entity Frameworkの枠に収まらない機能のひとつである。
「Entity FrameworkとAppFabricのセカンドレベルキャッシュ」というMSDNの記事において、
Julie Lerman氏は、Microsoft AppFabricのような優れたキャッシュサービスをEntity
Frameworkのセカンドレベルキャッシュで実装する方法について解説した。

なぜセカンドレベルキャッシュが必要なのか?

その昔、primary cache、secondary cache の後者を 「セカンドキャッシュ」と書いている雑誌記事が多くてげんなりしたことが。

■_ 比較

Imaginary/Real: Comparing Go with Lua


Thursday, 8 September 2011

Comparing Go with Lua

The Go language developed in the last few years by Rob Pike and Ken Thompson from Google
has gathered a lot of interest, particularly for its built-in concurrency support.
Anything released by these gentlemen (who did the first Unix and later Plan9, which
introduced UTF-8 to the world) is naturally going to cause a stir, since it's a little
like a new album by Led Zeppelin. And unlike the reappearance of most rock dinosaurs,
Go does not disappoint.

Most blogs naturally focus on the concurrency support, but here I'd like to point out 
some striking similarities with Lua. It may be convergent evolution, much as sharks 
and dolphins look similar to non-zoologists, or it may be a case of unconscious 
influence.

ほとんどのブログでは Go の並列処理のサポートに焦点を当てていますが、ここでは
いくつかの Lua との striking similarities について指摘しようと思います。
それは、イルカとサメの外見が (non-zoologists には)非常に似たものに見えるという
convergent evolution (平行進化?) であるかもしれないし、あるいは
unconscious influence (意図されていない影響?) であるかもしれません。

Both languages have anonymous functions, and these are proper closures, which is a 
fantastic thing to have. In Lua, closures reduce the need for classical classes 
enormously. This Go code works like the equivalent in Lua or JavaScript - the function 
will keep its own reference to name when it is later called.

どちらの言語にも無名関数があります。それはすばらしいものを備えていて、クロージャとして
適切なものです。Lua においては、クロージャは伝統的なクラスの必要性を大幅に軽減しています。
以下の Go でのプログラム片は Lua もしくは JavaScript の等価なものと同様に動作し、
あとで呼ばれたときに関数がその固有の名前に対する参照を持ち続けています。

  var name = "dolly"
  DoSomethingLater(func() {
      fmt.Println("hello",name)
  })

(略)
Posted by SteveD at 03:32

■_ The Right to be Wrong

なんかこう、四字熟語でびしっとはまる訳がありそうな気がするんだけど 意味が良く取れないw

The Right to be Wrong - Modern Perl Books, a Modern Perl Blog

The Right to be Wrong

By chromatic on September 7, 2011 10:40 AM | No Comments | No TrackBacks

Language design is hard work—not only because consistency of vision is a laborious process,
but because the only way to know what users will do with your language is to wait until
users use your language to do things. (略)


I have tremendous respect for the brave release managers of Perl 5, as a seemingly innocuous
change could cause countless hours of work for thousands, tens of thousands, or even hundreds
of thousands of developers. (One time I almost broke half of the CPAN myself.) The need to get
everything right exerts immeasurable pressure to not do anything wrong.

The difference between "doing it right" and "not doing it wrong" is a vast abyss.
「正しいことを行う」と「間違ったことを行わない」の間の違いは広大な abyss です。


■_ λ

Java 8でどうなるかというのが決まったとか

Syntax decision

Syntax decision
Brian Goetz brian.goetz at oracle.com
Thu Sep 8 13:07:03 PDT 2011


This just in: the EG has (mostly) made a decision on syntax.

After considering a number of alternatives, we decided to essentially 
adopt the C# syntax.  We may still deliberate further on the fine points 
(e.g., thin arrow vs fat arrow, special nilary form, etc), and have not 
yet come to a decision on method reference syntax.

多くの選択肢を考慮した後、わたしたちは本質的に C# の構文を適用することを
決定しました。それでもまだ熟考を重ねるかもしれません
(たとえば thin arrow を使うか fat arrow を使うか。あるいは special nialy form か
などなど)し、メソッド参照の構文をまだ決定していません。

The C# syntax is:
C# の構文は以下の通り

   lambda = ArgList Arrow Body
   ArgList = Identifier
             | "(" Identifier [ "," Identifier ]* ")"
             | "(" Type Identifier [ "," Type Identifier ]* ")"
   Body = Expression
             | "{" [ Statement ";" ]+ "}"

Here are some examples of lambda expressions using this syntax:
この構文を使ったλ式の例をいくつか挙げましょう:

   x => x + 1
   (x) => x + 1
   (int x) => x + 1
   (int x, int y) => x + y
   (x, y) => x + y
   (x, y) => { System.out.printf("%d + %d = %d%n", x, y, x+y); }
   () => { System.out.println("I am a Runnable"); }

The decision to choose this syntax was twofold:
この構文を選択した理由は twofold でした:

  - The syntax scores "pretty well" on most subjective measures (though 
has cases where it looks bad, just like all the others do).  In 
particular, it does well with "small" lambdas that are used as method 
arguments (a common case), and also does well with large 
(multi-statement) lambdas.

  - Despite extensive searching, there was no clear winner among the 
alternatives (each form had some good aspects and some really not very 
good aspects, and there was no form that was clearly better than the 
others).  So, we felt that it was better to choose something that has 
already been shown to work well in the two languages that are most like 
Java -- C# and Scala -- rather than to invent something new.

A compiler implementation should be available soon.
コンパイラーの実装はすぐにでもなされるでしょう。

reddit での反響から。

Java 8 lambda syntax decided (finally!). Similar to C# and Scala : programming

Java 8 lambda syntax decided (finally!). Similar to C# and Scala (mail.openjdk.java.net)


This is the boring part.(1)

(Some of) The big questions are:

    * How are those Lambdas represented in the type system and the object system?
      型システムやオブジェクトシステムの中でそれらのλはどのように表現される?

    * Do we get function types? Are they unified with generics?
      関数型を取得できる?
      それはジェネリクスで unify できる?

    * What is the solution about co/contravariance? Is (Object) => List a subtype of
      (String) => Collection (it should be)?
      covariance や contravariance はどのように解決されていますか?
      (Object) => List は (String) => Collection のサブタイプですか(it should be)?

    * Since normal generic types in Java are all invariant, how do we represent function
      types (which are contavariant in the argument type and covariant in return type)?

    * How do we deal with checked exceptions? Are 'throws' declarations part of the type?
      Are function types covariant in their thrown exception types? What is the type
      relation between functions that throw exceptions and those who don't?

      checked exceptions をどのように扱うのでしょうか?
      'throws' 宣言は型の一部なのでしょうか?

      例外を throw する関数としない関数との type relation は?

    * Are function objects just inner classes with a special method (like in Scala)? Or
      are they delegates to anonymous methods on objects that represent captured scopes
      (Like in C#)? Because of java.lang.dyn.MethodHandle we now have delegates in Java.

      関数オブジェクトは (Scala と同様に)単なる特殊メソッドを持った inner クラスに過ぎないので
      しょうか? あるいは (C# と同様に) caputured scopes を表現したオブジェクトに属する無名
      メソッドへ delegate しますか?

    * What is the class of a function object? Do we have to fight erasure again? (type
      erasure becomes much more problematic if you have function types, ask a Scala programmer)

      関数オブジェクトのクラスはなんですか?
      erasure とまた格闘しなければならないのですか?
     (type erasure は関数型がある場合にはよりいっそう problematic となります。
     Scala プログラマーに尋ねてみてください)

    * Can we treat instance methods on objects as function objects? If so, what do we
      do with varargs and generic methods?

      オブジェクトに属するインスタンスメソッドを関数オブジェクトとして扱えますか?
      もしできるなら可変引数やジェネリックメソッドに対する処理をどうしますか?

    * Can you mutate a closed over local variable? If so, are those mutations shared?
      What are the semantics for concurrent mutations? Can you aquire a monitor on the
      "scope object"?

      close over されたローカル変数を mutate できる?
      もし可能なら、その mutations は共有される?

    * 'return' statements in lambdas?
      λ中の 'return' 文は?

You ask yourself why Java doesn't have lambdas? This is what happens if you want to 
teach an old language new tricks. Language design is hard. Language evolution even 
moreso.

strangeness

(1) I actually liked the old syntax proposals better. #{Int x, Int y -> x + y} 
looks like a coherent unit (it's a function literal after all), is easier to parse and 
has the pound sign (#) as a distinct visual cue.


    Can you mutate a closed over local variable?

They can say no, to maintain consistency with anonymous classes, or they can do it 
exactly the way C# does it: every scope that has its local variables accessed by a 
lambda has these variables lifted into an explicit "stack frame"-like 
compiler-generated class (with lambdas themselves being methods of such classes). So 
all semantics work exactly as if you did that yourself.

    'return' statements in lambdas?

That was a really really stupid objection IMO. It's based on a flawed idea that dates 
back at least 30 years, to the Dijkstra's "GOTO considered harmful" paper, 
that code encapsulation and reuse can be achieved by means of structured programming. 
So that you can take a block of code guarded by a conditional statement and move it 
anywhere or duplicate it or remove the guard or add more guards, and it would not 
change its meaning. Turns out you can't do that with blocks because they critically 
depend on context (declared variables and such) for their core functionality, and when 
you want to do something like that, you should use functions instead.

So no, you can't expect wrapping arbitrary piece of code into an immediately called 
lambda to be an identity transformation, it's an unachievable harmful pipe dream.

    I actually liked the old syntax proposals better.

C# lambda syntax has one huge flaw: when you begin writing (x, y, code completion 
kicks in and fucks all your shit up, because it has yet to see =>. Maybe it can be 
fixed by more autocompletion, like, you are supposed to write => first, at which point 
IDE would add () and position the cursor between them. Still, I'd like lambdas to 
begin with a special symbol to make such perversions unnecessary.

Otherwise after a while lambdas begin to look like coherent units anyway.


In general you need some way to delimit them. But the compiler can figure out simple 
cases like ~a + ~b must mean (~a + ~b), because addition of functions is not defined 
in java.


If you can't come up with some simple rules, chances are it will be exceedingly hard 
to implement (does the parser need type information? then you're pretty much doomed) 
and likewise hard to understand. Consider what you gain vs. how much more complex it 
will be.

Perl 6 does this.

> (* + * + *)(1, 2, 3)
6
> -> $a, $b, $c { $a + $b + $c }(1, 2, 3)
6


Seriously. How many more years now until Java sees something to address asynchronous 
programming and concurrency?

Perl 6 の(* + * + *)(1, 2, 3) はなんなんだ…

■_

■_

What I learned from using Python for a project for 2 years : Python
1. To have a python-project that one is afraid to touch is not fun.
2. That will happen if there are not enough modularity and tests.
3. A class representing a working directory is great.
4. The main input and output can be hard to define early on, and will change. A class for each one is good.
5. Multi threading does not work great in Python. It is inconsistent across platforms.
6. Python2 is a lot more deployment-friendly than Python3.
7. Interfaces to ftp, e-mail and web are great.
8. Communicating over network with XML-RPC works great.
9. The relatively slow speed of Python itself really does not matter.

二人知らなかった。

Maximum PC | PC Pioneers: 10 Hackers Who Made History

The computer world has a rich history of hackers who steered the progress of computer 
science and gave shape to computers, the internet, and networking as we see it today - 
in some cases single-handedly. While the term “Hacker” today carries a negative 
connotation of an ill-intentioned computer genius, that’s only a small portion of 
what the word really means. Yes, there are the Black Hat hackers behind internet 
mayhem, thievery, and chaos, but there are also White Hat hackers who use their 
computer savvy for good. There’s also a different kind of hacker entirely: the 
tinkerer. They all played parts, big and small, in creating the computer world as it 
exists today. We’ve put together a list of 10 great hackers who all played a part in 
this history.

で、挙げられてた人たち(登場順)

  1. Konrad Zuse
  2. John “Captain Crunch” Draper
  3. Steve Wozniak
  4. Robert Tappan Morris
  5. Mark “Phiber Optik” Abene
  6. Kevin “Dark Dante” Poulsen
  7. Kevin Mitnick
  8. Tsutomu Shimomura
  9. Richard Stallman
  10. Linus Torvalds

■_

予習~~~~っ

2011年09月08日

■_

あともう少しでイカサマータイムも終わる…

歴群

■_

ずいぶんと面倒な条件な気もするけど、回答のひとつにもある通り とりあえず全部の : で split して不必要なところは再度 join しちゃうのが わかりやすくていいと思う。

regex - perl : how to split? - Stack Overflow

I have a string aa:bb::cc:yy:zz which needs to be split in such a way that I have an 
array with aa:bb::cc, yy, zz. i.e. I want to create two substrings from last with : as 
delimiter and remaining as a element of an array. What's the best way to achieve this?

ex:

aa:bb::cc:yy:zz --> ['aa:bb::cc','yy','zz']

dd:ff:gg:dd:ee:ff:fg --> ['dd:ff:gg:dd:ee','ff','gg']

I store IP address:port:protocol as a key in a file , and splitting wiht ":" 
to get IP,port,proto back and things were working fine when IP address is limited to 
Ipv4. Now I want to make it ported to Ipv6 in which case IP address contains 
":" so I can't get proper IP address by splitting with ":".

How about:

#!/usr/local/bin/perl 
use Data::Dump qw(dump);
use strict;
use warnings;

my $x = 'dd:ff:gg:dd:ee:ff:fg';
my @l = $x =~ /^(.*?):([^:]+):([^:]+)$/g;
dump @l;

output:

("dd:ff:gg:dd:ee", "ff", "fg")


Note that this will fail on 'two or less pairs' string, like 'dd:ff' or 'dd'

that's not a problem for me as I would expect miminum of 3 parameters. 


This code will correct handle situations when $string contains 2 or less pairs:

my $string = 'aa:bb::cc:yy:zz';
my @data = split /:/, $string;
if (@data > 2) {
    unshift @data, join ':', splice @data, 0, -2;
}

# $string = 'aa:bb::cc:yy:zz';
# @data contains ('aa:bb::cc', 'yy', 'zz')

# $string = 'aa:bb';
# @data contains ('aa', 'bb')


$ perl -wE '$_="aa:bb::cc:yy:zz"; say join "\n", split /:([^:]+):([^:]+)$/, $_;'
aa:bb::cc
yy
zz

Update: You did not mention this was meant to parse IP addresses. If it is, you would 
probably be better off trying to find a module on CPAN


I'd do an overly aggressive split followed by a join. I think the result is much more 
readable when you're not using a complicated regex for the split. So:

my $string = 'aa:bb::cc:yy:zz';
my @split_string = split(/:/, $string);
my @result = (join(':', @split_string[0..scalar(@split_string)-3]), $split_string[-2], $split_string[-1]);
print join(', ', @result), "\n";

Gives you:

aa:bb::cc, yy, zz

You'd have to do some array bounds checking on @split_string before you start indexing 
it like that.

$ perl -e'$_="aa:bb::cc:yy:zz"; @f=/(.*):([^:]+):(.+)/; print "$_\n" for @f'
aa:bb::cc
yy
zz

$ perl -e'$_="dd:ff:gg:dd:ee:ff:fg"; @f=/(.*):([^:]+):(.+)/; print "$_\n" for @f'
dd:ff:gg:dd:ee
ff
fg

■_ \n

-P は PCRE だから動作がそもそも微妙に違うってのはあるけど、 複数行読むようになるとは思えないんだけどなあ。 調べてみるか。

grep,sedコマンドについて | OKWave

昨日に引き続き、またまた質問です。
昨日回答してくださった方、ありがとうございました。

その後自分でも色々勉強しまして、ファイルの中身を処理するにはgrepコマンドとsedコマンドが
有効である事が分かりました。

今回やりたいことは以下のファイルの数字と時間の部分(//のついている2行)の削除です

//1
//00:00:03,600 --> 00:00:07,195
xxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxx

//2
//00:00:07,360 --> 00:00:09,635
xxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxx
    ・
    ・
(実際のファイルには"//"はついていません)

理想の出力
xxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxx

xxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxx

(xxxxxの部分には英語の台詞が入ります)


で、以下が自分が考えた方法です

1.sedコマンドのみで削除
$ sed "/[0-9]*\n[0-9][0-9].*/d" ファイル名

結果 ファイルの内容がすべて表示されるだけ (a)

2.grepコマンドで抽出しパイプ処理
まずgrepで削除部分を抽出
$ grep -P "^[0-9]*\n[0-9][0-9].*" ファイル名

結果 1
   00:00:03,600 --> 00:00:07,195

   2
   00:00:07,360 --> 00:00:09,635
        ・
        ・
   10

   11
        ・
        ・

となり、1~9までの数字と時間はちゃんと表示され
10以降は数字しか出ません。 (b)

また -P の部分を -E にすると、何も表示されません (c)
(perlの正規表現と拡張正規表現の違いはここでは無いように思えますが・・・)

2は最初でつまづいたのでどのコマンドに渡して行を削除するかはまだ分かりません (d)

削除の際、2行まとめて行うのは、一行ずつ行うと、台詞の部分に数字のみが入っていた場合
削除されるのを防ぐためです

以上長くなりましたが(a)~(d)の質問、疑問に回答していただけると嬉しいです。

よろしくお願いします。


難しく考えないで

grep -v "^[0-9]\+" |grep -v "^[0-9][0-9]:"

で、事足りるのでは?

お礼

回答ありがとうございます

はい、おっしゃる通りで、そうすれば必要な部分のみを表示させることが出来ますね

ただ、台詞が数字の時は表示されませんが・・・


あっ、この投稿をみて閃いたのですが
必要な部分(台詞で数字のみの部文も)をgrepで取ってリダイレクトすればいいのか!!

grep -v -P "^[0-9]+\n[0-9][0-9].+" 入力ファイル >> 出力ファイル

で、出来ました(^^)


でも、なんでsedでは出来ないんですかね?もう少しだと思うのですが

■_

■_ Why C++?

C++ and Beyond 2011: Herb Sutter - Why C++? | Channel 9
44 minutes, 52 seconds

We proudly present Herb Sutter's opening presentation at C++ and Beyond 2011. Thanks 
to Herb, Scott, and Andrei for allowing C9 to film this and air it

Here, Herb Sutter answers the question "Why C++?" in his usual thoughtful and 
well-articulated manner. He shares his perspectives on C++11 (yes, the name of the 
next version of C++ is officially official now!) and the C++ Renaissance as well as 
why C++ still matters and will continue to matter far into the future. This is a great 
introduction to the current state of the language, including a glimpse into the future 
of general purpose, performance-intensive, power-friendly, powerful native programming. 
As Herb says, C++ has legs and will continue to enable us to run fast into the future.

Tune in. Go native!

■_ What's Wrong with Ruby?

目を引くタイトルだけど、 一時間あるのかこれ。 What's Wrong with Ruby?

What’s Wrong with Ruby? : ruby

Ruby could be fixed and tidied up quite a bit there seems to be no real impetus to do so.

I am looking at mirah as an example of where ruby could go if the community wanted to.

It seems to me that at a minimum ruby should have the equivalent of perl's warn and 
strict (not the stupid ruby strict). They should also add optional typing, PHP did it 
why not ruby.


Optional typing is not a bad idea, but we don't really have a syntax for duck types.

Consider the method:

def test(obj)
  obj.to_s.gsub("#", "")
end

How do you express obj as a type? It's clearly a duck type of something that responds 
to "to_s" and returns something that itself responds to "gsub". We 
really don't have a nice syntax for anything like that yet.


There would be a tradeoff for sure. In your case if you were expecting any one of many 
types you would not declare it. OTOH it would be nice to have this option.

def test(person as Person)
   child_ids = person.children.map {|c| c.id}
end

it would be nice to know that person is always an instance of Person.

Another way to do it might be with pattern matching or guards like erlang has. I know 
there are a couple of pattern matching libs out there already so that certainly seems 
possible.

2011年09月07日

■_

「手ぬぐい」って作るのどれくらいかかるんですかね。お金とか。

■_

Perl で、新機能を使うときに何でわざわざ宣言しないといけないのよ 的な。

Why do new features need to be explicitly wanted? : perl

Why do new features need to be explicitly wanted? (self.perl)


Perl since 5.10 has always tried to pretend that it's still 5.8, except when you 
explicitly declare that you want the new features and behavior, by saying use 5.14.0.

Why?

imho the new features should be default, and if you have a legacy 5.8 program that 
breaks with modern Perl, it would be really easy to add use 5.8.8; to the top of those 
programs.


Because Perl 5 has never had a policy of requiring programs to specify the precise 
version of the Perl 5 semantics they want. In the absence of a declaration that a 
program wants Perl 5.8.x semantics, the best anyone can do is guess, and that's no way 
to produce robust code.


Are you seriously complaining about having to write a one-line use statement in 
software that is either a) new or b) actively-maintained so that the hojillions of 
lines of existing Perl code (including unmaintained-but-critical code) don't randomly 
break?

A friend of mine is just starting to learn Perl, and I had to tell him to use 5.14.0 
so he could use all the features of modern Perl, and then thought to myself, 
"this is a weird requirement for a language, isn't it? Other languages I've used 
don't selectively turn on new features when you specifically say you want them."


That's understandable, but you also need to think of how you'd feel if suddenly code 
you wrote that worked, didn't anymore and you had to figure out why, and how to fix it. 
Even someone new to the language should understand that code you wrote shouldn't 
auto-break periodically if you run it on different perl. It's not like this stuff is 
compiled and deployed as an executable and all you need to do is get it to work once 
on a development machine.

There's also the case of running a single version of code on both old and new versions 
of perl. If you make old-style code say use 5.8 and some machine tries to run the code 
on 5.7, it won't work. Also, if you write code that depends on the new semantics and 
leave the 5.14 out, you'll get unexpected behavior on older versions of perl. This way 
isn't perfect, but in the places it counts most, it's better.

I'm curious, what 5.14 specific features is he using that he needs the use 5.14.0?

■_

■_ その質問は間違っている

ItsJaredC
The wrong question: “I want to learn to code, what should I do?”

If you want to learn to code and build stuff and you’re starting by asking someone else
what you should do, you’re already thinking about it the wrong way. Immediately, right
now, with no preparation, in the blink of an eye, you can take a huge step toward your
goal by realizing that you don’t need an answer to your question. You can do it all by
yourself. Everything you need is waiting for you. Go get it. No one can stop you. Ready?

詳しくは元記事を

■_

2011年09月06日

■_

いいムダ知識(謎)のネタが出てこない

■_ 父親たちの(とは違う)FORTRAN

eric_t / Modern Fortran / wiki / Home — Bitbucket

This is not your father's Fortran

An introduction to modern Fortran programming

In online programming discussions, Fortran seems to have gotten an undeserved bad
reputation. Most of the time, comments of the language are based on the Fortran 77 
edition of the language, and fail to take into account that the language has seen four 
major revisions since then.

In my opinion, Fortran is a nice language for numerical programming. On this page, I 
will try to dispel myths about the language, and demonstrate features of the language 
which people seem to not know about. The goal is to convince people that Fortran is not
a horrible language to code in, and that you are not necessarily crazy for choosing
Fortran for a new project in 2011.

わたしの意見ですが、Fortran は数値計算プログラミングには良い言語です。
このページでは、Fortran にまつわる迷信 (myths) を解き明かす (dispel) ことを試みます。
また、あまり知られていないであろう機能を demonstrate します。目標とするところは
Fortran が コードを書くのに horrible な言語でないことを人々に知らせ、
2011の新しいプロジェクトで Fortran を選択するのに crazy である必要がないことを
明らかにすることです。

This introduction is divided into the following sections:

    * Old Fortran
    * Arrays, modules and functions
    * Parallel programming
    * Derived types and OOP
    * What's not so great about Fortran? 

All code snippets can be found in the repository.

This is a work in progress, so I would appreciate any suggestions or feedback!

Old Fortran
古いFortran

Here are some features from Fortran 77 that people seem to think still apply:
以下に挙げるのは、人々が今でもそうだとと考えているであろう Fortran 77 の機能の一部です

    * All upper case.
      すべてが大文字

    * Fixed column format.
      固定カラムフォーマット

    * Short variable names. In Fortran 77, variables can not be longer than 6 characters!
      短い変数名。Fotran 77では、変数名は6文字を超えることはできない!

    * Implicit variable declarations. Variables starting with a-h and o-z are real (float)
      and variables starting with i-n are integer. This easily leads to unpredictable
      behavior because of typos. It also leads to silly jokes like: "GOD is REAL,
      unless declared INTEGER"...

      暗黙の変数宣言。a から h もしくは o から z の間にある文字で始まる名前の変数は real (float)
      であり、i から n までの間にある文字で始まる名前の変数は integer である。
      この仕様は typo によって簡単に予想外の動作を引き起こしてしまう。この仕様はまた、
      ひとつのジョークを生み出した。

    * Extensive use of goto statements.
      goto 文の extensive use

    * Static memory allocation.
      静的なメモリー割付け

    * No recursion.
      再帰できない

Fortunately, newer language revisions have addressed all these issues!

Arrays, modules and functions
配列、モジュール、関数

The main feature of Fortran is the excellent support for multi-dimensional arrays. 
Here is a short program demonstrating some of these features. The program also 
demonstrates the module system and some of the features of functions. Some things to 
notice about this program:

Fortran の主たる機能は多次元配列に対する excellent support です。
以下に、そういった機能のいくつかを demonstrate する短いプログラムを紹介します。
このプログラムはまた、モジュールシステムや関数の機能の一部を demonstrate します。
このプログラムについて気がつくいくつかのこと

    * Modules are a nice way of organizing code, and no header files are necessary!
      モジュールはコードを organizing する nice way であり、ヘッダーファイルは不要!

    * A subroutine or function can take functions as arguments. We can specify how the
      function should look using interfaces. Trying to use functions not matching the
      interface will give a compile error.

      サブルーチンもしくは関数は、関数をその引数にとることができる。
      わたしたちはそのような関数がインターフェースをどのように使うかを指定できる。
      インターフェースにマッチしない関数を使うことはコンパイルエラーを導く。

    * The pure keyword means that the function is side effects free, i.e. it can not
      perform IO or modify its input arguments. This aids reasoning about the code.

      予約語 pure はその関数が副作用を引き起こさない (side effects free) であることを
      意味する。つまり、入出力を行えないし、入力引数の変更もできない。
      これはコードの reasoning を助ける

    * Function arguments can be named, and we can have optional arguments.

      関数の引数には名前をつけられ、省略可能な引数も持てる。

    * Arrays know their sizes, and trying to access values outside will give a compile
      error if the array is allocated statically and a runtime error if allocated
      dynamically. Of course, bounds checking can be expensive, so it has to be explicitly
      turned on using compiler flags (-fbounds-check for gfortran).

      配列は自身の大きさを知っていて、その範囲外へアクセスを試みると、配列が静的に
      割り付けられたものであればコンパイルエラーになるし、動的に割り当てられたものであれば
      実行時偉ーとなる。もちろん、境界検査は高価なものであるから、コンパイラーフラグ
      (gfortran であれば -fbounds-check) を使って explicitly に有効にしなければならない。

    * Array slicing is extremely convenient for performing complex array operations.

      配列のスライシングは複雑な配列操作を行うのに extremely convinient である

    * All common operations on arrays, plus several exotic ones, are supported, and
      linear algebra operations are built in.

      配列に対する一般的な操作はいくつかの exotic なものを含めてサポートされており、
      線形代数操作が組み込みで備わっている。

module array_operations

private
public :: foo

contains

    subroutine foo(func,a,b)
        ! Only functions matching the interface are valid
        interface
            pure function func(x) result(y)
                real, dimension(:), intent(in) :: x
                real, dimension(size(x)) :: y
            end function func
        end interface
        real, dimension(:),   intent(inout) :: a
        real, dimension(:,:), intent(inout) :: b
        ! An array knows its size
        real, dimension(size(a)) :: c

        c = func(a)

        ! Built-in linear algebra functions
        a = matmul(b,c)
        b = matmul(b,b)

    end subroutine foo

end module array_operations

(略)
This revision is from 2011-09-05 15:36

    * Copyright © 2011 Atlassian

■_

reddit での反応

This is not your father's Fortran : programming

Where's the arithmetic IF? Now I need to through out all my punch card decks.


Oh God, I recently came across this in a legacy code and had no idea what it did! I had to
ask an old professor who managed to find an old, tattered book which explained it...


This sounds too interesting not to be explained -- what's the arithmetic IF, for those 
of us who will hopefully never run into one?

Here's the example from the legacy code I was talking about:

3 IF((Y(I)*X(J)-X(I)*Y(J))/(X(J)-X(I))) 2,4,5 
4 INOUT=0 
   RETURN 
5 INOUT=-INOUT 
2 CONTINUE 

If the expression inside the parenthesis is negative, the execution jumps to label 2. 
If it is zero, it jumps to 4, and if it is positive it jumps to 5. Quite confusing!

Wow. That's awesome. Obfuscated quaternary goto operator FTW.

Most dialects of BASIC (say what you will about it) had a similar construct in ON 
<positive int> GOTO <line/label>, ... . Some equivalent code:

30 ON 2+SGN(FNY(I)*FNX(J)-FNX(I)*FNY(J))/(FNX(J)-FNX(I))) GOTO 120,40,50
40 LET IO=0:RETURN
50 LET IO=-IO
120 NEXT

Use of 2+SGN() brings the result of the calculation to 1 for negative, 2 for zero and 
3 for positive, since the GOTOs were chosen by positive integer.

A lot of the new programmers come from ecosystems created by a language. It would be 
great if you could describe a little bit the Fortran ecosystem.

My questions would be:

   1. How can one program in Fortran one the 3 big platforms (Win, Linux, OS X)
   2. Is there a standard library? What does it includes?
   3. Is there a module repository like CPAN or PyPI?
   4. How does one integrate FORTRAN with other languages (bindings)
   5. Any GUI creation libraries available?
   6. A list of recommended resources (books, sites, etc) with updated info.
These are all great questions. I will think about how to integrate them into the site. 
For now, here are some quick observations:

   1. GNU's gfortran works on all platforms and is a decent compiler. If you're not
      developing commercial stuff you can use the free edition of Intel's compiler, which
      in general is faster. There is also a .NET compiler for windows, Silverfrost FTN95.

   2. There is no standard library, but things that are often implemented as libraries in
      other languages are part of the core language, e.g. complex numbers and linear
      algebra operations. There is one library, FLIBS, which tries to provide generic data
      structures, database hooks and things like that, but I haven't tried it.

   3. The closest is http://www.netlib.org/, which contains a lot of great code.

   4. The newest language revision, Fortran 2008, significantly improves interaction with
      C, I should really have an example of this on the site. For python, there is F2PY
      which is part of numpy. I use that all the time.

   5. There are bindings to GTK for instance, gtk-fortran, and some commercial tools, but
      I vastly prefer writing my GUIs using Python and then interfacing to Fortran.
      Usually, my Fortran programs reads some input, then spends a few hours computing
      while spitting out some output files. This makes it easy to use other tools for
      pre- and post-processing.

   6. The book Fortran 95/2003 for Scientists and Engineers is useful since it contains
      a lot of code examples and is easy to read, while Fortran 95/2003 Explained is a
      good reference.

■_ おかしなおかしなおかしな x86

x86oddities - corkami - x86 oddities - reverse engineering experiments and documentations - Google Project Hosting


This page enumerates various oddities of the x86/x64.

They are all implemented and tested in Standard Test.

registers

MMX and FPU registers are mapped on each others, but in opposite directions: 0, 1,2,3... 
mapped to 7,6,5...

Thus, a single FPU operation on ST0 will modify FST, ST0, but also MM7 (and CR0, under XP).

d9eb: fldpi

=> fst = 03800h
   st0 = 04000c90fdaa22168c235h
   mm7 =     0c90fdaa22168c235h
   cr0 = 080010031h (under XP)

(略)

aad

aad is officially defined to use only 10/0Ah as a default operand, but can just use 
any other operand.

aad は公式には 10/0Ah のみがデフォルトオペランドとして使われるように定義されている。
しかし、そのほかのオペランドも使用可能である。

it makes it the first Add and Multiply opcode, as al = ah * operand + al.

ax = 325h

d507: aad 7

=> ax = 3 * 7 + 25h = 3ah

aam

Similar logic for aam:

    * it's officially defined with 10/0ah, but it just works with any byte.
    * it's a division, and quotient and remainder go to ah and al respectively. 

al = 3ah

d403: aam 3

=> ah = 3ah / 3 = 13h
   al = 3ah % 3 = 1

bswap

bswap is officially undefined on WORDS. In reality, it just clears the register, unexpectedly.
bswap は公式には WORDS に対しては定義されていない。
実際には予想に反してレジスターをクリアーする。

66 0fc8: bswap ax 

=> ax = 0

(略)

push

Even though selectors are WORDS-sized registers, like standard registers such as AX, 
they're not pushed on the stack the same way.

1e: push ds

=> esp = esp - 4
   word ptr [esp] = ds

66 50: push ax

=> esp = esp - 2
   word ptr [esp] = ax

no other word is changed.


©2011 Google - Terms - Privacy - Project Hosting Help

reddit での反響。 X86 oddities : programming

■_

2011年09月05日

■_

iPod nano
曲数がとてもたくさんあるときに一覧の最初の方から最後の方へくるくるするのって とても疲れるのですが、なんかこうぱっぱっとスクロールさせるワザってないんでしょうか

■_ Associative array → Hash

なぜか第三版からはこのくだりがなくなっているという。


ハッシュ: ハッシュ(hash)は、順序付けされていないスカラーの集合で、各スカラーに関連付けられた
文字列によってアクセスされる。そのためハッシュは「連想配列」(associative array)と呼ばれるこ
ともある。しかし、これは怠惰なタイピストにとってタイプするのが面倒だし、頻繁に使われるので、
私たちはもっと短くて、ぴりっとした(snappy)呼び名をつけることにしたのだ。「ハッシュ」という名
前を選んだ別の理由は、中身が順序付けされていないことを強調するためである(ハッシュは、内部的に
はハッシュ表を使って実装されている。ハッシュに値をどんなにたくさん格納しても、動作が速いのは、
ハッシュ表のおかげである)。

                                                         プログラミングPerl 改訂版 8ページより
  

データ型にHashはという名前はどうよという意見はまあそうなんでしょうけど、 HashTable というのはどうなんすかねえ。

■_ sort

locale が絡むと sort も大変というお話。

What's Wrong with sort and How to Fix It - Perl.com

What's Wrong with sort and How to Fix It

By Tom Christiansen on August 31, 2011 6:00 AM | No TrackBacks

By now, you may have read Considerations on Using Unicode Properly in Modern Perl 
Applications. Still think doing things correctly is easy? Tom Christiansen 
demonstrates that even sorting can be trickier than you think.

NOTE: The following is an excerpt from the draft manuscript of Programming Perl, 4th edition

Calling sort without a comparison function is quite often the wrong thing to do, even 
on plain text. That's because if you use a bare sort, you can get really strange 
results. It's not just Perl either: almost all programming languages work this way, 
even the shell command. You might be surprised to find that with this sort of nonsense 
sort, ‹B› comes before ‹a› not after it, ‹é› comes before ‹d›, and ‹ff› comes after 
‹zz›. There's no end to such silliness, either; see the default sort tables at the end 
of this article to see what I mean.

There are situations when a bare sort is appropriate, but fewer than you think. One 
scenario is when every string you're sorting contains nothing but the 26 lowercase (or 
uppercase, but not both) Latin letters from <a-z>, without any whitespace or 
punctuation.

bare sort が適切であるシチュエーションはありますが、それはあなたが考えるよりも
少ないものです。(bare sortが適切であるような)ひとつのシナリオは、ソートの対象と
なるすべての文字列が26個の lowercase Latin letters (もしくは uppercase のもの。
ただし、両方が一緒にあってはいけない)のみからなり、空白や punctuation が
一切ない場合です。


(略)

So what's wrong with sort anyway?
sort の何が問題なのでしょうか?

I know, I know. I can hear everyone saying, "But it's called sort, so how could 
that ever be wrong?" Sure it's called sort, but you still have to know how to use 
it to get useful results out. Probably the most surprising thing about sort is that it 
does not by default do an alphabetic, an alphanumeric, or a numeric sort. What it 
actually does is something else altogether, and that something else is of surprisingly 
limited usefulness.

Imagine you have an array of records. It does you virtually no good to write:

レコードの配列があると仮定しましょう。
次のように書くことは良いものではありません:

@sorted_recs = sort @recs;

Because Perl's cmp operator does only a bit comparison not an alphabetic one, it does 
nearly as little good to write your record sort this way:

なぜなら、Perl の cmp 演算子は alphabetic な比較ではなく bit ごとの比較しか行わない
ので、レコードをソートするには次のようにするのが多少望ましいものです:
#わかんねー

@srecs = sort {
    $b->{AGE}      <=>  $b->{AGE}
                   ||
    $a->{SURNAME}  cmp  $b->{SURNAME}
} @recs;

The problem is that that cmp for the record's SURNAME field is not an alphabetic 
comparison. It's merely a code point comparison. That means it works like C's strcmp 
function or Java's String.compareTo method. Although commonly referred to as a 
"lexicographic" comparison, this is a gross misnomer: it's about as far away 
from the way real lexicographers sort dictionary entries as you can get without 
flipping a coin.

問題なのは、レコードの SURNAME フィールドに対する cmp が alphabetic な比較でない
ということです。この場合はただ単に code point での比較をします。それは C の
strcmp 関数や Java の String.compareTo メソッドのように比較を行うということを
意味します。それは一般には "辞書的な"比較をすると受け止められているものですが
それは gross misnomer なのです。
それは実際の辞書的順序の比較によるソートではないのです。

Fortunately, you don't have to come up with your own algorithm for dictionary sorting, 
because Perl provides a standard class to do this for you: Unicode::Collate. Don't let 
the name throw you, because while it was first invented for Unicode, it works great on 
regular ASCII text, too, and does a better job at making lexicographers happy than a 
plain old sort ever manages.

幸運にも、辞書式順序でのソートのためのアルゴリズムをあなた自身が用意する必要はありません。
Perl がそれをおこなうための標準クラス Unicode::Collate を用意してくれているのです。

If you have code that purports to sort text that looks like this:

@sorted_lines = sort @lines;

Then all you have to get a dictionary sort is write instead:
これを辞書式順序でのソートを行うようにするには次のように書きます:

use Unicode::Collate;
@sorted_lines = Unicode::Collate::->new->sort(@lines);

For structured records, like those with ages and surnames in them, you have to be a 
bit fancier. One way to fix it would be to use the class's own cmp operator instead of 
the built‐in one.

構造を持ったレコードに対しては、そのレコードにある ages や surnames に対して
この手順を適用しますが、あなたはちょっとばかし fancier にある必要があります。
それを修正するひとつの手順がそのクラス固有の cmp 演算子を、組み込みのものに代えて
使うというものです

use Unicode::Collate;
my $collator = Unicode::Collate::->new();
@srecs = sort {
    $b->{AGE}  <=>  $b->{AGE}
          ||
    $collator->cmp( $a->{SURNAME}, $b->{SURNAME} )
} @recs;

However, that makes a fairly expensive method call for every possible comparison. 
Because Perl's adaptive merge sort algorithm usually runs in O(n · log n) time given n 
items, and because each comparison requires two different computed keys, that can be a 
lot of duplicate effort. Our sorting class therefore provide a convenient getSortKey 
method that calculates a special binary key which you can cache and later pass to the 
normal cmp operator on your own. This trick lets you use cmp yet get a truly alphabetic
sort out of it for a change.

しかし上記のやり方はメソッド呼び出しを比較の度に行っていてとても高価です。
Perl の使っているマージソートアルゴリズムは一般的に n 個のアイテムに対して
O(n ・ log n) 回の比較を行うからです。また、比較のたびに二つの異なる
何度も同じ事を行う可能性のあるような computed keys を必要とします。
このため、わたしたちの sorting クラスでは便利な getSortKey メソッドを提供
しています。これは特別な binary key を計算します。
結果はキャッシュしてあとで通常の cmp 演算しに渡されます。
このしかけにより変更を必要とせずに本物の alphabetic sort をあなたは手に入れます。

Here is a simple but sufficient example of how to do that:

use Unicode::Collate;
my $collator = Unicode::Collate::->new();

# first calculate the magic sort key for each text field, and cache it
for my $rec (@recs) {
    $rec->{SURNAME_key} = $collator->getSortKey( $rec->{SURNAME} );
} 

# now sort the records as before, but for the surname field,
# use the cached sort key instead
@srecs = sort {
    $b->{AGE}          <=>  $b->{AGE}
                      ||
    $a->{SURNAME_key}  cmp  $b->{SURNAME_key}
} @recs;

That's what I meant about very carefully preparing a mediated sort key that contains 
the precomputed binary key.

English Card Catalogue Sorts
英語のカードカタログのソート

The simple code just demonstrated assumes you want to sort names the same way you do 
regular text. That isn't a good assumption, however. Many countries, languages, 
institutions, and sometimes even librarians have their own notions about how a card 
catalogue or a phonebook ought to be sorted.

For example, in the English language, surnames with Scottish patronymics starting with 
<Mc> or <Mac>, like MacKinley and McKinley, not only count as completely identical 
synonyms for sorting purposes, they go before any other surname that begins with <M>, 
and so precede surnames like Mables or Machado.

Yes, really.

That means that the following names are sorted correctly -- for English:

Lewis, C.S.
McKinley, Bill
MacKinley, Ron
Mables, Martha
Machado, José
Macon, Bacon

Yes, it's true. Check out your local large English‐language bookseller or library -- 
presuming you can find one. If you do, best make sure to blow the dust off first.

Sorting Spanish Names
スペイン語の名前をソートする


(以下略)

■_ Become a Good Programmer in Six Really Hard Steps

まあ目新しいものはないんですが。

Become a Good Programmer in Six Really Hard Steps - GameDev.net

Become a Good Programmer in Six Really Hard Steps

05 September 2011

Posted by ApochPiQ 

One of the more popular topics here on the GDNet forums goes something like this:

"Hi, I just [bought a computer | wrote a simple game | discovered a game engine] 
and I want to know where to go from here. I'd like to [accomplish some particular goal] 
eventually. What do I need to learn to get there?"

First of all, understand that Peter Norvig nailed this on the head a long time ago: it 
takes ten years to learn to be a programmer. There's a glut of "learn X in some 
small number of days" type books out there; there are hordes of blog posts about 
"how to improve your programming-fu in a few easy ways"; and in general a 
lot of people come around looking for advice on how to become a whiz with minimal 
effort.

I'm going to change up the pitch a bit. Instead of Five Easy Ways to Make Your Code 
Amazing in 21 Days, I'm going to tell it like it is. Welcome to How to become a good 
programmer in six Really Hard steps.

そして挙げられた六項目とは (例によって詳細は省略)


Step One: Suck It Up. Get in it for the long haul, or take up bird watching.

Step Two: Write Lots of Code (コードをたくさん書こう)

Step Three: Read Even More Code (さらに多くのコードを読もう)

Step Four: Learn Many Languages. Master a Couple. (多くの言語を学び、複数マスターしよう)

Step Five: Create a Language. (言語を作ろう)

Step Six: Learn Something That Nobody Else Has Learned Yet (他人がまだ学んでいない何かを学ぼう)

最後にこういうのがあったりするのですが :)

Congratulations! You are now a good programmer!

Oh wait... actually, you just died of old age. Sorry. Better luck next life!

In all seriousness, though, don't expect to ever finish. The instant you stop making 
forward progress in your journey, you start to die, and become irrelevant. Some of the 
saddest failures I've seen in the world of programming stem from people who got a 
certain way down the path and decided they were done learning; to a man, they are now 
completely unimportant in the software world, and will likely never move beyond their 
current situation - unless, of course, they decide to start learning again.

Now, go forth, and code! Maybe someday when you're a great programmer, you can tell me 
how you did it.

I'd love to learn.

Copyright © 1999-2011 GameDev.Net LLC

GameDev.net™, the GameDev.net logo, and GDNet™ are trademarks of GameDev.net, LLC


■_

■_ 本日の丸投げ

しかし自分の所属ばれそうな情報出していいんかね

javaのプログラミング(英語)宿題 | OKWave
Java プログラミングの宿題です。
今週もかなり時間がかかってますが、まずこの問題がどんなプログラムを作らせたいのか
いまいちわかりません。

すごく情けないのですがわかる方のお力を借りたいです。

宿題なので全部でなくていいのですが
道筋だけでも教えていただけると助かります。

どうぞよろしくお願いします。

以下、リンク
http://www2.hawaii.edu/~esb/2011fall.ics211/hw2.html
十進Basicの円の課題を教えてください!!! | OKWave
十進Basicの円の課題を教えてください!!!

私は工業高校に通っているのですが病気で半年ほど学校を休んでいまして、夏休みの課題として
「十進Basicを使って円の体積と円の表面積を求めるプログラミングを書け」という課題が出ていて
分割して計算するらしいのですが全くわかりません。。
半径といくつに分割するかは
INPUT NUM
INPUT RADIUSとするらしいです。

一応形だけでもやりたいので、どうか解答よろしくお願いします!!!!!

「円」に体積とか表面積ってあったっけ?

分割して計算…どゆこと?

2011年09月04日

■_

午前中は寝てて、午後はずっとついったやってた気がするw

んでまあ、電子書籍を読むのにノートPC(やデスクトップPC)というのも今ひとつだなあ (可搬性やらで)と思い、じゃあ何がいいかと考えたりするのですが 実際なにがいいんですかねえ。 Kindle やら iPad やらそのほかいろいろありますが。 pdf と epub が読めればとりあえずはいいのかな? あ、充電なしで動かせる時間が長いに越したことはないですね。 あとiPad は契約形態とか良くわかんないんですよね(調べてないだけともいう)。 Wi-Fi接続のにしとけば月々の通信料はなし?

2011-09-01 - らいおんの隠れ家 GNU系ツールもばっちり使える、Windows の UNIX 互換環境を試してみる。 « みむらの手記手帳 Stories from my experiences learning Scrum Prologの難しさ(1) http://nojiriko.asia/prolog/prolog_no_muzukashisa_1.html

■_ How to become a great software developer

例によって reddit から。

How to become a great software developer « codeshite

How to become a great software developer

Posted on August 15, 2011 by codeshite	

   1. Start with design patterns – Always start with a design pattern, then try to make your
      problem fit it.  Ideally start with the pattern you have most recently read about as
      this is most likely to be the best one.

      デザインパターンから始めよう いつでもデザインパターンから始めて、それから
      あなたの問題をそれにfitさせましょう。

   2. Do programming Katas – Repeatedly solving the same simple problem is the best way to
      improve your coding skills.  The faster you can do it, and the more you sense a
      feeling of ‘flow’ when solving this problem, the better a developer you are becoming.
      Ideally, video yourself performing the kata, so others can learn from your achievements.

      programming Katas をしましょう

   3. Mock everything – When testing, make sure you mock everything. The less you're really
      testing the more likely your test will pass. Green lights in IDEs are the most
      important measure of the quality of your code.

   4. Follow practices strictly – Follow practices as laid out in books, or explained to you
      at conferences, and follow them to the letter.  It's a lot easier to follow rules than
      to think, and thinking poses certain risks (see point 12).

      practices に厳密に従いましょう

   5. Read only books written in the last 10 years – As we are all aware, nobody knew how to
      program until the dot com boom, and books written before this historic moment are of
      no value.  Ideally make sure the books you read are signed off or endorsed by a big
      name in the Agile community, as this will ensure quality.

      十年以内に書かれた本だけを読みましょう

   6. Be aware of old ideas – New ideas are always better, fact.

      古臭いアイデアには注意しましょう
      新しいアイデアは常に優れているのです。

   7. Pair program, properly – Pair often, and when you do, remember that your job is to
      make the other person code what you know to be correct.  Pair programming is the only
      way to resolve communication issues and conflicts. Focus on the process of pair
      programming, not on the people involved.

      ペアプログラミングをしましょう。適切に。

   8. Recognise bullshit when you hear it – Be suspicious when you hear words and phrases
      like ‘problem solving’, ‘planning’, ‘programming’, ‘coding’, ‘testing’,
      ‘algorithm’, ‘design’, ‘prototyping’ etc. Such buzzwords are made up by people
      who don’t really understand software development, or how it relates to martial arts
      and eastern culture in general.

   9. Learn new terms – The field of computer programming and software development is
      lacking in jargon.  The best way to improve your knowledge is by learning new
      terminology for the same concepts. Real knowledge is about memorising terminology,
      not understanding principles.

      新しい用語を学びましょう

  10. Java is dead – Do not learn Java, and if you're a Java programmer, you better start
      learning Ruby/Python/Scala/Clojure fast.  Java has been dead for many years and
      everyone knows this.  Ideally learn a language that allows you to write in 2 lines
      what would cost you 4 lines of Java.  Productivity and readability are about number
      of lines of code, fact.

      Javaは死んだ。
      Java を学んではいけないし、もしあなたが今Javaプログラマーであるのなら、
      すぐに Ruby や Python、Scala、Clojure といったものを学び始めなさい。
      Java はもう何年も前に死んでいるし、誰もがそれを知っています。
      Java で書くと4行になるようなものを2行で書けるような言語を学ぶのが理想的です。
      実際、生産性だとか可読性といったものはコードの行数に関するものなのです。

  11. Be a craftsman and a professional, not an engineer – You're not building a bridge,
      you're carving a beautiful statue.  Remember you're also just like a lawyer, or a
      doctor, you're a professional.  Spend your time contemplating who you are, not what
      you're doing.

      職人であれ、プロフェッショナルであれ。エンジニアではなく。
      あなたは橋をかけるのではなく、美しい彫像を彫っているのです。

  12. Never fall into the trap of thinking for yourself – Instead, read a book, post a
      question somewhere, follow a practice, phone uncle Bob, anything as long as it
      means you don’t have to think for yourself.  Thinking for yourself poses the risk
      that you will come up with the wrong answer. Books, forums, practices and
      consultants however, are always right.

  13. Read blogs, like this one – When you have a disagreement with somebody who doesn't
      follow the above advice like you do, send it to them.  Blogs are the authority on
      matters of programming, fact.

■_ 誤用

Togetter - 「カリー化と部分適用の違いと誤用」 から始まったやりとりが非常に活発でしたがその中で

Twitter / @glad2121: 用語の話のついでに。ずっと前から気になってるんだけど ...

用語の話のついでに。ずっと前から気になってるんだけど、ハッシュテーブルのことをハッシュ
と呼ぶのはどうなんだろう?ハッシュって本来ハッシュ値のことだと思うんだけど。

Twitter / @everpeace: @glad2121 その誤用はperlで最初に見た気 ...

@glad2121 その誤用はperlで最初に見た気がしますw

Twitter / @hiratara: @everpeace @glad2121 というか、 ...

@everpeace @glad2121 というか、その用語使うのPerlの人だけじゃないんですか?(笑
用語として定着しちゃってるので、Haskellでクライスリ圏のことをモナドって呼んでるのと似てるかもしれませんね。

Twitter / @glad2121: @hiratara @everpeace えっ?Ha ...


@hiratara @everpeace えっ?Haskell のモナドってモナドじゃないのか。
おいら Haskell のモナド以外にモナドを知らないけど…。(^^;)
ちなみに、Ruby のハッシュテーブルも Hash クラスですね。

Twitter / @hiratara: @glad2121 @everpeace なんとっ、 ...

@glad2121 @everpeace なんとっ、Ruby もだったんですか。それは知りませんでした。

Hash table を Hash と呼んだというか、 Assocoative array を Hash と呼ぶようにしちゃったというか。

あれ。Programming Perl の第二版にあった改称の理由についての記述を 打ち込んだのが見つからない。どこいった。

■_ Rで

VB やら PHP なんかでは良く見ましたがRは初めてな気が。

【統計ソフトR、繰り返し文の使い方】 - Yahoo!知恵袋

複数の変数(pro1~pro3)に値を代入するときです。例えば、

pro1=0
pro2=0
pro3=0

を実現したいとして、

> for(i in 1:3){
+ paste("pro",i) <- 0
+ }
以下にエラー paste("pro", i) <- 0 :
付値対象は非言語オブジェクトに展開されます

を行っても、このようなエラーがでて、全くうまくいきません。
となってしまい、どうしても上手くいきません。何か良い方法があればお教えください。


paste関数は、文字列を生成するだけで、そのままではRの命令になりません。
eval( parse( text=文字列 ) ) とすることによって、文字列をRの命令として実行することができます。

今回の場合、

pro1=0
pro2=0
pro3=0

for(i in 1:3){
  eval(parse(text=paste("pro",i,"<-1",sep="")))
}

でいいでしょうか。
実行後は、変数には1が入っています。
pasteは文字列を接続する際に余計な区切り文字を入れるので、
sepオプションで区切り文字を何もなしに変更しています。


Copyright (C) 2011 Yahoo Japan Corporation. All Rights Reserved.

eval を使えば…っていいのかなあそれで。 配列(リスト?)ではいけないんだろうか。

■_

Java 7: The Top 8 Features に、Java 7での変更点についての解説があるんですが

Java 7: The Top 8 Features

#1 Strings in switch

In programming, we often encounter situations where we need to do different things 
based on different values of a variable. For Boolean variables, an if-then-else 
statement is the perfect way of branching code. For primitive variable types we use 
the switch statement. However, for String variables, we tend to resort to using 
multiple if-then-else branches as follows.

© 1995–2011 S&S Media Group. Reproduction only with permission of the publisher

ときて、コード片が画像データで貼り付けられているという。

Java 7: The Top 8 Features : programming

That stupid box on the left is obnoxious.


Also JPEG text for code examples.


in a horrible, compressed type face, no less.


Also, three pages? For a list of 8 basic items? I had to check if it was on cracked.


Oh, there is more than one page. Thanks for pointing it out.


Code snippets as images is also excruciatingly moronic.


Not only images, but jpeg images.


To say nothing of the pointless use of Javascript to keep it in place. If only there 
was some simple, basic CSS that could do the same thing a million times better.....

いろいろいわれてます。

■_

2011年09月03日

■_

打ちのめされました

■_ 比較

というか喩えの比較というか

An Idiosyncratic Analogical Overview of Some Programming Languages from an Evolutionary Biologist's Perspective | Jeet Sukumaran

An Idiosyncratic Analogical Overview of Some Programming Languages from an 
Evolutionary Biologist's Perspective

Submitted by Jeet Sukumaran on Thu, 09/01/2011 - 11:06
 
This article was originally posted at geodendron.

R

R is like a microwave oven. It is capable of handling a wide range of pre-packaged 
tasks, but can be frustrating or inappropriate when trying to do even simple things 
that are outside of its (admittedly vast) library of functions.
R は電子レンジのようなものです。あらかじめパッケージされたタスクの広い範囲を扱う
ことが可能ですが、R の持つ関数ライブラリからはずれたものについてはたとえ簡単なもので
あっても不満を覚えたり不適切であったりするでしょう。
略

Python

If R is like a microwave oven, then Python is a full-fledged modern kitchen. You can 
produce almost anything you want, from toast to multi-course banquets, but you 
probably need to do some extra work relative to R.

R が電子レンジであるのなら、Python は full-fledged modern kitchen です。
#羽の生えそろった近代的なキッチン??
トーストから multi-course banquets まで、あなたの望むものはほぼなんでも作れます。
しかし、R と比べると some extra work が必要となるでしょう。
略

C++

If R is like a microwave, and Python is like modern kitchen, then C++ is like an 
antique Victorian kitchen in the countryside, far, far, far away from any supermarket. 

R が電子レンジであり、Python が modern なキッチンであるのなら、
C++ はスーパーマーケットから遠く離れたところにある countryside の
antique なヴィクトリア調のキッチンです。

略
Java

Java, like Python, is a modern kitchen, allowing for a full range of operations with all the
sanity-preserving conveniences and facilities (e.g., garbage-collection/memory-management).
But it is a large, industrial kitchen, with an executive chef, sous chefs, and a full team
of chefs de partie running things.

Java は Python のような modern なキッチンで、full range な operations が
(all the sanity-preserving conveniences と facilities でもって) 可能です。
しかしこれは大きな、executive chef や sous chefs、さらには
full team of chefs de partie running things を備えた industrial なキッチンです。
略

© 2008-2010 Jeet Sukumaran unless otherwise noted. All rights reserved.

コメント欄は省略

■_ 8 ways to report errors in Haskell revisited

元の8通りはちょっと前の記事でしたが

8 ways to report errors in Haskell revisited : Inside 233

8 ways to report errors in Haskell revisited

by Edward Z. Yang

In 2007, Eric Kidd wrote a quite popular article named 8 ways to report errors in 
Haskell. However, it has been four years since the original publication of the article. 
Does this affect the veracity of the original article? Some names have changed, and 
some of the original advice given may have been a bit... dodgy. We’ll take a look at 
each of the recommendations from the original article, and also propose a new way of 
conceptualizing all of Haskell’s error reporting mechanisms.

I recommend reading this article side-to-side with the old article.

詳細は元記事をあたっていただくとして、8通りとは以下のもの。

1. Use error
2. Use Maybe a
3. Use Either String a
4. Use Monad and fail to generalize 1-3
5. Use MonadError and a custom error type
6. Use throw in the IO monad
7. Use ioError and catch
8. Go nuts with monad transformers
This is, for all intents and purposes, the same as 5; just in one case you roll your 
own, and in this case you compose it with transformers. The same caveats apply. Eric 
does give good advice here shooing you away from using this with IO.

Here are some new mechanisms which have sprung up since the original article was 
published.

9. Checked exceptions

Pepe Iborra wrote a nifty checked exceptions library which allows you to explicitly 
say what Control.Exception style exceptions a piece of code may throw. I've never 
used it before, but it’s gratifying to know that Haskell’s type system can be 
(ab)used in this way. Check it out if you don’t like the fact that it’s hard to tell 
if you caught all the exceptions you care about.

10. Failure

The Failure typeclass is a really simple library that attempts to solve the interoperability
problem by making it easy to wrap and unwrap third-party errors. I've used it a little, but
not enough to have any authoritative opinion on the matter. It's also worth taking a look at
the Haskellwiki page.

Failure typeclass はサードパーティのエラーを wrap したり逆に unwrap しやすくすることによって
interoperability problem に対処しようとする非常に単純なライブラリです。

Conclusion

There are two domains of error handling that you need to consider: pure errors and IO 
errors. For IO errors, there is a very clear winner: the mechanisms specified in 
Control.Exception. Use it if the error is obviously due to an imperfection in the 
outside universe. For pure errors, a bit more taste is necessary. Maybe should be used 
if there is one and only one failure case (and maybe it isn’t even that big of a deal), 
error may be used if it encodes an impossible condition, string errors may be OK in 
small applications that don’t need to react to errors, custom error types in those 
that do. For interoperability problems, you can easily accomodate them with your 
custom error type, or you can try using some of the frameworks that other people are 
building: maybe one will some day gain critical mass.

考慮する必要のあるエラー処理には二つの領域があります。
ひとつは pure erros であり、もうひとつは IO えらーです。
IO エラーに対しては、非常に明確な winner が存在します。
それは Control.Exception で specify されている機構です。


It should be clear that there is a great deal of choice for Haskell error reporting. 
However, I don't think this choice is unjustified: each tool has situations which are 
appropriate for its use, and one joy of working in a high level language is that error 
conversion is, no really, not that hard.

Published: August 29, 2011

  

© Edward Z. Yang. All Rights Reserved. Powered by WordPress and Manifest

■_ ヒストリー

むかーし、一生懸命 C shell のヒストリーコマンド覚えたなあ。 完璧に忘れちゃったけど。

Unixコマンド コマンドを再実行 | OKWave


Windowsのコマンドプロンプトで、前回行ったコマンドを再実行する際、F3キーを押しますが、
それと同様な処理を行なうUnixコマンドを教えて下さい。

投稿日時 - 2011-03-30 11:57:55
質問者が選んだベストアンサー

素の csh なら C-p か !! か, その辺じゃなかったかなぁ?
「ヒストリ (履歴)」で調べてもらうといいかも.

お礼

「!!」でできました。
ありがとうございます。

■_ Guile

extension language としてはどーなってんすかね。Guile。

Why Guile is still relevant today, as an "extension language (for GNU)" : programming

It is also the ONLY Opensource SCHEME with POSIX threads support and actively developed.


    It is also the ONLY Opensource SCHEME with POSIX threads support and actively developed.

Gauche has POSIX thread support, is open source, actively developed, quite fast, and 
has very nice POSIX integration. Also, Shiro Kawai, the maintainer, has an awesome 
track record with Scheme (having used it in neat places at Sony), does real world work 
with Scheme, and has always been awesome whenever I've emailed him with questions or 
bugs. Oh, and he's really good with Unicode, so there aren't as many "ASCII is 
the only thing that exists" type issues with Gauche (sane defaults for enabling 
multi-byte, for instance).


Stallman should go home and be a family man.


A really poignant article, thanks for the link. Shiro is a wonderful hacker. It's corny,
but I do think that "one day" we will make it there.


    Guile is the GNU extension language. This is the case because Richard Stallman said so, 17 years ago.

Sorry dude, but Guile isn't relevant anymore. Hell, it never was. I say good riddance to bad rubbish.

If only Stallman hadn't started his crusade against Tcl... talk about not-invented-here-syndrome.

Sadly the GNU folks didn't understand Tcl

But while Guile dies Tcl is still going strong, suck it GNUfags!

なんと shiro さんの名前が!

corny ってどういう意味だろう… corny の意味とは - Yahoo!辞書

■_

2011年09月02日

■_

とある会合に参加

■_

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

404 デフォルトの名無しさん [] 2011/09/02(金) 14:22:48.91 ID: Be:
    他の掲示板やコミュニティなどで、多くのカテゴリがあり、主に最新技術の話題で盛り上がってるところってありますか?
    はてなとか、スラッシュドットくらいしか知らないんですが、どちらも盛り上がってるというより、
    前者は個別の日記が盛んで掲示板で話合うという形式じゃないっぽくて、後者は盛り上がってるのか?という感じを受けます。
    2chを基準に考えてるせいかもしれませんが、ここ以外で活発なサイトを自分は知りません。
    どこか良いところがあったら教えてください。 

405 デフォルトの名無しさん [sage] 2011/09/02(金) 14:26:52.66 ID: Be:
    >>403
    pixivを買収するのが手っ取り早い
    そのための金は十分にあるという設定で 

406 デフォルトの名無しさん [sage] 2011/09/02(金) 15:05:21.59 ID: Be:
    ttp://vip0nanzo.blog109.fc2.com/blog-entry-629.html
    こんな所を買ってもうれしくもなんともないわ
    末代までの恥 

407 デフォルトの名無しさん [sage] 2011/09/02(金) 15:28:25.81 ID: Be:
    >>405
    できました
    ありがとうございます 

408 デフォルトの名無しさん [sage] 2011/09/02(金) 15:28:36.53 ID: Be:
    最新技術の話したいなら海外のフォーラム覗いた方がいいんじゃない 

409 デフォルトの名無しさん [sage] 2011/09/02(金) 15:54:53.45 ID: Be:
    >>408
    正論だけど、日本のフォーラムどうにかならんかw 

412 デフォルトの名無しさん [sage] 2011/09/02(金) 17:40:06.14 ID: Be:
    >>409
    脱ゆとり世代が大人になるまで㍉

Q&Aのサイトにしてもそうだけど、なんでなんでしょうねえ。

■_

■_

2011年09月01日

■_

プログラミングの心理学
新しく訳しなおしたんですね。 買って比較してみようかな(悪趣味) 新訳の人のほかの訳書はいくつか読んだものがあって、とくにひっかかった記憶もないから 大丈夫かな…tってなに「解説」って?
プログラミングの心理学―または、ハイテクノロジーの人間学 25周年記念版 プログラミングの心理学 【25周年記念版】

■_

The UTF8 flag and you | Aristotle [blogs.perl.org]

The UTF8 flag and you
UTF8フラグとあなた

By Aristotle on August 30, 2011 12:18 PM

If you are looking at the UTF8 flag in application code then your code is broken. 
Period.

あたがもしアプリケーションのコード中でUTF8 フラグというものに注目していたのなら
あなたのコードは壊れている。
以上。

The flag does NOT mean that the string contains character data. It ONLY means that the string
contains a character > 255 either now or could have, at some point in the past.

このフラグは、文字列がcharacter data を保持しているということを「意味しません」。
ただ単に、その文字列が255を越えるコードポイントのcharacterを持っているか
過去のある時点で持っていた可能性があるかというものでしかありません。

For strings that contain characters > 127 < 256, you have no idea whatsoever about
whether the string contains characters or bytes regardless of what the UTF-8 flag says.
(For strings with only characters < 128 there is no difference whether they are ASCII
or binary, and strings with any characters > 255, must be either all characters – or
corrupt (character and binary data mixed together).)

127を越え、かつ256未満のコードポイントの character を含む文字列に対しては、
UTF-8 フラグが表していることに関係なく 文字列が character か bytes のいずれを
保持しているのか についてはあなたは no ideaです。
#you have no idea whatsover about がよくわからん
128未満の character しかない文字列ではそれが ASCII であってもバイナリであっても
違いはまったくありません。また 255 を超える character を含む文字列は
すべてが character であるか、あるいはまったく character でないものでなければなりません。
さもなければおかしいものです (character とバイナリデータが混ざっている).



The following will produce a perfect copy of lolcat.jpg in lolol.jpg:

次に示すコードは lolcat.jpg の完全なコピーである lolol.jpg を作り出します:

  my $funneh = do { local ( @ARGV, $/ ) = 'lolcat.jpg'; <> };
  utf8::upgrade( $funneh );
  # now the utf8 flag on $funneh is set!
  open my $copy, '>', 'lolol.jpg' or die $!;
  print $copy $funneh;


It makes no difference at all that the data was internally UTF-8-encoded at one point! 
Because those UTF-8-encoded string elements still represented bytes. And the UTF8 flag 
would not – because it could not, because that's not what it means – (not) tell you 
that this is binary data.

It makes no difference at all that the data was internally UTF-8-encoded at one point! 
なぜならそれらの UTF-8エンコードされた文字列要素は依然としてバイト列を表しているからです。
そしてそのUTF8 フラグはあなたに対してそれがバイナリデータであると伝えないのです。
なぜならそれが、そういったことを意味しないものなので伝えることができないのです。

So don't ask it that.

The flag tells perl how the data is stored, it does not tell Perl code what it means. 
Strings in Perl are, essentially, simply sequences of arbitrarily large integers that 
know nothing of characters or bytes; and perl has two different internal formats for 
storing such integer sequences – a compact random-access one that cannot store 
integers > 255, and a variable-width one that can store anything and just so 
happens to use the same encoding as UTF-8 because that is convenient. The UTF8 flag 
just says which of these two formats a string uses. (It has been pointed out many 
times over the years that the flag should have been called UOK instead, in keeping 
with the other internal flags.)

このフラグは perl にデータがどのように格納されているかを伝えます。
Perl のコードにそれが何であるかを伝えるものではありません。
本質的には、Perlにおける文字列は (know nothing of characters or bytes な)
任意の大きさの整数の単純な並びです。
また、perl はそのような整数のならびに関して二つの異なる内部形式を持っています
ひとつは 255 を超える整数を格納できない compact random-access できるもので、
もうひとつは何でも格納できる variable-width なものです。
後者はエンコーディングとして UTF-8 を扱うのに便利なものです。
#わからん
UTF8フラグは単に、文字列が使っているフォーマットがこれら二つのいずれなのかを示すだけです。
(It has been pointed out many 
times over the years that the flag should have been called UOK instead, in keeping 
with the other internal flags.)

If you check the perldelta you will in fact find that the major innovation that started in
Perl 5.12 and largely completed in 5.14 is to (finally) stop the regex engine from making
this exact mistake, namely, it no longer derives semantics about a string from its internal
representation.

Whether any particular packed integer sequence represents bytes or characters, in Perl, is
for the programmer to know. The strings themselves carry no knowledge of what they are. If
you are designing an API in which bytes vs characters is a concern, then in each case it
accepts a string you must decide whether you prefer bytes or characters there, then document
that this is what you expect, and then write the code so it always treats that string the
same way – either always as characters or always as bytes. No trying to magically do the
right thing: you can't.

■_

When your program asks for a "first name" or "last name", you're doing it wrong: Naming traditions in various languages, courtesy of the W3C. [xpost/linguistics] : programming

■_ R はどのくらい R で書かれているか?

結構 FORTRAN があるのに驚いた。

How Much of R is Written in R? | (R news & tutorials)

How Much of R is Written in R?

August 26, 2011

By wrathematics

This article was first published on librestats » R, and kindly contributed to 
R-bloggers

My boss sent me an email (on my day off!) asking me just how much of R is written in 
the R language.  This is very simple if you use R and a Unix-like system.  It also 
gives me a good excuse to defend the title of this blog.  It's librestats, not 
projecteulerstats, afterall.

So I grabbed the R-2.13.1 source package from the cran and wrote up a little script 
that would look at all .R, .c, and .f files in the archive, record the language (R, C, 
or Fortran), number of lines of code, and the file the code came from; then it's just 
a matter of dumping all that to a csv (converted to .xls (in LibreOffice) because 
WordPress hates freedom).

(略)


From the R script, we can get precise figures, which I prefer to pictures any day. But 
I seem to be an outlier in this regard…

Number .R source files:		 729
Number .c source files:		 586
Number .f source files:		 45
-------------------------------------
Total source files examined:	 1360

Lines of R code:	 149520
Lines of C code:	 346778
Lines of Fortran code:	 175409
-------------------------------
Total lines of code:	 671707

Among all lines of code being either R, C, or Fortran:
% code in R:		 22.259705
% code in C:		 51.626379
% code in Fortran:	 26.113916



Copyright © 2011 R-bloggers. All Rights Reserved.

■_

↑について

How Much of R is Written in R... : programming

    By a respectable majority, most of the source code files of core R are written in R

Not when the graph is labelled "percent of core R sourcecode files" and the 
axis only goes up to 0.5, they aren't. <:-)


R programmers aren't so good with statistics


Based on what do you claim this?! Who are the "good in statistics" people? 
SAS programmers? non-programmers?! Do you mean theoretical statistics or applied 
statistics?


    Trust me, you really want C and Fortran to be doing all the heavy lifting so that things
    stay nice and peppy.

I really don't agree with this position.

Instead, I think you want R to be used to write R so:

    * VM designers are forced to make the language itself fast, instead of punting to C
      (and yes, that also applies to Python, Ruby and others). This makes the language 
      better.

    * The core is shorter and easier to maintain (bugs count is a direct function of your
      loc count, and tentative contributors to R likely already know R, the more core R 
      is available to them without having to learn or remember Fortran the better). This 
      also makes the language better.

On the other hand, I don't know that R tries to be a general-purpose language. If R is 
a domain-specific language, it makes sense that you don't write the R VM in it, 
because it's going to be bad.


PyPy is doing stuff that only JUST started coming out in the 90s, in commerical 
dynamic languages, such as VisualWorks SmallTalk, and later Java via HotSpot.

Public domain scripting languages that were not the result of a university research 
project into "How to write a fast VM", are only just now beginning to apply 
these ideas.

Factor is another scripting language that suprises me how fast it is. And they spent a 
lot of time, right off the bat, optimizing their VM. Is optimizing a VM difficult? Yes. 
But no one will ever complain about a vm being too fast... ;)

I think part of the issue that writing a simple VM is easy, and you get a good 80% of 
the benefit of using a simple VM + C libs.


    PyPy is doing stuff that only JUST started coming out in the 90s, in commerical dynamic
    languages, such as VisualWorks SmallTalk, and later Java via HotSpot.

Most of that work was pioneered by Self, which was anything but commercial (most of 
the early work was done at Standford). This work was used by the Strongtalk team 
(commercial indeed), which got acquired by Sun, leading to HotSpot.

    languages that were not the result of a university research project into "How to
    write a fast VM", are only just now beginning to apply these ideas.

Sure, but that research is still 20 years old.


Just how do you write an interpreter in the language it's supposed to interpret? Or 
does VM not mean what I think it does here?

    Just how do you write an interpreter in the language it's supposed to interpret?

Bootstrapping (see also self-hosting). That's also what you do to write a C compiler 
in C. And the vast majority of C compilers are indeed written in C.

As an old guy who made a decent living cleaning up COBOL prior to Y2K, I have to say 
I'm amused that FORTRAN is still being used for "heavy lifting".

FORTRAN is used for almost all major math libraries. They are mature and fast.

For example, JBLAS is a wrapper for ATLAS, written in FORTRAN.

そういや gfotran の生成するコードの質って最近はどんなんでしょか。

■_ Is learning Assembly Language worth the effort?

Hacker News から拾ってみた。

Hacker News | Is learning Assembly Language worth the effort?

Absolutely yes, for many different reasons:

1. If you program in any compiled language, being able to read assembly is critical to 
figuring out what the compiler is doing with your code. A quick glance over the 
assembly can often reveal why the code is slower than expected, often including 
suboptimalities in your higher-level code such as unexpected aliasing.

2. If you program in a C-like language, parsing the output of gdb is impossible 
(beyond the bare basics) without knowing assembly.

3. SIMD assembly can give performance improvements of 10-20x or even higher for many 
types of real-world code. Skill at using SIMD is in incredibly high demand at the 
moment, especially on ARM (with NEON). If you are writing code where performance is 
critical, you should always consider how to optimize with SIMD. If you don't, you're 
effectively throwing away >90% of the capabilities of your CPU.

4. If you understand the capabilities of the machine you're optimizing for, you can 
better write code (in a low-level language like C) to take advantage of it. Examples 
of this include the ability on ARM to do conditional instructions effectively for free, 
or the ability on x86 to do reg3 = (reg1+(reg2<<{0,1,2,3})+<const>) in one 
instruction.

Learning assembly is quite easy; for example, last Google Code-In we had a student 
(age 17) who started knowing not a single iota of anything about assembly and, within 
a week, was writing literally thousands of lines of SIMD code and passing stringent 
code reviews.


Intrinsics tend to be incredibly difficult to read (and write) compared to 
hand-written assembly. For practical purposes, it's write-only code, and C simply 
doesn't provide the syntactical niceties necessary to easily write assembly code.

Inlining SIMD functions is typically not possible in most applications unless you're 
compiling a dozen versions, one for each possible CPU, since different CPUs will use 
different SIMD functions that are optimized for their performance characteristics.

Nevermind the fact that intrinsics generally give atrocious performance compared to 
properly-written code, as your average 3-year-old can probably allocate registers 
better than gcc.

It totally depends on what kind of programming you want to do.

  - If you want to make web applications, then probably not.
  - If you want to build web infrastructure, then probably.
  - If you want to make desktop games, then probably.
  - If you want to make mobile or console games, then yes.
  - If you program in higher-level languages and want to exercise your brain, then yes (do
    it for your "one new language a year").


Assembly writing, not so much. Assembly reading, a huge win. However, the thing is you 
can't read assembly very well unless you've written it at some point.

The key factor is that besides the actual instructions and their syntax in assembly 
language you will also need to internalize the conventions for register usage and 
subroutine calling for a platform. Or several platforms. That's what allows you to 
eyeball compiler generated assembly and make sense out of it. Otherwise you'll just 
see moves between registers and stack, and wonder what happens next whereas the code 
in fact pops the return address from stack to pc and continues from a whole another 
location.

I think that the best way to learn assembly these days would be to write an assembler 
and machine code interpreter for some known platform, such as ARM. You can write the 
assembler and interpreter even in Python but at the end you should be able to execute 
existing native binary code, though slowly. The mental investment is larger than 
toying around with existing toolchains but gives you much more bang for the buck with 
regard to understanding cpus.

Absolutely!

In fact, you should try to learn as many languages that have real differences between 
them as possible.

There is something to be gained from a low level perspective on how a computer 
operates just as much as there is from higher levels, even if you will not use that in 
your everyday job.

No point in learning three varieties of the same thing but you get real insight from 
learning languages that are very different.

C/C++/Java

Python/Perl/Ruby/PHP (puts on flame proof gear)

Lisp/Clojure/Scheme

Smalltalk/?

APL/R/J/Mathematica

IO/Forth/Factor

Assembler (there a many different flavors of assembly)

VHDL/Verilog (not true programming languages but very interesting all the same).

Pick one or more entries from each of the above lines and you'll have a better perspective than if you left that line out.

Of course there are many more options than the ones in the list above, but you get the general idea.

x86(とARM)一色というのはどうにも面白くないw (68000派)

■_


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

ホームへ


リンクはご自由にどうぞ

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