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

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

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

ホームへ

2009年09月20日

■_

・シルバーウィーク
なんかわりと違和感なく受け入れて使っている人が多いみたいですね。 自分はどうも積極的に使う気にはならんのですが(止めろという気もない)。

■_ You're never too old for XCode

77歳でゲーム開発者とかすげー婆様だな。

Why the Granny Coder decided to make her first iPhone game aged 77, feature, Gelex, PocketGamer.biz

In terms of her biographical details, Marie Bila is a 77 year-old grandmother, who 
lives in small village in the Czech Republic with a cat called Jasmina, 15 chickens 
and goat Liza.

彼女は自身の biographical details に従えば、Marie Bila という名前の
チェコ共和国の小さな村で
Jasmina という名前の猫と15羽の鶏、Liza というヤギとともに暮らす
77歳のgrandmother である。

This year however, she's become Granny Coder, and is proving you're never too old to 
become a game developer.

今年はしかし、彼女は Granny Coder となり、また、
あなたがゲーム開発者になるのに決して歳をとりすぎていないのだということを
実証した。


On her blog, and helped by her three grandsons, she's been documenting the process of 
making her first game - an iPhone physics puzzle game called Gelex.

彼女のblogに、三人の孫の助けを借りながら
最初のゲームである Gelex という名前の iPhone 用の物理パズルゲーム
を作るプロセスが書かかれている。

Not only is it an interesting read in terms of the development process, but her 
enthusiasm for the game she's making also makes it a delight.

これは開発プロセスの物語として読んで面白いだけでなく、
彼女の enthusiasm 


We wanted to find out more...

Pocket Gamer:
Can you provide us with some background information about yourself?
自己紹介をしていただけますか?

Marie Bila:
My name is Marie, I'm from little village called Lhota in the Czech Republic and I'm 
retired.

わたしの名前は Marie といいます。チェコ共和国の Lhota と呼ばれている小さな村から
出てきましたが、今は退職しています。

I had lots of free time, and a few month ago my grandson Michal bought me an iPhone. 
It really amazed me, and when I realised you can make your own applications on it, and 
that even little kids can do that, I decided to use my free time and to try and create 
something by myself.

わたしには自由になる時間がたくさんありました。そして二ヶ月ほど前のことですが
孫の Michal がわたしに iPhone を買ってくれたのです。それはわたしをとても驚かせる
ものでした。そしてユーザーが、たとえ小さな子供であったとしても自分でアプリケーションを
作ることができるということを知ったときに、わたしは自分の自由になる時間を iPhone
で動く自分用の何かを作ってみることに使おうと決心したのです。

Have you done any programming before?
それまでプログラミングの経験はおありだったんですか?

I've had lots of different jobs in my life, but the important job for my current 'game 
developer' career was probably working at University in Brno, where (apart from other 
things) I was involved in some IT projects and learnt basics of the C and C++ 
programming language.

わたしはいろいろな仕事をしてきましたが、現在の“ゲーム開発者”のキャリアに対して
最も重要だったのはおそらくBrno 大学で働いたことでしょう。そこでは (apart from other things)
幾つかのITプロジェクトに参加して、また、CやC++といったプログラミング言語の基礎を
学びました。

I wouldn't call myself a programmer, but after this experience I know a little bit 
about how things work.

わたしは自分がプログラマーであるとは言いませんが、この経験によりそれらがどのように
働いているのかということをちょっとだけ知りました。

Have you played many computer games, and why did you decide to start making an iPhone 
game?

これまでたくさんのコンピューターゲームをプレイしたりしていましたか? また、なぜ、iPhone
用のゲームを作り始めようと決心されたのでしょうか
  
I'm playing games on my iPhone now and before that I've played a few PC games - like 
Luxor - I really love that one. I also like the Czech game Polda.

iPhone 用のゲームをプレイする前に、LuxorのようなPC用ゲームをいくつかプレイしたことがあ
ります。わたしはこのゲームがとても好きです。  チェコのゲームのPoldaも好きですね。

The first games I ever played were in the 1980s on the ZX Spectrum. I felt a need to 
create a game then, but at that time I had lots of other things to do. When iPhone 
came into my life, I felt that need again. And this time I have another reason for 
creating a game - I wanna do a game for my grandchildren.

わたしが最初にプレイしたゲームは 1980年代の ZX Spectrum 上のものでした。わたしはゲーム
を作る必要があると感じたのですが、そのときはほかにすべきことがたくさんあったのです。
iPhone がわたしの人生に登場したときにわたしは再度その必要性を感じたのです。そして今回
はゲームを作るもうひとつの理由がありました。それはわたしの孫たちのためのゲームを作りた
いというものです。

What was the spark of inspiration for your game Gelex?
Gelex の inspiration を spark させたものはなんだったのですか?

I had an idea about a 'physics Tetris' game a long time ago. That idea evolved in my 
head. It was influenced by games such as Luxor and Zuma and also by the movie Flubber.

わたしは長いこと  'physics Tetris' のようなゲームのアイデアを温めていました。そのアイ
デアはわたしの頭の中で進化しました。  Luxor や Zumaと いったゲームにも影響を受けました
し、 Flubberという映画からも影響を受けました。

  
And, of course, the game Tryptich is quite similar to Gelex and had huge impact on me 
when I've discovered it.

そして、忘れてはいけないのが、Tryptich と言うゲームでこれは Gelexにとてもよく似ていて、
見つけたときにとても大きな衝撃を受けました。
  
Why did you decide to make a puzzle game rather than things you're interesting in such 
as gardening and farming?

なぜパズルゲームを作ろうと決めたのですか?  あなたが興味を持っている gardening や 
farmingではなくて

I decided on a puzzle game because I wanted to start with something simple. I know 
every detail about farming and gardening, and a game based on these things would be 
really complex and much harder for me to create.

パズルゲームにしたのは、単純なものから始めたかったからです。わたしは farming や 
gardening の詳細をよく知っていていますがそういったものをベースしたゲームはとても複雑な
ものになってしまうことが予想されて、わたしにとって作るのがとても困難に思われたのです。

  
And another thing, I want this game mainly for my grandchildren and they are not 
really into gardening and farming, so I guess they wouldn't like them in a game either.

それともう一つ。わたしはこのゲームを孫たちへのものにしたかったのです。彼らはgardening 
や farming を実際にしてはいなかったので、わたしはそういったもののゲームを彼らが好むこ
とはないだろうと考えたのです。

What's been the most difficult thing so far in making Gelex?
Gelex を作るうえで最も難しかったのはどんなことでしたか?

Optimising the code. I've written some articles about that on my blog and I'm 
preparing another one. I'm still finding ways to improve the code, but it's really 
hard and takes lots of time.

コードの最適化です。そのことについて blogでもいくつかのアーティクルを書きましたし、そ
れとは別のものを使いました。今でもコードを改良する方法を捜し求めています。でも、本当に
難しくて時間もかかりました。
  

What parts of the game do you still have to finish?

ゲームでまだ終わらせる必要のある部分は何ですか?
  
I'm working on the high score system right and I'm designing the main menu in my head. 
I want it to be more interactive. In other games you've just got some buttons such as 
New Game, Setting etc... But in Gelex, there will be other little things to do. They 
will be useless, but funny.

ハイスコアシステムについて作業していて、
それと頭の中でメインメニューの設計をしています。
わたしはゲームをよりインタラクティブなものにしたいと思っているのです。
ほかのゲームでは新しいゲームやセッティングなどもろもろのように数個のボタンを見るでしょうけれども
  Gelexでは行うべきことは少ないものでしょう。
  たくさんあるボタンは使いどころがないでしょうしあってもおかしなことになるでしょう。
  
  
But there are still lots of other things to do like music and sounds. I don't have any 
of them yet. According to my plans I want to finish the game in a month or month and a 
half.

  音楽や効果音のようなことをも大半が残っていますね。
これらについてはまだぜんぜん手をつけていません。
  自分の計画に従えば、一月か一月半くらいで完了させたいです。
  
What do you think is the best bit of Gelex so far?

Gelex の一番よい点はどういったところだと思われますか?
  
I love just playing with the bricks, hitting one with another and seeing how the 
physics works. That's what I really like in the game.

Do you think you will make more games when Gelex is finished?

Gelexが完成したら、もっとゲームを作るお考えはありますか?
  
I would love to. I already have some ideas about a new game and if I'm healthy enough 
to continue with game development then I don't see any reason to stop.

是非そうしたいですね。
新しいゲームのアイデアはいくつか持っていますし、
ゲームの開発を続けられるくらい健康であれば、開発をしない理由はありません。
  
  
What does your family think about your new hobby?

あなたの新しい趣味についてご家族はどのようにお考えなんですか?

I have a huge support from my three grandsons. Michal bough me an iPhone as I 
mentioned, then they gave me a Mac, because I had a Windows PC. One of them is 
studying IT at university, so he is my adviser sometimes. And all three of them are 
watching everything I create and give me feedback. They've also made the videos on my 
blog.

三人の孫からは大いにサポートを受けています。
Michal は既に申し上げたように iPhoneを買ってくれましたし、
その後 Mac も孫達がくれたのです。
わたしはそれまで Windows PCしか持っていませんでしたから。
孫の一人は大学で IT を学んでいるのでわたしのアドバイザーになってくれることもあります。
And all three of them are watching everything I create and give me feedback.
They've also made the videos on my blog.  
  

  
The rest of the family doesn't really care, but my grandsons are my biggest fans and 
my motivation.

残りの家族はぜんぜん気にしていません。でも孫たちはわたしの一番のファンですし、わたしの 
motivationになっています。
  
Have you had much contact with other people making iPhone games?

iPhone 向けゲームを作っているほかの人にコンタクトを取ったことはありますか?
  
As I mentioned before, my grandson Pavel helps me sometimes with some harder things 
about programming. He is really good at it, but he is not doing anything on iPhone.

すでに申し上げたように、わたしの孫の一人である Pavel はプログラミングに関していくつか
の困難なことがらについてときどきわたしを助けてくれました。彼は本当に good at it ですが、
彼は iPhone では何もしていません。
  
I am also a member of some developer forums, but I am a passive member - just reading 
what other people say. And I have some contact with other iPhone developers through 
twitter. That mainly helps my motivation.

わたしはいくつかの開発者フォーラムのメンバーでもあります。でもわたしは passive メンバ
ーで、ほかの人の発言を読むだけです。ツイッターを通じてわたしは何人かの iPhone デベロッ
パーにコンタクトを取ったことがあります。That mainly helps my motivation.
  
What advice would you have for anyone who has never coded a game but is interested?

これまでゲームのプログラミングをしたことがないけれども興味を持っているような人に対して
何かアドバイスをいただけますか?
  
If your dream or goal is to create a game, you should definitely follow it. It's not 
easy to create a game: especially in the beginning you will need to learn a lot, but 
it is worth it. Each time I create a new part of the game I am so proud of it and that 
feeling is worth the effort.

もしあなたの夢や目標がゲームを作るということならそれに従うべきです。ゲームを作るという
ことは簡単なことではありません。特に始めたばかりのときはあなたには学ばなければならない
ことがたくさんあることでしょう。でもそれは学ぶ価値のあるものなのです。わたしは、ゲーム
の新しいパーツを作るたびにわたしは自分をとても誇らしく思いますし努力した甲斐があったと
思うのです。

Many thanks to Marie for her time

You can keep up to date with the development of Gelex on her Granny Coder blog and via 
twitter.

こういう話とか、iPhoneの活用事例とか見たり聞いたりするとかなり心が動くんだけど、 今のところは Apple様に忠誠を誓う気にはなれないのだったw

■_ いい加減古い話ではありますが

Zed 関連はできるだけフォローしたいので。

 >In defense of BSD licenses ≪ objects in motion

In defense of BSD licenses

Posted July 14, 2009

Zed Shaw just blogged about why he uses the GPL instead of a BSD-style license. His 
arguments for the GPL are interesting but I feel that counterpoint is needed, since at 
Enthought (where I work), we try to BSD as much of our code as possible.

Zed Shaw は彼がなぜ BSD 形式のライセンスではなく GPLを使っているのかということについて
のblog 記事を書きました。GPLに関する彼の主張は興味深いものではありましたが、その 
counterpoint が必要であろうとわたしは考えました。なぜなら (わたしが関わっている) 
Enthought では 可能な限りわたしたちのコードを BSDライセンスによるものとしようと試みて
いたからです。

“It's the Author's Right”(それは書き手の権利だ)

First off, I'd like to encourage everyone in the Python community to be respectful. It 
is never appropriate to get angry at another person for their choice of license, and I 
am disappointed that Zed feels slighted by the community reaction to his work. (If you 
don't like the license on a package, it is sometimes appropriate to ask the author if 
they'd consider changing it, but obviously beggars can't be choosers.) Hopefully it's 
just a few bad apples (“ungrateful turds”, as he calls them). That being said,
“it's the author's right” is not really a reason for the GPL, just an admonishment.

わたしは Python コミュニティでは誰もが respectful であることを促進する (engourage) の
を望んでいます。誰か別の人を、選択したライセンスによってその人に対して怒りを覚えること
は決して適切なことではありません。そしてわたしは、Zed が彼の作品に対するコミュニティの
リアクションによって感じたことに失望しました。(もしあなたがあるパッケージのライセンス
が気に入らないのなら、そのライセンスを変えてもらえないか作者にお願いするのが適当なので
すが、明らかに beggars (寄付を募集する人、乞食) は choosers (選挙人、選択者)にはなれま
せん)。そういった人が極少数の bad apples (彼の言葉を借りれば“恩知らずのくそったれども”)
であればよいのですが。
That being said, “it's the author's right”(それは書き手の権利である) と主張することは
GPL を選択した本当の理由ではなく、単なる admonishment (警告) のためなのです。

“I Don't Want To Be Ignored Again”/”You Have To Tell Your Boss You're Using My Gear”

The fact that Zed wrote Mongrel and got no recognition is possibly an indictment of 
several things: the RoR buzzstorm, the Rails community, the “OMG Ruby is the new Java 
for Web 2.0” technorati, maybe even venture capitalists. But it is not an indictment 
of the BSD license.

Zed が Mongrel を書いたけれども recognition を得られなかったということはおそらくいくつ
かの事象に対する indictment (告発、起訴)でしょう。それは RoR buzzstorm でしょうし、
Rails のコミュニティや “OMG Ruby is the new Java for Web 2.0” technorati、そしておそら
くはベンチャーキャピタリストも。しかしそれは BSD ライセンスに対する indictment ではありま
せん。

Numpy and Scipy are two very successful projects, and they are BSD licensed. They have 
healthy communities, and many people make a living off of consulting work or 
commercial projects built on those tools. There are also countless companies whose 
staff make use of them internally, and occasionally give back to the projects. I would 
consider both Numpy and Scipy to be healthy, open-source projects with plenty of 
mature collaboration between commercial, academic, and hobbyist users. If either 
project were suddenly to become GPL, they would lose their commercial viability and 
the communities would undoubtedly suffer.

Numpy と Scipy は BSD ライセンスを採用している非常に成功しているプロジェクトですこれら
のプロジェクトには良好なコミュニティがあって、多くの人が それらのツールを使って
consulting work の living off をしたり商用プロジェクトを立ち上げたりしています。内部的
にこれらのツールを使っていて、時折りプロジェクトに give back する企業もたくさんありま
す。わたしは Numpy と Scipy の両方が healthy であるために、商用ユーザー、学術方面のユ
ーザー、それに加えてホビーストユーザーといったものがコラボレーションしているオープンソ
ースプロジェクトであると考えているのです。もし突如としていずれかのプロジェクト(のライ
センス)が GPL になってしまったら、そのプロジェクトはプロジェクトの commercial 
viability を失ってしまいコミュニティは undoubtedly suffer となるでしょう。


SAGE, an open-source Pythonic replacement for Maple/Mathematica/Magma/Matlab, is 
another very successful project, but they staunchly use the GPL. Their reasoning is 
much like Zed's, because the symbolic math software community has been burned in the 
past by people profiting from proprietary extensions of BSD code without attribution 
or contribution. However, the GPL means that people cannot realistically use SAGE in a 
commercial tool, either as a platform/runtime, or as an embedded component. The SAGE 
authors have, presumably, weighed the trade-offs and decided it's ultimately more 
valuable to be protected than to have the contributions of that segment of developers.

Maple/Mathematica/Magma/Matlab に対する Python 的なオープンソースの replacement である 
SAGEは、また別の非常に成功しているプロジェクトですが、こちらは staunchly に GPL を使っ
ています。その理由は Zed のそれととてもよく似たものです。かつて symbolic math software 
のコミュニティは、attribution や contribution なしにBSD ライセンスのコード に対するプ
ロプラな拡張 (proprietary extensions) から利益を得た人たちによって burned したことがあ
るからなのです。しかし GPL にしたということは、SAGE を platform/runtime としても 
embedded component としても商用のツール (commercial tool) として realistically に使用
できなくなったということを意味します。おそらくSAGEの作者たちはトレードオフを熟考して
that segment of developers の貢献を待つよりも、プロテクトすることのほうが決定的に 
valuable であると判断したのでしょう。

The style of license both depends on and defines the type of community that develops 
around a project. If you feel that the potential audience of your project consists of 
the sort of people that are liable to use your code without attribution and without 
becoming part of the user community, then by all means protect yourself with the GPL. 
If your code is the outgrowth of a community that already has a healthy number of 
commercial users, then there's usually no downside risk of using BSD, while you get 
the upside of reaching a larger audience. Based on what I've seen, the Python 
community has a pretty healthy mix of commercial developers, and so as a whole I don't 
think people there get burned by choosing the BSD license.

ライセンスのスタイルというものは開発するプロジェクトを取り巻くコミュニティのタイプに依
存しますし、またそれにより規定されるものです。もしあなたが自分のプロジェクトの潜在的な 
audience に、あなたのコードを attribution (権限?) 抜きに使ったりユーザーコミュニティの
一部になろうという意識なしに使うような人たちが含まれていると感じているのであれば、GPL 
にしてあなた自身を守りましょう。もしあなたのコードがすでに healthy number の  
commercial users を抱えているコミュニティの outgrowrh (副産物、当然の結果) であれば、
通常は BSDを使うことについて downside risk はありませんwhile you get the upside of 
reaching a larger audience.わたしが見てきたことから判断すると、Python のコミュニティに
は pretty healthy mix of commercial developers があって、BSD ライセンスを選択してしま
ったためにプロジェクトを burned してしまう人はいないだろうとわたしは確信しているのです。

“If It's Good, Pay For It”(良いものだったら、その対価を払ってくれ)

Here is where we are in agreement, but there are numerous ways to approach this. Phil 
Thompson uses a dual licensing scheme with PyQT, wherein commercial developers have to 
pay for it. Travis Oliphant implemented an interesting “world price”/community 
fixed-fee scheme to fund the development of Numpy: he wrote a big pile of 
documentation (the Numpy Book) and sold it until a certain total dollar amount had 
been reached, at which point the book became freely available. At Enthought, we earn 
consulting contracts based on our BSD-licensed Enthought Tool Suite and our 
involvement with the Numpy and Scipy projects.

わたしたちが合意できる点がここにあります。しかしそのためのアプローチには多くの方法があ
ります。Phil Thompson は PyQT でデュアルライセンスという方式を使っていますこれは 
commercial developers は相応の対価を支払わなければならないというものです。Travis 
Oliphant  は Numpy の開発資金 のために“world price”/community fixed-fee scheme とい
う興味深いやり方をしています:彼は big pile of documentation  (Numpy 本)を書いてその本
を売上の合計がある一定の金額 (certain total dollar amount) に達するまで販売し、その額
に達した時点で本を無料で入手できるようにしたのです。Enthought では、BSDライセンスの 
Enthought Tool Suite に基づくコンサルティング契約(consulting contracts based on our 
BSD-licensed Enthought Tool Suite)とNumpy プロジェクトや Scipy プロジェクトに対するわ
たしたちの改良とによってわたしたちは収入を得ています。


