私がPerlに こだわる理由 s:Why I Stick With Perl ---- id:jrockway http://github.com/jrockway/ http://blog.jrock.us/ ---- なぜPerlを? s:Why Perl? ---- もっと 根本的には s:But first, a deeper question ---- なぜ プログラミングを? s:Why programming? ---- いろんな理由が あるだろう s:Many reasons: ---- 構文 s:Syntax ---- 実装のしやすさ s:Speed of implementation ---- 友好的な コミュニティ s:Friendliness of community ---- でも、違う! s:No! ---- 構文なんてどうでもいい s:You don't care about the syntax ---- 速さも そう s:You don't care about speed ---- コミュニティもそう s:You don't care about the community ---- なぜ プログラミングを するのか? s:Why programming? ---- なにかを 片付けるためだ! s:To get things done! ---- 問題がある s:You have a problem ---- アイデアがある s:You have an idea ---- 実装したい s:You want to implement it ---- それだけ s:That's it ---- じゃあなぜPerlを? s:So why Perl? ---- なにかを 片付けるため s:To get stuff done ---- どうやって? s:How does Perl do this? ---- ライブラリ s:Libraries ---- 経験 s:Experience ---- コミュニティ s:Community ---- ライブラリ s:Libraries ---- 仕事を 片付けるときには 一番大事 s:Most important thing for getting work done ---- ライブラリ: Perlにはある! s:Libraries: Perl has them! ---- ここまでの道のり? s:How did we get here? ---- 歴史 s:History ---- UNIX ---- すべてが お互いに 通信できる s:Everything can talk to everything else ---- 再利用可能な ユーティリティ 作り s:Make reusable utilities ---- もう自分でCコンパイラを 書かなくてもいい s:No more writing your own C compiler ---- パーサジェネレータもそう s:Or a parser generator ---- プロセス間の橋渡しを するものもそう (シェルがある) s:Or glue between processes (we have the shell) ---- その他のものもそう s:And so on... ---- これはほんの手始め! s:This was just the beginning! ---- Perl ---- 相互通信が もっと簡単に s:Make it even easier for things to talk to each other ---- コードやアルゴリズムの 再利用ももっと簡単に s:Make it even easier to reuse code and algorithms ---- しばらくはコア+UNIXの いいとこ取りだった s:Core + UNIX good for a while ---- ほかの領域でも 使われるようになる s:Other problem domains emerged ---- ライブラリが 出始める s:Libraries start to pop up ---- CPAN誕生! s:CPAN created! ---- Perlが新しいことを できるようになる s:Now Perl can do new things ---- 新しいことを したくなった? s:Want to do something new? ---- どうぞどうぞ s:Do it. ---- ほら、ほかの人も できるようになった! s:Now everyone else can too! ---- ライブラリの文化 s:Culture of libraries ---- これは本当に新しい すばらしいことだった s:This was really a new and great thing ---- 我々はいまその 恩恵を受けている s:And we reap the benefits today ---- おかげで人助けの 文化が生まれた s:This created a culture of helping people ---- 競争ではなく s:(Instead of competing with others) ---- 過去の膨大な 蓄積の上に乗る s:"Standing on the shoulders of giants" ---- 大きなアプリを 作ることもできる s:You can build your big application ---- 土台の心配を する必要はない s:Without worrying too much about the foundation ---- コミュニティを助ければ、 コミュニティが助けてくれる s:You help the community, the community helps you ---- さて、いまのPerl s:So, Perl today ---- ライブラリとコラボレーション s:Libraries and collaboration ---- それで我々が 得たものは? s:What does that get us? ---- 古いアイデアを s:Old ideas ---- 少しずつ新しいものに s:Can be gradually replaced ---- たとえば、 オブジェクト指向 s:Example: OO ---- 最初は 手作業だった s:First there was the manual way ---- package Class; our @ISA = ('Parent'); sub new { my $class = shift; return bless {@_}, $class; } sub foo { my $self = shift; return $self->{foo}; } ---- OK、ないよりはまし s:OK, fine, better than nothing ---- コミュニティが OOに慣れてくると s:The community gets used to that idea ---- モジュールが 書かれるように s:People teach others, modules get written ---- こんなことを 考える人もあらわれた s:Someone else comes along ---- どうすれば改善できるだろう s:"I wonder how I can improve this?" ---- Class::Accessor! (ガクブル) s:Class::Accessor! (Shudder.) ---- package Class; use base 'Class::Accessor'; __PACKAGE__->mk_accessors(qw/foo/); ---- いいね。 コードも減った s:Getting better; less code ---- ポイントは s:The key ---- 新しいやり方でも 古いやり方でも 動くということ s:The new way and the old way work together ---- 新しいコードの方が 簡単になるよう努力はする s:The community made making new code easier ---- でも古いコードを 捨て去ることはしない s:But it didn't throw away all the old code! ---- もっとよくなった s:It gets better ---- package Class; use Moose; has foo => ( is => 'ro' ); ---- これなら拡張して 機能を追加する余地がある s:Even better; room for expansion and new features. ---- でも、古いコードもまだ動く s:But it still works with old code ---- 時は流れて s:Time passes ---- 我々はまだ改善を 試みている s:We still try to improve things ---- class Class { has foo => ( is => 'ro' ); } ---- ここでのポイント s:Point of the example ---- コミュニティはPerlの 改善を続けている s:The community continues to improve Perl ---- 日々新しいものが 登場しているし s:Every day there is something new to play with ---- 日々新しいアプリを書くのが 簡単になっている s:Every day it gets easier to write new applications ---- コミュニティから 得られるものってそれしかないの? s:What else do we get from community? ---- 新しいアイデア s:New ideas ---- 依存モジュールを 減らしたい s:"Minimize dependencies" ---- アプリそのものを 再利用したい s:"Reuse your app in itself" ---- こういったアイデアがまた 新しいモジュールのベースになる s:These ideas form the basis new libraries ---- サブコミュニティもある s:We also get sub-communities ---- CatalystやMoose、POE、 HTTP::Engine等々 s:Catalyst, Moose, POE, HTTP::Engine, etc. ---- Catalyst::Fooの 使い方を教えてよ s:"How do I use Catalyst::Foo?" ---- 自信はないけどきっと こうじゃないかな s:"I don't know what that is, but probably..." ---- Perlコミュニティ内の 小さなグループ s:Small sections of the Perl community ---- 同じような考えを 持つ仲間がお互いに 切磋琢磨できる場所 s:Where like-minded people can improve each other's applications ---- 知り合いかどうかなんて関係なし! s:Without even knowing about each other! ---- すごいことが起こるのは このサブコミュ s:Cool stuff happening here ---- 参加するいい方法 s:Great way to get involved ---- 改善できるパターンを 覚えよう s:Notice a pattern that you can improve ---- MooseXとかCatalyst::*とか POE::Componentとかにしたらどうだろう s:Make it a MooseX:: or Catalyst::* or POE::Component or ... ---- みんなのためになる s:Everyone gets to benefit ---- ライブラリ s:Libraries ---- コミュニティ s:Community ---- それだけ? s:What else? ---- 「そんなの間違ってる」 s:"UR DOIN IT RONG" ---- そんなことはない s:But the opposite ---- コミュニティがサポートしているコードを 使うのは正しい s:When you use the community-supported code, you're doing it right! ---- ライブラリは作者が一番得意な やり方で書かれているもの s:The people that are writing libraries like to write code the best way they know how ---- それを使えば作者の専門技術を ただで使わせてもらえることになる s:When you use their stuff, you get their expertise for free ---- Catalystの場合 s:Catalyst example ---- コントローラは薄く、モデルは厚く s:Thin controller, thick model = good ---- Catalyst::Model::Adaptorは そのためのもの s:That's why there is Catalyst::Model::Adaptor ---- 正しいやり方だと 自信を持ってもらうためにある s:It's there to help you know you're on the right track ---- Moose ---- 型制約 s:Type constraints ---- コード自身に テストさせよう s:Let your code test itself ---- いいね! s:Good! ---- MooseX::Types ---- 型制約を まとめるもの s:Organize those type constraints ---- いいね! s:Good! ---- MooseX::AttributeHelpers ---- 内部表現を 隠すもの s:Hide your internal representation ---- いいね! s:Good! ---- こういったモジュールを使うと いいコードが簡単に s:All these modules let you easily write good code ---- 悪いコードを書くより 簡単に書けるようになる! s:And they make it easier to write good code than bad code! ---- ライブラリ s:Libraries ---- コードを確実に 再利用できるように s:Ensure you reuse code ---- いいコードを 書けるように s:Make sure you write good code ---- ほかの人に理解して もらえるように s:Make sure others understand your code ---- ほかの人に使って もらえるようにする s:Make sure your code is usable by others! ---- 将来? s:What about the future? ---- どんなアイデアが 生まれるだろう? s:What ideas will we have? ---- 過去を振り返ってみよう s:Let's look at the past ---- Webまわり s:Web stuff ---- CGI.pm ---- 結構便利。 リクエストを受け、 HTMLを生成できる s:Pretty nice, you can accept requests and produce HTML ---- 手書きよりはまし s:Better than doing it manually ---- CGI::Application ---- コンポーネントを 再利用するための フレームワーク s:Framework for reusing components ---- Catalyst ---- その考えを 発展させたもの s:Evolution of this idea ---- 自動と設定の バランス s:The right level of automatic vs. configuration ---- 大人気 s:Massively popular ---- 人気が人気を 呼んでいる s:This made it even more popular ---- 大事な ポイント s:Key idea ---- フレームワーク s:Frameworks ---- コードの共有を簡単に。 とにかく動く s:Let people share code easily, in a way that "just works" ---- 将来? s:What about the future? ---- フレームワークは もういい s:No more frameworks ---- ライブラリの復活 s:Libraries again ---- フレームワークができる すべてのことに対応 s:Do everything frameworks can do ---- ほしいものは ユーザに選ばせる s:But let the user pick exactly what he wants ---- だめな機能を無視したり、 使うのをやめるのではなく s:(Instead of ignoring "bad" features, don't have them at all) ---- 例 s:Example ---- HTTP::Engine ---- Catalystアプリの デプロイは簡単 s:Catalyst apps are easy to deploy ---- でもCatalystを 使いたくない場面もある s:But sometimes you don't want Catalyst ---- 解決策 s:Solution ---- Catalystに 依存しないように s:Make that part reusable outside of Catalyst ---- ライブラリを頼る、 フレームワークに頼らない s:More library, less framework ---- それが将来! s:That is the future! ---- 本題に戻ろう s:Back to my main point ---- ライブラリもいいし、 みんな親切 s:All these libraries and friendly people are nice ---- 今を楽しく というのもいい s:Having fun now is cool ---- 将来の計画を 立てるのもいい s:Planning for the future is great ---- でも、なんでそんなこと 気にしてるんだろう s:But why do I care? ---- なぜって s:You care because ---- 正しいことをしているのが わかっているから s:You know you're doing it right ---- ほかの人も自分のアプリの 動きを把握していて s:Other people know how your app works ---- デモ前日の朝の3時に 助けてくれたりする s:And can help you at 3am before your demo ---- 自分が見つける前にバグ 取りしてくれるし s:They can fix bugs before you find them ---- YAPCでビールをおごって くれたりもする :) s:They can buy you beer at conferences :) ---- プログラミングが したいんでしょう? s:You care about programming ---- Perlを使うと楽しいことを 簡単にプログラムできるようになる s:Perl makes it easy to program the fun stuff ---- Perlを使うとつまんないことは コミュニティにしてもらえる s:Perl lets the community handle the "boring" stuff ---- なんでPerlにこ だわるのかって? s:Why do I stick with Perl? ---- みなさんがいるからですよ! s:Because of you, the community! ---- みなさんが いろいろしてくれるから s:All the work you've done for me ---- みなさんがいつも 助けてくれるから s:All the times you've helped me ---- ありがとう! Perl大好き! s:Thanks! That's why I love Perl! ----