123
 123

Tue 25 September, 2007

Click here to bookmark this link.Channel Image03:10 The language of bias» Loud Thinking by David Heinemeier Hansson

If you don't like something new that's getting a lot of attention, you call it out as being all hype propelled by fanboys enamoured by an immature solution.

If you like that something new, you say it has momentum that's being accelerated by passionate advocates of a fresh approach.


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl

Mon 24 September, 2007

Click here to bookmark this link.Channel Image23:51 仕事耕具:“旧ソ連の発明法則”でアイデア出し──「智慧カード」 - ITmedia Biz.ID» Matzにっき
これすごい。 物体は軽くすれば強度は弱まり、強度を強めれば重くなることが多い。この「物体の重さ」と「強度」の項目もマトリックスの縦と横に入っており、その交差する部分には「非機械的なシステムで機械的なシステムを交換する」「高価で耐久性のある物の代わりに、経済的で寿命の短い物を使う」「機械的振動」「複合的な物質」といった4つの技術的ブレークスルーが書かれている。このブレークスルーをヒントにすると、いいアイデアが産まれる──というわけだ。 うむ、これに従うだけで技術的ブレークスルーを実現できる(可能性が高..
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image23:51 モデリングフォーラム 2007» Matzにっき
先日も書いた通り、「好きに話してください」と依頼されたので好きに話してきた。 タイトルも「Rubyからのメッセージ」。 要するに「言語おたく」全開の話(ほんとはちょっとセーブしてるけど)。 モデリングな人々置いてきぼりのような気がしないでもないが、 そこはそれ。メッセージをから意味を読み取るのはレシーバの責務ということで。 責務と言えば、前日のキーノートは 「Responsibility Driven Approach」のRebbecca Wirfs-Brockだったのだそうだ。 彼女のファンとしては惜しいことをした。
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image23:51 「フェアユース」の経済効果は4兆5,000億ドル、米業界団体調査» Matzにっき
締めつけることしか考えてない近視眼的な権利団体の連中に読ませてやりたい。 いや、読んでも信じないんだろうけど。 私は(もともとそんなにこだわってないし)新しい音楽とテレビには そろそろ見切りをつけはじめている。 だって生活必需品じゃないんだもの。
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image23:51 urekatのスカンク日記3 - Softbank 705SHからUTF8で絵文字が来ましたCommentsAdd Star» Matzにっき
うわぁ、UTF-8で絵文字かぁ。 ケータイの世界はなにが起きるか分からないなぁ。 なんとなく「イヤな臭い」がする。 きっと将来苦労するんじゃないだろうか。
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image21:15 Look at the sea. What does ...» Projectionist
Look at the sea. What does it care about offenses?”

Buck Mulligan


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image21:11 idiolect: The language or s...» Projectionist
id•i•o•lect
[id-ee-uh-lekt]noun
The language or speech pattern of one individual at a particular period of life.

add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image19:38 XRuby 0.3.1和Ruby Hacking Guide中文版» 梦想风暴

今天是一个发布的日子,XRuby发布了0.3.1,Ruby Hacking Guide中文版发布了第一部分。

XRuby 0.3.1

相比于前一个版本,XRuby 0.3.1最大的进步在于完成标准库的预编译。预编译意味着什么?标准库代码无需在每次运行时编译,这意味着今后使用XRuby的标准库性能会得到一定的提升。

有一个与编译相关的话题。之前,Jon Tirsen曾经谈到JRuby的一个问题,运行在AppServer中会有占用太多内存。经过分析得知,为了提高程序的并发性,程序运行会启动多个JRuby。每个JRuby解析Ruby脚本都会建立一棵完整的语法树,这就意味着,由于这种解析模式本身的限制,对于同样的内容,内存中需要保存多份相同的语法树,这种做法意味着无谓的耗用了大量的内存。采用编译的做法,则可以很好的避免这个问题。因为在运行时,相同的是字节码,而JVM很好的帮我们解决字节码共享问题,无需耗用大量的内存。

Ruby Hacking Guide中文版第一部分

RHG终于完成了第一次发布。已经发布的第一部分介绍的是Ruby的对象模型。我正是从这个部分开始了解Ruby实现的,进而完成了XRuby的Runtime的重写。所以,我一直觉得这部分是了解Ruby实现非常好的一个起点。

从翻译Ruby Hacking Guide到现在已经超过了一年,从第一次发布消息算起也超过了9个月。相比XRuby,这个项目的进展可以用异常缓慢形容。这是一本日文书,也是一本技术书,而且是一本讲语言实现的书。任何一个点都会增加翻译的难度。几个懂日语的朋友先进行一遍初译,然后,我对再对译稿进行一遍校验,并根据自己的理解修改译稿,这样的过程无疑延长了处理的时间。这是一个业余时间的项目,而我更多的业余时间在XRuby上,没有太多精力投入上面。种种的因素造成了这个项目的一托再托。

目前,我手头已经有了第二部分全部和第三部分几章的初译稿,不过,按照之前的进度来看,这几章的发布可能要等到许久之后了。如果你有兴趣,可以加入到这个项目中来,这样,有助于加快这个项目的进度。


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image11:59 Tweets on 2007-09-23» halostatue
@lylejohnson I don’t find that a yikes. There are a few points that he makes that don’t surprise me. # Powered by Twitter Tools.
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image11:59 Tweets on 2007-09-23» halostatue
@lylejohnson I don’t find that a yikes. There are a few points that he makes that don’t surprise me. # Powered by Twitter Tools.
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image11:59 Tweets on 2007-09-23» halostatue
@lylejohnson I don’t find that a yikes. There are a few points that he makes that don’t surprise me. # Powered by Twitter Tools.
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image09:23 On Derek Siver’s Return to PHP…» halostatue
Derek Siver's rewrite of CD Baby with Rails failed, but it's not Ruby's fault.
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image09:08 Thinking about The Big Rewrite?» Loud Thinking by David Heinemeier Hansson

Rewriting existing applications from scratch in a Big Bang-style is rarely a good idea and often ends in failure. Chad Fowler wrote a good post summarizing some of the reasons why a year ago: The Big Rewrite.


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl

Sun 23 September, 2007

Click here to bookmark this link.Channel Image23:45 摘录NPO纵横中的一段» Suave's Blog
看NPO纵横05年9月创刊号中的《扶贫日记:崇敬和回报穷人的美德》,中间有这样两段话。 人 们也许会习惯地认为贫困的人自身应该负有主要责任。也许是。但我接触多了贫困的人们后,觉得不...
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image06:12 Rails框架技术讲座:网络应用软件页面技术jMaki on Rails» 道喜技术日记
Rails框架技术讲座:网络应用软件页面技术jMaki on Rails

目录
 (一)系统环境:

  1. Ruby 语言 1.8.4版本, 点击这里Ruby1.8.4。要想安装多个Ruby语言运行环境请看这里
  2. Rails 框架 1.2.1版本,安装方法请看这里,最简单方法是第一种方法即可。
  3. Windows XP 或者 Windows 2000操作系统 或者 Linux操作系统
  4. 需要一个浏览器,如FireFox1.5.0.1以上版本。
  5. 开发编辑工具 Notepad2 ,安装方法请单击这里,复制一个notepad2.exe,并且更名为vi.exe。
  6. 在Windows XP上安装Linux核心命令,点击这里
  7. 如何在Windows Console下使用命令svn(下载软件),点击这里
  8. 安装数据库系统SQLite3,点击这里

 (二)前提条件:

  1. 在本机Winodw操作系统上,我们的工作目录为d:\works_rails。
  2. 你的电脑必须在线。

 (三)目的:

  1. 本文将说明网络页面技术jMaki上如何和Rails框架技术相互有机地结合在一起的。
  2. 本讲座的完整代码请您在Google Code Hosting上查看:
    http://cnruby.googlecode.com/svn/trunk/rails-projects/use-jmaki
    或者下载
    svn co http://cnruby.googlecode.com/svn/trunk/rails-projects/use-jmaki

 (四)解决方案:

  1. 我们创建Rails框架应用软件的根目录:
    mkdir use_jmaki
    cd use_jmaki
  2. 安装基于Rails框架的jMaki插件:
    ruby script/plugin source http://jmaki-goodies.googlecode.com/svn/trunk/rails_plugins
    ruby script/plugin install jmaki_core
    ruby script/plugin install jmaki_yahoo
    我们的实例仅仅使用到jMaki框架软件的一个插件jmaki_yahoo,其它的插件也可以使用,安装方法如下:
    ruby script/plugin install jmaki_dojo
    ruby script/plugin install jmaki_ext
    ruby script/plugin install jmaki_flickr
    ruby script/plugin install jmaki_google
    ruby script/plugin install jmaki_native
    ruby script/plugin install jmaki_scriptaculous
    ruby script/plugin install jmaki_spry
  3. 编辑数据库配置文件 database.yml
    vi config\database.yml
  4. 利用Rails框架自动代码生成技术,我们创建一个模型Admin及其相关代码:
    ruby script/generate scaffold_resource admin
  5. 针对我们的模板页面文件,增加jMaki技术的相关代码 admins.rhtml,以便使用JavaScript和CSS代码。这是本文的精华部分之一。
    vi app/views/layouts/admins.rhtml
      <%= stylesheet_link_tag "jmaki-standard", :media => "all" -%>
      <%= javascript_include_tag "jmaki" -%>
      <%= jmaki_setup -%>
  6. 编辑数据库移植技术文件 001_create_admins.rb ,并且创建数据库及其相关表:
    vi db/migrate/001_create_admins.rb
          t.column :username, :string
          t.column :password, :string
          execute "INSERT INTO admins VALUES(1, 'munich', '24680')"
          execute "INSERT INTO admins VALUES(2, 'beijing', '13579')"
    rake db:migrate
  7. 利用Rails框架技术和jMaki框架技术,修改页面 index.rhtml 文件。注意这是本文的精华部分之二。下面的代码有二部分代码,前面的是利用Rails框架技术把实际存储到一个Array中;后面的是jMaki框架的代码技术。
    vi app\views\admins\index.rhtml
      <h1>Listing admins</h1>

      <% @table_data = [] %>
      <% for admin in @admins %>
        <% @table_data << [ admin.username, admin.password,
                             link_to('Show', admin_path(admin)),
                             link_to('Edit', edit_admin_path(admin)),
                             link_to('Destroy', admin_path(admin), :confirm => 'Are you sure?', :method => :delete)
                           ] %>
      <% end %>

      <%= jmaki_widget 'yahoo.dataTable',
          :args => {
              :columns => [
                  { :title => 'Usename', :width => 200, :locked => false },
                  { :title => 'Password', :width => 75, :renderer => 'italic' },
                  { :title => 'Show', :width => 60, :renderer => 'italic' },
                  { :title => 'Edit', :width => 60, :renderer => 'italic' },
                  { :title => 'Destroy', :width => 60, :renderer => 'italic' },
              ]
          },
          :value => @table_data
      -%>

      <br />
      <%= link_to 'New admin', new_admin_path %>
  8. 启动网络服务器:
    ruby script\server
  9. 浏览我们的网络应用软件:
    start http://localhost:3000/admins

 (五)视听教学:



 (六)必须注意的问题:

  1. 利用NetBeans工具,可以更好地使用jMaki框架技术。

 (七)参考资料:

  1. https://ajax.dev.java.net/files/documents/3115/45044/org-netbeans-modules-sun-ajax-updatecenter.nbm
  2. https://ajax.dev.java.net/servlets/ProjectDocumentList?folderID=0
  3. http://blogs.sun.com/arungupta/entry/jmaki_on_rails_for_dummies
  4. http://jmaki.com/

 (八)命令清单:

mkdir use_jmaki
cd use_jmaki

ruby script/plugin source http://jmaki-goodies.googlecode.com/svn/trunk/rails_plugins
ruby script/plugin install jmaki_core
ruby script/plugin install jmaki_dojo
ruby script/plugin install jmaki_ext
ruby script/plugin install jmaki_flickr
ruby script/plugin install jmaki_google
ruby script/plugin install jmaki_native
ruby script/plugin install jmaki_scriptaculous
ruby script/plugin install jmaki_spry
ruby script/plugin install jmaki_yahoo

mysqladmin -u root -proot create jmaki
vi config\database.yml

ruby script/generate scaffold_resource admin

vi app/views/layouts/admins.rhtml
<%= stylesheet_link_tag "jmaki-standard", :media => "all" -%>
<%= javascript_include_tag "jmaki" -%>
<%= jmaki_setup -%>

vi db/migrate/001_create_admins.rb
t.column :username, :string
t.column :password, :string
execute "INSERT INTO admins VALUES(1, 'munich', '24680')"
execute "INSERT INTO admins VALUES(2, 'beijing', '13579')"
rake db:migrate

vi app\views\admins\index.rhtml
<h1>Listing admins</h1>

<% @table_data = [] %>
<% for admin in @admins %>
<% @table_data << [ admin.username, admin.password,
link_to('Show', admin_path(admin)),
link_to('Edit', edit_admin_path(admin)),
link_to('Destroy', admin_path(admin), :confirm => 'Are you sure?', :method => :delete)
] %>
<% end %>

<%= jmaki_widget 'yahoo.dataTable',
:args => {
:columns => [
{ :title => 'Usename', :width => 200, :locked => false },
{ :title => 'Password', :width => 75, :renderer => 'italic' },
{ :title => 'Show', :width => 60, :renderer => 'italic' },
{ :title => 'Edit', :width => 60, :renderer => 'italic' },
{ :title => 'Destroy', :width => 60, :renderer => 'italic' },
]
},
:value => @table_data
-%>

<br />
<%= link_to 'New admin', new_admin_path %>

ruby script\server


 (九)下载文件pdf:


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image01:36 Summary of security articles and plugins» Riding Rails - home

The QuarkRuby blog has created a great Ruby on Rails Security Guide that gives you a wealth of links to articles and plugins dealing with security in Rails applications. Everything fromn XSS to CSRF stuff is covered.


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image01:36 韓国でオープンソースの利用が進まない理由は本当に英語?:日経パソコンオンライン» Matzにっき
韓国では「韓国人は英語が苦手だからオープンソース利用が進まない」と言われているが、 韓国人よりもさらに英語が苦手な日本では結構進んでいるのではないか、という話。 でも、韓国で「オープンソース利用が進んでいない」という印象はあまりないんだけど、 韓国内にいる人はそう思うのかな。少し前まではWindows全盛という話は聞いていて 政府や大企業のサイトがActiveX使いまくり(なのでWindows以外ではネットバンキングも 政府サイトアクセスもできない)という状況だったそうだけど、 今ではずいぶん改善されているんで無かったかな。..
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image01:36 取材» Matzにっき
今日だけで二件も取材を受ける。なんだか有名人になったみたい。
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image01:36 スライド作成» Matzにっき
ついつい後回しになっていたModelingForumのスライド作成。 前日だっていうのに大丈夫か(だって忙しかったんだもん)。 「モデリング」なんてやったことないので、 かなり場違いな感じがするが、 「なにを話しても構いません」と言われたので、 開き直って全然関係ない話をしようと思う。 最近、エンタープライズとかビジネスそういう話ばかりなので、 いっそ思いっきり「言語おたく」全開の話をしよう。
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image01:36 err.the_blog.find_by_title('Even More Ambitious')» Matzにっき
構文木を参照することでSQLを生成するライブラリAmbitiousの続報。 高速化、個別DBMS対応(MySQLとPostgreSQL)、gitによるリポジトリ公開など。 引き続き注目していきたい。あと、1.9でこれらがどうなるかについては 我々が考察せねばなるまい。構文木ってなくなっちゃうよねぇ。
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image01:36 [OOP] OOエンジニアの輪! 〜 第 38 回 笹田 耕一さんの巻 〜» Matzにっき
ささだくんインタビュー。 そういえば、ささだくんってこれまであんまり自分のこと語ってないよね。 私なんかあちこちで自分のこと吹聴しまくってて 個人情報漏れまくりなのに。 大変面白かった。
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image01:36 Redick - J in Scheme» Matzにっき
APLの後継であるJの機能をSchemeで提供するという試み。 Jの配列演算ははまれば非常に生産性が高いのだが、 なにぶん演算子が難しい。JはASCIIで表現できるので オリジナルAPLよりはマシなのかもしれないが、 それでもまだつらい。 Redickについては、ユーザガイドを 読む限りでは(少なくともAPIは)見て覚えられるようなもののようだ。 そのぶん、簡潔さは失っているんだけど、write-only languageになるよりは 良いことなんじゃないだろうか。 SchemeでできるということはRubyでもできるということだよね。 誰か挑戦してみないかなあ。
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image01:36 Logix» Matzにっき
Pythonの文法を自由に再定義できるようにした新言語。 またはPythonバイトコードを吐くマクロ処理系。 が、1分で分かる紹介を 読んでもあんまりうれしい気がしないのはなぜだろう。
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image01:36 It isn't Easy to Remove the GIL» Matzにっき
Guido van Rossumが「GIL (global interpreter lock)を取り除いてくれ」という公開メールに 対して「言うほど簡単じゃないんだよ。以前やってみた時には大幅に遅くなったし」と 返事した、という話。 それはYARVでも同じこと。1.9になってもlockが無くなる予定はない。 理由もほぼ同じで、 性能が向上する保証がない(むしろ低下する自信がある) C extentionの多くはthread safeじゃない C libraryにもthread safeじゃないものは多い という状況でそう簡単にGILを消去できるとは思えない。 Guidoじゃないけど「じゃあ、まず自分でやってみ..
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image01:36 ActionBox» Matzにっき
GTD(Getting Thing Done)を実践するためのツール。 世の中にはGTDといいつつ単なるToDo管理ツールでしかないものは 数多くあるのだが、こちらは 思いつくものを頭が空っぽになるまで書き出す(collect) それを分類する(process) 組織化する(organize) タスクとする(task) 完了(done) という「ちゃんとした」GTDの手順にのっとっている。 私自身はGTDを身に付けてないので使いこなす自信は無いが、 自分の生産性をあげるためには有効なツールのような気がする。 actionboxはエントリ作成に重心が置かれていて、 その点は優秀なので、今後は..
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image01:30 peregrination: A traveling ...» Projectionist
per•e•gri•na•tion
[per-i-gruh-ney-shuhn]noun
A traveling from one country to another; a wandering; sojourn in foreign countries.

add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image01:29 Stop me if I violate your s...» Projectionist
Stop me if I violate your sensibilities.

Marcel, to a class


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl

Sat 22 September, 2007

Click here to bookmark this link.Channel Image18:31 A RailsConf Europe '07 Diary» chris blogs

Flight STR–TXL, Sunday

Flying with air berlin is very pleasant: You get to choose from five newspapers, get free coffee and cake, and they show you the stupid (albeit rendered) security video on a TV screen.

Sunday evening

Time for some Bratwurst (pics)! After arriving at our apartment and figuring out how the WLAN is supposed to work, we take the tube to Kalkscheune where lots of people are already. The rug-b people made name tags for us. (Hey Vico!) After we all had enough Bratwurst, some go play Werewolf while we decide to go to the Tacheles (a.k.a. “shitty building”) and have some beer.

Monday

Since I didn’t book any tutorial sessions, it’s time to sleep out. We try to fix the WLAN but completely fuck it up. (You should have seen us trying to even find the router!) Later, we go to the great St. Oberholz (blog) cafe which has good coffee, good food, free wifi and Bionade. Not to forget nice waiters (Hey Ines!) and lots of Mac users. I had a heavy walnut tarte.

Monday evening

We missed Dave Thomas’s keynote because had a big Thai dinner. It was awesome and very tasty. And hot. Some go play Werewolf. Later we tried to find the Havanna Club Club, where there was a guy which a friend of a friend one of us knows. We searched for an hour, and ended up at the Madonna Bar, where we had some beer.

Tuesday

Being a bit late, I rushed into the DHH keynote. He showed evolutionary advancements on the way to Rails 2.0, for example automatic database setup, easier-to-read ActiveRecord inspects (yay) and partials by object type (which is pretty nice). He also demonstrated how to add new content-types to create special output for the iPhone. Finally, he announced a Rails 2.0 preview release to appear shortly after the conference.

Then, I attend the first sessions: Deployment and Continuous Integration from the Trenches by Fernand Galiana, who talked about new features in Capistrano 2 such as namespaces, different deployment strategies and events, which allow for seperation of aspects. After a whirlwind tour of cap2 we learned about certain traps and how to avoid them, for example by using lazy variable expansion. He also showed best practices such as factoring common code with load, multistage deployment and caches, which also can use rsync now. Fernand concluded his talk by showing a quick example of how to write your own tasks and announcing his Rails-driven Capistrano frontend dubbed Capote. His talk was amusing and full of hilarious engineering pictures.

Next up was Dr. Nic Williams with his excellent talk Meta-Magic in Rails: Become a Master Magician which started with a list of features he liked in Ruby and which help doing meta-stuff like the flexible syntax and the highly dynamic behavior. He explained he likes “a big number of complexity” and went on to compare Perl with a puppy unconscious of itself, Java with Keith Richards, and Ruby with Matrix’s Neo, who knows everything about himself and his environment. He introduced his Magic Models which use const_missing to generate ActiveRecord models on the fly and outlined a few important meta-programming techniques. It was a really funny and instructive talk (at least if you are not already a Ruby pro).

In the lunch break, I got to know some found the Havanna Club Club later, and it was just where we searched. Sigh.

In the afternoon, I attended Really scaling Rails by Britt Selvitelle, who works for flickrtwitter (thanks, nec). After explaining to the audience that most of them probably won’t need his hints yet, he explained their mongrel setup (they only proxy one request at a time from Apache to each mongrel, so requests won’t queue up) and gave tips on benchmarking actions. He insisted on not over-architecting. Furthermore, he explained how to create daemons for long-running tasks (such as informing 10000 followers of twitter’s popular users) and how to cache DB queries. He also introduced starling, which is an in-house queue server they wrote. If you can, cheat, he recommended to us, meaning that users won’t notice if things don’t update in real time or are totally synchronous. He also told about essential things for deployment, such as monitoring and easy deploy/rollback. Scaling is only needed where it matters. Lastly, he explained the importance of an API for twitter and how it was relevant for the big community they now have.

The next talk was Improving the Rails ecosystem by Evan Phoenix, the leader of the Rubinius project. He talked about how a better Ruby results in a better Rails and how Rubinius is focused on improving some Ruby deficiencies, like full operator overloading (you can overload != by itself), better memory usage (better sharing among forked processes), .rba archives for easier code deployment and more readable and informative backtraces. He announced they would release a 1.0 at the end of the year and concluded the talk with an extensive Q&A session. This was a very funny talk as well, last but not the least because of his sole usage of made-up statistics. (Rubinius is faster than three-legged dogs and turtles, but slower than the Space Shuttle, you knew?)

The day ended with Roy Fielding’s keynote The Rest on REST2, who once looked at the entire web—back when it was fifty sites. After a short history of the web until 1995, we got to know he was the main HTTP RFC editor and he went on outlining the web’s architecture. He explained how REST implies hypertext in some sense and how it made the web bigger. He also told he had a look at Rails and tried to show how to make it more RESTful (he lauded the CRUD); most things already can be done easily. It was a good talk (have a look at the slides, they are self-explaining mostly) and I really liked the small quotes on top of each slide.

Tuesday evening

We had some Schnitzel at a restaurant Unter den Linden which name I forgot. Then, we headed to RejectConf which took place at the Pirate Cove (noone noticed that tomorrow would be Talk Like A Pirate Day, though. Arrr!!) Some went to play Werewolf.

Dr. Nic praised me for even being able to talk about Ruby meta-programming after some rounds of Jägermeister shots. No big deal. ;-)

