<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Kanru&#039;s 探險日誌 &#187; 讀書心得</title>
	<atom:link href="http://blog.kanru.info/archives/tag/%e8%ae%80%e6%9b%b8%e5%bf%83%e5%be%97/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.kanru.info</link>
	<description>當發現美好的事物時，所要做的第一件事，就是把它分享給所有人</description>
	<lastBuildDate>Sun, 23 May 2010 09:51:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>借書</title>
		<link>http://blog.kanru.info/archives/212</link>
		<comments>http://blog.kanru.info/archives/212#comments</comments>
		<pubDate>Thu, 02 Mar 2006 13:34:08 +0000</pubDate>
		<dc:creator>kanru</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[讀書心得]]></category>

		<guid isPermaLink="false">http://blog.kanru.info/archives/212</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p>今天去圖書館挖寶，又借了三本書：</p>

<ul>
<li><a href="http://as.wiley.com/WileyCDA/WileyTitle/productCd-0764574817.html">Reversing: Secrets of Reverse Engineering</a></li>
<li><a href="http://www.amazon.com/gp/product/0072253630/002-1308173-8432840?v=glance&amp;n=283155">OOP Demystified</a></li>
<li><a href="http://www.hp.com/hpbooks/prentice/ptr_0130886742.html">COM+ Programming: A Practical Guide Using Visual C++ and ATL</a></li>
</ul>

<p>本來還要借 <a href="http://www.apress.com/book/bookDisplay.html?bID=374">Advanced .NET Remoting</a> 的，可是應該是看不完，就先留給別人了&#8230;</p>

<p>很喜歡逛圖書館，在裡面搜刮的感覺很棒&#8230; 面對永遠都看不完的書，有時後會想：住在圖書館裡面好了 XD</p>

<p>btw, 似乎應該要找一些文學類的來看阿 @@</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kanru.info/archives/212/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.NET &#8211; Plugin</title>
		<link>http://blog.kanru.info/archives/70</link>
		<comments>http://blog.kanru.info/archives/70#comments</comments>
		<pubDate>Sat, 18 Feb 2006 14:11:14 +0000</pubDate>
		<dc:creator>kanru</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[讀書心得]]></category>

		<guid isPermaLink="false">http://blog.kanru.info/archives/70</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p>我之前在 <a href="http://blog.kanru.info/archives/45">.NET &#8211; Load Plugins</a> 寫過如何實做簡單的 plugin interface，最近真正在用的時候才發現問題。</p>

<p>Assembly.Load* 雖然可以把 .dll 檔案動態載入，可是卻找不到任何方法可以 unload.. Assembly 在被載入之後是處於鎖定的狀態，如果這時候把檔案換掉的話，Assembly.Load 便無法再重新載入，會出現 Exception</p>

<p>這樣就沒辦法在後端偷偷換掉 backend 了 -_-</p>

<p>要實做動態的 load, unload 好像是要使用 System.AppDomain 來做（時際上是用 Remoting 的技術），看似簡單，可是我試到現在還沒成功過&#8230; 還變成好像 Assembly 被 Cache 起來的情況，怎麼 load, unload 都是用到舊的 Assembly&#8230; 天阿</p>

<p>參考：<a href="http://dlwang2002.cnblogs.com/archive/2005/10/18/257425.aspx">通过应用程序域AppDomain加载和卸载程序集之后，如何再返回原来的主程序域</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kanru.info/archives/70/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Suffix Tree</title>
		<link>http://blog.kanru.info/archives/56</link>
		<comments>http://blog.kanru.info/archives/56#comments</comments>
		<pubDate>Sat, 14 Jan 2006 16:58:05 +0000</pubDate>
		<dc:creator>kanru</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[讀書心得]]></category>

		<guid isPermaLink="false">http://kanru.info/~kanru/blog/archives/56</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.csse.monash.edu.au/~lloyd/tildeAlgDS/Tree/Suffix/">Suffix Tree</a>，在字串處理上有非常多的應用，尤其是字串的搜尋、定位等等，利用這個資料結構很多都可以在 O(n) 也就是 linear time 做完。</p>