BSD/LGPL does not imply that you will not make money, and GPL does not ensure that you 
do. The only way to ensure that you *do* make money is to explicitly dual license. 
(Edited: as some have pointed out, dual licensing basically requires the use of the 
GPL with a commercial license, as BSD does not prohibit commercial use.)

BSD/LGPL はあなたが金を稼がないことを意味するものではありませんし、GPL もあなたがそう
しないことを保証 (ensure) しません。あなたが金を稼ぐことを ensure する唯一の方法は明確
な形でデュアルライセンスにすることです。
(編集: 一部の人が指摘しているように、デュアルライセンスは基本的にGPL を商用ライセンスと
一緒に使うことを要求していますが、BSD の場合は商用利用を禁止してはいません。)

“Finally, Value”(結局のところは価値なんだ)

I think there is a very good discussion to be had about how to commercialize the 
success of open source. Talented coders need to be compensated so they can afford to 
continue to innovate. Users should be free to use code however they wish, with no 
limitations on their freedoms, because code is ultimately a form of expression. But we 
need an interaction model that allows the expression of values and economic 
preferences without grounding certain values to zero, which is that traditional OSS 
licenses tend to do. As the practice of software development matures, we simply have 
to find a better economic model than the traditional Stallman-Gates bifurcation.

わたしはオープンソースの成功をいかにして商業化 (commercialize) するかということについ
て非常に良い話し合いができたと思っています。才能溢れるコード書き (Talented coders) に
対しては、彼らが継続して innovete するのを afford できるように compensated する必要が
あります。ユーザーはコードの作り手の希望とは無関係に自由にコードを使えるようになってい
るべきです。なぜならコードとは ultimately a form of expression (表現の究極の
形態?) だからです。しかしわたし
たちには grounding certain values to zero することなしに expression of values と 経済的
な preferences を許すような interaction model が必要です。そしてそれは伝統的な OSS ラ
イセンスが tend to do したものです。ソフトウェア開発の matures の practice として、わ
たしたちは伝統的な Stallman-Gates bifurcation を超越したより良い経済モデル (economic 
model)を見つけ出す必要があります。

However, I think that choosing GPL or BSD is orthogonal to whether or not you feel 
your work is valuable; it is merely a way to define the kind of community you want 
around your project. If the community is filled with selfish, short-term opportunists, 
then protect your code and yourself with the GPL. If the community has a large, 
healthy contingent of commercial developers, then you're only hurting yourself if you 
shut them out.

しかしGPL か BSD かを選択するということと、あなたの成果に価値があるのかないのかという
こととは直交した(関係がない)ものだとわたしは考えます。あなたのプロジェクトを囲んで欲し
いようなコミュニティの kind を定義するやり方はほとんどありません。コミュニティが 
selfish と short-term opportunists であふれているのであればあなたのコードとあなた自身
とを GPL でもって守ってください。コミュニティが大きくて、healthy contingent of 
commercial developers であるのなら、あなたがそのコミュニティを遮断したときにだけあなた
自身を傷つけることになります。

I recognize that in the scientific Python community, we've been extremely lucky to 
have developed the user base that we have, but I think that has largely been possible 
*because* we use the BSD license.

scientific Python コミュニティにおいてわたしたちが自分たちのユーザーベースを開発できた
ことはこの上もなく幸運なことだと私は認識していますが、それはわたしたちが BSDライセンス
を採用したが故に可能になったのだと強く思っています。


んで、これに対する Zed からの回答ってのがあるんだよなあ。ふう。

■_ 本日の巡回から

2009年09月19日

■_

・ぐすたふ
(う)さんのついったでの呟きを眺めてたら、たださんのところのにゃんこの名前に対する 突込みらしいタイミングで「カール・グスタフ」と。 んー、わたしはグスタフというとこの人が真っ先に思い浮かぶのですが、 ほかにはいないんでしょうかねえw。 → グスタフ2世アドルフ (スウェーデン王) - Wikipedia