The caboosers also got a new set of t-shirts. (Thanks, chrissturm.)

Wednesday

The second day of the conference sessions started with Best Practices by Marcel Molina Jr. and Michael Koziarski of the Rails core team. (We learned Jamis Buck wasn’t there because his wife got a child.) They noticed most Rails projects stuff too much stuff into the controller and not enough into models. They explained that the controller merely should contain action code and most of the business logic belongs to the models. Marcel recommened the Smalltalk Best Practices book again, which is really worth a read. Michael talked about how association proxies make you code easier to understand and how to factor code into many descriptive methods.

Then, I attended JRuby at Thoughtworks by Ola Bini, who complained about MRI having threading issues, bad unicode support, and speed and GC problems. JRuby, which was started in 2001(!), tries to address all these problems. He also told that Java 6 made JRuby twice as fast without changing anything. JRuby will be compiled to bytecode to allow obfuscation, which is important for certain businesses. It also allows for easier deployment. At the end of his talk, he introduced his new Apress book “JRuby on Rails”.

After this, I went to Ruby on Rails Security by Heiko Webers, which was a lemon. He tried to shock the audience by telling he saw lots of session ids on the wifi, but proceded to give a totally boring talk about essential security concepts which would have been demonstrated a lot better by, well, demonstrating them. More action please!