<p>這是在這學期的 字串學(stringology) 學到的，作業就是實做 suffix tree，我用的是 Ukkonen 的演算法，可以用 on-line construction 的方法建構 suffix tree。</p>

<p>我是用 <a href="http://nemerle.org/Main_Page">Nemerle</a> 寫的（因為在練習），後來也有用 C# 改了另外的版本，但是還是 Nemerle 的版本比較完整。原本是用 System.Collections.Generic.Dictionary 來存每個 State 裡面的 transitions，可是非常的吃記憶體，用 mono &#8211;profile 可以很容易看出來一個 500kb 的檔案，在建構的時候光 Dictionary 就可以吃掉近 150mb 的記憶體；後來改用自己的 linked list 來做，節省了很多資源，2mb 的測試檔可以在 9 秒內建完樹並回報內部節點個數。</p>

<p>整個程式應該還有多可以改進的地方，但是目前的效率作為作業已經可以接受了，先放上來。在<a href="http://stu.csie.ncnu.edu.tw/~kanru.96/program/suffix.n">這裡</a>。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kanru.info/archives/56/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nemerle &#8211; Redefining symbols</title>
		<link>http://blog.kanru.info/archives/47</link>
		<comments>http://blog.kanru.info/archives/47#comments</comments>
		<pubDate>Wed, 28 Dec 2005 14:57:51 +0000</pubDate>
		<dc:creator>kanru</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[讀書心得]]></category>

		<guid isPermaLink="false">http://kanru.info/~kanru/blog/archives/47</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p>在 nemerle 裡面，可以用</p>

<pre><code>def a = 123;
</code></pre>

<p>這樣的格式來定義一個 immutable 的變數</p>

<p>然而，這樣的寫法也是 vaild 的</p>

<pre><code>def a = 123;
def a = "123";
</code></pre>

<p>雖然看起來像是給 immutable 的 a assign 了兩次不同的值，實際上兩者有完全不同的意義，所以</p>

<pre><code>def (x, y) = (1, 3);
def (x, y) = (y, x);
</code></pre>

<p>也都是被接受的語法。</p>

<p>詳細：<a href="http://nemerle.org/Nemerle_for_OOP_Programmers_Week_4#Side_note:_redefining_symbols">Side  note: redefining symbols</a><span style="font-weight: bold" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kanru.info/archives/47/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.NET &#8211; Program Glue</title>
		<link>http://blog.kanru.info/archives/46</link>
		<comments>http://blog.kanru.info/archives/46#comments</comments>
		<pubDate>Sun, 25 Dec 2005 11:55:29 +0000</pubDate>
		<dc:creator>kanru</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[讀書心得]]></category>

		<guid isPermaLink="false">http://kanru.info/~kanru/blog/archives/46</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p>C 的 stdio.h 有 popen/pclose 可以用，python 有 popen/popen2&#8230; ，perl 可以把程式當作檔案代號直接開啟執行，這些都可以做到程式間黏合、互動，那 .NET 要怎麼作呢？</p>

<p>可以用 System.Diagnostics.Process 來做到一樣的功能：</p>

<pre><code>using System;
using System.Diagnostics;

public module T {
    public Main (args: array[string]) : void
    {
        def proc = Process ();
        def proc_info = ProcessStartInfo (args[0]);

        proc_info.CreateNoWindow = true;
        proc_info.UseShellExecute = false;
        proc_info.RedirectStandardInput = true;
        proc_info.RedirectStandardOutput = true;
        proc_info.RedirectStandardError = true;
        proc.StartInfo = proc_info;

        proc.Start ();
        while (true) {
            proc.StandardInput.WriteLine (Console.ReadLine ());
            Console.WriteLine (proc.StandardOutput.ReadLine ());
        }
    }
}
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.kanru.info/archives/46/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.NET &#8211; Load Plugins</title>
		<link>http://blog.kanru.info/archives/45</link>
		<comments>http://blog.kanru.info/archives/45#comments</comments>
		<pubDate>Sun, 25 Dec 2005 09:32:56 +0000</pubDate>
		<dc:creator>kanru</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[讀書心得]]></category>

		<guid isPermaLink="false">http://kanru.info/~kanru/blog/?p=45</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p>寫 c/c++ 的時候，可以用 dlopen 來讀入 .so/.dll 檔當作 plugin 用，寫 perl 的時候用 require 就可以把另一個 perl module 讀到記憶體，elisp 也有類似的用法，.NET 則提供了 System.Reflection.Assembly 類別來處理這樣的事。</p>