読んだ
エニグマ・コードを解読せよ エニグマ・コードを解読せよ
買ったのはだいぶ前のはずなんですが、例によってこれまで積まれてましたw んで、感想などですが、見事にアマゾンのレビューと重なってしまう内容で面白くない(^^; もうちょっとチューリングを中心として、プレッチレーパークのエピソードがあると期待してたんですが。 まあ、太平洋戦線での「コードトーカー」の話は知らないエピソードもあったので それは良かったんですが、全体としてはちょっとはずしたかなあと。 少しだけ解読の戦術的な内容も載っていますが、殆どは関係者達の回顧録を集めたような構成です。 という指摘はそのとおりだと思います。

■_

reddit からネタ拾い。 ただし大元だけw

"When they talk about code re-use around here, they mean cut and paste." : programming

I test code as part of my job with a medium-sized, world-wide corporation that 
develops software. Today, I ran into a problem where I thought there shouldn't be any. 
I went to one of the programming gurus here to inquire, as he originally programmed 
this bit of functionality that was since applied by other programmers. We checked out 
the applicable code and took a look.

I don't get a chance to look at the code much, but when I do, I always come away a bit 
queasy. Today's problem has to do with the title above. That's the exact quote the 
programmer gave me. I was horrified; he less so, since he long ago resigned himself to 
grappling with the sub-standard coding that goes on around here.

I remarked to him that what goes on violates the principle of orthogonality.

"And encapsulation," he added.

He went on. "Take a look at this class. It's 15,000 lines long."

Anyone here dealing with this kind of horror show?

■_ ちっ

reddit 経由で見つけた Never mind the language, the programmer is what matters | Psychology of Programming を元に話を広げようとしたら2000年の話じゃないか。あー、このページ自体は今書いたものか。

Never mind the language, the programmer is what matters | Psychology of Programming

Another piece of old research. It’s so interesting, though, I can’t help putting a 
note up about it. In a piece of research released in 2000, Lutz Prechelt compared C, 
C++, Java, Perl, Python, Rexx, and Tcl.  (It’s gotten a fair bit of attention before, 
so it’s not new material)


Never mind the language, the programmer is what matters | Psychology of Programming

What’s so interesting, though, is how this demonstrates in hard numbers the 
importance of human variables in programming. It’s almost like framework matters less 
than the people using it.. funny, eh?

■_

お次は stackoverflow.com から。


What is your favorite esoteric programming language? - Stack Overflow

In the spirit of "fun polls"... What is your favorite esoteric programming language?

Guidelines:

    * One language per response, upvote to echo others' responses
    * If you can, describe what makes it your favorite
    * Provide a code sample (if practical)

See Also:

    * Is it worth it to learn an esoteric programming language?
    * What is the strangest programming language you have used?
    * Most interesting non-mainstream language?

I thought it might be nice to summarize the responses, because although there are 
other lists (see comments below), it turns out that this list resulted in some 
(arguably) non-esoteric languages getting in. Also, to my knowledge none of the other 
lists is ranked based on votes, but these of course are. Note that only responses with 
at least 1 upvote are listed below.

Responses by Votes

    * LOLCODE
    * Brainfuck
    * Whitespace
    * Ook!
    * APL
    * Perl
    * The Shakespeare Programming Language
    * HOtMEfSPRIbNG
    * Scratch
    * Prolog
    * Lisp
    * Piet
    * LabVIEW
    * F#
    * Bash
    * INTERCAL
    * Subtext

といろいろ挙がってますが(APLとかPrlogがこのくくりで挙げられるのはなぜなんだw)、 んで、これがいいな。 使える処理系があれば使ってみたい。

What is your favorite esoteric programming language? - Stack Overflow
K Language, a wild APL/Scheme crossbreed.
http://en.wikipedia.org/wiki/K_programming_language

Hello world:

"Hello world"

Compute maximum running sum inside a list of numbers:

|/0(0|+)\

Sudoku solver:

p,:3/:_(p:9\:!81)%3
s:{*(,x)(,/{@[x;y;:;]‘&21=x[&|/p[;y]=p]?!10}’)/&~x}

N-queen solver:

qn:{[n],/{:[n=#*x;,*x;,/_f'f x,\:/:(!n)_dvl,/x]}’(f:0 -1 1+/:)@!n}
bd:{[p]`0:”.Q”p=\:!#p}

You still think Perl is terse?

この iota ってのもなかなか。

cite="http://stackoverflow.com/questions/187715/what-is-your-favorite-esoteric-programming-language" title="What is your favorite esoteric programming language? - Stack Overflow">
Iota:
http://barker.linguistics.fas.nyu.edu/Stuff/Iota/#iota

an unambiguous Turing-complete language with just two symbols. Iota exploits the 
amazing fact that any combinator (i.e. lambda-definable term) can be written using 
only the two combinators S (lambda (x) (lambda (y) (lambda (z) ((x z) (y z))) and K 
(lambda (x) (lambda (y) x).

This fact is closely tied to the Curry-Howard isomorphism: the types of combinators 
correspond to tautologies of propositional logic. For example, the type of K is A -> B 
-> (B -> A). Read A, B, C as variables and -> as implication. Try S: A -> B -> C -> 
((A -> C) -> (B -> C). Even more, any tautology can be derived from S and K using 
modus ponens. Why? The rules (for abstraction and application) in typed 
lambda-calculus correspond to the rules (for introduction and elimination of 
implication) in a natural deduction system.

■_ FQA

FAQ ではなくFQA。

Writing Your Own Toy Compiler Using Flex, Bison and LLVM : programming
I find tools like Flex and Bison a bit outdated.

Bison only accepts LALR(1) grammars so that means you are limited to one token of 
lookahead. I am not even sure if GCC uses Bison for parsing C++.

For parser generators, I prefer ANTLR, it has a lot more features and works with 
multiple languages. But in general, I now favor a completely different approach called 
parser combinators, where there is no code generation, instead you express the grammar 
directly in the code by combining different operators (kind of like a EDSL). Although 
this approach is not really viable if your compiler implementation language is java or 
C++.

It has features that are not immediately obvious if you approach it with basic yacc 
functionality in mind:

    * GLR Parsers
    * Reentrant Parsers

    limited to one token of lookahead

Sure enough, wikipedia seems to state that ANTLR is LL(*). An interesting paragraph:

    There is contention between the "European school" of language design, who
    prefer LL-based grammars, and the "US-school", who predominantly prefer 
    LR-based grammars.[citation needed] This is largely due to teaching traditions and
    the detailed description of specific methods and tools in certain text books; another 
    influence may be Niklaus Wirth at ETH Zürich in Switzerland, whose research has 
    described a number of ways of optimising LL(1) languages and compilers.

I always wanted a "universal" parser generator that furthermore doesn't 
strip control from your hands, ie. you are the one passing input to the generated 
parser(s), it's not the parsers taking their own input while you stand by. So I wrote 
a library called Externally Driven Parser, where you specify the LR(1) grammar 
programmatically. It proved to be more of a programming exercise than production code :) 
I guess the API is horrible, performance is without doubt horrible. The code is 
correct, I think, though, and it passes a malloc() test very similar to the 
Out-Of-Memory Testing of SQLite.

I used the word "universal" in the sense that

    Every LR(k) grammar for k > 1 can be mechanically transformed into an LR(1) 
    grammar for the same language

(quote)

    I am not even sure if GCC uses Bison for parsing C++.

It can't, C++ has no context-free grammar. See eg. here or here. I believe I read 
somewhere that g++ employs a "convolution" (very wrong word here, I know) of 
otherwise separate compiler components; ie. the lexer, the parser, decorating with 
attributes all reach over to each other. Or something like that :)

C++ の構文規則は LALR(1) じゃないじゃんという話経由で C++ FQA Lite: Defective C++



C++ FQA Lite: Defective C++

This page summarizes the major defects of the C++ programming language (listing all 
minor quirks would take eternity). To be fair, some of the items by themselves could 
be design choices, not bugs. For example, a programming language doesn't have to 
provide garbage collection. It's the combination of the things that makes them all 
problematic. For example, the lack of garbage collection makes C++ exceptions and 
operator overloading inherently defective. Therefore, the problems are not listed in 
the order of "importance" (which is subjective anyway - different people are 
hit the hardest by different problems). Instead, most defects are followed by one of 
their complementary defects, so that when a defect causes a problem, the next defect 
in the list makes it worse.

いろいろと面白そうな回答がそろっているので、ぜひ誰か訳(ry

■_ ヲチ

Ruby 初心者スレッド Part 31

172 デフォルトの名無しさん [sage] 2009/09/19(土) 14:23:19 ID: Be:
    "[hoge]"とか"{hoge}"みたいな文字列の前後の括弧を取り外すのに

    "[hoge]".sub(/\[(.+?)\]/){$1}

    なんかじゃなくて、なんかもっとスマートな方法はありませんか? 

173 172 [sage] 2009/09/19(土) 14:26:22 ID: Be:
    できれば
    "[hoge]".split(//)[1...-1].join
    も無しの方向で。 

174 デフォルトの名無しさん [sage] 2009/09/19(土) 14:28:01 ID: Be:
    "[hoge]"[1...-1] では駄目と申すか。 

175 デフォルトの名無しさん [sage] 2009/09/19(土) 14:36:42 ID: Be:
    String[] の動作が期待に添っていて、短いのがスマートだと勘違いしているのなら、>>174
    そのまんまの正規表現でマッチした部分を取り出す以上のわかりやすいスマートなものはないかと思われ

    str =~ /\A[\(\{\[<](.+?)[\)\]\}>]\Z/; $1

    開きカッコの対応を取るライブラリは標準では無いので自作してくれ 

176 デフォルトの名無しさん [sage] 2009/09/19(土) 14:38:04 ID: Be:
    というかカッコの対応は正規表現では本来書けない。
    とCマガで大昔に読んだけど、最近の拡張しまくりのだと可能かもなー。

177 デフォルトの名無しさん [sage] 2009/09/19(土) 14:48:30 ID: Be:
    後ろの1文字はchopで毟れるけど、先頭の1文字を毟り取るメソッドっ
    てないよな。

178 デフォルトの名無しさん [sage] 2009/09/19(土) 14:51:08 ID: Be:
    >>177
    その手があったか

    "[hoge]".chop.reverse.chop.reverse 

179 デフォルトの名無しさん [sage] 2009/09/19(土) 14:52:59 ID: Be:
    >>178
    ちょwwwwwプwwwww 

180 デフォルトの名無しさん [sage] 2009/09/19(土) 14:54:21 ID: Be:
    小橋の回転チョップを思い出した 

181 デフォルトの名無しさん [sage] 2009/09/19(土) 17:26:08 ID: Be:
    右のほうをチョップされたら左のほうを差し出せ 

182 デフォルトの名無しさん [sage] 2009/09/19(土) 20:20:22 ID: Be:
    ×ほう
    ○ほお 

183 デフォルトの名無しさん [sage] 2009/09/19(土) 20:28:43 ID: Be:
    >>172
    "[hoge]"[/\[(.+?)\]/, 1]
    とも書ける。

    >>175
    Onigurumaならできるはず。 

184 デフォルトの名無しさん [sage] 2009/09/19(土) 21:00:13 ID: Be:
    すんません。このスレどっからドコまで自作自演なんてしょうか? 

185 デフォルトの名無しさん [] 2009/09/19(土) 21:06:16 ID: Be:
    ココまで俺の自演 

■_ 本日の巡回から

2009年09月18日

■_

アリスカラーのホイホイさんフィギュア欲しい喃。

・読んだ
Amazon.co.jp: だから、新書を読みなさい: 奥野 宣之: 本 自分にはあまりあってなかったかな。 内容にはなるほどと思わせる部分も少なからずあったのだけど、 ちょっとなーと気になるところがいくつかあって、そのせいで印象が悪くなっているような気がする。 たとえば、 p61 の 「新書にはロングセラーが多い」という下りとか、 p71 の 総じて、玉石混淆の単行本の世界に比べて、 新書の書き手は比較的質が高いので安心して読める。 とか。

・書肆アクセスという本屋があった
書肆アクセスという本屋があった―神保町すずらん通り1976‐2007
書肆アクセスという本屋があった―神保町すずらん通り1976‐2007
まだ途中までしか読んでないけどこれは良かった。 さらに新刊ではなくて2007年の本ではあるのだけど。 この本で書かれているような書店は、greentea さんの望んでる形をある程度表しているのかも。

・IRC
クライアントソフトのインストール完了。

■_ 予告編

最後のほうでかなり悩んでますw

The Lisp Machine
The Lisp Machine:
Noble Experiment Or Fabulous Failure?
Draft 11 July 1991
P. T. Withington
Symbolics, Inc.

The "Lisp Machine", a custom computer work-station designed specifically for
the execution of Lisp, has been an important part of the Lisp tradition for 20 years.
Recently, the Lisp Machine has been deprecated in view of the demise of many Lisp
Machine vendors, the swing towards standardization, and the advances that reduced
instruction set (RISC) architectures have brought. But rumors of its death are greatly
exaggerated.

Lispを実行するのに特化して設計されたカスタムワークステーションである “Lispマシン”
は二十年にわたりLisp の重要な部分でありました。近年、多くの Lisp マシンベンダーの終焉
を目にしてLisp マシンは deprecated (不賛成、非難)されるようになっていて、標準化の方向
へと方向転換して縮小命令セット (RISC) アーキテクチャーが伸びてきました。しかし、Lisp
マシンの死の風評は非常に誇張されたものなのです。

Unlike most commercial computer languages, Lisp has always been a language of ideals.
Its roots are in the theory of lambda-calculus. Whereas other languages burden the
programmer with implementational gaps in their abstractions, Lisp has always had the
aim of supporting complete abstractions.[1] This idealistic bent of Lisp has led to it
often being the language of choice for computer-oriented research in universities and
industry. Removing the more mundane difficulties of computer programming allowed
researchers to experiment with super-complex (at the time) technologies such as
windowing, presentation managers, object-oriented programming, integrated programming
environments, computer music, integrated-circuit design, and of course Artificial
Intelligence (AI).

大部分の商用コンピューター言語とは違い Lisp は常に language of ideals でした。Lisp と
いう言語のルーツには λ計算があります。Lisp 以外の言語がその抽象化における実装的ギャッ
プ (implementational gaps in their abstractions)でプログラマーを苦しめていたのに対して、
Lisp は常に complete abstractions.[1] をサポートすることを目指していました。この Lisp
の idealistic bent は大学や産業界における computer-oriented research 向けの language
of choise でした。より多くのコンピュータープログラミングに関する mundane difficulties
(ありふれた困難?) を取り除くことによってプレゼンテーションマネージャー、オブジェクト指
向プログラミング、統合プログラミング環境、コンピューター音楽、集積回路の設計、そしても
ちろん人工知能 (AI, Artificial Intelligence) といった(当時は)非常に難しいことの実験を
研究者が行うことを可能にしたのです。


But, Lisp's purity did not come without a price. The choice by many languages to
expose implementational limitations is often a choice of efficiency. The speed of the
normal case is optimized at the risk of the abnormal case going undetected. Lisp, on
the other hand, guarantees the unusual as well as the usual will be dealt with
uniformly. It must always be on its guard: every operation must be checked for
exceptions. As a consequence, Lisp on conventional machines has historically been
ponderous to work with.

しかし Lisp の purity (純粋さ) は価格から来たものではありませんでした。多くの言語で為
された expose implementational limitations (実装上の制限の表面化?) のための選択はしば
しば choice of efficiency (効率のための選択?) でした。通常のケースでの速度は正常でない
ケースを検出しない場合もあるというリスクの上で最適化が行われていました。一方 Lispでは
unsusalなものは は usual なものと同じように統一的に扱われていて、すべての操作で例外の
検査を行われることが要求されていました。その結果として conventional machines 上の Lisp
はそういった検査を行っているために伝統的に動作が重いものになっていたのです。

■_

同じくλと申せども

C++0xの新機能「ラムダ式」を次期Visual Studioでいち早く試す(3/3):CodeZine
キャプチャ(capture)とは

 ラムダ式中で使えるオブジェクトは引数で受け渡された変数だけでなく、例えば上記のように
std::coutのようなグローバルなインスタンスが使えます。

 また、スコープ内のautomatic変数をラムダ式内部にキャプチャする(抱き込む)ことができ
ます。この場合は[]内にキャプチャする変数名を指定します。

#include <iostream>

int main() {
  int n = 123;
  auto capt_print =
    [n]() { std::cout << n << " をキャプチャしています\n"; };
  capt_print(); // "123 をキャプチャしています"
}

 キャプチャは、ラムダ式が定義された時点で行われます。そのため、このサンプルにおいてラ
ムダ式の定義の後でnの値を変更しても、既にキャプチャされているので、capt_print()は、
"123 をキャプチャしています"を出力します。

int n = 123;
auto capt_print =
  [n]() { std::cout << n << " をキャプチャしています\n"; };
n = 456; // ラムダ式の評価には影響を及ぼさない
capt_print(); // "123 をキャプチャしています"

 ここで、試しにラムダ式の評価の度にnをインクリメントしてみましょう。キャプチャされた
変数をラムダ式内部で変更するには、ラムダ引数の後にmutableを指定します。

#include <iostream>

int main() {
  int n = 123;
  auto capt_print =
    [n]() mutable { std::cout << n++ << " をキャプチャしています\n"; };
  capt_print(); // "123 をキャプチャしています"
  capt_print(); // "124 をキャプチャしています"
  capt_print(); // "125 をキャプチャしています"
  std::cout << "n = " << n << std::endl;
}

 …おや? キャプチャされた変数nは、ラムダ式の評価後に変更されていませんね。これは変数
nの「値」がキャプチャされたからです(値キャプチャ)。ラムダ式の評価によってキャプチャ
された変数を変更したいときは。「参照キャプチャ」を用います。

参照キャプチャの例

#include <iostream>

int main() {
  int n = 123;
  auto capt_print =
  // ↓この'&'が参照キャプチャを意味する
    [&n]() { std::cout << n++ << " をキャプチャしています\n"; };
  capt_print(); // "123 をキャプチャしています"
  capt_print(); // "124 をキャプチャしています"
  capt_print(); // "125 をキャプチャしています"
  std::cout << "n = " << n << std::endl; // "n = 126"
  n = 456;
  capt_print(); // "456 をキャプチャしています"
  std::cout << "n = " << n << std::endl;// "n = 457"
}

(以下略)

以前にも書いたことなんですが、このラムダ式を使ったC++のコードってどんな機械語 (or アセンブリ言語)に落ちるんでしょうか。 特に、ラムダ式からその外側のスコープに属する変数(上の説明で言うと 「キャプチャされている」変数ですか)をアクセスするときにどういうコードになっているか。 とか。

むかーし、Pascalコンパイラを作ったときに、 関数(手続き)の中にある関数(手続き)をほかの関数に対する引数として渡したときに きちんと動くように、内側の関数の変数のスコープを管理したりするのがえらく大変だった 記憶があります。 つか、あの Turbo Pascal でさえ Versioon 4.0 あたりまでこの辺の仕様は 標準 Pascalに劣ったものだったはず。

■_ ヲチ

前スレに輪をかけて

C++0x 7 

5 デフォルトの名無しさん [sage] 2009/09/18(金) 22:37:59 ID: Be:
    C++学園の人々

    ○コンセプトさん
    ついに一度も登校することなくお星様になってしまった。
    この事件によって学園に激震が走り、入学式が一年延期になる事態に。
    彼女の再起はあるのだろうか。

    ○ラムダさん
    コンセプトさんに代わって新入生代表に抜擢されることに。
    だが服が汚い上デザインが二転三転してるのでよくいじめられる。
    コンセプトさんと同じ目に遭わないかと内心ビクビクもの。

    ○右辺値参照さん
    一足先に本格的な通学を始めつつある新入生。
    よく出来た子として先生方には評判が高いが、
    気難しいので普通の生徒たちからは敬遠されている。

    ○拡張for文さん
    forさんの妹。コンセプトさん問題の一番の被害者。
    きったない服で通学することになりテンションガタ落ち中。

    ○type_traitsさん
    ライブラリ科の新入生。
    コンセプトさんの代役としてにわかに注目を集め始めた。
    思わぬスポットライトに浮かれすぎで最近テンションがやばい。

    ○static_assertさん
    type_traitsさんの相方としてこちらも注目を集める新入生。
    面倒な相手との仕事が増えそうで最近憂鬱。
    assertさんの妹だが、マクロ科と予約語科の立場の違いで仲が悪い。 

6 デフォルトの名無しさん [sage] 2009/09/18(金) 22:38:09 ID: Be:
    ○initializer_listさん
    vectorさんが泣いて喜ぶコンテナ部悲願の新人。
    だが似たような服を着た生徒が元から多いので、一部では
    「またややこしい奴が来た」と陰口を言われているらしい。

    ○テンプレート可変長引数さん
    テンプレ部が泣いて喜ぶ期待の新人。部の熱狂的な歓迎ぶりと
    「変態が増えた」と嘆く周囲の温度差に困惑中。
    stdargさんとは顔がよく似てるが血の繋がりはない。

    ○autoさん
    地味で消えそうだった子が一転、イメチェンで今やモテモテに。
    そのあまりの変貌ぶりに周囲は戸惑いを隠せない。
    最近まで同じ立場だったregisterさんの胸中はいかに…

    ○decltypeさん
    autoさんの妹の新入生。姉が記憶クラス科にいた過去は知らない。
    姉に劣らぬ人気者だが、服装のちょっとした違いで性格が変わる面倒な一面も。

    ○ユーザー定義リテラルさん
    「わかりにくい」「見るからにきもい」「関数さんでいいじゃん」と
    すこぶる評判の悪い新入生。強く生きていって欲しい。

    ○nullptrさん
    「今さら来られても……」「なんで今までいなかったの?」という
    心ない陰口に傷ついている地味な新入生。

    ○long longさん
    え?新入生だったの?

    ○禿
    校長先生。 

7 デフォルトの名無しさん [sage] 2009/09/18(金) 22:46:04 ID: Be:
    >>5-6
    乙 

8 デフォルトの名無しさん [sage] 2009/09/18(金) 22:54:08 ID: Be:
    > きったない服で通学することになりテンションガタ落ち中。

    ここで爆笑した 

9 デフォルトの名無しさん [sage] 2009/09/18(金) 22:57:04 ID: Be:
    ・Raw String Literalさん
    なんだかよく分からないアクセサリーを頭とお尻に付けている。
    しかもアクセサリーは日替わり。

    ・auto_ptrさん
    落第。一応、まだ学校にはいる。

    ・unique_ptrさん
    auto_ptrさんを蹴落として進級してきた。

    ・Smart pointerさん
    とても頭がいいが、循環参照も扱えるかどうかは、学校によって異なる。

    ・Unordered associative containerさん
    いつも、とても大きなカバンを引きずっている。
    ただし、カバンから物を取り出すのはとても早い。

    ・Regular expressionさん
    頭は良いらしいのだが、何を言っているのかよく分からない。
    周囲からは中二病だと思われている。

    ・Atomic operationさん
    細かいことばかり気にしている神経質な子。
    口癖は、「だってその可能性はゼロじゃないし~」

    ・threadさん
    カバンも持たずに登校してくるミニマリスト。
    ペンと紙一枚あればそれで十分でしょと言い張る。
    どうしようもないときは、魔法の言葉、「ねぃてぃぶ・はんどる~」を唱えると、とりあえず何とかなる。


10 デフォルトの名無しさん [sage] 2009/09/18(金) 23:13:33 ID: Be:
    ・type_indexさん
    type_info君と仲が良いらしい。
    噂では、いくとこまでいったとかいってないとか。
    ただし、開校前のクラス分けで離ればなれになってしまった。

    ・System error supportさん
    いじめられて転校してきたらしい。
    たぶん、どの学校でも相手にされない子。
    ほとんどの学校には、学校独自の、もっとマシな子がいるし。

    ・Tupleさん
    博愛平等主義者。ほとんどのクラスメートと仲が良い。

    ・Binder姉妹(bind1st,bind2nd)
    落第。一応、まだ学校にはいる。

    ・Function template bindさんと、Polymorphic function wrapperさん
    二人とも、とても頭が良い。
    なんでも、「ぶーすと」という一流の進学校から転校してきたらしい。
    あまりに成績が良かったために偏差値を押し上げて、Binder姉妹を落第させる原因をつくった。

    ・Time utilitieさん
    2038年問題も3000年問題も大丈夫と豪語。

    ・Compile-time rational arithmetic君
    Time utilitieさんと仲が良いらしい。 

11 デフォルトの名無しさん [sage] 2009/09/18(金) 23:21:05 ID: Be:
    だんだん説明が投げやりになってるなw

    あとは擬人化だ
    絵師を呼べ! 

12 デフォルトの名無しさん [sage] 2009/09/18(金) 23:30:46 ID: Be:
    lambdaが消されることはまずないよ。
    range-based forとかuser defined literalsは、このままだと問題が多いと思うけれど。 

13 デフォルトの名無しさん [sage] 2009/09/18(金) 23:35:16 ID: Be:
    >服装のちょっとした違いで性格が変わる面倒な一面
    括弧のことか。 

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

44 デフォルトの名無しさん [sage] 2009/09/18(金) 02:07:47 ID: Be:
    mallocは"エムアロック"と読むのであって断じて"マロック"は許されない。
    mallocを"マロック"って読むというのならじゃあcallocのことは"キャロック"と読むのかと。
    mallocのことは”マロック"と読んでおいてcallocのことは"シーアロック"と読むような
    そんな統一感のない人き方は軽蔑されるべきだ。同様にcharを"キャラ"と読むならintは"インテ"と読まないなら市ね!! 

45 デフォルトの名無しさん [] 2009/09/18(金) 02:15:55 ID: Be:
    callocはカロックだろ。
    もちろん、mallocはマロックだ。 

46 デフォルトの名無しさん [sage] 2009/09/18(金) 02:19:31 ID: Be:
    キャラとイントでサーセン 

48 デフォルトの名無しさん [sage] 2009/09/18(金) 04:40:24 ID: Be:
    イントと読む人はcharをなんと発音すれば?キャル? 

49 デフォルトの名無しさん [sage] 2009/09/18(金) 04:41:26 ID: Be:
    チャー 

63 デフォルトの名無しさん [sage] 2009/09/18(金) 16:16:42 ID: Be:
    charをキャラと読む人は
    intをインテ
    macをマッキ
    と読んでいる。 

64 デフォルトの名無しさん [sage] 2009/09/18(金) 18:51:21 ID: Be:
    呼んでない 

■_ 本日の巡回から

2009年09月17日

■_

・副都心線
今朝もまた西武池袋線で発生した事故の影響で 副都心線のダイヤが狂っていたようです。 本当にこれで東横線とも接続して相互乗り入れが始まったらどうなってしまうのだろう。 朝の東横線でダイヤが狂うと結構影響でかいんだなあ。

・勘弁してくれ
戦国BASARAのDVDは手を出してないんだよ~

GA Graphic:戦国BASARA DVD初回版全巻購入特典はOP足軽ダンスのスペシャルDVD!

現在DVDシリーズが絶好調リリース中の「戦国BASARA」について、初回限定版の全巻購入者特典
が発表された。

 DVD初回限定版全7巻を購入した人全員に、あの話題沸騰のオープニング「足軽ダンス」完全フ
ルバージョンほかを収録したDVDがプレゼントされる。これを見れば、足軽ダンサーズによる
「足軽ダンス」を完全マスターできるぞ。

好きなんだよ足軽ダンスw

■_ これでラスト

最後はちょっと分類が違うけど。

Signs that you're a bad programmer ?(Software Engineering Tips)?
Signs that you shouldn't be a programmer
(あなたがプログラマーになるべきではない兆候)

The following may not have any remedies if you still suffer from them after taking a
programming course in school, so you will stand a better chance of advancing your
career by choosing another profession.

以下に挙げる項目は、学校のプログラミングコースを履修した後でもまだ残っていてもそれに対
する治療法が一切存在していないものである。したがって、もし一つでも該当するものがあった
なら、another profession (別の専攻?) を選択しchance of advancing your career を待つの
別の仕事を選んでキャリアを重ねる機会を待つ
が望ましい。

1. Inability to determine the order of program execution
   プログラムが実行される順序を判断できない

Symptoms

a = 5
b = 10
a = b

print a

1. You look at the code above and aren't sure what number gets printed out at the end
  上記のコードを見ても、どういった順序で実行されて最後に何が出力されるのかに自信がない。

Alternative careers

  1. Electrician
  2. Plumber
  3. Architect
  4. Civil engineer

2. Insufficient ability to think abstractly (抽象的に考える能力の不足)

Symptoms

  1. Difficulty comprehending the difference between objects and classes
     オブジェクトとクラスの間の違いを把握し理解することが困難

  2. Difficulty implementing design patterns for your program
     自分のプログラムでデザインパターンを実装することが困難。

  3. Difficulty writing functions with low cohesion
     結合性の低い(low cohesion) 関数群を記述することが困難

  4. Incompetence with Regular Expressions
     正規表現を扱う能力がない

  5. Lisp is opaque to you
     Lisp は自分にとっての意味不明 (opaque) のものだ

  6. Cannot fathom the Church-Turing Thesis
     Church-Turing Thesis (チャーチ・チューリング理論?) を理解できない

Alternative careers

  1. Contract negotiator
  2. Method actor

3. Collyer Brothers syndrome (Collyer 兄弟症候群)

Symptoms

  1. Unwilling to throw away anything, including garbage
     ゴミさえも捨てるのを惜しむ

  2. Unwilling to delete anything, be it code or comments
     何かを削除することを嫌い、コードにしたりコメントにする

  3. The urge to build booby-traps for defense against trespassers
     不法侵入者 (trespassers) に対する防衛としてブービートラップを仕掛けることを
     強硬に主張する

  4. Unwilling to communicate with other people
     他の人間とコミュニケートするのを好まない

  5. Poor organization skills
     貧しい organization skills

Alternative careers

  1. Antique dealer
  2. Bag lady

4. Dysfunctional sense of causality

Symptoms (症状)

  1. You seriously consider malice to be a reason why the compiler rejects your program

     コンパイラーが自分のプログラムを拒絶するのは(コンパイラーの)悪意のためだと本気で思い
     込んでいる。

  2. When called on to fix a bug in a deployed program, you try prayer

     deploy 済みのプログラムに存在するバグを修正するために呼び出したときに prayer を試す

  3. You take hidden variables for granted and don't think twice about blaming them
     for a program's misbehavior

     隠し変数 (hidden variables) を作ってしまい、そういった変数がプログラムの
     誤動作 (misbehavior) の原因だと考えない

  4. You think the presence of code in a program will affect its runtime behavior,
     even if it is never invoked

     プログラム中に存在しているコードはそれが決して実行されないものであっても、
     実行時の挙動に影響を及ぼすと考えている。

  5. Your debugging repertoire includes rituals like shining your lucky golf ball,
     twisting your wedding ring, and tapping the nodding-dog toy on your monitor. And when
     the debugging doesn't work, you think it might be because you missed one or didn't do
     them in the right order

     デバッグ手法のレパートリーに、幸運のゴルフボールを磨く (shining your lucky golf ball) 
     とか結婚指輪を twisting する、モニターに乗っている nodding-dog toy をタップするなどの
     ような儀式 (rituals) がある。そしてデバッグがうまくいかないとき、それは儀式を一つ忘れ
     ていたり、正しい手順で行わなかったためかもしれないと考える。

Alternative careers

  1. Playing the slot machines in Vegas
     ラスベガスでスロットマシーンをプレイする

5. Indifference to outcomes

Programming could still be a hobby for you, but it would be in society's best
interests to defend itself against your entry into the world of professional software
development.

それでもまだプログラミングをあなたの趣味とすることもできるだろう。しかし、あなたがソフ
トウェア開発のプロの世界 (the world of professional software development)に足を踏み入
れないままでいることが社会にとっての最善の道かもしれないのだ。

Symptoms (症状)

  1. You aren't interested in fixing a bug that can be worked around by rebooting the
     computer

     コンピューターをリブートするというワークアラウンドが使えるときにバグを修正するのを
     嫌がる

  2. Your installation program silently deploys unsolicited third party programs that
     are unrelated to the function of yours *

     インストールプログラムがあなたのプログラムの機能に関係ない unsolicited なサード
     パーティ製のプログラムを黙って deploy してしまう。

  3. You don't use any ergonomic model when designing user interfaces, nor do you
     have any interest in usability studies

     ユーザーインターフェースの設計をするときに ergonomic model を一切使わないし
     ユーザビリティの学習ということにまるで興味がない

  4. Your program exhibits pretension and grandeur beyond its utility, eg: displaying
     splash screens over active programs while loading in the background, or placing
     multiple launch icons in premium desktop locations *

     あなたのプログラムがその utility の領分を越えて過剰に自己主張する。たとえば、バック
     グラウンドでロードしている間じゅう、アクティブなプログラムの上にスプラッシュスクリー
     ンを表示してしまったり、あるいは複数の起動アイコンをデスクトップの一等地に置いてしま
     うなど。

  5. Your program produces output to be read by another (eg: a browser), or implements
     a network protocol, and relies on the other party's software to be significantly
     tolerant to spec violations

     プログラムは他のプログラム(たとえばブラウザー)によって読み込まれる出力を生成する。
     あるいはネットワークプロトコルを実装してしまったり be significantly tolerant to
     spec violations のためにほかの会社のソフトウェアに依存してしまう

  6. You write busy-wait loops even when the platform offers event-driven programming

     イベントドリブンなプログラミングが推奨されているプラットフォームであっても
     ビジーウェイトするループを書いてしまう

  7. You don't use managed languages and can't be bothered to do bounds checking or
     input validation

     マネージド言語を使わないし、境界チェックや入力の検査を行うのに bothered できない。

  8. Your user interfaces do not make the difficulty of accidentally invoking a function
     proportionate to its destructiveness (eg: the "Delete Database" button is
     next to "Save", just as big, has no confirmation step and no undo)

     ユーザーインターフェースを、破壊的な操作を行う機能を誤って実行されにくいようにして
     おかない (たとえば“データベースの削除”ボタンが“保存”のボタンのすぐ隣に、同じく
     らいの大きさで置かれていて、しかもボタンを押しても確認のステップがないしアンドゥも
     できないようなもの)

  9. You don't use whitespace, indentation or comments

     空白やインデント、コメントといったものを使わない

* - These are actually imposed by management more often than by the programmer, who
only implements them. We'd still group them together for the sake of this self-test,
though, and at the most suggest that one seek employment at a better firm, while the
other goes back to business school to learn less destructive ways of making a profit.

Alternative careers

  1. Debt collection
  2. Telemarketing

_displayNameOrEmail_ - _time_ - Remove

_text_

 Sign in   Terms   Report Abuse   Print  |  Powered by Google Sites


Signs you may be a bad programmer : programming
http://www.reddit.com/r/programming/comments/98c14/signs_you_may_be_a_bad_programmer/

■_ Hello HAIKU

BeOSのなれの果てがオープンになって開発が続けられたものですが、 つい先日めでたく 1.0 がリリースということに。 BeOSでのプログラミングはやったことがないのですが、 C++を積極的にサポートしてたような記憶が。 んで、BeOS での hello, world 的なプログラムを。 Programming for Haiku: Hello World « Rob Hoelz’s Blog

#include <Application.h>
#include <Button.h>
#include <Window.h>
#include <stdio.h>

const int32 HELLO_HAIKU = 'HELO';

class HelloWindow : public BWindow
{
    public:
    HelloWindow(BRect frame) : BWindow(frame, "Hello Window", B_TITLED_WINDOW, 0)
    {
	BView *view = new BView(Bounds(), NULL, B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
	AddChild(view);
	BButton *button = new BButton(view->Bounds(), NULL, "Hello", new BMessage(HELLO_HAIKU));
	view->AddChild(button);
    }

    bool QuitRequested()
    {
	be_app_messenger.SendMessage(B_QUIT_REQUESTED);
        // or be_app->PostMessage(B_QUIT_REQUESTED);
	return BWindow::QuitRequested();
    }

    void MessageReceived(BMessage *msg)
    {
	switch(msg->what) {
	    case HELLO_HAIKU:
		printf("Hello, Haiku!\n");
		break;
	    default:
		BWindow::MessageReceived(msg);
	}
    }
};

class HelloHaiku : public BApplication
{
    public:
    HelloHaiku() : BApplication("application/hello-haiku")
    {
    }

    void ReadyToRun()
    {
	BWindow *win = new HelloWindow(BRect(100, 100, 300, 200));
	win->Show();
    }
};

int main(void)
{
    HelloHaiku app;

    app.Run();

    return 0;
}

  

ウィンドウシステムのプログラムとしては(C++を使っているというのは置いといて) それほど変わったものでもない? プログラムの詳しい解説は、元記事にありますので興味のある向きはどうぞ。

ところで、Smalltalkとか、Altoのウィンドウ描画ってどういう感じでハンドリングしてたんでしょう? やっぱりなんかしらのウィンドウメッセージとコールバックの組み合わせのようなものなんだろうか。

■_UTF-8 の冗長表現

や、冗長表現ってのが正しい呼び方かはあれですが、よろしくお察しください。 んで、 Route 477 - Tab Sweep 経由で UTF-8の冗長なエンコードとは何で、なんでそれがセキュリティ的に危ないのか?を文字コード知識レヴェル3くらいの凡プログラマが考えてみる - それ図解で。・・・tohokuaikiのチラシの裏

UTF-8の冗長なエンコードとは何で、なんでそれがセキュリティ的に危ないのか?を文字コード知識レヴェル3くらいの凡プログラマが考えてみる - それ図解で。・・・tohokuaikiのチラシの裏
しかし、これを「このよう事は簡単に理解できると思っていたので、」と言っちゃうohgakiさんには
      r ‐、
      | ○ |         r‐‐、
     _,;ト - イ、      ∧l☆│∧  セキュリティ エバンジェリストの諸君!
    (⌒`    ⌒・    ¨,、,,ト.-イ/,、 l  われわれPHPerにとって大切なのは
    |ヽ  ~~⌒γ⌒) r'⌒ `!´ `⌒)  すぐ使えるサンプルか、コピペで動くコードだけだ。
   │ ヽー―'^ー-' ( ⌒γ⌒~~ /|  PHPerを買いかぶらないでもらいたい
   │  〉    |│  |`ー^ー― r' |
   │ /───| |  |/ |  l  ト、 |
   |  irー-、 ー ,} |    /     i
   | /   `X´ ヽ    /   入

と、言いたい。

ウケた。っとここは本題ではないのだった。 これの次のエントリに力作があるのですが、その最後の最後。

アプリケーションがどうやってUTF-8を理解して表示しているのか?そして、なぜ「間違ったUTF-8エンコード」を解釈してしまうのかを考えてみた - それ図解で。・・・tohokuaikiのチラシの裏

しかし、UTF-8をDefineしたときは、こんな穴があるなんて思いもしなかったんだろう。

だけど、自分みたいなぺーぺーがこのコードの成り立ちを理解しようとすると「ハタ」と気付い
てしまって、「じゃあ・・・」って思ったりするんだな。初心者目線大切。

まあ最初の最初からというのは判断できませんが、RFCにまとめられている段階で

RFC日本語化計画 より

http://www.akanko.net/marimo/data/rfc/rfc2279-jp.txt

6.  セキュリティ対策

    UTF-8 の実装者は、どのようにそれらが不正ななUTF-8文字列を扱うかとい
  うセキュリティ面を考慮する必要がある。いくつかの状況で、攻撃者が、
  UTF-8構文により許されないオクテット列をそれに送り、不注意なUTF-8パー
  ザを利用することができることが想像可能である。

    この攻撃の特に微妙なフォームは、UTF-8符号化されたその入力に対して
  安全性調査を行なうパーザに対して実行され得る。しかしある不正なオクテッ
  ト列は文字と解釈される。例えば、パーザは、単一のオクテット列00として
  符号化される時に、NUL文字を禁止できるが、不正な2オクテット連続C0 80
  を誤って許し、それをNUL文字と解釈する。別の例は、オクテット列
  2F 2E 2E 2F ("/../")を禁止するパーザであるにも関わらず、不正なオクテッ
  ト列2F 0C AE 2E 2Fを許してしまう。

  
おなじく

http://www.akanko.net/marimo/data/rfc/rfc3629-jp.txt

10.  セキュリティ対策

   UTF-8 の実装者は、どのようにそれらが不正ななUTF-8文字列を扱うかとい
 うセキュリティ面を考慮する必要がある。いくつかの状況で、攻撃者が、
 UTF-8構文により許されないオクテット列をそれに送り、不注意なUTF-8パー
 ザを利用することができることが想像可能である。

    この攻撃の特に微妙なフォームは、UTF-8符号化されたその入力に対して
  安全性調査を行なうパーザに対して実行され得る。しかしある不正なオクテッ
  ト列は文字と解釈される。例えば、パーザは、単一のオクテット列00として
  符号化される時に、NUL文字を禁止できるが、不正な2オクテット連続C0 80
  を誤って許し、それをNUL文字と解釈する。別の例は、オクテット列
  2F 2E 2E 2F ("/../")を禁止するパーザであるにも関わらず、不正なオクテッ
  ト列2F 0C AE 2E 2Fを許してしまう。この最後の方法は、実際に2001年の間
  の広範囲に及んだWebサーバ攻撃ウイルスにおいて使われた; 従って、セキュ
  リティ面で現実の驚異である。

   別のセキュリティ問題は、UTF-8に符号化する際に起こる: UTF-8のISO/IEC 
 10646定義により、文字番号最大U+7FFFFFFFを符号化すると、最大で6バイト
 のシーケンスが作られる。従って、もし文字数の範囲がU+10FFFFに明示的に
 制限されないか、または、バッファサイズ制限により5あるいは6バイトシー
 ケンスの可能性が考慮されないならば、バッファオーバフローのリスクがあ
 る。


   セキュリティは、同じくUTF-8を含むいくつかの文字符号化の特性に潜んで
 いるかもしれない: 「同じもの」(利用者が話せるくらい遠く)は、いくらか
 の明白な文字列で表され得る。例えば、鋭アクセントを持つeは、従来からの
 U+00E9 E ACUTE文字、または正統的に等しいシーケンスU+0065 U+0301で表さ
 れているかもしれない(E + 連結用ACUTE)。例えUTF-8が単一バイト列を個々
 の文字列に提供しても、文字列一致調査、索引、検索、分類、正規表現との
 一致調査、および選択に関係する時には、いつでも「同じもの」のための複
 数の文字列の存在が、セキュリティ問題を持っている。例として、証明書と
 アクセス制御リストエントリに出現する識別子の文字列一致調査である。こ
 の問題は、Unicode標準化フォームに基づく解決策に従順である。[UAX15]を
 見よ。

  

という記述がありますから、「define したときにこんな穴があるとは思わなかった」 というのは違うんじゃないかなあ。

この種のセキュリティホールは C/C++セキュアプログラミングクックブック〈VOLUME1〉基本的な実装テクニック に詳しく載ってなかったかなあと思って確かめたら1ページしかなかったでござる(苦笑) C/C++セキュアコーディング (SEI SERIES・A CERT BOOK) こっちはどうだったかなあ。 現物が行方不明で確認できない。 関数呼び出しのスタックフレームの詳細(カナリーとか)なんかがあったのは覚えているのだけど。

■_ 本日の巡回から

2009年09月16日

■_

・EmEditor
なんか EmEditor 界隈で一騒動起きているようですね。 わたしはフリー版のインストールもしたことすらないのでよくわかりません。

・Open Watcom C/C++ Compiler
ただいまお試しちう。

■_ Signs that you're a bad programmer

あともうひとつ。

Signs that you're a bad programmer ?(Software Engineering Tips)?
4. Unfamiliar with the principles of security
  セキュリティの原則に不案内

If the following symptoms weren't so dangerous they'd be little more than an issue of
fit-n-finish for most programs, meaning they don't make you a bad programmer, just a
programmer who shouldn't work on network programs or secure systems until he's done a
bit of homework.

以下に挙げる症状がそれほど危険でないのなら、ほとんどのプログラマーにとっての
fit-n-finish の issue よりも重要ということはない。それらはあなたを bad programmer にす
るのではなくhe's done a bit of homework までは単にネットワークプログラムやセキュアなシ
ステムに関係すべきではないプログラマーにするということを意味する。

Symptoms (症状)

  1. Storing exploitable information (names, card numbers, passwords, etc.) in plaintext

     プレインテキストに (名前、カード番号、パスワードなどの)exploitable information を格納する

  2. Storing exploitable information with ineffective encryption (symmetric ciphers with the
     password compiled into the program; trivial passwords; any "decoder-ring", homebrew,
     proprietary or unproven ciphers)

     exploitable な情報の格納を効果的でない (ineffective) 暗号化 (コンパイルしたパスワードを
     プログラムに埋め込んだ symmetric ciphers、trivial なパスワード、すべての "decoder-ring",
     自家製暗号、プロプラだったり検証されていない暗号) を使って行ってしまう

  3. Programs or installations that don't limit their privileges before accepting
     network connections or interpreting input from untrusted sources

     ネットワークのコネクションをアクセプトする前や信頼できないソースからの入力を
     解釈する前に権限 (privileges) を制限しないプログラムやインストーラー

  4. Not performing bounds checking or input validation, especially when using
     unmanaged languages

     特にマネージドでない言語を使っているときに境界検査や入力のバリデーションを行わない。

  5. Constructing SQL queries by string concatenation with unvalidated or unescaped input

     バリデーションやエスケープをしていない入力と文字列連結を使って SQLのクエリーを組み立てる

  6. Invoking programs named by user input

     ユーザーが入力した名前を使ってプログラムを起動する

  7. Code that tries to prevent an exploit from working by searching for the
     exploit's signature

     exploit のシグネチャを検索することによって exploit からコードを防御することを試みる

  8. Credit card numbers or passwords that are stored in an unsalted hash

     ソルトを使っていないハッシュ (unsalted hash) にカード番号やパスワードを格納する

Remedies (治療)

The following only covers basic principles, but they'll avoid most of the egregious
errors that can compromise an entire system. For any system that handles or stores
information of value to you or its users, or that controls a valuable resource, always
have a security professional review the design and implementation.

以下に挙げたものは basic princliples (基本的な原則?) しかカバーしていませんがシステム全
体を compromise する可能性のある egregious なエラーの大部分を排除するであろうもので
す。あなたやシステムのユーザーにとって価値のある情報を取り扱ったり格納するようなシステ
ムだとか価値のあるリソースを制御するシステムについてはすべて、常にセキュリティの専門家
による設計と実装に関してのレビューを行うこと。

Begin by auditing your programs for code that stores input in an array or other kind
of allocated memory and make sure it checks that the size of the input doesn't exceed
the memory allocated for storing it. No other class of bug has caused more exploitable
security holes than the buffer overflow, and to such an extent that you should
seriously consider a memory-managed language when writing network programs, or
anywhere security is a priority.

あなたのプログラムの入力を配列やその他の割り当てたメモリに格納したりするコードがあるか
入力のサイズが格納するために割り当てられたメモリーの大きさを越えていないかどうかの検査
といった audititing から開始するバッファオーバーフローよりもさらに exploitable なセキ
ュリティホールになるようなバグのクラスはなく、ネットワークプログラムを書くときとかある
いはセキュリティが priority な場合にはメモリマネージド言語を使うことを真剣に考えるべき
なのだ。

Next, audit for database queries that concatenate unmodified input into the body of a
SQL query and switch to using parameterized queries if the platform supports it, or
filter/escape all input if not. This is to prevent SQL-injection attacks.

続いて unmodified な入力を連結して SQL クエリの本体にしているようなデータベースクエリ
を audit し、プラットフォームがサポートしている場合には parameterized queries  を使う
ように変更する。サポートがない場合にはすべての入力に対してフィルタリングとエスケープを
行うこれは SQLインジェクション攻撃に対抗するものである。

After you've de-fanged the two most infamous classes of security bug you should
continue thinking about all program input as completely untrustworthy and potentially
malicious. It's important to define your program's acceptable input in the form of
working validation code, and your program should reject input unless it passes
validation so that you can fix exploitable holes by fixing the validation and making
it more specific, rather than scanning for the signatures of known exploits.

セキュリティバグに関してふたつの最も悪名高いクラスを de-fanged したあとでも、プログラ
ムに対するすべての入力を完全に untrustworthy でありかつ malicious な可能性があるものだ
と考えつづけるべきである。あなたのプログラムがバリデーションコードが動作するフォームに
おいて受け入れ可能な入力とプログラムが reject すべき入力を定義することは重要である。
バリデーションに引っかかれば、バリデーションを修正し、かつそれをより specific にするこ
とで既知の exploits のシグネチャをスキャンするのではなくexploitable holes をふさぐこと
が可能である。

Going further, you should always think about what operations your program needs to
perform and the privileges it'll need from the host to do them before you even begin
designing it, because this is the best opportunity to figure out how to write the
program to use the fewest privileges possible. The principle behind this is to limit
the damage that could be caused to the rest of the system if an exploitable bug was
found in your code. In other words: after you've learned not to trust your input you
should also learn not to trust your own programs.

Going further,
あなたのプログラムが perform するのに必要な operations とそのためにホストから必要とさ
れる権限 (privileges)を設計を始めるよりさらに前に常に考えておくべき。なぜならそれは必
要最小限の権限だけを使ったプログラムの書き方を figure out する絶好の機会だから。この背
後に隠されている原則とは、あなたのコードに exploitable なバグが見つかったときにシステ
ムの残りの部分に対して引き起こされるダメージを限定するということ。言い換えると、入力を
信用しないと言うことを学んだ後では自分自身のプログラムも信用しないことを学ぶべきなのだ

The last you should learn are the basics of encryption, beginning with Kerckhoff's
principle. It can be expressed as "the security should be in the key", and
there are a couple of interesting points to derive from it.

最後に、あなたが学んでおくべきなのは暗号の基礎であり、Kerckhoff's の原則から始めよう。
これは "the security should be in the key" と表現することができ、そこから派
生するいくつかの興味深いポイントがある。

The first is that you should never trust a cipher or other crypto primitive unless it
is published openly and has been analyzed and tested extensively by the greater
security community. There is no security in obscurity, proprietary, or newness, as far
as cryptography goes. Even implementations of trusted crypto primitives can have flaws,
so avoid implementations you aren't sure have been thoroughly reviewed (including your
own). All new cryptosystems enter a pipeline of scrutiny that can be a decade long or
more, and you want to limit yourself to the ones that come out of the end with all
their known faults fixed.

第一に、ある暗号 (cipher) やその他 crypto primitive は、それが広く公開されていてかつ
greater なセキュリティのコミュニティによって解析され extensively にテストされるまでは
決して信用すべきではない。trusted crypto primitives の実装でさえも欠陥を持ってい
る可能性があるので、レビューされたどうかあなたが確信できていない実装は (あなた自身によ
る実装を含めて) 排除する。
すべての new cryptosystems (新規の暗号システム?) は pipeline of scrutiny に入る。
その scrutiny は十年以上になるかもしれず、
and you want to limit yourself to the ones that
come out of the end with all their known faults fixed.

The second is that if the key is weak, or stored improperly, then it's as bad as
having no encryption at all. If your program needs to encrypt data, but not decrypt it,
or decrypt only on rare occasions, then consider giving it only the public key of an
asymmetric cipher key pair and making the decryption stage run separately with the
private key secured with a good passphrase that the user must enter each time.

第二に、仮にキーが弱いものであったり不適切な格納をしていたらそれはまったく暗号化をしな
いのと同じくらい悪いことなのだ。あなたのプログラムがデータの暗号化を必要としているけ
れども複合は不要であったり、あるいは複合が滅多にないことであれば、非対称暗号キーのペア
(asymmetric cipher key pair) の公開キー (public key) だけを与えておき、複合ステージを
実行するには望ましいパスフレーズで secure にされたプライベートキー (private key) を毎
回ユーザーが入力しなければならないようにすることを考えよう。

The more is at stake, then the more homework you need to do and the more thought you
must put into the design phase of the program, all because security is the one feature
that dozens, sometimes millions of uninvited people will try to break after your
program has been deployed.

さらに問題なのは行わなければならないより一層の homework とプログラムの設計段階でもっと
考慮しておかなければならなかったことで、これらはすべて、セキュリティとは多くの機能の中
の一つであり、あなたのプログラムが deploy されたあとになってからときとして数百万もの招
かれざる客がそれを破ろうと試みることになるものだからだ。

The vast majority of security failures traceable to code have been due to silly
mistakes, most of which can be avoided by screening input, using resources
conservatively, using common sense, and writing code no faster than you can think and
reason about it.

The vast majority of security はつまらない失敗のために生じていて。 traceable にするの
に失敗している。それらのほとんどは入力のスクリーニングをするとかリソースを 
conservatively に使ったり常識を働かせるとかして、you can think and reason about it よ
りも早くなることなくコードを書くことによって除去可能である。

■_

Erlang のススメ


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

Tuesday, September 08, 2009

Erlang for Java Programmers

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

一つ前のポストで、わたしは自分の Javaに対する monogamous な関係
の終わりを宣言しました。
I really played the field for a little while, 
but it did not take long for an infatuation with Erlang to take hold. 
Clojure は runner up で すぐに explore しようと考えているものですが
二つの言語を同時にやるというのはちょっと大変だったのです。

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

Erlang は関数型の言語ですが、Java デベロッパーのようにわたしを scare したりしません。
構文は little out ですが そのコンセプトは map pretty neatlyです。


Immutability (不変性)

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

I have always erred on the naughty side with Java when it comes to the use of objects. 
I tend to have fairly struct like domain objects with getters and setters, 
and leave the business logic to manager type classes. 
I was never comfortable tying business logic to something 
I read out of the db and pass around and 
which may have different requirements in different apps. 
ですから関数型言語への切り替えもとても簡単なもので、
the main difference is instead of using setters,
主な違いは setter を使うのではなく
オブジェクトの pdating が clone/set combo にちょっとよっているということです。
これはメモリー浪費するものだろうと感じられるかもしれませんが、
 you get over it.


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

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

Java ではわたしのメソッドは最終的にはさまざなオブジェクトの状態に対してif/then/else  
テストをするものになる傾向があります。Erlang では case 文がエラーを返さない関数である
ことを保証されているものとして使われることがあります。 but not much else.  
そうではなく、Erlang は完全に新しいレベルのオーバーロードされたメソッドの考え方を採用
しています。パターンマッチングはとても理解しやすいもので、なおかつ信じられないくらい強
力なものです。各関数の入力はこれや関数の他のバージョンに対するダイレクトなflow in とし
て使うことが可能です。このことはコピペの山を招きかねないように聞こえるかもしれませんが、
far easier to reason about な関数の few succinct versions での結果となります。

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

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

わたしがErlang を取り上げた理由の主な一つが、Haskell のようなより伝統的な関数型言語よ
りもprocesses の考え方を推し進めているからです。副作用を除去し、状態がなくなることで何
がどうなるのかはわたしにははっきりとはわかりませんしかし Erlang は状態すべてを neatly 
にプロセスの内側に wrapped up してしまいました。Erlang におけるプロセスとは 
instantiated された関数です。
You heard that right, unlike in Java, where an object is an instantiated class, 
オブジェクトがインスタンス化されたクラスでありようなJava とは違っていて
in Erlang you run a function in a recursive loop forever. 
Erlang では再帰的なループの中で永久に関数を実行します。
Weird right? 
Well ethe only real trick to this is now that the loop is going infinitely,
自分の状態を自分自身に送りつけ、外側の世界と対話する手段が必要です。
receive block を関数の内側に押し込めることによって
他のプロセスがメッセージを送ってくるまでスリープします。
It will then wake, handle the message, 
(メッセージが届くと) プロセスは復帰しメッセージを取り扱って
ループしてからスリープ状態に戻ります。


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

考慮すべきコンセプトが他にもたくさんあります。たとえば OTP には触れませんでしたが、こ
れは 最初の Erlang 本を読んでいるときにわたしが遭遇した main hurdles です。Joe 
Armstrong の本は fantastic だと思いますし、新しい O'Reilly の本も同じく solid なもので
す。

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

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

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

■_

greetea さんに説教くらいそうなネタw

C definition formatting question - Stack Overflow
http://stackoverflow.com/questions/1419087/c-definition-formatting-question

I am thinking about changing my formatting style. I have been doing this:

char *foo(IULabel *label, char *buffer) {

まあ、引数リストやらのインデントどうします。てな話です。

■_

Perl 6 デザインミーティングから。

◆chromatic: Perl 6 Design Minutes for 09 September 2009
http://use.perl.org/~chromatic/journal/39631

Patrick:

    * added contextual variables to Rakudo
    * they seem to work just fine
    * added a couple of ops to Parrot to make that easier
    * PCT already uses contextuals in PGE and NQP

Patrick:

    * he's the Release Iron Man


Allison:

    * spent some time looking over the JIT deprecation and replacement proposal
    * wanted an initial plan to figure out where we're headed
    * we're not just ripping it out without a plan to replace it
    * speaking at the JVM languages summit next week
    * speaking at the Bay Area Python users group after that
    * might have some interesting perspectives from the Unladen Swallow group
    * they're also building on LLVM

Allison:

    * Class doesn't support the exclude and alias options to support Role
    * Role only supports those for methods, not for attributes
    * that's a matter of adding a few lines of code to one method in Class and one in Role

Patrick:

    * Rakudo uses Role
    * it works well enough for whatever we do
    * Rakudo subclasses it into P6Role to give it some of its own behaviors

◆perl6.announce: Parrot 1.6.0, "half-pie" Released! by jerry gay
http://www.nntp.perl.org/group/perl.perl6.announce/2009/09/msg605.html
http://parrot.org/download

contextual variables ってなんだろう?

traits とか role というのもなんかピンとこないんだよなあ。

■_ 本日の巡回から

2009年09月15日

■_

・読んだ
日本「半導体」敗戦 (光文社ペーパーバックス)
この体裁というかこのシリーズはあまり好きではないのでそれほど読んではいないのだけど、 たまには。 電子立国日本の自叙伝では その冒頭で全盛時代を謳歌する半導体産業(というかDRAM工場)がでてきたりしたわけですが、 往時に世界の生産量の大半を占めた日本のDRAM産業は今は見る影もありません。 それはなぜなのか。一度考えてみるといいんじゃないかと思います。

しかしニコンも露光装置のシェアをがくっと落としてたのね。 知らんかったわ。

・んで
今度はこういうのも読んでみる。
カルチュラル・コンピューティング―文化・無意識・ソフトウェアの創造力
本屋で見かけて、ぱらぱらと斜め読みしたら結構面白そうだったので。

チャールズ・バベッジについては 高橋会長が紹介されているもの とか何冊かありますし、フォン・ノイマンも伝記的なものがあったと思います。 が、アラン・チューリングはなかったかな? かつてビジネスジャンプで連載された「BRAINS」というマンガでチューリングが取り上げられたり したんですけど、これは現在入手困難(わたしは持ってますけど)。 このマンガ、バベッジ、チューリング、アタナソフ、とコンピューターの開発史に輝かしく その名を残す面々が登場するのですが、最終回がヴァニバー・ブッシュだったりして フォン・ノイマンやウィルクスは取り上げられなかったりするんですよね。 当時はいずれ連載が再開されるとかあったような記憶があるのですが、 まあいろいろ事情があったのでしょう。

The Annotated Turing: A Guided Tour Through Alan Turing's Historic Paper on Computability and the Turing Machine
とか、どこか翻訳本出してくれないかなあ。

■_ Signs that you're a bad programmer (その3)

あともう一回。

Signs that you're a bad programmer ?(Software Engineering Tips)?

3. Pinball Programming
  ピンボールプログラミング

When you tilt the board just right, pull back the pin to just the right distance, and
hit the flipper buttons in the right sequence, then the program runs flawlessly with
the flow of execution bouncing off conditionals and careening unchecked toward the
next state transition.

あなたがボードを正しくティルトするときは正しい距離だけピンをプルバックして正しい手順で
フリッパーボタンを叩いてから、execution bouncing off conditionals のフローを持ったプロ
グラムを flawlessly に実行しそして unchekced を next state transition にむけて傾ける
(careening)。

Symptoms (症状)

  1. One Try-Catch block wrapping the entire body of Main() and resetting the program
     in the Catch clause (the pinball gutter)

     Main() の本体全体をひとつの Try-Catchブロックで包み込んでしまい Catch clase の
     なかで (ピンボールの gutter よろしく) プログラムをリセットしてしまう

  2. Using strings/integers for values that have (or could be given) more appropriate
     wrapper types in a strongly-typed language

     強い型付けを行う言語において、もっと適切なラッパー型が存在している値に対して文字列や
     整数を使ってしまう

  3. Packing complex data into delimited strings and parsing it out in every function
     that uses it

     複雑な構造のデータをデリミターつきの文字列にパックし関数ごとにそれを解析する

  4. Failing to use assertions or method contracts on functions that take ambiguous input

     あいまいな入力を受け取った関数で assersion や method contracts を使うのに失敗する

  5. The use of Sleep() to wait for another thread to finish its task

     別のスレッドがそのタスクを完了するのを待つのにSleep()を使ってしまう

  6. Switch statements on non-enumerated values that don't have an "Otherwise" clause

    "Otherwise" clause を持っていない non-enumerated な値に対する switch 文

  7. Using Automethods or Reflection to invoke methods that are named in unqualified user input

     unqualified なユーザーからの入力により名前の指定されたメソッドを起動するのに
     Automethods やリフレクションを使ってしまう

  8. Setting global variables in functions as a way to return multiple values

     関数からの複数の値を返すためにグローバル変数に値をセットする

  9. Classes with one method and a couple of fields, where you have to set the fields
     as the way of passing parameters to the method

     メソッドにパラメーターを渡す方法としてフィールドに値をセットしないといけない
     ような、一つのメソッドと二つのフィールドを持ったクラス

  10. Multi-row database updates without a transaction

     トランザクションせずに multi-row データベースを更新する

 11. Hail-Mary passes (eg: trying to restore the state of a database without a
     transaction and ROLLBACK)

     トランザクションとロールバックをせずにデータベースの状態のリストアを試みる

Remedies (治療)

Imagine your program's input is water. It's going to fall through every crack and fill
every pocket, so you need to think about what the consequences are when it flows
somewhere other than where you've explicitly built something to catch it.

あなたのプログラムに対する入力が水であると考えてみよう。
水はすべてのチェックを通り抜けてすべてのポケットを満たしていくので
so you need to think about what the consequences are when it flows
somewhere other than where you've explicitly built something to catch it.


You will need to make yourself familiar with the mechanisms on your platform that help
make programs robust and ductile. There are three basic kinds:

あなたには、プログラムを頑健かつ ductile にするのを手助けするような
あなたの使っているプラットフォームでの機構に慣れ親しむ必要があるだろう。
そういったものは基本的には以下の三種類がある:

  1. those which stop the program before any damage is done when something unexpected happens,
     then helps you identify what went wrong (type systems, assertions, exceptions, etc.),

     期待していない何かが起きたときに、なんらかのダメージが発生するより前にプログラムを
     停止させるもので、停止させた後で何がまずかったのかを特定するのを助けるもの(型シス
     テム、アサーション、例外、などなど)

  2. those which direct program flow to whatever code best handles the contingency
     (try-catch blocks, multiple dispatch, event driven programming, etc.),

     緊急事態 (contingency) を最もよく処理するコードであるダイレクトなプログラムフロー
     (try-catch blocks, multiple dispatch, event driven programming, etc.),

  3. those which pause the thread until all your ducks are in a row (WaitUntil
     commands, mutexes and semaphores, SyncLocks, etc.)

     あなたのアヒルすべてが一列に並ぶまでスレッドを一時停止させるもの
     (WaitUntil commands, mutexes and semaphores, SyncLocks, etc.)

There is also a fourth, Unit Testing, which you use at design time.
第四のものもある。それはユニットテストであなたが設計時に使うものだ。

Using these ought to become second nature to you, like putting commas and periods in
sentences. To get there, go through the above mechanisms (the ones in parenthesis) one
at a time and refactor an old program to use them wherever you can cram them, even if
it doesn't turn out to be appropriate (especially when they don't seem appropriate, so
you also begin to understand why).

センテンスでどのようにカンマとピリオドを使うのかということと同様に
second nature にするためにこれらの ought を使う。
To get there,
一度にひとつの上述の機構を(カッコの中のもののひとつ) go through する。
そして、リファクタリングが適切であると判断できない場合でも、
可能であればどこでも古いプログラムを使うためのリファクタリングをする。
(especially when they don't seem appropriate, so you also begin to understand why).
リファクタリングが適切でないように思われるときでも、
そのコードを理解するための手掛かりにできる

■_



■自宅待機プログラマが自宅から集うスレ 3ヶ月目■ 
222 仕様書無しさん [sage] 2009/09/15(火) 19:08:33 ID: Be:
    今朝、会社から電話があったらしい。

    こっちは、9:00就寝、18:00起きなんだから、起きてる間に電話しろっつーの!! 

223 仕様書無しさん [sage] 2009/09/15(火) 19:38:03 ID: Be:
    なぜその時間帯を選んで寝るw 
スレ立てるまでもない質問はここで 100匹目
318 デフォルトの名無しさん [] 2009/09/14(月) 19:29:16 ID: Be:
    ピログラミングなんですけども、
    条件判定は真判定と偽判定の
    どちらをメインにすれば
    いいのですか。

    おいどんは偽判定、
    エラーになる条件を弾いていけば
    自然と正常なものばかりになると思って
    いるのですが

    先輩が
    「それはボンバーヘッドが大きすぎる」
    といいます

319 デフォルトの名無しさん [sage] 2009/09/14(月) 19:30:59 ID: Be:
    ちょっと笑った自分が恥ずかしい 

320 デフォルトの名無しさん [sage] 2009/09/14(月) 20:01:27 ID: Be:
    場合によって違う、としか言いようが無い 

321 デフォルトの名無しさん [sage] 2009/09/14(月) 20:05:28 ID: Be:
    >>318
    全ての状態を自分が把握できるときならいいかも試練が、
    巨大なコードになってくるとそんなこといってられないぞ
    まぁ、その内わかるさ 

322 デフォルトの名無しさん [sage] 2009/09/14(月) 20:23:34 ID: Be:
    >>318
    ボンバヘッの大きさは大して変わらんと思うからそのままでいいよ 

329 デフォルトの名無しさん [] 2009/09/15(火) 12:54:42 ID: Be:
    ×ボンバーヘッド
    ○オーバーヘッド 

330 デフォルトの名無しさん [sage] 2009/09/15(火) 13:04:41 ID: Be:
    みんなピログラミングには突っ込まないのなw 

331 デフォルトの名無しさん [sage] 2009/09/15(火) 13:14:38 ID: Be:
    まさか突っ込む奴がいるとは思わなかった。 

333 デフォルトの名無しさん [sage] 2009/09/15(火) 19:49:00 ID: Be:
    >>329
    どうしちゃったの!? 

■_ なまえじゅうよー

Guillaume Nargeot's Technical Blog: Think twice before naming your new programming language

Think twice before naming your new programming language
あなたの新しいプログラミング言語に名前をつける前にもう一度考えよう

Smart people invent new programming languages, with powerful features, that perform 
really well. What else do we need?

賢い人たちが新しいプログラミング言語を発明する。とても役に立つ強力な機能とともに。それ
以外にわたしたちが必要にしているものとはなんでしょうか?

When you want to learn and use these new programming languages, you might want to buy 
books or to search for tutorials, code examples, blog articles, etc.

あなたがこういった新しいプログラミング言語を学んだり使いたいと思ったときには、本を買っ
たり、あるいはチュートリアルだとかコードの例、blogのアーティクルといったものを探すでし
ょう。

There comes the name: you might have plenty of good reasons for choosing a certain 
name for your programming language, but before deciding on it please think about 
people who are willing to use it.

ここで問題になるのが名前です: ひょっとしたらあなたには、自分のプログラミング言語にある
特定の名前を選ぶのにしっかりとした理由があるのかもしれません。でも本当にそれに決めて
しまう前に、その言語を使う人のことを考えてみて欲しいのです。

I am one of those: recently, I am learning the Factor and J programming languages, or 
I should say "I am trying to learn". I suppose that you can imagine my 
frustration when I try to search for information using Google, or for books using 
Amazon.

わたしもそういった人たちの一人です: 最近、わたしは Factor と J というプログラミング言
語を学んでいます。いえ、「学ぼうとしている」と言うべきかもしれません。わたしがGoogle 
を使ってこれらの言語の情報を検索しようとしたときやAmazon でこれらの言語の書籍を探そう
としたときにわたしが感じたフラストレーションがどういったものかあなたにも想像できるだろ
うと思います。

Just think about what kind of results you will get when looking for something related 
to Factor on Google...

Google で Factor に関係することがらを検索しようとしたときに、
あなたが得るであろう検索結果についてちょっと考えてみてください。

Of course you could tell me that there is the Factor documentation. But I don't want 
to limit myself to the official documentation: I want to read books if they exist, I 
want to read code snippets shared by other people, I want to read blog posts, search 
on GitHub (Factor is not registered yet), and the reality is that I just can't. This 
is so frustrating, especially for language such as J, which are even more difficult to 
search for, and I don't need to explain you why...

もちろんあなたは、Factor にはドキュメントがあるとわたしに教えてくれるかもしれません。
しかしわたしはオフィシャルなドキュメントに限定したくはないのです。本が出版されていれば
それを読みたいですし、ほかの人と共有されているコード片も読みたければブログの書き込みだ
って読みたいのです。さらに GitHub で検索もしたい(Factor はまだ登録されていませんが)の
ですがこういったことは実際にはぜんぜんできないことなのです。これはとてもフラストレーシ
ョンがたまることで、特に J のようなさらに検索が難しくなっている言語についてはそうです。
その理由を説明する必要はないでしょう。

Some work have been done to make C and C++ easy to search on the internet, but nothing 
yet for J yet. I think the same goes for R, and if I read this wiki page, it seems 
that I could quote almost the whole alphabet!

C や C++をインターネット上で検索しやすくするためには努力が払われましたが、J のためには
まだなにも行われていません。これは R にも同じことが言えると思いますし、このページを読ん
だら、ほとんどすべてのアルファベットについて同じことが言えるでしょう!

So please, I beg you, the next time you create a great programming language such as 
Factor or J, think carefully about a name that will be easy to search for on the 
internet. Do not use a one-character or two-character name, only use characters from 
the Latin alphabet, do not use a common word, and just make it as unique as possible.

ですからどうかお願いします。次にあなたがFactor や J のような偉大なるプログラミング言語
を作るときにはインターネットで検索がしやすいような名前を注意深くつけてください。一文字
や二文字の名前はいけません。ラテンアルファベットの文字だけを使い、一般的な単語は避けて
可能な限り他と混同されることのないようなものにしてください。

Posted by Guillaume Nargeot

sykora said...

    When I was learning J I met with the same problem. I partially got over that by just
    searching for the word "jsoftware". That said, there isn't much in the J
    world that isn't linked to by its own wiki, so it isn't so bad.

gnaff said...

    Haskell, Scala, Java are good names.
    Lisp, Forth, Scheme are not bad.

    .Net, R and all of the #Sharps are terrible.

Joe Chung said...

    Just add programming to your search term, e.g., "R programming," 
    "Factor programming," etc.

Efrique said...

    Yeah, searching for R is mostly useless but slowly getting better, but "R software",
    "R code" and "R programming" and similar searches work okay.

Vsevolod said...

    it's not a problem of names, but rather of stupid search engines  ;) 

John said...

    The sharps work fine in google.

Enchanted *nix Blog - said...

    Clojure (a new dynamic language on the JVM, sort of the python of lisps) did this 
    perfectly. When Rich Hickey chose the name, it had ZERO results on google.

    It's perfect because it makes life so easy finding documentation.

    I don't know how much coolness factor or fashion appeal the name "Clojure"
    (pronounced 'closure') will end up having, but I certainly like it.

    I think the community will be reaping the benefits of that decision for a long 
    time to come.

■_ 本日の巡回から

2009年09月14日

■_

・近況
書くに書けない(お察しください)

■_ ここでモナドが出るのか

ついったでは「どこが不思議なんだ」的に片付けられてしまいましたが。 いやまあHaskellの専売特許とか考えていたわけではないし、 Scalaは関数型言語の要素も多分に取り込んでいるので確かに不思議ではないのですが まあそのなんというか。


第13回 Scalaプログラミングの勘所(3) - 刺激を求める技術者に捧げるScala講座:ITpro

 実はScalaのfor文では,さらにもっとすごいことができます。以下の例は,クラス国のListで
ある国一覧とクラス都市のListである都市一覧から,「人口が1千万人を超える都市を持つ国の
首都の一覧」を作成するScalaの式です。

 「for (city <-都市一覧;if city.人口> 10000000;nation <-国一覧;if nation.名前== city.国名) yield nation.首都.name」

がこの式の核心部分でまさに問い合わせ言語という趣です。このfor文の実行結果は「東京,東京,
ワシントン」と東京が重複するのでSetを用いて重複を取り除いています。(東京が重複するのは
東京と阪神の2つが1千万人を超えるため。)

val 大都市首都一覧 = Set((for (city <- 都市一覧;if city.人口 > 10000000;nation <- 国一覧;if \
    nation.名前 == city.国名) yield nation.首都.name): _*)

 これを以下のように出力します。

    println("大都市首都一覧 = %s".format(大都市首都一覧.mkString(",")))

 実行結果は以下の通りです。

大都市首都一覧 = 東京,ワシントン

 この例からわかるとおり,Scalaのfor文はSQLなどの問合わせ言語に相当する処理を記述する
ことが可能です。

 なお,for文が内部的に行っている処理を明示的に書くと以下のようになります。関数型言語
に親しんでいる人はこちらの方がわかりやすいかもしれませんが,筆者はfor文の方がわかりや
すいと感じます。

val 大都市首都一覧 = Set((都市一覧.filter(nation => nation.人口 > 10000000).flatMap(city \
    => (国一覧.filter(nation => nation.名前 == city.国名).map(nation => \
    nation.首都.name)))): _*)

 コレクションのforeachメソッドやmapメソッドとクロージャを組み合わせて使うと関数型的で
美しいわけですが,筆者も含めて関数型に慣れていない場合には,コレクションに対する処理は
とりあえずfor文で考える,というアプローチでよいと思います。また,Scalaのfor文は手続き
型言語の繰り返しを扱うためのfor文ではなく,関数型の重要なコンセプトであるモナド(monad)
の文法糖衣でもあるので,for文の利用は関数型言語としてのScalaの意図を汲んだ利用方法でも
あります。そういう意味でもfor文を主体にプログラミングするのがバランスがよいでしょう。

for文とモナド

 Scalaのfor文はモナドという種類のオブジェクトに対して処理を行う言語機能です。Scalaに
おけるモナドは(四捨五入していうと)以下のシグネチャを持つオブジェクトです。

abstract class C[A] {
  def map[B](f: A => B): C[B]
  def flatMap[B](f: A => C[B]): C[B]
  def filter(p: A => Boolean): C[A]
  def foreach(b: A => Unit): Unit

 for文が繰り返しとして動作するのは,コレクションが繰り返し機能を提供するモナドだから
です。つまり,別の機能を持つモナドを作成すればfor文は繰り返しとは別の振舞いを提供する
ことができます。

 例えば,本節の「人口が1千万人を超える都市を持つ国の首都の一覧」を検索する例では,
JDBCを用いてデータベースにアクセスするモナドや,AtomPubプロトコルを用いてWebにアクセス
するモナドといった応用が可能かもしれません。こういった応用が可能になれば,Scalaのfor文
は単なる繰り返しの抽象化という枠組みを超えて,プログラミング技術に革新をもたらす新しい
次元の文法ということになるでしょう。

 Scalaは「Scalable Language」をビジョンとしているプログラミング言語ですが,for文のこ
のような拡張性はまさにスケーラブルであり,Scalaの特性をよく表しています。 

むーん。

■_ What makes a ‘good' programmer?

良いプログラマーの条件。つか。


What makes a ‘good' programmer? | Haseman on Mobile

Many column inches have been devoted to defining the ‘good' programmer.  We programmers
read such stuff because we're all paranoid that we fall under the ‘bad' or 'stupid'
programmer.  We all, if we read up on the art of making software, like to think of
ourselves as members of the elite few.  I have a news flash for you: you're probably not.
(but then, neither am I)

多くのコラムにおいて“優れた”プログラマー (‘good' programmer) の定義づけを熱心に行っ
ています。わたしたちプログラマーはそのような資質 (stuff)を read しますなぜならわたした
ちは皆、 “ろくでもない”プログラマーとか“おばかな”プログラマーに分類されるような
(we fall under the ‘bad' or 'stupid' programmer)パラノイド (paranoid) であるからです。
わたしたちはソフトウェアを作る技術において自分自身を数少ないエリートの一員であると考え
がちです。ここであなたにニュース速報: たぶんあなたはそうではありません(まあわたしもで
すが)

You cannot define what a ‘good' programmer is without first examining the environment
in which this programmer will be producing code.

そのプログラマーがコードを書く環境をまず試験しないことには“優れた”プログラマーである
かどうかを判断することはできません。

Just as different martial arts have advantages and disadvantages based on the battlefield,
programmers, given a set of skills and abilities, will have an environment in which they
will excel.  The art of finding ‘rockstar' programmers is less about tricky math problems
(above a certain point) and more about matching their particular quirks (we all have them)
with an environment that allows them produce.

異なる武術 (martial arts) がその戦場とするところに応じてアドバンテージやディスアドバン
テージがあるというのと同じようなものです。プログラマーには、与えられた技術や能力の set 
がありその各々はそれぞれ得意とする環境を持っています。“ロックスター” プログラマーを
見つけ出す技法 (art) とは math problems (above a certain point) よりはトリッキーではなく、
さらにいえば、彼らの独特な quirks (わたしたちすべてがそれを持っています)
とそれを作り出すことを許す環境とをマッチングしたものです。

For the sake of expediency, I'll break down programmers into Cooks and Bakers.  This
is absolutely an arbitrary distinction.  There are more interesting ways to bisect the
programming world, but this one makes for a quick explanation.

ここで便宜上のものとしてプログラマーを Cook (コック)と Baker (パン屋)に break down します。
これはまったく恣意的な区別です。
プログラミング世界を二つに分類する基準にはもっと面白いものもありますが
しかしこれは  quick explanation のためのものです。

Cooks are the creative ones.  They enjoy the big pictures, they like putting things
together (especially in the early stages).  They struggle to remember small minute
details like thread timing and tend towards simple, crippling, off-by-one-type errors.
Give them a blank page and they're make you a mural…just don't expect every building
to be exactly to scale.  In the later stages of a project, they make for amazing
problem solvers but will often cause more bugs on the way to a solution.  Cooks, sadly,
are the most common type of programmer out there. (I say 'sadly' because I'm a cook
more than a baker)

Cook は creative な人物です。彼らは big pictures を楽しみ、物事をまとめてしまうことを
好みます(特に初期段階においては)。彼らはスレッドのタイミングのような small minute 
details を思い出すことに struggle して、単純で、crippling で、一個外しエラー
(off-by-one-type errors) をやりがちな傾向にあります。彼らに空白のページを与えると、彼
らはあなたを mural (壁画) にするでしょう…すべての building が本当にスケールするという
ことを単純に期待してはいけません。プロジェクトの終盤のステージで彼らは信じられないよう
な problem solvers を作るのですがその途上でより多くのバグを作ってしまうことがしばしば
起こりうるのです。cook とは悲しいことですがプログラマーに一番良く見られるタイプなので
す(“悲しい”というのは、わたしが baker よりも cook であるからです)。

Bakers, on the other hand, revel in the details.  Give them a comprehensive
specification and they'll be a hog in a manure farm.  They often miss the big picture,
frequently say ‘but that's not in the spec' and often struggle with the blank page.
They hardly ever make mistakes of omission but the mistakes that they do make tend to
be large in scale an very difficult to fix.  Hard core bakers are rare, which is good
as they often fight with each-other.  But at any successful company you'll always find
one.

一方で baker たちは詳細に夢中になります。彼らに comprehensive な仕様を渡せば、彼らは 
hog in a manure farm となるでしょう。彼らはしばしば big picture を見失い、“だってそん
なの仕様にないし”などとと言う台詞を連発しては空白のページと格闘することが頻繁にありま
す。彼らが mistakes of omission してしまうことは滅多にありませんがしかし彼らがしてしま
った失敗というのは大きな問題になってしまう傾向があって、修正するのがとても困難になって
しまうものなのです。Hard core な bakers というのはとても稀です。しかし、成功している企
業ではそういった baker たちを発見することが常にできるでしょう。

You wouldn't wear Japanese samurai armor to fight trench warfare.
In the same way, you shouldn't ask engineers to work exclusively with what they're bad at.

あなたはtrench warfare を戦うために日本の鎧兜を着込むことはしないでしょう。
それと同様に、エンジニアに対して排他的に仕事を
するための what they're bad at を尋ねるべきではないのです。

There's more than style to consider.  If you're a contractor and you're working on a
project you won't have to maintain, there's no incentive to write clean ledge-able,
extensible code.  On the flip side, if you're on salary, you work on long lived
libraries or applications you better be or work with a baker.

スタイルよりも考慮すべきことがあります。もしあなたが contractor であり、自分が保守する
必要のないプロジェクトで働いているのであればクリーンで ledge-able な、拡張も可能なコー
ドを書こうというインセンティブはそこにはありません。反対にあなたが給料を貰う立場であれ
ば (you're on salary)、long lived なライブラリやアプリケーションのために働くことになる
でしょう。

With this in mind, I would offer the following hypothesis:

このことを念頭におきながら以下のような hypothesis を offer します:

A ‘good' programmer has two traits, which, interestingly enough, haven't anything to
do with the ability to bang out code:

“すぐれた” プログラマーは二つの traits (性質、属性)を持っています。
それら二つはとても interestingly で
コードを bang out するのにこの他には必要ないような能力 (ability) です。

1) They can communicate.  They build trust, hit their deadlines (or give you plenty of
warning when one will be missed) and don't hide their shortcomings.

優れたプログラマーは communicate できます。彼らは信頼を積み上げ (build trust)、彼らの
デッドラインを hitして、自分たちの shortcomings を隠すようなことはしません。

2) They are adaptable.  They may have a preferred working style and project type, but
they're willing to work outside their comfort zone.  They know the rules, but, when
the situation calls for it, they abandon them with alacrity.

優れたプログラマーは adaptable です。彼らには好みのワーキングスタイルやプロジェクトタ
イプというものがあるかもしれません。しかし彼らは自分たちの  comfort zone の outside で
働くことでしょう。彼らは規則を知っていますが、
the situation calls for it の場合には they abandon them with alacrity.

That's it.  If, in defining what makes a great programmer, you list a series of
programming habits and skills, you're only defining a programmer who works well in a
particular environment.  I've seen programmers blow a simple linked list reversal in
an interview and then turn around upon being hired and blow my mind.

これだけです。仮に偉大なるプログラマー (great programmer) の条件を定義するときにあなた
がプログラミングに関係する習慣や技術を列挙していったなら、あなたはそれによってただ単に
ある特定の環境においてよく働くであろうプログラマーを定義しているだけなのです。
わたしはインタビュー中に単純なリンクつきリストを逆向きに blow していて
その後 turn around upon being hired and blow my mind した
プログラマーたちを見たことがあります

Building a good team is less about complex logic problems and obscure programming
knowledge and more about building a group of people that complement eachother.  When
you interview your next potential team-mate, make them write some code, and then take
the time to figure out how they work.

優れたチームを作り上げるということは複雑なロジックの問題 (complex logic problems) と曖
昧なプログラミングの知識 (obscure programming knowledge)を減らすというよりはむしろ互い
を補い合う人たちのグループを作り上げるということなのです。あなたが自分の next
potential team-mate にインタビューする場合彼らにコードを書かせておいてからそれがどのよ
うに動作するのかを説明させる時間を確保しましょう。


Copyright c 2009 Haseman on Mobile
WordPress Theme by Michael Tyson.

■_


Lisp Scheme Part27 
958 デフォルトの名無しさん [sage] 2009/09/14(月) 00:29:09 ID: Be:
    > そもそも、日本では、SICPなんて古典を未だに有り難がって神格化し、
    > そのせいか若い人の勉強会でも未だに人気が衰えていないという不思議な
    > 現象がある。こんなの世界広しと言えどもあまり他の国では見たことが
    > ない。ここでもガラパゴス化しているんだよな。
    http://kashino.tumblr.com/post/186793436/technical-requirements-special-software-is 

959 デフォルトの名無しさん [sage] 2009/09/14(月) 00:32:12 ID: Be:
    そんなことより Lisp の話しよーぜ 

960 デフォルトの名無しさん [sage] 2009/09/14(月) 00:42:28 ID: Be:
    ガラパゴス化賛成。鎖国賛成。 

961 デフォルトの名無しさん [sage] 2009/09/14(月) 00:47:36 ID: Be:
    >>960
    そんなこと言ってると割り込みベースの言語とかが生まれちゃうぞ(割り込みの概念の持ち込みが実は日本発だとしってびっくり中)

962 デフォルトの名無しさん [sage] 2009/09/14(月) 00:48:11 ID: Be:
    >>958
    「ガラパゴス化」って言いたい病を治さないとな。 

964 デフォルトの名無しさん [sage] 2009/09/14(月) 00:56:23 ID: Be:
    SICP に書いてある内容なんて
    職業プログラマなら一般教養として学生時代に勉強してるべきことだし
    今更読書会で読む必要もないよね
    とか言ってみる 

tumblr から引っ張ってるのは、tumblr の方の全文を読むとちょっと印象が違う気がしないでもない。

■_ Signs that you are a mediocre programmer (あなたが二流プログラマーである兆候)

つづき。

Signs that you're a bad programmer ?(Software Engineering Tips)?

Signs that you are a mediocre programmer (あなたが二流プログラマーである兆候)

2. Lack of critical thinking
  批判的思考 (critical thinking) の欠如

Unless you criticize your own ideas and look for flaws in your own thinking, you will
miss problems that can be fixed before you even start coding. If you also fail to
criticize your own code once written, you will only learn at the vastly slower pace of
trial and error. This problem originates in both lazy thinking and egocentric thinking,
so its symptoms seem to come from two different directions.

自分のアイデアを criticize して look for flaws in your own thinking しない限りあなたは
コーディングを始める前ですら解決可能な問題を見失ってしまうだろう。あなたが自分の書いた
コードの criticize に失敗した場合でも試行錯誤 (trial and error) のとんでもなく遅いペー
スでのみ学ぶことになるこの問題は lazy thinking と egocentric thinking の両方に起因して
いるためにその症状は二つの異なる directions からきているように見える。

# http://en.wikipedia.org/wiki/Critical_thinking
# http://ja.wikipedia.org/wiki/%E6%89%B9%E5%88%A4%E7%9A%84%E6%80%9D%E8%80%83

Symptoms (症状)

  1. Homebrew "Business Rule Engines"

     自家製のビジネスルールエンジン ("Business Rule Engines")

  2. Fat static utility classes, or multi-disciplinary libraries with only one
     namespace

     膨れ上がった static なユーティリティクラスもしくはただ一つの名前空間しか持って
     いない multi-disciplinary なライブラリ

  3. Conglomerate applications, or attaching unrelated features to an existing
     application to avoid the overhead of starting a new project

     新しいプロジェクト開始のオーバーヘッドを解消するためにアプリケーションを
     Conglomerate したり既存のアプリケーションに関係のない機能を付け加えたりする

  4. Architectures that have begun to require epicycles

     epicycles を要求し始めた Architectures

  5. Adding columns to tables for tangential data (eg: putting a "# cars owned"
     column on your address-book table)

     関係のないデータ (tangential data) のためにテーブルにカラムを追加する
     (例: 住所録テーブルに“車の所有の有無”カラムを追加する)

  6. Inconsistent naming conventions

     一貫性のない命名規約

  7. "Man with a hammer" mentality, or changing the definitions of problems
     so they can all be solved with one particular technology

     “ハンマーを持った男”思考、もしくは問題の定義を変更しまうことで一つの特定のテクノ
     ロジーでもってすべてを解決するのを可能にしてしまう

  8. Programs that dwarf the complexity of the problem they solve

     解決する問題の複雑さを小さく見せてしまうプログラム

  9. Pathologically and redundantly defensive programming ("Enterprisey
     code")

     病的かつ冗長 (Pathologically and redundantly) な防衛的プログラミング
     ("Enterprisey code")

 10. Re-inventing LISP in XML
     XML で LISPを再発明する


Remedies (治療)

Start with a book like Critical Thinking by Paul and Elder, work on controlling your
ego, and practice resisting the urge to defend yourself as you submit your ideas to
friends and colleagues for criticism.



Once you get used to other people examining your ideas, start examining your own ideas
yourself and practice imagining the consequences of them. In addition, you also need
to develop a sense of proportion (to have a feel for how much design is appropriate
for the size of the problem), a habit of fact-checking assumptions (so you don't
overestimate the size of the problem), and a healthy attitude towards failure (even
Isaac Newton was wrong about gravity, but we still love him and needed him to try
anyway).

他の人があなたのアイデアに対して試験をどのようにするのかを一度理解すれば、s自分自身で
アイデアの試験を始めてaそれに加えて、あなたには(その問題の規模に対する適切な設計を感じ
取るための) proportion のセンス、(so you don't overestimate the size of the problem) 
fact-checking assumptions の習慣、失敗に対しての healthy attitude の develop が必要で
ある。(アイザック・ニュートンでさえ重力に関して間違いをしているけれどもわたしたちは今
でも彼を敬愛し、try anyway のために彼を必要としている).


Finally, you must have discipline. Being aware of flaws in your plan will not make you
more productive unless you can muster the willpower to correct and rebuild what you're
working on.

最後に、あなたは規律 (discpline) を持たなければならない。あなたが自分の行っていること
の訂正 (correct) と再構築 (rebuild)のための自制心 (willpower) を muster しない限りあな
たの計画の不備があなたを more productive にはしないということに注意を払う。

どうも今ひとつな文章にしかならん。sigh.

■_ 本日の巡回から

2009年09月13日

■_

・PASMO
今日出かけるときに PASMOを忘れてしまったのですが、 切符を買って電車に乗ったのはずいぶん久しぶりのような気がします。 おかげで料金を間違えたり、路線を乗り換えて(東京メトロ→東急)精算の必要があるのに しないで改札を通ろうとして引っかかったり。

・オネアミスの翼
ついったでJAXAの件がちょっと賑わったときに、ふと オネアミスの翼で、主人公に対して地上には飢えている子供もいるのになぜ役にも立たない ロケットに大金をつぎ込むのか(正確に覚えてません)と インタビュアーがくってかかるシーンがあったなあと

・FX-60
欲しいなあ。

えもの
土曜日に明倫館でげっとしたのと、YAPCの会場で購入した同人誌。 こういうのをコミケに出向いて買いたいとは思うんだけど、どういうタイミングで行けばいいやらw

■_


Perlについての質問箱 41箱目
398 デフォルトの名無しさん [sage] 2009/09/12(土) 11:10:10 ID: Be:
    ファイル名を取得するとき、opendirとglobどっちを使うべきなのでしょうか? 

399 デフォルトの名無しさん [sage] 2009/09/12(土) 11:47:16 ID: Be:
    File::Slurpのread_dirオススメ

400 デフォルトの名無しさん [] 2009/09/12(土) 16:42:48 ID: Be:
    ファイルグロブなんか使ったらいかんと誰かがブログで書いてたよ 

401 デフォルトの名無しさん [sage] 2009/09/12(土) 17:41:16 ID: Be:
    >>400
    それって結局「いかん根拠なんてないじゃん」という話じゃなかったか? 

402 デフォルトの名無しさん [sage] 2009/09/12(土) 20:35:07 ID: Be:
    .と..をいちいち除外しなくていい 

403 デフォルトの名無しさん [sage] 2009/09/12(土) 22:42:15 ID: Be:
    古いperlは、ファイルグロブはシステムに依存してた。
    (「ファイル名が長過ぎます」エラー等のperlの外の問題を切り離す事が出来ない。)
    つー事で古くからの人間は「グロブなんざ使うんじゃねえ。」と言いがち。
    で、それら諸先輩に影響を受けた人々が、本来の根拠と別に理由をこじつけ
    「だからグロブは使いません!」って言ってる(人もいる)。

    今となってはどっちでも良いんでねえの?10年以上前の常識だし、
    俺はグロブ使わんけど。

404 デフォルトの名無しさん [] 2009/09/12(土) 23:31:36 ID: Be:
    >>398
    opendirはファイル名のみとりたいときに便利。

    globはパスごととりたいとき便利。 

407 デフォルトの名無しさん [sage] 2009/09/13(日) 03:34:06 ID: Be:
    Perl界の重鎮、子飼弾氏は以下のように述べております。

    404 Blog Not Found:perl - glob,readdir, and regexp
    http://blog.livedoor.jp/dankogai/archives/51058540.html 

408 400 [sage] 2009/09/13(日) 08:39:41 ID: Be:
    今更ただのシャレだったなんていい出しづらい雰囲気だな 

409 デフォルトの名無しさん [sage] 2009/09/13(日) 11:02:01 ID: Be:
     えっ・・・みんな気づいてなかったのか? 

410 デフォルトの名無しさん [sage] 2009/09/13(日) 11:58:28 ID: Be:
    はいはい、>>407は気がついていた。偉い偉い。 



Ruby 初心者スレッド Part 30
913 デフォルトの名無しさん [] 2009/09/13(日) 12:39:10 ID: Be:
    すいません質問させてください

    (@@connections ||= []) << self

    上記のコードの
    @@がクラス変数, << が配列への要素の追記ということはわかったのですが
    ||= の記号の意味がうまく調べられませんでした
    どなたか教えていただけないでしょうか?

914 デフォルトの名無しさん [sage] 2009/09/13(日) 12:42:56 ID: Be:
    @@connections = @@connections || [] 

915 デフォルトの名無しさん [sage] 2009/09/13(日) 13:08:12 ID: Be:
    >>913
    ||=は左辺がnil、falseでないときは何もしない
    もしnil、falseなら右辺を代入する。 

916 デフォルトの名無しさん [sage] 2009/09/13(日) 13:29:01 ID: Be:
    このページ全部に目を通しておくといいよ
    http://doc.okkez.net/static/187/doc/spec=2foperator.html 

917 デフォルトの名無しさん [sage] 2009/09/13(日) 14:10:48 ID: Be:
    >>913
    foo ||= []
    は
    foo = [] unless foo
    とおなじ。
    (foo ||= []) << "aaa"
    は
    foo = [] unless foo
    foo << "aaa"
    とだいたい同じ。 

918 デフォルトの名無しさん [sage] 2009/09/13(日) 15:18:56 ID: Be:
    foo = [] unless defined?(foo) じゃないと動作しないだろ、というツッコミは
    これはこれで面倒な話でありましてですな 

919 デフォルトの名無しさん [sage] 2009/09/13(日) 15:34:47 ID: Be:
    まあ、

    irb> (p "ok") if foo
    NameError: undefined local variable or method `foo' for main :Object
         from (irb):1
         from :0

    がエラーで

    irb> (foo = "ok") if foo
    nil

    が OK というのは不条理っちゃ不条理ではある
    ちなみに (foo = "ok") if foo のあと、 foo は nil を返す 

920 デフォルトの名無しさん [sage] 2009/09/13(日) 15:42:16 ID: Be:
    へえ!そんな違いあるのか 初めて知った
    どういう基準で分かれてるんだろう? 

921 デフォルトの名無しさん [sage] 2009/09/13(日) 16:11:24 ID: Be:
    >>920
    FAQ にもあるんだが、ローカル変数は、構文解析で代入が見つかるかどうかだけが鍵
    実際に(いつ)実行されるかどうかは関係がない

    if false
    foo = "OK"
    end
    foo

    上記は NameError を起こさないが、以下は foo が NameError を起こす

    for e in [1, 2 ,3]
    if e == 2 then
    foo
    else
    foo = "OK"
    end
    end

    動作は同一なはずの unless で 代入記述の順番を変えると NameError は起こらない
    for 構造はスコープを作らないことに注意

    for e in [1, 2 ,3]
    unless e == 2 then
    foo = "OK"
    else
    foo
    end
    end

922 デフォルトの名無しさん [sage] 2009/09/13(日) 16:15:42 ID: Be:
    FAQはこちら
    ttp://www.ruby-lang.org/ja/man/html/FAQ_CAD1BFF4A1A2C4EABFF4A1A2B0FABFF4.html#a2.2e3.20.a5.ed.a1.bc.a5.ab.a5.eb.ca.d1.bf.f4.a4.cf.a4.a4.a4.c4.bb.b2.be.c8.b2.c4.c7.bd.a4.cb.a4.ca.a4.eb.a4.ce.a4.c7.a4.b7.a4.e7.a4.a6.a4.ab
    長い長すぎる

    FAQでは昔ながらに「nil で初期化しとけ」と書いてあるが、
    こんな繰り返しのスコープを意図的に利用するスクリプトを書くことのほうがヤバい兆候であることがわかってる
    素直に他の方法を考えるのがよい
    そもそも一般的な each ではスコープが毎回切れるからこれの再現すらできないしな 

923 デフォルトの名無しさん [sage] 2009/09/13(日) 16:16:02 ID: Be:
    これ、実際改良する気ないのかな。Rubyの実装もいろいろ出てきてるんだし。
    気持ち悪くないのかな。それとも、別に実装の都合ではなくてポリシーなのか? 

924 デフォルトの名無しさん [sage] 2009/09/13(日) 16:31:24 ID: Be:
    もともとそういうポリシー。
    ブロックでスコープをわけないようにするという話もあったりするので、
    遠い未来の2.0あたりでは>>921の例も動くようになるかも。 

925 デフォルトの名無しさん [sage] 2009/09/13(日) 16:41:10 ID: Be:
    スタックに積まれるローカル変数は明示的に初期化すべしってのはrubyに限ったことじゃない。 

926 913 [] 2009/09/13(日) 16:46:38 ID: Be:
    >>914-919
    ご丁寧にありがとうございます。
    ソース読んでいてここだけわからなくて困っていたのですが助かりました。 

927 デフォルトの名無しさん [sage] 2009/09/13(日) 16:48:29 ID: Be:
    >>925
    if ARGV
     opt1 = ...
    end
    opt1_runner(opt1) if defined?(opt1)

    これが期待通り動作しないということなんだぜ
    たかがローカル変数で

    opt1 = nil
    if ARGV
     opt1 = ...
    end
    opt1_runner(opt1) if opt1

    とか書かなければならないのは流石にバカっぽい 

928 デフォルトの名無しさん [sage] 2009/09/13(日) 17:13:36 ID: Be:
    バカっぽいか?すごく素直な書き方でいいと思うけど。 

929 デフォルトの名無しさん [sage] 2009/09/13(日) 17:15:13 ID: Be:
    Rubyのifはスコープを作らないだろ

    いわんとすることはわかるが 

930 デフォルトの名無しさん [sage] 2009/09/13(日) 17:18:18 ID: Be:
    そんな小さな労力のために仕様変更してたらぐちゃぐちゃになるわ。
    ローカル変数を初期化不要にしてしまうと、フィールド変数を参照してるつもりでスペルミスしてもエラーにならなくなる。
    あらゆる場所で意図しないローカル変数が勝手に生成される可能性があるわけで何とも気持ち悪い。

    フィールドはオブジェクトの属性という意味合いから初期値があるのは自然だけど、
    ローカル変数はちょっと値を保存しておく場所って意味合いしかないから、ソースコードを簡略化するために初期値を設けるってのも設計上美しくない 

わたし個人の意見としては変数を宣言する文を追加して欲しいんだけど、 まつもとさんはそのつもりはないと以前どこかで言ってたはず (というのを前にも書いた)。 そいやPython にも宣言文ないね。global とか nonlocal とかはあるけど。



推薦図書/必読書のためのスレッド 51
515 デフォルトの名無しさん [] 2009/09/11(金) 21:46:09  ID: Be:
    昨日、突然「C++プログラミングがしたいっっ!」と思い立ちました。
    そこで今日書店へ行ってみたのですが、本の種類が多すぎて選べません。
    仕方なく検索をして見つけ出したこのスレを>>1から読んだのですが、頭が爆発しそうです。現に耳から変な汁が出てきました。
    最悪の自体を防ぐためにも、現段階でのオヌヌメを教えてください。
    C++がそんなに死ぬほど難しくてすごいのであればCの良い解説本を教えてください。お願いします。

565 デフォルトの名無しさん [sage] 2009/09/13(日) 15:07:00 ID: Be:
    誰か >>515 に答えてやれよ 

566 デフォルトの名無しさん [sage] 2009/09/13(日) 15:14:05 ID: Be:
    >>515
    新・これならわかる C++
    ttp://www.asahi-net.or.jp/~yf8k-kbys/ncppsup.html 

567 デフォルトの名無しさん [sage] 2009/09/13(日) 15:35:49 ID: Be:
    >>515は明らかにネタくさくて…なぁ。
    C++から勉強するならAccelerated C++かC++プライマーで。

    ただ、Accelerated C++は例外安全なコードになっていないので
    あと2、3年もすると使えない本になるかもね。 

568 デフォルトの名無しさん [sage] 2009/09/13(日) 17:26:06 ID: Be:
    Accelerated C++ってCの知識前提じゃなかったか? 

569 デフォルトの名無しさん [sage] 2009/09/13(日) 17:45:20 ID: Be:
    逆。

    >CやC++の経験があるプログラマ諸氏へ
    (中略)
    >この本にあるC++を理解するには、これまでの知識が驚くほどほとんど役に立たない

    この本はいきなり(プログラム言語的な意味で)高度な抽象から入り、
    低レベルの詳細は最後の最後まで無視する。
    Cの知識があっても役に立たない。 

570 デフォルトの名無しさん [sage] 2009/09/13(日) 18:09:58 ID: Be:
    でも、C++って言語+ライブラリだけだと抽象度が低くないか?
    IOとstringとSTLくらいで、ちょっと込み入ったことをするとなるととたんに低レベルになるような。 

571 デフォルトの名無しさん [sage] 2009/09/13(日) 18:27:07 ID: Be:
    入門書で説明する必要のある低レベルの抽象が必要になるような
    「ちょっと込み入ったこと」の具体例は?

    Accelerated C++は低レベルの抽象をまったく教えないわけではないけど
    mallocは出てこない。かわりにallocatorが出てくる。
    配列はもっぱらvectorで、生の配列を教えたとたん、
    vectorクラスの自作をすることになる。
    ポインタが必要になるとまもなくハンドルクラスの説明と
    参照カウント式スマートポインタの自作が出てきて
    以降はそれで代用される。

    初心者は、allocatorが使えてvectorとstringと参照カウント式スマートポインタの自作が出来れば
    もうそれ以上の低レベルな詳細が必要になるような込み入ったプログラムは
    そうそう組まないんじゃないだろうか。
    (むしろ、他の教科書で学んでこれらのものが組める初心者がどれほどいるだろうか?)

    ま、実際のところ、実務でC++を使おうと思ったら
    Accelerated C++を読んだあとに別途Cの本を読む必要があるし
    Windows APIを使おうと思ったりしても同様の結果にはなる。
    Accelerated C++はあくまで「C++」の入門書。
    Cの入門書でもそれ以外のなにかの入門書でもない。 

572 デフォルトの名無しさん [] 2009/09/13(日) 18:35:47 ID: Be:
    たぶん最初に読んだときは全てを理解できないだろうけど、
    ハゲ本を一通り読んで、あとは、実践あるのみだと思うよ。

    C++みたいな混沌として何でもありな言語は、
    系統的に学習するのは、不可能だと思う。 

実際どういうのがいいんでしょね。 スマートポインターの自前での実装は、あまり自信ねーな(苦笑)

■_

reddit でついたコメントからすると、そうなったらいいな的な第三者の意見みたいだけど、 タイトルからはそうは思えんw


The many JIT projects... Parrot plans to ditch it's own JIT and move towards one using LLVM.

Friday, September 11, 2009

The many JIT projects... Parrot plans to ditch it's own JIT and move towards one using 
LLVM.

たくさんのJITプロジェクトがある。Parrotは独自JITを捨てて、LLVMを使う方向へ [要出典]

It seems LLVM has gained another user, in the parrot multi language VM project. They 
plan to ditch their current JIT implementation and start using LLVM.

LLVM は parrot からあらたなユーザーを得たようだ。
彼らは現在のJIT の実装を放棄して、LLVMを使い始めることを計画している。

Full details are on their jit wiki planning page.

Parrot aligns very nicely with the LLVM project which itself is attempting to be used 
by many language projects.

Along with the unladen swallow project(python using LLVM for JIT), this brings other 
dynamic languages in contact with LLVM. This can only mean good things for dynamically 
typed languages on top of LLVM.

Mac ruby is another project switching to LLVM - they have been working on it since 
march.

Hopefully this will help LLVM become more portable, and faster at creating code... as 
well as being able to create larger amounts of code(LLVM only supports generating up 
to 16MB of code currently, but that limit is being worked on).

It's yet to be proven that a major dynamically typed language can be sped up nicely 
with LLVM, but these projects using it should help it get there.

luaijt for lua and psyco V21 for python are both successful JIT projects for dynamic 
languages. However, both are limited in their platform support - only supporting 32bit 
x86 platforms. Other successful JITd dynamically typed languages include the many 
javascript and action script implementations... including V8(x86 32 and arm) and 
tracemonkey (which uses nanojit which supports many backends: arm, x86 64/32, sparc, 
ppc etc).

pypy decided not to use LLVM too, and has embarked on making their own jit system. At 
one point there was code in the pypy svn repository to support LLVM, but it was 
removed a while ago. One comment in the past was that LLVM was too slow at generating 
code, and that it was a very large dependency. LLVM is C++ code that takes quite a 
while to compile itself, and the library is quite large.

Despite these downsides of LLVM, it can generate very efficient code. LLVM is often 
comparable to the fastest generated code for the C language. This is one reason why 
the unladed swallow project has chosen it. The unladen swallow projects goal is to 
optimize long running server processes... so it doesn't care that much about 
generating fast math code, or in taking its time to generate native code. This makes 
sense, considering that it is a google sponsored project.

Another interesting project for python is the corepy project. It's a run time 
assembler for python. One project corepy is used for is to accelerate numpy operations 
- using SSE and multiple cores - so even the numpy written in C can go much faster 
with the corepy accelerated version.

In the same vein of accelerating numpy code - the pygpu, and pycuda projects make it 
possible to use GPU accelerated versions of numpy functions. This allows python code 
to run way faster than is possible on any available CPU. These projects generate 
shader code in C-like languages to run on the GPU. So in a way they are also JIT 
libraries.

liborc is a runtime cross platform assembler which supports many vector operations. 
Unlike many of the code generators that do not support vector operations - liborc does. 
It's a replacement for liboil and is used for gstreamer and dirac multimedia libraries.

Inferno is a virtual machine project which includes a JIT for many platforms.

1psyco v2 doesn't seem to have a web page yet, just a svn(not the old psyco v1 svn on 
source forge).

updates: from the comments... added note about mac ruby using llvm, and the inferno vm.

■_ 本日の巡回から

2009年09月12日

■_

・明倫館
一冊掘り出し物みっけてげと。

・会社方面
[お察しください]

■_

★★Java質問・相談スレッド132★★ 

563 デフォルトの名無しさん [sage] 2009/09/12(土) 15:50:51 ID: Be:
    教えてください。Java初心者の為、意味がわかりません。
    Java言語で「変数A = new String(変数B)」と書いたらDevPartnerに
    「Stringコピーコンストラクタを使用しています」と言われた
    何? 

564 デフォルトの名無しさん [sage] 2009/09/12(土) 15:56:55 ID: Be:
    >>563
    じゃ・・・ば・・・? 

565 デフォルトの名無しさん [sage] 2009/09/12(土) 16:13:54 ID: Be:
    DevPartner? 

566 デフォルトの名無しさん [sage] 2009/09/12(土) 16:34:28 ID: Be:
    >>565
    ttp://www.microfocus.co.jp/products/TestingASQ/devpartner_fm/devpartnerjavaedition/
    ソース分析ソフト 

567 デフォルトの名無しさん [sage] 2009/09/12(土) 16:59:59 ID: Be:
    市販品じゃねーか
    こんなもんがある環境ならレクチャーしてくれる人の1人や2人くらい周囲にいそうなものだが 

568 デフォルトの名無しさん [sage] 2009/09/12(土) 17:15:32 ID: Be:
    使いこなせもしないのにこんな製品買うのか・・・いいねぇ、金があって 

571 デフォルトの名無しさん [sage] 2009/09/12(土) 17:32:15 ID: Be:
    そもそも>>563は何を質問しているんだ?
    コピーコンストラクタの意味なのか、コピーコンストラクタで警告される理由なのか、
    エラーを解決する方法なのか、それとももっと別のことなのか 

572 デフォルトの名無しさん [sage] 2009/09/12(土) 17:48:16 ID: Be:
    >>571
    Stringはイミュータブルなので、本質的にはコピーコンストラクタ呼び出しを必要とする理由がありません。

    変数bはaと同じ内部状態を持つ別のオブジェクトとして作成されますが、
    bオブジェクトの内部状態を変更することはできません(イミュータブルなため)。

    オブジェクトaとオブジェクトbは、そのオブジェクトのライフサイクルの全ての期間において、
    全く同じ値を持つ別のインスタンスとして存在し続けることになってしまいます。

    以下のコードが理解の助けになるでしょう。

    String a = "string";
    String b = new String(a);
    String c = a;
    System.out.println(a == b);
    System.out.println(a == c);

    結果
    false;
    true; 

573 デフォルトの名無しさん [sage] 2009/09/12(土) 17:51:28 ID: Be:
    >>567
    >>568
    私が持っているのではないので・・・誰も教えてくれる人が周りにいないのですよ。

    >>571
    レスさんくすです。
    すいません、ほんとに初歩的なところからで申し訳ないのですが、
    コピーコンストラクタの意味もあまりわかっていないのです・・・。
    エラーというわけではなくて、アプリとして動いているけどこの
    ソフトで分析すると警告(?)が出るらしい。
    ということでとりあえず「コピーコンストラクタで警告される理由」が知りたいところです。

    String 変数A = "";
    String 変数B = "あたい";
    変数A = new String(変数B);

    いろいろ調べてみたのですが、もしかしてnewしているのが悪いって事かな?
    参考にしたWeb > ttp://www.javaroad.jp/java_character2.htm 

574 デフォルトの名無しさん [sage] 2009/09/12(土) 17:56:48 ID: Be:
    >>572
    レスさんくすです!
    おお!どうやら私の調査結果と近い答えが!
    一言に要約すると「文字列変数間の文字列コピーにnewを使うな」ってことでOK?
    変数A=変数B;
    って書けばよかったのかな。 

575 デフォルトの名無しさん [sage] 2009/09/12(土) 17:57:14 ID: Be:
    Javaを解る人間雇えよ・・・ 

576 572 [sage] 2009/09/12(土) 18:04:19 ID: Be:
    アンカ間違えてた。スマソ

    そうです。newで同じ値を持つ別のオブジェクトをわざわざ作るのは、
    bオブジェクトの内部状態を変えても、
    その影響がaオブジェクトに響かないようにするためのはずです。

    しかし、Stringは値の変更ができないため、
    そもそも値が同じ別のオブジェクトを作り出すメリットがありません。

    bの値を変えた場合は、新しいオブジェクトとして作成される(プログラマが意識しているかは別として)ため、
    同じ値である間は、同じオブジェクトを参照していて問題がありません。 

577 デフォルトの名無しさん [sage] 2009/09/12(土) 18:15:39 ID: Be:
    自分用にフォント選択ダイアログ作ってたんだけど
    親ウィンドウのフォント情報って取得どうすればいいんでしょうか?
    フォント情報ごと渡すしかありませんか・・・?
    親ウィンドウのgetFontしてもNULLでした 

578 563 [sage] 2009/09/12(土) 18:18:37 ID: Be:
    >>576
    Java詳しいみなさんありがとうでした!
    ふぅ・・・オブジェクト指向?とやらは概念が難しいですね。

    ちょっとびっくりしたのは、(あと今後の自分の為のメモ書きとしても)
    私がString変数だと勘違いしているStringはClassというオブジェクトであり、
    通常Javaはゲッターセッターで内部と値をやり取りしているが、
    Stringにはセッターが無い(?)ので、代入をすると毎回コンストラクタが発動(?)して
    名前は同じだけど別のオブジェクトとして変数の箱が存在しているという事かな。

    じゃぁさ、私みたいにDISKBasic~VB6時代のPGしかわからん人が考えているような
    ループ処理などのカウンタなどにString変数を使うとなんか変な気がしてきた。
    これやるとメモリにオブジェクトが大量にできあがってしまうのか!?な?

    うぅもうちょっと勉強してみよう。

    あと、ソフトに関して書いていた人へ
    DevPartnerというソフトは、使ってみるとすごいよ。
    コーディングチェックだけじゃなくてメモリ解放し忘れとか
    いろいろコンパイルエラーじゃないけど今回のような問題箇所を
    ばしばしと見つけてくれるので。で、さっき書いたURLに行けば
    体験版DLできるから試してみたら良いと思う。 

579 デフォルトの名無しさん [sage] 2009/09/12(土) 18:25:04 ID: Be:
    カウンターにString変数・・・?
    Stringってオブジェクトじゃなかったっけ・・・変数だっけ? 

580 デフォルトの名無しさん [sage] 2009/09/12(土) 18:32:25 ID: Be:
    >>563
    悪いがEclipseとか無償で入手できるツールで大抵のことは可能なんだわ
    有償が悪いとは言わないが、誰も使ったことのないツールよりも相談すれば誰かが回答できるツールのが良い 

581 デフォルトの名無しさん [sage] 2009/09/12(土) 18:36:34 ID: Be:
    >>578
    普通のループカウンタにオブジェクトを使うメリットはみあたらない。
    というか、Stringオブジェクトをどうやったらカウンタに使えるのか
    わかりません(^^;;
    いままでそういう発想をしたことすらなかった 

582 デフォルトの名無しさん [sage] 2009/09/12(土) 18:52:16 ID: Be:
    >>578

    なんていうの
    小学生が大学教授に数学の講義でもしようっての?
    アドバイスくれてやろうなんてお前には100年早い 

583 デフォルトの名無しさん [sage] 2009/09/12(土) 20:06:50 ID: Be:
    for(String sCounter = ""; !sCounter.equals("11111"); sCounter += "1"){
     処理
    } 

584 デフォルトの名無しさん [sage] 2009/09/12(土) 20:07:43 ID: Be:
    うっわ。そんなウンコみたいな処理よく考え付くね。 

585 デフォルトの名無しさん [sage] 2009/09/12(土) 20:30:26 ID: Be:
    そいつの脳じゃこんなんだろ
    for(String sCounter = ""; sCounter != "11111"; sCounter = new String(sCounter + "1")){
     処理
    } 

DevPartner か。会社で見たことがあるような。 にしても…釣り。だよなあ。

【CodeGear】Embarcaderoオッチャ その18【Delphi】
119 デフォルトの名無しさん [sage] 2009/09/11(金) 23:32:52 ID: Be:
    否定派の連中はちょっと静粛に!
    これから肯定派だけで根本的な問題を考えてみる

    Q.我々はなぜDelphiという開発環境に拘るのか?

120 デフォルトの名無しさん [sage] 2009/09/12(土) 01:09:15 ID: Be:
    んー Delphiが発売されるから。 

121 デフォルトの名無しさん [sage] 2009/09/12(土) 01:18:29 ID: Be:
    僕が一番うまくガンダムに乗れるから 

何だこの流れ。

ぐち0x1B ~最も働いている現場の人間から解雇~ 

978 仕様書無しさん [sage] 2009/09/09(水) 22:13:40 ID: Be:
    俺には16進数禁止令が出てます。
    16進数を2進数に脳内変換してビット演算できる人間が
    社内に俺(入社2年目)と課長A(社員20人で課長以上が8人)の2人しかいないから。
    課長Aは社内で一番仕事が出来るというか一人で仕事を完結させちゃう人なのでOKらしい。 

979 仕様書無しさん [sage] 2009/09/09(水) 22:23:03 ID: Be:
    というか2進数とか論理演算とかネットワークとか電子回路とか
    基本情報処理試験レベルの仕事が課長以上の専売特許みたいなもので、
    俺がすらすらとコード書いたら、他の人間が誰も理解できずに勝手にコメントアウトして
    1ヶ月に及ぶデスマの素になった。
    「なんで勝手に仕事したんだ」とか言われても。
    言われたとおりに仕様書どおりにコーディングしたら減給処分。
    今高卒初任給。
    早く景気回復しないかなー 

981 仕様書無しさん [sage] 2009/09/09(水) 22:26:29 ID: Be:
    何書いたんだ
    その文章を読む限りでは
    コードのレベルはともかく糞スパゲティだっただけちゃうんか
    としか思えない 

982 仕様書無しさん [sage] 2009/09/09(水) 23:25:33 ID: Be:
    例えば a &= 0x7000とか
    必要不可欠な処理なのにコメントアウトした状態で、
    先輩が「単体テスト通った」扱いにしました(絶対通るわけない)。
    「コメント多いから消せ」と誰かが言いました。
    まあ最終的には、俺が書いて誰もいじってないバージョンならそのまま結合テストでもほぼ動くことが判明したけど
    全ての責任は「誰も理解できないコードを書いた」俺が被らされました。
    基本情報処理レベル以上はヒラはやっちゃいけないのが会社の不文律らしい。
    俺は別プロジェクトの火消しに行っていたのでそれ以上の経緯は知らない。

    つうかここんとこ糞つまらないデスマの火消しばっかり。便利に使われてるな。
    糞コードの修正ばかりで気が狂いそう。A課長とかはあまりバグ出してくれないし。

    「赤字続きで残業代出せない」そうなので俺はサービス残業せず定時で帰ってるから
    それが評価低い原因の一つかも知らんけど。 

    >>982
983 仕様書無しさん [sage] 2009/09/10(木) 00:35:10 ID: Be:
    >例えば a &= 0x7000とか
    >全ての責任は「誰も理解できないコードを書いた」俺が被らされました。

    例えなのかもしれないけど、
    俺がコードレビューしたらこんなマジックナンバーを使っているコーディングは許さない。
    ビットフィールド定義で明確にした領域をラベル定数のみ使用を許すようにしないと他人が理解出来ないよ。

    ところで、何故ビット操作が必要なのだ?
    組み込み系なら、メモリマップドI/Oのレジスタ操作等で多用するが
    それ以外の場面で使ったことないぞ。

    安直にビットをフラグに使用しているとか、符号ビットを強引に操作しているなら、
    俺だったらコード書いた奴をぶっ飛ばす。

986 仕様書無しさん [sage] 2009/09/10(木) 00:52:38 ID: Be:
    >>983
    組み込み系ですが何か?
    もちろん実際にはマジックナンバーは使ってない。
    あとビットをフラグにするのは元請けが出してきた詳細仕様書に書かれていたことで、
    弊社は3次受けなのでそれに従うだけですが。
    まあハードウェア的にかなりギリギリの仕様なので、
    ビットをフラグにするのが安易とは思わなかったな。 

988 仕様書無しさん [sage] 2009/09/10(木) 01:47:19 ID: Be:
    >>986
    組み込みは保守的なところは徹底的に保守的だからな。 

989 仕様書無しさん [sage] 2009/09/10(木) 01:56:27 ID: Be:
    組み込み系で  a &= 0x7000 が理解できない奴だらけとか、
    御伽噺ですよね?......... 

990 983 [sage] 2009/09/10(木) 02:13:48 ID: Be:
    >>986
    組み込み系ですか。それなら関係者全員ビット操作の理解は必須かと。

    でも自分だったら、コーディングの際は
    #define FLG_SET  1
    #define FLG_RESET 0

    typedef struct _t_CONTROL_ {
      union {
        unsigned short Ctrl;
        struct {
          unsigned flg_exit    : 1;
          unsigned flg_hogehoge  : 1;
          unsigned field_payopayo : 2;
          unsigned field_honyarara : 4;
          unsigned field_uaa    : 8;
        };
      };
    } CONTROL;

    と定義しておいて

    :
    CONTROL status;
    :
    status.flg_exit = FLG_SET; //フラグセット
    status.flg_exit = FLG_RESET; //フラグリセット
    if( status.flg_exit == FLG_SET ) //フラグ判定

    て感じで使う。

991 仕様書無しさん [sage] 2009/09/10(木) 02:41:01 ID: Be:
    なぜだかとても field_uaa を操作したくなる 

992 仕様書無しさん [sage] 2009/09/10(木) 02:49:05 ID: Be:
    あのね、a &= 0x7000って2進数だと0111000000000000なのね。
    つまり残念ながらこれはフラグじゃなくて、0~7の変数なのね。
    確か輝度か何かのコードだったかな。

    ところで次スレ立てられなかった。誰か頼む。 

998 仕様書無しさん [sage] 2009/09/10(木) 10:08:56  ID: Be:
    >>992
    尚更ビットフィールドの出番じゃないか。
    尤も、MSB/LSB どっちから使われるかは事前に確認する必要があるが。 

999 仕様書無しさん [sage] 2009/09/10(木) 12:18:16 ID: Be:
    >>990
    ビットフィールドを使うヤツはバカ。
    そんなヤツが他人を非難するな。 

ビットフィールドは今ひとつ使いにくいところがあるんだよな。 特に今回みたいに、 あるポートのビット配置をビットフィールドで表現するというのはいろいろと問題が出やすい。

■_ このシリーズは面白そうだ

今日の時点でその2まで。



All Developers Should Know How They Learn Best
All Developers Should Know How They Learn Best

by Alan Skorkin on August 31, 2009

This is the first post in the teaching and learning series. The teaching and learning 
series includes the following posts:

   1. All Developers Should Know How They Learn Best (this post)
   2. The Secret Of Being A Great Mentor
   3. The Secret Of Being A Great Apprentice
   4. Become A Better Developer By Indexing Your Brain
   5. Learn More ? Faster By Using The World-Wide Community
   6. What Playing Cards Can Teach Us About Ramping-Up And Transferring Knowledge

Software development is one of those industries where you can’t really help it but be 
constantly learning. No matter how knowledgeable you are with the technologies you 
currently work with you still daily discover new, better, more efficient ways of doing 
what you do. It is even more hectic when you move to a new environment or end up on a 
new project where the technologies may not be as familiar, (or you could be a 
downright newbie) the domain is completely different and you have to work extra hard 
to get across everything in order to become effective as fast as possible.

(以下略)

ぼちぼち訳してみるか。

■_ 本日の虫干し

あとちょっとで終わりというのが結構あるんだよな。


Nirav's Contemplations: How Scala's pattern matching can replace Visitors

Thoughts on Programming, Eclipse and Open Source Software development.
Tuesday, April 21, 2009

How Scala's pattern matching can replace Visitors
(Scala のパターンマッチングはどのようにビジターパターンを置き換えることが可能であるか)

The primary motivation of Visitor design pattern is to separate model traversal from
operational logic. A visitable model takes the responsibility of model navigation
while the behavior is defined by arbitrary visitors. In this post I will try to
explain problems associated with Visitors in general and how Scala's pattern matching
feature can eliminate such problems cleanly. Consider a simplified Insurance Policy
model as follows (In Java):

デザインパターンにある Vistor パターンを使う大元の動機というのはmodel の traversal と 
operational logic を分離するということです。ある visitable モデルは model navigation 
の responsibility を受け取りますがその動作 (behavior) は任意のビジターによって定義され
ます。このポストでは、一般的なビジターに associate されている問題とScala のパターンマ
ッチング機能が如何にそのような問題をきれいに取り除けるのかについて説明しようと思います。
(Javaの場合を例にとって)以下のような単純化した Insurance Policy model を考えてみましょ
う:

public class PolicyElement {
 static class Quote extends PolicyElement {
  protected final Risk risk;
  public Quote(Risk risk) {
   this.risk = risk;
  }
  public void accept(PolicyVisitor visitor){
   visitor.visit(this);
   visitor.visit(this.risk);
  }
 }

 static class Risk extends PolicyElement {
  protected Coverage coverage;
  public Risk(Coverage coverage) {
   this.coverage = coverage;
  }
  public void accept(PolicyVisitor visitor){
   visitor.visit(coverage);
  }
 }

 static class Coverage extends PolicyElement {
  protected final Premium prem;
  public Coverage(Premium prem) {
   this.prem = prem;
  }
  public void accept(PolicyVisitor visitor){
   visitor.visit(prem);
  }
 }

 static class Premium extends PolicyElement {
  protected final double amt;
  public Premium(double amt) {
   this.amt = amt;
  }
  public void accept(PolicyVisitor visitor){
   visitor.visit(this);
  }
 }
}

public interface PolicyVisitor {
 public void visit(Quote quote);
 public void visit(Risk risk);
 public void visit(Coverage cvrg);
 public void visit(Premium prem);
}
public class PolicyTest {
 static class PremiumCalcVisitor implements PolicyVisitor {
  private double totalPremium;

  @Override
  public void visit(Premium prem) {
   totalPremium = getTotalPremium() + prem.amt;
  }

  @Override
  public void visit(Coverage cvrg) {
  }

  @Override
  public void visit(Risk risk) {
  }

  @Override
  public void visit(Quote quote) {
  }

  public double getTotalPremium() {
   return totalPremium;
  }
 };

 public static void main(String[] args) {
  Quote quote1 = new Quote(new Risk(new Coverage(new Premium(10))));
  Quote quote2 = new Quote(new Risk(new Coverage(new Premium(30))));
  PremiumCalcVisitor visitor1 = new PremiumCalcVisitor();
  PremiumCalcVisitor visitor2 = new PremiumCalcVisitor();
  quote1.accept(visitor1);
  quote2.accept(visitor2);
  assert visitor1.getTotalPremium() + visitor2.getTotalPremium() == 40;
 }
}
(Generally, we introduce one more abstract class to omit empty implementations in Visitors but I have left it for brevity.) Now, not so apparent problem here is that if the object model changes (which is more frequently the case in real life), we have to add one more method to PolicyVisitor interface, all visitor implementations if change is substantial and have new Policy elements implement visitor methods. This invasive nature of Visitor couples it tightly with the model. With pattern matching and views in Scala, you can have alternative implementation which is precise as well as non-invasive unlike visitors. (一般的に、わたしたちは二つ以上の抽象クラスを空の実装を omit するためにVisitors に導入 しますが、brevity を理由としてわたしは放置しています)さてここでは not so apparent な問 題とは、オブジェクトモデルが変更された場合(which is more frequently the case in real life)にPolicyVisitor インターフェースにもう一つメソッドを追加する必要があるということ と変更が substantial かつ新しい Policy 要素を持つものであった場合にはすべてのビジター の実装においてビジターメソッドの実装が必要となってしまうということです。このビジターの invarsive nature は couples it tightly with the model. Scala ではパターンマッチングと views によって、あなたはビジターとは異なり non-invarsive と同じくらい precise である alternative implementation を持つことが可能になるのです。

class PolicyElement
case class Quote(risks: Risk) extends PolicyElement
case class Risk(cvrg: Coverage) extends PolicyElement
case class Coverage(limit: Premium) extends PolicyElement
case class Premium(amt: Double) extends PolicyElement

object PremCalcTest {
  class PremCalculator(pol: PolicyElement){
    def calcPrem : Double = calcPrem(pol)
    def calcPrem(policy: PolicyElement): Double = policy match{
      case Quote(risk)   => calcPrem(risk)
      case Risk(coverage)  => calcPrem(coverage)
      case Coverage(premium)=> calcPrem(premium)
      case Premium(amt)  => amt
    }
  }

  implicit def calPremV(pol: PolicyElement)= new PremCalculator(pol)

  def main(string: Array[String]){
    val risk1 = Risk(Coverage(Premium(10)))
    val risk2 = Risk(Coverage(Premium(30)))
    println(Quote(risk1).calcPrem + Quote(risk2).calcPrem)
  }
}

This code requires some explanation. What we have done here is we labeled domain classes with a 'case' keyword in Scala. If you tag a class with 'case' it can be used for pattern matching in a switch-case like structure as done in method 'calcPrem'. You don't need to create members or setter/getters for them, they are created by compiler for you. A case class can be instantiated without 'new' keyword; So Risk(Coverage(Premium(0)) is translated as new Risk(new Coverage(new Premium(0D))) in equivalent Java code. The code in 'calcPrem' function can be assumed to be something similar to instanceOf checks for each possible case in Java, for example: このコードにはある程度の説明が必要でしょう。わたしたちがここで行っていることはドメイン クラスを Scala の 'case' キーワードでもってラベル付けすることです。'calcPrem' メソッド の中で行っているように switch-case のような構造でパターンマッチングを使用できるように クラスに 'case' でもってタグを打った場合メンバーやそれに対するsetter/getter をあなたが 作成する必要はありませんそれらはコンパイラーがあなたのために生成してくれます。case ク ラスは 'new' キーワードを使わずにインスタンス生成するこが可能です。ですから、 Risk(Coverage(Premium(0)) は等価なJava コードである new Risk(new Coverage(new Premium(0D))) へと変換されます。'calcPrem' 関数にあるコードでは Java の case で使うことのできる instanceOf チェックと同様なことを行うと仮定することができます。例を挙げましょう: if(object instanceOf Premium) return ((Premium)object).amt; What we also have done silently is added a method 'calcPrem' to PolicyObject class. This is done through implicitly defined function 'calPremV', this will allow us to call 'calcPrem' method on any PolicyObject without actually modifying the domain model code. This type of lexically scoped class extension is known as a View in Scala and is similar to what is available in Ruby as open classes except without scoping. In case if the model changes in this case, we just need to modify a single function and we are done. These programming language features of Scala frees us from coupling introduced by inheritance. So it is easy to see that Scala's language features can be elegant and far more powerful than other languages (specifically Java) without sacrificing compiler checks and type safety. わたしたちが暗黙のうちに行っていることにはPolicyObject クラスに 'calcPrem' メソッドの 追加もあります。これは暗黙裡に定義されている関数 'calPremV' を通じて行われるので、ドメ インモデルコードを修正することなく任意の PolicyObject の 'calcPrem' メソッドを呼び出す ことが許されるようになります。この種の lexically scoped class extension はScala では View として知られているもので、Ruby で使うことのできるオープンクラスとスコープにおける 相違を除けば同様なものです。こういったケースでモデルが変更されたときにわたしたちに必要 なのは関数を一つ修正することだけです。Scala のこのようなプログラミング言語機能 は coupling introduced by inheritance からわたしたちを解放してくれます。こういったScala の言語機能をコンパイラーのチェックや型安全を犠牲にすることなしに他の言語(特にJava)より もエレガントかつちょー強力にできるということは一目瞭然です。 Posted by Nirav Thaker

■_ 本日の巡回から

2009年09月11日

■_

・副都心線
二日連続で、人身事故によるダイヤの乱れとかアナウンスしてたけど、 この調子で東横線が乗り入れる状態になったらどうなるんだろうか。

・渡里さん
今回のYAPCASIA では無事お会いすることができました(笑)。 LLTVにもいらしてたらしいのですが、どうもわたしがオライリーのブースに行った時間が 悪かったようです。 んで、せっかくなので 一冊(Book:アート・オブ・アプリケーション パフォーマンステスト) 買いました。 Perlのイベントということで、Perlのステッカー (O'Reilly Village/オラの村 - 9月の直販キャンペーン:使える言語を示す動物ステッカーと秋のオライリーTシャツ)をプレゼントのところを Rubyのくれとわがままぶっこいたのは、ワ・タ・シ(笑)

■_ で、YAPC::Asia

すみません。まとめてる気力が。

でまあ、ついったでもつぶやいたのですが(誰も反応してくんなかったけどw)、 RubyKaigi とは来ている人たちの印象が違う感じがして興味深かったです。 どっちがどうとかいうことでなく。 YAPCの方が髭率が高いとか?


YAPC::Asia Tokyo 2009 スペシャルレポート:2日目レポート[随時更新]|gihyo.jp … 技術評論社
「YAPC::Asia Tokyo 2009」開催 9月10日から2日間、計60以上のセッション:CodeZine

例によってなーんも考えてない思いつきなんですが、 今回から YAPC::Asia の開催を取り仕切っている JPAの代表の牧さんと、 角谷さんとか高橋会長あたりで対談とかして欲しいなあとか考えてみたり。 この種のイベントに対する姿勢とか考えとか。 牧大輔氏インタビュー「YAPCで人とのつながりを」 - @IT自分戦略研究所

■_ -0?

■_

Perl in five sentences « Not this…

Perl in five sentences
Filed under: perl — TimBunce @ 12:00 pm

I just added a concluding slide to my updated Perl Myths talk. Having comprehensively 
debunked some myths with hard facts about perl and its ecosystem, I wanted to end with 
a slide that summarized some truths.

I liked the slide text so much I wanted to share it with you:


    Perl:

    has a massive library of reusable code
    has a culture of best practice and testing
    has a happy welcoming growing community
    has a great future in Perl 5 and Perl 6
    is a great language for getting your job done
        for the last 20 years, and the next 20!

ふむ。

■_ 本日の巡回から

あとで

The Secret Of Being A Great Mentor
http://www.skorks.com/2009/09/the-secret-of-being-a-great-mentor/

The 7 Software Development Wastes - Lean series Part 6 - Delays | Agile Software Development
http://agilesoftwaredevelopment.com/blog/jackmilunsky/7-software-development-wastes-lean-series-part-6-delays

mik's blog ≫ Quality-oriented teaching of programming
http://blogs.kent.ac.uk/mik/2009/09/04/quality-oriented-teaching-of-programming/

heron-language - Project Hosting on Google Code
http://code.google.com/p/heron-language/

3 Sets of Programming Exercises to Polish Your Skills
http://charlesmaxwood.com/3-sets-of-programming-exercises-to-polish-your-skills/

As programmers, how often have you got to work non-paid extra-hours? : programming
http://www.reddit.com/r/programming/comments/9j4vu/as_programmers_how_often_have_you_got_to_work/

Dobbs Code Talk - A Heron update and PEG Parsing in C#
http://dobbscodetalk.com/index.php?option=com_myblog&show=A-Heron-download-and-PEG-Parsing-in-C-Sharp.html&Itemid=29

Treatment of Alan Turing was “appalling” - PM | Number10.gov.uk
http://www.number10.gov.uk/Page20571

UK apologizes for treatment of Alan Turing : programming
http://www.reddit.com/r/programming/comments/9jc1x/uk_apologizes_for_treatment_of_alan_turing/


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

ホームへ


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

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