In the lunch break, I met David Chelimsky of the RSpec team. We talked a bit about BDD and the future of RSpec and test/spec. He also explained the new StoryRunner to me. Then, I met Geoffrey Grosenbach and we recorded a Ruby on Rails podcast out of the blue!

The first afternoon session I attended was Browser-based Testing of Massive Ajax-using Rails Applications with Selenium, by Till Vollmer of MindMeister, a pretty neat AJAX mindmapping tool. He explained what Selenium is, and how usual tests don’t test browser behavior, which is essential for them. After a quick overview of Selenium’s features, he demonstrated their test suite for a live example.

Next was Functional JavaScript Development with Prototype by Ben Nolan. He told about JavaScript lambdas and what binding them means and went on talking about Prototypes enumberable extensions which have lots of useful methods like invoke, pluck or inGroupsOf. He mentioned taking some Haskell courses at university and stated JavaScript code is much easier to develop and debug when it consists of small, idempotent functions. Also, he recommended to store data in the DOM and not in private properties of JavaScript objects.

After the afternoon break, I went to Jay Fields’ talk on Extending Rails to Use the Presenter Pattern which was very fuzzy and mellow. He couldn’t really get his point across and most of the audience left the session without knowing what a presenter even is, which is kind of sad since it surely could have been useful in some situations. Or not.