<p>首先為了統一 Plugin 的介面，我們可以定義幾個 Plugin 專用的 interface：</p>

<pre><code>// PluginInterfaces.dll
namespace Plugin.Interfaces
    public interface IPlugin
        Calculate (input: int) : int
</code></pre>

<p>然後 Plugin 的實做寫在另一個 Assembly：</p>

<pre><code>// Plugins.dll
using Plugin.Interfaces
namespace Plugin.Test
    public class Test1 : IPlugin
        public Calculate (input: int) : int
            input * 2
    public class Test2 : IPlugin
        public Calculate (input: int) : int
            input + 3
</code></pre>

<p>然後主程式就可以把這些 plugins 動態的讀近來：</p>

<pre><code>// Run.exe
using System
using System.Reflection
using Plugin.Interfaces
public module R
    public Main (args: array[string]) : void
        def p = Assembly.LoadFile (args[0]).CreateInstance (args[1]) :&gt; IPlugin
        Console.WriteLine (p)
        Console.WriteLine (p.Calculate (100))
</code></pre>

<p>實際執行的結果：</p>

<pre><code>$ ncc PluginInterfaces.n -out:PluginInterfaces.dll -target:library
$ ncc Plugins.n -ref:PluginInterfaces.dll -out:Plugins.dll -target:library
$ ncc Run.n -ref:PluginInterfaces.dll -out:Run.exe
$ ./Run.exe Plugins.dll Plugin.Test.Test1
Plugin.Test.Test1
200
$ ./Run.exe Plugins.dll Plugin.Test.Test2
Plugin.Test.Test2
103
</code></pre>

<p>嗯，大概就是這樣 <img src='http://blog.kanru.info/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kanru.info/archives/45/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>TPOP</title>
		<link>http://blog.kanru.info/archives/36</link>
		<comments>http://blog.kanru.info/archives/36#comments</comments>
		<pubDate>Tue, 29 Nov 2005 00:47:15 +0000</pubDate>
		<dc:creator>kanru</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[讀書心得]]></category>

		<guid isPermaLink="false">http://kanru.info/~kanru/blog/?p=36</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p><a href="http://cm.bell-labs.com/cm/cs/tpop/">The Practice of Programming</a> 中文名稱《程式設計專家手冊》，在圖書館閒逛的時候發現這本書，這本書談的是關於實務上的程式設計技巧，程式的風格、常用的資料結構、有效率的除錯、程式最佳化……等等。內容言之有物，的確都是一些非常實用的東西，難怪此書會被翻譯成這麼多語言的版本 <img src='http://blog.kanru.info/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>

<p>中文版的翻譯還可以接受，雖然有些中文術語與現在所使用的不太相同，但是整體上來說並不會影響閱讀。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kanru.info/archives/36/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>頭先設計範式</title>
		<link>http://blog.kanru.info/archives/21</link>
		<comments>http://blog.kanru.info/archives/21#comments</comments>
		<pubDate>Sun, 02 Oct 2005 11:25:18 +0000</pubDate>
		<dc:creator>kanru</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[讀書心得]]></category>

		<guid isPermaLink="false">http://kanru.info/~kanru/blog/archives/21</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p>今天去搭車時經過天瓏書局，想起同學拜託幫忙看一下「UNIX System Programming」這本書，所以進去逛了一下，發現「頭先設計範式(Head First Design Patterns)」已經出中文版了。</p>

<p>我之前已經等不及先買了英文版回家，今天翻了一下中文版，讓我更加確定先買是對的，因為中文版的排版雖然也不差，風格樣式也跟原文吻合，可是整體的感覺就是差一點，也可能是先入為主吧，總之我看起來就覺得不一樣 <img src='http://blog.kanru.info/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>

<p>最後，我要看的那本書標價台幣 1400 元&#8230; 真貴，已經超出我跟我同學的預算，所以我便兩手空空的去搭車了。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kanru.info/archives/21/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