The last session, PhD on Rails by Sam Aaron however saved the day. It was such a refreshing, intelligent and humorous talk that I completely forgot to take notes. Let me try to remember: He created a database backed system to keep track of objects which are rendered in a three dimensional spaces and then implemented a query language to operate on them. Really cool. And the first person I met that uses VRML.

Wednesday evening

We tried to find a restaurant for roughly 25 persons which was not that easy. We ended up in a pretty expensive French brasserie, but I liked my dinner. Some went to play Werewolf. The rest went to Ambulance Bar where we had half a dozen cocktails each. They were very good. We got back to the appartment at 3am, just before the Werewolf players finished.

Thursday

I decided to stay one more day after the conference, and we spent all day at St. Oberholz again. I had a great tiramisu and a beagel. Yum.

Thursday evening

We decided to go to the Fernsehturm for dinner, had a Weizenbier up there waiting until we could enter the spinning restaurant, which was pretty cool. The food was far better than I expected and not even that expensive.

After dinner, we went back to the appartment because we all would need to wake up pretty early.

Flight TXL–FMM, Friday

I had to wake up 6am to get to the airport in time. I met Geoffrey there again and we had another little chat. I flew back with tuifly, which let me chose whether I wanted to be seated to the window or not but had no free coffee or other features. They play the stupid security video for you. It was a bit cheaper, though.

General points

  • git is gaining popularity among Ruby hackers, I saw lots of them installing it and toying around.

  • Berlin: I had forgotten how great the city is. The complete and utter lack of aesthetics actually is appealing, but the icky typography in the subway hurts my soul.

NP: Bob Dylan—This Wheels On Fire


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image18:16 Mehr Bücher» chris blogs

Beim heutigen Bücherflohmarkt in der vhs (meiner Zivistelle ab Oktober übrigens) erworben:

  • Georg Unger, Die Rettung des Denkens. Exkurse über mathematische, physikalische und kybernetische Grundbegriffe.

  • Albert Einstein und Leopold Infeld, Die Evolution der Physik. Von Newton bis zur Quantentheorie.

  • Jürgen Dahl, Der Tag des Astronomen ist die Nacht. Von der Vergeblichkeit der Himmels-Erforschung.

  • Ephraim Kishon, Der seekranke Walfisch oder Ein Israeli auf Reisen.

  • Ephraim Kishon, Arche Noah, Touristenklasse.

  • William Gibson, Neuromancer (Deutsch).

  • Roger Price, Des Drudels Kern. Drudel für Anfänger und Fortgeschrittene.

  • Friedrich Dürrenmatt, Der Besuch der alten Dame. Tragische Komödie.

  • Bertolt Brecht, Leben des Galilei.

  • Friedrich Nietzsche, Also sprach Zarathustra. (Kann man am Bildschirm nicht lesen.)

Unkosten: 7€.

P.S.: Kennt jemand eine schöne, unixige Buchverwaltung, die Metadaten von Amazon und so integrieren kann?

NP: Bob Dylan—Death Of Emmet Till


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image17:40 Streaming Zip Files with PHP» Pablotron: News

The problem: how do you dynamically generate arbitrarily large downloadable zip files from PHP? All of the existing solutions I found all generate a local temp file, which means the server needs to

  • have a web-writable directory large enough to store the intermediate temp file, and
  • be able to generate and start streaming the entire file before the client times out

I wasn't particularly fond of either constraint, so I came up with a solution: ZipStream-PHP. ZipStream is a library for dynamically streaming dynamic zip files from PHP without writing to the disk at all on the server. Using it is dirt simple, too. Here's how:

# create a new stream object

$zip = new ZipStream('example.zip');



# then add one or more files



# add first file

$data = file_get_contents('some_file.gif');

$zip->add_file('some_file.gif', $data);



# add second file

$data = file_get_contents('another_file.txt');

$zip->add_file('another_file.txt', $data);



# finally, finish the stream

$zip->finish();

You can also set file comments and creation dates, like so:

$data = file_get_contents('foo.txt');

$zip->add_file('foo.txt', $data, array(

  'comment' => 'this is an interesting comment',

  'time'    => time() - 3600, # created one hour ago

));

Here are the links, enjoy:


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image14:09 Links for 2007-09-21 [del.icio.us]» John Lam on Software

add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image11:59 Tweets on 2007-09-21» halostatue
groggily writing up yesterday’s FogBugz demo # Powered by Twitter Tools.
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image09:27 Learning Lisp» James Britt - Code, Content, Caffiene

If you are serious about computer science and/or programming, you will be learning Lisp. Finding good material can be tricky. However, for an outstanding Common Lisp tutorial (or any Lisp tutorial) I highly recommend Peter Seibel’s Practical Common Lisp .

Peter has made it freely available on the Net, though I encourage you to consider buying a printed version. It will rewards those who have taken the time and trouble to publish such a work, and (hopefully) encourage more such publications.


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image07:58 Set TextMate to Default to ...» Projectionist

Tip Set TextMate to Default to Ruby Mode For New Files

$ defaults write com.macromates.textmate OakDefaultLanguage E00B62AC-6B1C-11D9-9B1F-000D93589AF6


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image07:56 lethologica: Psychological ...» Projectionist
le•tho•lo•gi•ca
[leh-tho-lau-gee-ca]noun
Psychological disorder that inhibits one’s ability to articulate thoughts by temporarily forgetting key words, phrases or names in conversation.

add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image03:00 チケット駆動開発 … ITpro Challenge のライトニングトーク (4)» Matzにっき
先日のITpro Challengeで私が帰ってから行われたLTのひとつ。 チケット駆動開発というのは、増井さんのところでも語られていた。 やっぱ、記録という観点からも、意思疎通という観点からもこういうの 必要かもしれないなあ。 Ruby開発でも導入するかなあ。 なんども挑戦しては失敗してるんだけど。
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image03:00 【MySQL Users Conference】MySQL社がアジア初のカンファレンス開催» Matzにっき
朝から東京へ移動。 MySQL Users Conferenceへ。 私はMySQLを尊敬してはいるが実際に使ったことはないので、 この話が来た時に断ろうと思ったのだけど、 ちょっと断れないコネクションで依頼されてしまった。 が、MySQLの「素晴らしさ」については、 きっと会場のユーザの方々の方がよくご存じなので、 しょうがない「オープンソース」の話をすることにした。 スウェーデン大使とか企業のえらいさんの挨拶が続いて 私の番が来た時にはセッション終了予定時刻まであと5分であった。 スタッフに「5分でいいですか?」と聞いたら、 「予定通..
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image01:54 Ontario Votes: Voting Format Referendum» halostatue
There’s a referendum going on in Ontario on how we will vote in the future. Others summarize it far better than I do: Spacing.ca — MMP Primer Part I Spacing.ca — MMP Primer Part II Spacing.ca - Web Resources for MMP I don’t think that it’s a bad system, but I am concerned about the reduction in the [...]
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl

Fri 21 September, 2007

Click here to bookmark this link.Channel Image20:28 FogBugz World Tour in Toronto» halostatue
So, Joel Spolsky has been making his world tour demonstrating the latest version of FogBugz (6.0), and I was able to attend last night’s demonstration. It was a small pleasure to be able to meet someone whose blog I’ve been reading for several years. Joel doesn’t present FogBugz as a bug tracking tool, but as [...]
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image16:05 Links for 2007-09-20 [del.icio.us]» John Lam on Software
  • Microsoft Pro Photo site
    Absolutely stunning photography site. Wonderful photos in the galleries by some of my favorite landscape photographers

add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image11:59 Tweets on 2007-09-20» halostatue
going home. finally. # ISO quality scriptable-and-localizable Windows installer software. Nothing by Macrovision need apply. That means you, InstallShield. # off shortly to go see Joel Spolsky’s Toronto FogBugz 6 demo # at the FogBugz demo # Powered by Twitter Tools.
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image11:46 RailsConf EU '07 is over» Riding Rails - home

The party in Berlin came to an end all too soon. I had a blast there and so did everyone else it seemed. Such a fantastic atmosphere and group of people. If you weren’t able to make it, you can peruse the presentation slides or the pictures. Thanks to everyone who made it possible and to all who was able to come.


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image11:46 Rails tool space is heating up» Riding Rails - home

There’s a lot of action going on in the Rails IDE space these days. Besides Aptana RadRails, which has been around for a long time, Sun’s got impressive Rails support in the new NetBeans, and just this week CodeGear launched their 3rdRail IDE, which also looks like a great setup.

I’m personally not quite ready to leave TextMate behind, but it’s encouraging to see all these options for dedicated Rails IDEs. It’s not going to be long before they’ll be giving regular text editors a serious run for their money.


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image03:43 JRuby语言内部报道:软件包Jar无Manifest问题» 道喜技术日记

JRuby语言内部报道:软件包Jar无Manifest问题

  • 说明:尽管JRuby语言版本1.0.1已经发行,但是JRuby运行环境还是有些问题没有得到解决。要是我们的Java语言软件包jar中没有目录META-INF,就有可能出现错误。
  • 错误报告及其实例:
    http://jira.codehaus.org/browse/JRUBY-1229

add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl

Thu 20 September, 2007

Click here to bookmark this link.Channel Image11:59 Tweets on 2007-09-19» halostatue
i hate InstallShield. I like that Ruby can mostly fix InstallShield stupidities. # fighting installshield again. pure hell. lunch now, though. # @court3nay I only just got it, but I’m rather enjoying it. It feels a bit like PHM to me, with a bit of Broken and Spiral thrown in # Powered by Twitter Tools.
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image10:36 Sun surprises at RailsConf Europe 2007» Loud Thinking by David Heinemeier Hansson

The biggest surprise at RailsConf Europe 2007 was hearing Craig McClanahan from Sun speak. Craig is the creator of Struts, the original blockbuster web framework for Java, and more recently Java Server Faces. Not exactly an obvious advocate for Ruby on Rails, but he sure played the part well.

And not just on a superficial level because Sun was a diamond sponsor of the conference, but from months of experience developing Rails applications using the latest techniques and frameworks (like pushing the envelope with Active Resource). He even went as far as to say that developing web applications in Java after working with Rails would probably not be a particularly pleasant experience for him. Wow.

Sun's support for Rails goes even further, though. Their work on making Netbeans a kick-ass Rails IDE seems to be progressing at a rapid clip (and already winning fans). Yet it pales in comparison to the rise of JRuby as driven by Thomas, Charles, and Ola. These guys are improving their JVM implementation of Ruby at a truly insane speed.

JRuby on Rails is already in production at a fair number of companies. The Rails is just a WAR argument is certainly making it easier for companies like ThoughtWorks to push Rails deep into the enterprise. Throw the "integrate with your Java legacy" argument on top (where you can even go as far as work with EJBs!) and it's easy to see why The Enterprise is getting all giddy.

"Why are they doing all this?", that's a common concern with most Ruby folks (and a question I must have asked them personally at least half a dozen times ;)). Apparently, they see this as something quite simple: A Sun that's heavily involved with Rails on the software side is a Sun that's much better positioned to sell loads of hardware to run all these new Rails applications in both the enterprise and to start-ups.

It seems to be working too. Joyent is running all their new gear with Sun badges. And they got some serious applications cooking there, including Twitter.

So it's kinda hard to argue with their good deeds. Which is a peculiar feeling for a Rails person to have towards a company that used to be regarded solely as the high church of enterprisey. I guess that they've accepted that Java (the language) is no longer always the answer regardless of the question, as it used to be.

Yet there's still that nagging doomsday image of a mystery man sitting somewhere inside of Sun petting a black cat with a hollow laugh just waiting to reveal his evil master plan as the reason for all this. But the exceptional work and high character of people like Tim Bray, Nick Sieger, Thomas Enebo, Charles Nutter, and now even Craig McClanahan championing Ruby and Rails inside Sun, I think I'll have to waive goodbye to the last sliver of that suspicion very soon.


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image10:36 Good times at RailsConf Europe» Loud Thinking by David Heinemeier Hansson

It's hard to fathom that we've just finished our fourth RailsConf in just 15 months. The first one already seems so long ago, which just underlines how fast things have been moving in the Rails world.

It's even more impressive to think of all the people we've had go through the conferences. More than three thousands attendees combined and some of the most interesting speakers in technology.

This year I was especially pleased to hear Roy Fielding speak and to have the opportunity to chat with him afterwards. The past year and a half been about trying to understand and implement the ideas and the specifications that Roy has been involved with for more than a decade. It was very pleasing to hear him talk so warmly of our progress so far.

Sun continued to surprise positively (and still slightly puzzling), but I had so much to say about that, I went ahead and wrote it up separately in Sun surprises at RailsConf Europe 2007.

As I process all the inputs from the conference, I'm sure I'll have more to say. But for now I want to make sure to thank everyone involved. Ruby Central and O'Reilly did a spectacular job organizing everything. And I had a great time speaking to so many different users of Rails. The most amazing things are being done with this framework we're building.

P.S.: My keynote slides were few and almost entirely without meaning out of context, but Casper Fabricius did a good job with his summary.


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl

Wed 19 September, 2007

Click here to bookmark this link.Channel Image19:27 Blackberry Links and a Rant About Thieving Bastards» Pablotron: News

I just got a Blackberry for work, and I've been looking around for some simple applications. The entire experience reminds me of looking for Windows Mobile software; a bunch of small, money grubbing companies trying to nickel and dime people for things they have no business charging for. $5 for a crappy theme that you obviously spent 15 minutes on? No thanks, I'll make my own. $15 for your E-Book reader? I already made a mistake when I bought your shitty software for my PDA two years ago; I won't be fooled again. What a bunch of thieving bastards.

The good news is that I did manage to find a couple of decent applications. Here they are:

  • MidpSSH: Mobile SSH client. Brian dug this one up. The source is also a pretty good reference for MIDP development.
  • Opera Mini: The crackberry comes with a half-assed built-in browser. Opera Mini makes up the other half by resizing images and scaling the page so it fits nicely on your screen.
  • jmIrc: Decent mobile IRC client.

Also, Blackberry Freaks and GetJar both have lists of free software for the Blackberry. Actually, GetJar is useful for any J2ME/MIDP-capable device; that's where I got most of the software for my Samsung t809. There's also midlet.org, although everything there seems to be straight out of 2002.

The best overall Blackberry forum I've found so far seems to be Blackberry Forums. I particularly like the developer forum.

I also managed to get the MIDP SDK up and running without too much effort. You basically just uncompress the archive wherever, then add the $MIDP_DIR/classes directory to your classpath when compiling your .java files. It includes an MIDP emulator which works fine for several applications I've tried, and also seems to hate the JAD files I'm generating for no apparent reason. Oh well. Here are the interesting MIDP and Blackberry development links I've dug up:

Fire an email or comment my way if you've got any more useful links.


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image11:59 Tweets on 2007-09-18» halostatue
aw, damn. Robert Jordan died. # Ruby + REXML cleans up InstallShield ISM Files. Yay! # @lylejohnson just because one side is full of jerks doesn’t mean that the other side is clean, either. # @lylejohnson that, and there’s a lot of nonsense about power control from authority figures anyway. too ready to use too much force. [...]
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image09:33 管窥Ruby——类的变量(更新版)» 梦想风暴

管窥Ruby——类的变量》写在去年,写成之后便更新了一次,因为最初的描述存在一些偏差。即便如此,jxb8901依然指出了其中的一些不足。最近,dennis-zane再次提出了这个问题。回过头来仔细品味,确实有些地方写得不是很到位,索性把它重新写过。

管窥Ruby——类的变量

变量和方法是面向对象难以割舍的两个重要组成部分。在《管窥Ruby——类的方法》中,我们谈到方法,沿着这条路继续,我们再来看看类中的变量。

开始之前,我们还是要再次回顾RClass的定义:
struct RClass {
    struct RBasic basic;
    struct st_table *iv_tbl;
    struct st_table *m_tbl;
    VALUE super;
};
(ruby.h)

如果你看过《管窥Ruby——类的方法》,了解了方法存储方式,变量的存储方式便也一目了然了,同样的st_table,意味着同样的处理方式。

不得不承认的一点是,在讨论类的方法时,我故意忽略了一个事实:方法分为类的方法和实例的方法两种。如果对其它语言实现有些许了解,我们知道,这两种方法差别仅仅是this(C++或Java的说法),到了底层时,这个差别可以视为无物,可以统一存放。关于这点,有兴趣可以参考一下《深入Java虚拟机》,它的第五章讲解了虚拟机内方法的表现形式。在Ruby中,类的方法和实例的方法并不是存放在一起的,这里定义的实际上是实例方法,而类的方法是定义在类的Singleton类中。

遇到变量时,我们会碰到同样的问题:类的变量和实例变量是无法统一管理的。因为类的变量只有唯一的一份,而实例变量则是每个实例都有一份。所以,RClass存放的并不是真正实例变量。代码是说明问题的最好方式,下面这段代码说明了如何设置实例变量:

VALUE
rb_ivar_set(obj, id, val)
    VALUE obj;
    ID id;
    VALUE val;
{
    if (!OBJ_TAINTED(obj) && rb_safe_level() >= 4)
        rb_raise(rb_eSecurityError, "Insecure: can't modify instance variable");
    if (OBJ_FROZEN(obj)) rb_error_frozen("object");
    switch (TYPE(obj)) {
      case T_OBJECT:
      case T_CLASS:
      case T_MODULE:
          if (!ROBJECT(obj)->iv_tbl) ROBJECT(obj)->iv_tbl = st_init_numtable();
          st_insert(ROBJECT(obj)->iv_tbl, id, val);
          break;
      default:
          generic_ivar_set(obj, id, val);
          break;
    }
    return val;
},
(variable.c)

抛开前面那些复杂的东西,直接来看switch语句后面的内容。这里存在两种情况,对于存在T_OBJECT、T_CLASS和T_MODULE标记的,变量会写入iv_tbl,而其余的情况则转交 generic_ivar_set处理。iv_tbl是“实例变量表(instance value table)”的缩写,不过,如果当前对象是个类对象,这个“实例”变量实际上就是类变量,所以,这个名字多少有些名不符实。

除此之外,还有一个generic_ivar_set。下面是generic_ivar_set的实现:

static void
generic_ivar_set(obj, id, val)
    VALUE obj;
    ID id;
    VALUE val;
{
    st_table *tbl;

    if (rb_special_const_p(obj)) {
        special_generic_ivar = 1;
    }
    if (!generic_iv_tbl) {
        generic_iv_tbl = st_init_numtable();
    }

    if (!st_lookup(generic_iv_tbl, obj, (st_data_t *)&tbl)) {
        FL_SET(obj, FL_EXIVAR);
        tbl = st_init_numtable();
        st_add_direct(generic_iv_tbl, obj, (st_data_t)tbl);
        st_add_direct(tbl, id, val);
        return;
    }
    st_insert(tbl, id, val);
}
(variable.c)

同样忽略一些非主干的部分,我们看到,这段代码先在一个generic_iv_tbl中进行查找,用作查找键值的是对象实例(obj),而目标同样是一个st_table。得到这个表之后,利用变量名做键值将值插入到表中。我们便不难分析在这种做法中实例变量的存储方式。存在一个全局的实例变量表,走到这里的实例都在其中拥有一席之地,而实例变量存储在实例对应的表中。Ruby通过这样一个二级结构,解决了这些实例变量存储的问题。

了解过基本的做法之后,随之而来的一个问题就是,这些代码都会在什么情况下起作用。

代码已经说得很明白了,只有在有那几个标记的情况下,才会直接调用iv_tbl。T_CLASS和T_MODULE都很好理解,那什么情况下会有T_OBJECT呢?在C Ruby中,在Ruby层次上定义的类,生成的实例都是会标有T_OBJECT(参见《管窥Ruby——Allocator》)。所以,所有由Ruby层次上生成的对象都会走到这里来。

那generic_ivar_set呢?除了那几个标志外的其他部分都会走到这里。除此之外的标志表示什么呢?读一下代码我们便不难发现,几乎就是builtin的几个类,比如数组、字符串、正则表达式等等。那为什么这些builtin类没有一个iv_tbl。对于这些builtin而言,它们真正的实例变量都是以C的形式给出,所以,额外存在一个iv_tbl实际上是一种空间上的浪费。

虽然不是常态,但我们依然可以为这些builtin类添加自己的实例成员。为了保持Ruby的动态特性,这才有了generic_ivar_set的存在。


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl

Tue 18 September, 2007

Click here to bookmark this link.Channel Image20:20 参加中日社会企业(家)支援型组织交流会» Suave's Blog
昨天在凯德大厦参加这个关于社会企业的谈论会,整个过程大多还是关于概念上的讨论,有些收获整理在下面。 首先是非营利孵化器主任 吕朝说的: 现在的NGO与其做存量的改造,不如做增量...
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl

Mon 17 September, 2007

Click here to bookmark this link.Channel Image21:09 pythonic无处不在» 动态感觉 静观其变
总是有pythonic的人想出pythonic的点子,css也能和python挂上勾,有人放出了clevercss,很有意思,按python的写法有趣的多。development和product,还是不同的。开发的时候,要能快速的改动,快速看结果,所以需要能尽量的少的步骤解决问题,而实际运行的时候,就需要稳定的。
clevercss可以把按python格式些的文件,一次性转换成css文件。开发的时候,则要动态转换了。
http://sandbox.pocoo.org/clevercss/
http://lucumr.pocoo.org/cogitations/2007/09/17/using-clevercss-in-django/
...
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Sources