<?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>Adztec Independent - Blog</title>
	<atom:link href="http://www.adztec-independent.de/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.adztec-independent.de</link>
	<description>Programming Ruby / JRuby / Rails / Common Lisp by Christopher Bertels</description>
	<lastBuildDate>Wed, 04 Nov 2009 14:09:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Screencast: Debugging with Emacs &amp; GDB</title>
		<link>http://www.adztec-independent.de/2009/11/screencast-debugging-with-emacs-gdb/</link>
		<comments>http://www.adztec-independent.de/2009/11/screencast-debugging-with-emacs-gdb/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 00:29:18 +0000</pubDate>
		<dc:creator>Christopher</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[compiler]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[free software]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[hobbies]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[screencast]]></category>
		<category><![CDATA[stupidvm]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.adztec-independent.de/?p=265</guid>
		<description><![CDATA[Hey there.
I wish I&#8217;d be posting more recently, but haven&#8217;t really had the time to do so.
I just wanted to share with you a small screencast I created today on debugging with emacs and gdb, since I think it might be of interest to someone else as well.
You can check out the video at my [...]]]></description>
			<content:encoded><![CDATA[<p>Hey there.<br />
I wish I&#8217;d be posting more recently, but haven&#8217;t really had the time to do so.<br />
I just wanted to share with you a small screencast I created today on debugging with emacs and gdb, since I think it might be of interest to someone else as well.</p>
<p>You can check out the video at my blip.tv channel: <a href="http://bakkdoor.blip.tv/" target="_blank">http://bakkdoor.blip.tv/ </a><br />
Currently the video is being converted to flash video (.flv), so you might want to check out the .ogv video file here, if it&#8217;s not done yet: <a href="http://blip.tv/file/2804484" target="_blank">http://blip.tv/file/2804484</a></p>
<p><strong>[Update:]</strong><br />
Video is available now. You can also watch it here:<br />
<embed src="http://blip.tv/play/g7R2gayxfAA" type="application/x-shockwave-flash" width="525" height="402" allowscriptaccess="always" allowfullscreen="true"></embed></p>
<p>Anyhow, I hope you like it and I&#8217;d like to hear some feedback.</p>
<p>Btw, the programm I&#8217;m debugging in the video is <strong>stupidvm</strong>, a small &#038; stupid virtual machine I&#8217;ve started working on 2 weeks ago, written in C.<br />
You can check out the code either on <a href="http://gitorious.org/stupidvm/stupidvm/" target="_blank">gitorious</a> or <a href="http://github.com/bakkdoor/stupidvm/" target="_blank">github</a>.</p>
<p>Feedback is, as always, welcome <img src='http://www.adztec-independent.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
I hope you like it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.adztec-independent.de/2009/11/screencast-debugging-with-emacs-gdb/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Small update &amp; Introduction of &#8216;Stackd&#8217;</title>
		<link>http://www.adztec-independent.de/2009/09/small-update-introduction-of-stackd/</link>
		<comments>http://www.adztec-independent.de/2009/09/small-update-introduction-of-stackd/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 17:41:25 +0000</pubDate>
		<dc:creator>Christopher</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.adztec-independent.de/?p=260</guid>
		<description><![CDATA[Oh wow. 3 months have passed &#8211; how time flys by!
So, what have I been up to in the past quarter year (doesn&#8217;t it sound like a lot more like this?!) ?
First of all, I did some stuff for university, as the summer semerster came to an end. I will upload a homework I wrote [...]]]></description>
			<content:encoded><![CDATA[<p>Oh wow. 3 months have passed &#8211; how time flys by!</p>
<p>So, what have I been up to in the past quarter year (doesn&#8217;t it sound like a lot more like this?!) ?</p>
<p>First of all, I did some stuff for university, as the summer semerster came to an end. I will upload a homework I wrote in computer science shortly. The topic is &#8220;software architectures&#8221; &#8211; it&#8217;s in german of course, but I suppose that some day some one speaking german might find this interesting &#8211; isn&#8217;t this what the internet is for? <img src='http://www.adztec-independent.de/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Also, I&#8217;ve had a visit from my grand parents from California over in July. And then, I&#8217;ve been working at <a href="http://www.intevation.de">Intevation GmbH</a> as an intern for the last month. Intevation is a very nice company to work at. All employees are very friendly and what I think is great as well, is that they only do free software (as in free speach).<br />
Since I&#8217;m a big fan of free software and its movement, I applied for an internship earlier this year and, well, they&#8217;ve accepted my application <img src='http://www.adztec-independent.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>So currently, I&#8217;ve been working on some packaging related stuff for Ubuntu and Debian. I&#8217;ll probably talk more about that in another upcoming post soon. </p>
<p>Alright, let&#8217;s get to the next topic I wanted to adress here:<br />
I&#8217;ve started to work on a(nother) interpreter for a stack-based programming language I&#8217;ve called &#8220;Stackd&#8221;. It&#8217;s basically a poor &#038; small reimplementation of the <a href="http://factorcode.org">Factor programming language</a>, but still missing many features of course.<br />
If you&#8217;re interested in how it works and what it&#8217;s all about to programm in a <em>concatinative programming language</em>, as stack-based languages are often called, take a look here: <a href="http://concatenative.org">http://concatenative.org</a>. There you&#8217;ll find plenty of information, most of which will also apply for Stackd.</p>
<p>You can follow the current development progress at my git repositories here:</p>
<ul>
<li><a href="http://gitorious.org/stackd">Project page on Gitorious</a></li>
<li><a href="http://github.com/bakkdoor/stackd">And on GitHub</a></li>
</ul>
<p>I&#8217;ve started to use <a href="http://gitorious.org">Gitorious</a> next to GitHub because I like the fact that it&#8217;s free software and I want to support it in a way. Besides, it&#8217;s well thought out and I guess more people should take a look at it instead of just choosing GitHub without checking out what else is left. Of course, GitHub does have some nice features, which Gitorious is still missing &#8211; but that might change in the future.</p>
<p>I&#8217;ll probably make another post soon explaining a little more my new language. If there are any questions, feel free to contact me either on GitHub, Gitorious or via email (see <a href="http://www.adztec-independent.de/impressum/">&#8216;About me&#8217;</a> page).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.adztec-independent.de/2009/09/small-update-introduction-of-stackd/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Blocktalk Rubygem</title>
		<link>http://www.adztec-independent.de/2009/06/blocktalk-rubygem/</link>
		<comments>http://www.adztec-independent.de/2009/06/blocktalk-rubygem/#comments</comments>
		<pubDate>Mon, 08 Jun 2009 21:05:27 +0000</pubDate>
		<dc:creator>Christopher</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[blocktalk]]></category>
		<category><![CDATA[free software]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[rubygems]]></category>

		<guid isPermaLink="false">http://www.adztec-independent.de/?p=255</guid>
		<description><![CDATA[Blocktalk can now be easily installed via Rubygems:

gem sources -a http://gems.github.com (if not done yet)
sudo gem install bakkdoor-blocktalk

You can then simply run blocktalk from the shell via

blocktalk sourcefile.bt

To look at some debug information (e.g. the AST, the generated ruby code etc.) type:

blocktalk sourcefile.bt &#8211;debug
or
blocktalk sourcefile.bt &#8211;ruby (to only show the generated ruby code)

Feel free to [...]]]></description>
			<content:encoded><![CDATA[<p>Blocktalk can now be easily installed via <a href="http://rubygems.org/" target="_blank">Rubygems</a>:</p>
<blockquote><p>
<b>gem sources -a http://gems.github.com</b> (if not done yet)<br />
<b>sudo gem install bakkdoor-blocktalk</b>
</p></blockquote>
<p>You can then simply run blocktalk from the shell via</p>
<blockquote><p>
<b>blocktalk sourcefile.bt</b>
</p></blockquote>
<p>To look at some debug information (e.g. the AST, the generated ruby code etc.) type:</p>
<blockquote><p>
<b>blocktalk sourcefile.bt &#8211;debug</b><br />
or<br />
<b>blocktalk sourcefile.bt &#8211;ruby</b> (to only show the generated ruby code)
</p></blockquote>
<p>Feel free to play around with it, check out the examples in the examples folder, if you want to get a start.<br />
Would love to hear some feedback from anyone who&#8217;s interested, since this is my first attempt to language design <img src='http://www.adztec-independent.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.adztec-independent.de/2009/06/blocktalk-rubygem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Blocktalk version 0.1 released</title>
		<link>http://www.adztec-independent.de/2009/06/blocktalk-version-01-released/</link>
		<comments>http://www.adztec-independent.de/2009/06/blocktalk-version-01-released/#comments</comments>
		<pubDate>Mon, 08 Jun 2009 01:47:31 +0000</pubDate>
		<dc:creator>Christopher</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[blocktalk]]></category>
		<category><![CDATA[free software]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[hobbies]]></category>
		<category><![CDATA[interpreter]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.adztec-independent.de/?p=253</guid>
		<description><![CDATA[I just released version 0.1 of Blocktalk at Github.
I&#8217;ve added quite some features in the past few days and got all of my main problems fixed and the most important features working.
One thing that was on that list until today was chained method calls.
Up to this point, the only way to chain method calls was [...]]]></description>
			<content:encoded><![CDATA[<p>I just released <a href="http://github.com/bakkdoor/blocktalk/downloads">version 0.1 of Blocktalk at Github</a>.<br />
I&#8217;ve added quite some features in the past few days and got all of my main problems fixed and the most important features working.<br />
One thing that was on that list until today was chained method calls.<br />
Up to this point, the only way to chain method calls was to surround each method call with parentheses, like this:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://www.adztec-independent.de/wp-content/plugins/wp-codebox/wp-codebox.php?p=253&amp;download=parens.bt">parens.bt</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2534"><td class="code" id="p253code4"><pre class="smalltalk" style="font-family:monospace;">str <span style="color: #000066; font-weight:bold;">=</span> <span style="">&#40;</span><span style="color: #007f00; font-style: italic;">&quot;Hello, world!&quot;</span> upcase<span style="">&#41;</span> gsub: <span style="color: #007f00; font-style: italic;">&quot;,&quot;</span> with: <span style="color: #007f00; font-style: italic;">&quot;:&quot;</span></pre></td></tr></table></div>

<p>Now you can do something like this:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://www.adztec-independent.de/wp-content/plugins/wp-codebox/wp-codebox.php?p=253&amp;download=no-parens.bt">no-parens.bt</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2535"><td class="code" id="p253code5"><pre class="smalltalk" style="font-family:monospace;">str <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #007f00; font-style: italic;">&quot;Hello, world!&quot;</span> upcase gsub: <span style="color: #007f00; font-style: italic;">&quot;,&quot;</span> with: <span style="color: #007f00; font-style: italic;">&quot;:&quot;</span></pre></td></tr></table></div>

<p>Which is equivalent to this ruby code:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://www.adztec-independent.de/wp-content/plugins/wp-codebox/wp-codebox.php?p=253&amp;download=no-parens.rb">no-parens.rb</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2536"><td class="code" id="p253code6"><pre class="ruby" style="font-family:monospace;">str = <span style="color:#996600;">&quot;Hello, world!&quot;</span>.<span style="color:#9900CC;">upcase</span>.<span style="color:#CC0066; font-weight:bold;">gsub</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;,&quot;</span>, <span style="color:#996600;">&quot;:&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></td></tr></table></div>

<p>Much nicer, if you ask me. Of course you can chain as many methods as you want, even with each method taking a codeblock, if you want to (as it is possible in ruby as well).<br />
So now that I&#8217;ve got the most important things done, I&#8217;ll try to focus a little more on refactoring, working on the standard library (adding more classes &#038; methods) and thinking about some more unique, new features for the language <img src='http://www.adztec-independent.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.adztec-independent.de/2009/06/blocktalk-version-01-released/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Blocktalk code available @ Github</title>
		<link>http://www.adztec-independent.de/2009/06/blocktalk-code-available-github/</link>
		<comments>http://www.adztec-independent.de/2009/06/blocktalk-code-available-github/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 01:38:56 +0000</pubDate>
		<dc:creator>Christopher</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[blocktalk]]></category>
		<category><![CDATA[free software]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[hobbies]]></category>
		<category><![CDATA[interpreter]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.adztec-independent.de/?p=250</guid>
		<description><![CDATA[I just released the code for my Blocktalk interpreter at Github.
Feel free to clone my repository, create patches or file in some bugs, if you dare to  
]]></description>
			<content:encoded><![CDATA[<p>I just released the code for my Blocktalk interpreter <a href="http://github.com/bakkdoor/blocktalk/" target="_blank"><strong>at Github</strong></a>.<br />
Feel free to clone my repository, create patches or file in some bugs, if you dare to <img src='http://www.adztec-independent.de/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.adztec-independent.de/2009/06/blocktalk-code-available-github/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Blocktalk: A simple portscanner</title>
		<link>http://www.adztec-independent.de/2009/06/blocktalk-a-simple-portscanner/</link>
		<comments>http://www.adztec-independent.de/2009/06/blocktalk-a-simple-portscanner/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 00:14:36 +0000</pubDate>
		<dc:creator>Christopher</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[blocktalk]]></category>
		<category><![CDATA[free software]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[hobbies]]></category>
		<category><![CDATA[interpreter]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.adztec-independent.de/?p=242</guid>
		<description><![CDATA[Here&#8217;s a little blocktalk script, that shows the latest working feature I&#8217;ve added to my Blocktalk interpreter: Exception handling  
Basically, it&#8217;s just a simple portscanner.

?Download portscan.btSystem require: &#34;socket&#34;
&#160;
host = &#34;localhost&#34;
&#160;
&#40;ARGV at: 0&#41; if &#123;
  host = &#40;ARGV at: 0&#41;
&#125;
&#160;
open_ports = &#91;&#93;
&#160;
1 upto: 1024 do &#124;port&#124;
  Thread new &#123;
    try&#123;
 [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a little blocktalk script, that shows the latest working feature I&#8217;ve added to my Blocktalk interpreter: Exception handling <img src='http://www.adztec-independent.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Basically, it&#8217;s just a simple portscanner.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://www.adztec-independent.de/wp-content/plugins/wp-codebox/wp-codebox.php?p=242&amp;download=portscan.bt">portscan.bt</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2428"><td class="code" id="p242code8"><pre class="smalltalk" style="font-family:monospace;"><span style="color: #0000ff;">System</span> require: <span style="color: #007f00; font-style: italic;">&quot;socket&quot;</span>
&nbsp;
host <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #007f00; font-style: italic;">&quot;localhost&quot;</span>
&nbsp;
<span style="">&#40;</span><span style="color: #0000ff;">ARGV</span> at: <span style="color: #00007f;">0</span><span style="">&#41;</span> if <span style="">&#123;</span>
  host <span style="color: #000066; font-weight:bold;">=</span> <span style="">&#40;</span><span style="color: #0000ff;">ARGV</span> at: <span style="color: #00007f;">0</span><span style="">&#41;</span>
<span style="">&#125;</span>
&nbsp;
open_ports <span style="color: #000066; font-weight:bold;">=</span> <span style="">&#91;</span><span style="">&#93;</span>
&nbsp;
1 upto: <span style="color: #00007f;">1024</span> do |<span style="color: #00007f;">port</span>|
  <span style="color: #0000ff;">Thread</span> new <span style="">&#123;</span>
    try<span style="">&#123;</span>
      t <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #0000ff;">TCPSocket</span> new: <span style="color: #00007f;">host</span> port: <span style="color: #00007f;">port</span>
      open_ports &lt;&lt; port
&nbsp;
      s <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #0000ff;">Socket</span> getnameinfo: <span style="">&#91;</span><span style="color: #007f00; font-style: italic;">&quot;AF_INET&quot;</span>, <span style="color: #00007f;">port</span>, <span style="color: #00007f;">host</span><span style="">&#93;</span>
      <span style="color: #0000ff;">Console</span> puts: <span style="">&#40;</span><span style="color: #007f00; font-style: italic;">&quot;\nPort #{port} (#{s[1]})&quot;</span> + <span style="color: #007f00; font-style: italic;">&quot; is open.&quot;</span><span style="">&#41;</span>
&nbsp;
      catch<span style="">&#123;</span>
        <span style="color: #0000ff;">Console</span> print: <span style="color: #007f00; font-style: italic;">&quot;.&quot;</span>
      <span style="">&#125;</span>
&nbsp;
      ensure<span style="">&#123;</span>
        t if <span style="">&#123;</span> t close <span style="">&#125;</span>
      <span style="">&#125;</span>
    <span style="">&#125;</span>
  <span style="">&#125;</span>
end
&nbsp;
<span style="color: #0000ff;">Console</span> puts
<span style="color: #0000ff;">Console</span> puts: <span style="color: #007f00; font-style: italic;">&quot;Open ports on #{host} are:&quot;</span>
<span style="color: #0000ff;">Console</span> puts: <span style="">&#40;</span><span style="color: #00007f;">open_ports</span> join: <span style="color: #007f00; font-style: italic;">&quot;, &quot;</span><span style="">&#41;</span></pre></td></tr></table></div>

<p>So yeah, this is actually working. Now I&#8217;ve basically have most of the language features done that I had in mind first. Next to come are probably some performance optimizations as well as some more unique features, I still have to come up with. We&#8217;ll see <img src='http://www.adztec-independent.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </p>
<p><b>Update:</b><br />
I&#8217;ve added Threading to the code, this speeds up the process a little <img src='http://www.adztec-independent.de/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.adztec-independent.de/2009/06/blocktalk-a-simple-portscanner/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Blocktalk: Dealing with classes &amp; modules</title>
		<link>http://www.adztec-independent.de/2009/06/blocktalk-dealing-with-classes-modules/</link>
		<comments>http://www.adztec-independent.de/2009/06/blocktalk-dealing-with-classes-modules/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 02:45:47 +0000</pubDate>
		<dc:creator>Christopher</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[blocktalk]]></category>
		<category><![CDATA[compiler]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[interpreter]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[meta-programming]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.adztec-independent.de/?p=232</guid>
		<description><![CDATA[Alright. I&#8217;ve renamed my language again: Blocktalk is what I&#8217;ve settled on (finally I hope).
I think it resembles a little more the Smalltalk heritage, although most implementation related concepts come from Ruby though. Oh well, I like the name better, so that&#8217;s why i chose to name it that way.
Current progress:
Class &#038; module definitions work [...]]]></description>
			<content:encoded><![CDATA[<p>Alright. I&#8217;ve renamed my language again: <b>Blocktalk</b> is what I&#8217;ve settled on (finally I hope).<br />
I think it resembles a little more the Smalltalk heritage, although most implementation related concepts come from Ruby though. Oh well, I like the name better, so that&#8217;s why i chose to name it that way.</p>
<p><b>Current progress:</b><br />
Class &#038; module definitions work correctly now, meaning that it now fully supports nearly all concepts that you find in Ruby. The main difference is, that in contrast to Ruby, Blocktalk does not have any real Keywords predefined, except for just a few including:</p>
<ul>
<li><b>def</b> (for indicating method definitions)</li>
<li><b>do</b> &#038; <b>end</b> (for codeblocks)</li>
<li><b>self</b> (the same as in Ruby &#038; Smalltalk: reference to the current object)</li>
<li><b>return</b> (explicitly returning from withing the middle of a method)</li>
<li><b>yield</b> (same as in ruby: yielding to a given implicit block)</li>
<li>Some <b>literal syntax</b> (not real Keywords, but somehow belongs into this category) for <b>Arrays, Hashes, Codeblocks, Integers, Floats, Strings, Symbols, Characters</b> and of course <b>Assignment</b></li>
</ul>
<p>That&#8217;s pretty much it, regarding predefined keywords in the language itself. Everything else relies on expressions like message passing (a.k.a. method calling) to objects, assignments and arithmetic. Even defining new modules or classes is done by sending a message to the Class or Module class-object (very similar to how it&#8217;s done in Smalltalk and how you can also do it in Ruby).</p>
<p>Here&#8217;s a small example of defining a class and a module:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://www.adztec-independent.de/wp-content/plugins/wp-codebox/wp-codebox.php?p=232&amp;download=class-example.bt">class-example.bt</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p23210"><td class="code" id="p232code10"><pre class="smalltalk" style="font-family:monospace;"><span style="color: #0000ff;">Module</span> &gt;&gt; :<span style="color: #0000ff;">ModuleA</span> do
  def method_a <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #00007f;">do</span>
    <span style="color: #0000ff;">Console</span> puts: <span style="color: #007f00; font-style: italic;">&quot;in ModuleA#method_a!&quot;</span>
  end
end
&nbsp;
&nbsp;
<span style="color: #0000ff;">Module</span> &gt;&gt; :<span style="color: #0000ff;">ModuleB</span> do
  def method_b <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #00007f;">do</span>
    <span style="color: #0000ff;">Console</span> puts: <span style="color: #007f00; font-style: italic;">&quot;in ModuleB#method_b!&quot;</span>
  end
end
&nbsp;
<span style="color: #0000ff;">Class</span> &gt;&gt; :<span style="color: #0000ff;">Place</span> do
  def <span/<span style="color: #00007f;">1</span>/><span style="color: #7f007f;">self</span></span> from_city <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #00007f;">do</span> |<span style="color: #00007f;">city_name</span>|
    <span style="color: #000066; font-weight:bold;">#</span> should do something useful here ...
    <span style="color: #0000ff;">Place</span> new
  end
&nbsp;
  def coordinates <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #00007f;">do</span>
    <span style="color: #000066; font-weight:bold;">#</span> do some calculation here...
    <span style="color: #00007f;">return</span> <span style="">&#40;</span><span style="color: #0000ff;">Kernel</span> rand<span style="">&#41;</span>
  end
end
&nbsp;
<span style="color: #0000ff;">Class</span> &gt;&gt; :<span style="color: #0000ff;">Person</span> do
  <span/<span style="color: #00007f;">1</span>/><span style="color: #7f007f;">self</span></span> mixin: <span style="">&#91;</span><span style="color: #0000ff;">ModuleA</span>, <span style="color: #0000ff;">ModuleB</span><span style="">&#93;</span>
&nbsp;
  <span style="color: #000066; font-weight:bold;">#</span> constructor with named params
  def initialize <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #00007f;">do</span> |name age: <span style="color: #00007f;">age</span> city: <span style="color: #00007f;">city</span>|
    @name <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #00007f;">name</span>
    @age <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #00007f;">age</span>
    @city <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #00007f;">city</span>
  end
&nbsp;
  def go_to <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #00007f;">do</span> |place with: <span style="color: #00007f;">vehicle</span>|
    <span style="">&#40;</span><span style="">&#40;</span><span style="color: #00007f;">place</span> is_a?: <span style="color: #0000ff;">Place</span><span style="">&#41;</span> and: <span style="">&#40;</span><span style="">&#40;</span><span/<span style="color: #00007f;">1</span>/><span style="color: #7f007f;">self</span></span> distance_to: <span style="color: #00007f;">place</span><span style="">&#41;</span> &lt; 10.<span style="color: #00007f;">5</span><span style="">&#41;</span><span style="">&#41;</span> if_<span style="color: #7f007f;">true</span> <span style="">&#123;</span>
      vehicle take: <span/<span style="color: #00007f;">1</span>/><span style="color: #7f007f;">self</span></span> to: <span style="color: #00007f;">place</span>
    <span style="">&#125;</span>
  end
&nbsp;
  def place <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #00007f;">do</span>
    <span style="color: #0000ff;">Place</span> from_city: @city
  end
&nbsp;
  def distance_to <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #00007f;">do</span> |<span style="color: #00007f;">place</span>|
    <span style="">&#40;</span><span style="color: #00007f;">place</span> is_a?: <span style="color: #0000ff;">Place</span><span style="">&#41;</span> if_<span style="color: #7f007f;">true</span>: <span style="">&#123;</span>
      dist <span style="color: #000066; font-weight:bold;">=</span> <span style="">&#40;</span><span style="">&#40;</span><span/<span style="color: #00007f;">1</span>/><span style="color: #7f007f;">self</span></span> place<span style="">&#41;</span> coordinates<span style="">&#41;</span> - <span style="">&#40;</span><span style="color: #00007f;">place</span> coordinates<span style="">&#41;</span>
      dist abs
    <span style="">&#125;</span> if_<span style="color: #7f007f;">false</span>: <span style="">&#123;</span>
      0.<span style="color: #00007f;">0</span>
    <span style="">&#125;</span>
  end
end
&nbsp;
chris <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #0000ff;">Person</span> new: <span style="color: #007f00; font-style: italic;">&quot;Christopher Bertels&quot;</span> age: <span style="color: #00007f;">22</span> city: <span style="color: #007f00; font-style: italic;">&quot;Osnabrück&quot;</span>
city <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #0000ff;">Place</span> from_city: <span style="color: #007f00; font-style: italic;">&quot;Berlin&quot;</span>
&nbsp;
<span style="color: #0000ff;">Console</span> puts: <span style="color: #007f00; font-style: italic;">&quot;Distance from chris to city:&quot;</span>
<span style="color: #0000ff;">Console</span> puts: <span style="">&#40;</span><span style="color: #00007f;">chris</span> distance_to: <span style="color: #00007f;">city</span><span style="">&#41;</span>
&nbsp;
<span style="color: #000066; font-weight:bold;">#</span> <span style="color: #0000ff;">Person</span> mixed in <span style="color: #0000ff;">ModuleA</span> &amp; <span style="color: #0000ff;">ModuleB</span>:
<span style="color: #00007f;">chris</span> method_a
chris method_b</pre></td></tr></table></div>

<p>I&#8217;m still tweaking a little here and there, but I think most of the standard language features are working now. Now I&#8217;ll try to come up with some more unique things. I do have a few ideas already, but I still need to see, if they really work out nice. Let&#8217;s see <img src='http://www.adztec-independent.de/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.adztec-independent.de/2009/06/blocktalk-dealing-with-classes-modules/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Blockd: Mixing Ruby &amp; Smalltalk</title>
		<link>http://www.adztec-independent.de/2009/05/blockd-mixing-ruby-smalltalk/</link>
		<comments>http://www.adztec-independent.de/2009/05/blockd-mixing-ruby-smalltalk/#comments</comments>
		<pubDate>Fri, 29 May 2009 17:42:18 +0000</pubDate>
		<dc:creator>Christopher</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[blocktalk]]></category>
		<category><![CDATA[free software]]></category>
		<category><![CDATA[functional]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[hobbies]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.adztec-independent.de/?p=216</guid>
		<description><![CDATA[My new simple language, blockd, that I&#8217;ve mentioned in my last blog post is progressing quite nicely.
Since my last post a few days ago, I&#8217;ve worked on it quite a bit and I&#8217;ve got a first simple interpreter for it working.
For now, the interpreter is able to understand &#038; execute methodcalls on objects, anonymous methods [...]]]></description>
			<content:encoded><![CDATA[<p>My new simple language, <b>blockd</b>, that I&#8217;ve mentioned in my last blog post is progressing quite nicely.<br />
Since my last post a few days ago, I&#8217;ve worked on it quite a bit and I&#8217;ve got a first simple interpreter for it working.</p>
<p>For now, the interpreter is able to understand &#038; execute methodcalls on objects, anonymous methods (blocks &#038; procs in ruby) and some other minor stuff.</p>
<p>Heres a small example, that actually works now:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://www.adztec-independent.de/wp-content/plugins/wp-codebox/wp-codebox.php?p=216&amp;download=first_test.blk">first_test.blk</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p21613"><td class="code" id="p216code13"><pre class="smalltalk" style="font-family:monospace;">y <span style="color: #000066; font-weight:bold;">=</span> <span style="">&#123;</span> |<span style="color: #00007f;">x</span>|
  <span style="color: #0000ff;">Console</span> puts: <span style="color: #00007f;">x</span>
  <span style="color: #0000ff;">Console</span> puts: <span style="">&#40;</span><span style="color: #00007f;">x</span> * <span style="color: #00007f;">x</span><span style="">&#41;</span>
<span style="">&#125;</span>
y call: <span style="color: #00007f;">10</span>
&nbsp;
m <span style="color: #000066; font-weight:bold;">=</span> <span style="">&#123;</span> |<span style="color: #00007f;">x y</span>|
  <span style="color: #0000ff;">Console</span> puts: <span style="">&#40;</span><span style="">&#40;</span><span style="color: #00007f;">x</span> upcase<span style="">&#41;</span> * <span style="color: #00007f;">y</span><span style="">&#41;</span>
<span style="">&#125;</span>
m call: <span style="color: #007f00; font-style: italic;">&quot;cool &quot;</span> y: <span style="color: #00007f;">10</span>
&nbsp;
square <span style="color: #000066; font-weight:bold;">=</span> <span style="">&#123;</span> |<span style="color: #00007f;">y</span>|
  y * <span style="color: #00007f;">y</span>
<span style="">&#125;</span>
cubic <span style="color: #000066; font-weight:bold;">=</span> <span style="">&#123;</span>|<span style="color: #00007f;">x</span>| <span style="">&#40;</span><span style="color: #00007f;">x</span> * <span style="color: #00007f;">x</span><span style="">&#41;</span> * <span style="color: #00007f;">x</span><span style="">&#125;</span>
&nbsp;
<span style="color: #7f0000;">3</span> times do |<span style="color: #00007f;">i</span>|
  <span style="color: #0000ff;">Console</span> puts: <span style="color: #00007f;">i</span>
end
&nbsp;
foo <span style="color: #000066; font-weight:bold;">=</span> <span style="">&#123;</span>
  <span style="color: #7f0000;">3</span> times <span style="">&#123;</span> |<span style="color: #00007f;">i</span>| <span style="color: #0000ff;">Console</span> puts: <span style="">&#40;</span><span style="color: #00007f;">square</span> call: <span style="color: #00007f;">i</span><span style="">&#41;</span> <span style="">&#125;</span>
<span style="">&#125;</span>
&nbsp;
<span style="color: #0000ff;">Console</span> puts: <span style="color: #007f00; font-style: italic;">&quot;--&quot;</span>
&nbsp;
foo call
&nbsp;
<span style="color: #7f0000;">10</span> times &amp;foo</pre></td></tr></table></div>

<p>This basically is equivalent to the following ruby code:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://www.adztec-independent.de/wp-content/plugins/wp-codebox/wp-codebox.php?p=216&amp;download=first_test.rb">first_test.rb</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p21614"><td class="code" id="p216code14"><pre class="ruby" style="font-family:monospace;">y = <span style="color:#CC0066; font-weight:bold;">Proc</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>x<span style="color:#006600; font-weight:bold;">|</span> Console.<span style="color:#CC0066; font-weight:bold;">puts</span><span style="color:#006600; font-weight:bold;">&#40;</span>x<span style="color:#006600; font-weight:bold;">&#41;</span>;Console.<span style="color:#CC0066; font-weight:bold;">puts</span><span style="color:#006600; font-weight:bold;">&#40;</span>x.<span style="color:#006600; font-weight:bold;">*</span><span style="color:#006600; font-weight:bold;">&#40;</span>x<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
y.<span style="color:#9900CC;">call</span><span style="color:#006600; font-weight:bold;">&#40;</span>10<span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
m = <span style="color:#CC0066; font-weight:bold;">Proc</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>x,y<span style="color:#006600; font-weight:bold;">|</span> Console.<span style="color:#CC0066; font-weight:bold;">puts</span><span style="color:#006600; font-weight:bold;">&#40;</span>x.<span style="color:#9900CC;">upcase</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#006600; font-weight:bold;">*</span><span style="color:#006600; font-weight:bold;">&#40;</span>y<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
m.<span style="color:#9900CC;">call</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;cool &quot;</span>, 10<span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
square = <span style="color:#CC0066; font-weight:bold;">Proc</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>y<span style="color:#006600; font-weight:bold;">|</span> y.<span style="color:#006600; font-weight:bold;">*</span><span style="color:#006600; font-weight:bold;">&#40;</span>y<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
cubic = <span style="color:#CC0066; font-weight:bold;">Proc</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>x<span style="color:#006600; font-weight:bold;">|</span> x.<span style="color:#006600; font-weight:bold;">*</span><span style="color:#006600; font-weight:bold;">&#40;</span>x<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#006600; font-weight:bold;">*</span><span style="color:#006600; font-weight:bold;">&#40;</span>x<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
3.<span style="color:#9900CC;">times</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&amp;</span>Proc.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>i<span style="color:#006600; font-weight:bold;">|</span> Console.<span style="color:#CC0066; font-weight:bold;">puts</span><span style="color:#006600; font-weight:bold;">&#40;</span>i<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
foo = <span style="color:#CC0066; font-weight:bold;">Proc</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#123;</span>3.<span style="color:#9900CC;">times</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&amp;</span>Proc.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>i<span style="color:#006600; font-weight:bold;">|</span> Console.<span style="color:#CC0066; font-weight:bold;">puts</span><span style="color:#006600; font-weight:bold;">&#40;</span>square.<span style="color:#9900CC;">call</span><span style="color:#006600; font-weight:bold;">&#40;</span>i<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
Console.<span style="color:#CC0066; font-weight:bold;">puts</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;--&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
foo.<span style="color:#9900CC;">call</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
10.<span style="color:#9900CC;">times</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&amp;</span>foo<span style="color:#006600; font-weight:bold;">&#41;</span></pre></td></tr></table></div>

<p>Now, to make this clear: The ruby code above is what the current interpreter actually executes. The way I&#8217;ve implemented it for now (and for simplicity only &#8211; just to get something working first) is, that it simply parses the blockd code and <i>translates</i> it into equivalent ruby code, which then gets executed via <i>eval</i> in ruby.<br />
Now I know, this isn&#8217;t the best way to do it, for several reasons:<br />
Normally, an interpreter executes the code it gets fed directly, expression for expression, as this is also the case for ruby. If you have an syntax error within the code that is evaluated, the interpreter usually notices this only at the moment it reaches that part of the code and tries to evaluate it. This isn&#8217;t the case for the current interpreter I wrote here. The reason I chose to do it this way, was that I wanted to get something working as possible. I do want to change it though later on, so that each expression gets executed on the fly, once it is parsed.</p>
<p>So for now, i evaluate the parsetree, and each expression node gets turned into a string of equivalent ruby code, that then gets saved in a global list (within a class called <i>Evaluator</i>). When the parser has done it&#8217;s job and all the values (strings of ruby code) of all expression nodes have been accumulated, i simply run ruby&#8217;s <i>eval</i> on it and at that point do the actual evaluation (and possibly get semantic errors here &#8211; like missing variables etc.).</p>
<p>I still need to implement some stuff regarding classes  &#038; modules, but I&#8217;m quite happy for now, since it wasn&#8217;t so hard as I had expected before. Once I have everything working, I&#8217;ll start to actually rewrite the parser in a way, that it evaluates &#038; executes code on the fly, expression per expression and not all of them at once at the end. This should also improve performance, which is obviously another downside of my current approach, since I have to wait for all expressions being parsed &#038; evaluated to appropriate ruby code first, before even beginning the actual evaluation process&#8230; </p>
<p>For anyone, who is interested, here is a simple benchmark of the code above:</p>
<p>The <b>blockd version</b> (executed with my current interpreter):</p>
<blockquote><p>
real	0m0.264s<br />
user	0m0.184s<br />
sys	0m0.072s
</p></blockquote>
<p>The <b>ruby version</b> of the equivalent code (generated by my parser):</p>
<blockquote><p>
real	0m0.021s<br />
user	0m0.008s<br />
sys	0m0.008s
</p></blockquote>
<p>As you can see, there&#8217;s quite a performance overhead. Although not really noticeable by a viewer, the numbers tell the story. So I expect quite an improvement in performance, once I&#8217;ll start rewriting the interpreter in the way I&#8217;ve mentioned above. Still cool though, if you ask me <img src='http://www.adztec-independent.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.adztec-independent.de/2009/05/blockd-mixing-ruby-smalltalk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Parser generation with Ruby</title>
		<link>http://www.adztec-independent.de/2009/05/parser-generation-with-ruby/</link>
		<comments>http://www.adztec-independent.de/2009/05/parser-generation-with-ruby/#comments</comments>
		<pubDate>Wed, 27 May 2009 00:12:25 +0000</pubDate>
		<dc:creator>Christopher</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[blocktalk]]></category>
		<category><![CDATA[free software]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[hobbies]]></category>
		<category><![CDATA[interpreter]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[meta-programming]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[recursion]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.adztec-independent.de/?p=201</guid>
		<description><![CDATA[I&#8217;ve started to play a little with Treetop, a parser generator library for Ruby.
Why? you might ask. While I&#8217;ve been dreaming of my own programming languages and designing them for quite some time now, I never really managed to actually get beyond the design-phase. I&#8217;ve come up with several language designs in the past, each [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve started to play a little with <a href="http://treetop.rubyforge.org">Treetop</a>, a parser generator library for Ruby.<br />
Why? you might ask. While I&#8217;ve been dreaming of my own programming languages and designing them for quite some time now, I never really managed to actually get beyond the design-phase. I&#8217;ve come up with several language designs in the past, each time getting closer to something that I think really could work (which doesn&#8217;t mean, that it actually could be useful or &#8216;good&#8217; &#8211; if that even makes sense).<br />
While I&#8217;ve been looking at many different languages in the past, I&#8217;ve found the dynamic, object-oriented and functional  high-level languages to be most interesting &#038; fun to work with. Naturally, after working with Ruby alot, I&#8217;ve started looking a little bit at Smalltalk and how it differs to Ruby.</p>
<p>Inspired by what Smalltalk and Ruby have to give, I started designing my own language, heavily influenced by those two great, very dynamic, truly object-oriented programming languages and came up with a quite simple language named <b>blockd</b>.</p>
<p>The name is based upon the main principle of the language: Everything is an object, and in the end, all code is defined within blocks &#8211; that are ruby / smalltalk like blocks. Naming these blocks is done via simple assignment. So instead of having a huge amount of keywords, the language itself is pretty simple, because all we really need is a way to describe assignments, instantiate objects and easily create blocks to pass to methods or use in an assignment.</p>
<p>So in contrast to Ruby, where there are procs, lambdas and blocks, blockd only knows blocks, which basically behave like Smalltalk like blocks &#8211; they simply are anonymous procedures / blocks of code (or functions, if you want to call them that &#8211; although not pure as in Haskell).</p>
<p>The syntax is a mix of Ruby&#8217;s and Smalltalk&#8217;s with some minor tweaks I thought would be cool (or not? I don&#8217;t know <img src='http://www.adztec-independent.de/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ).<br />
To give you an example of how the language looks, here is a small snippet of some sample code, that actually doesn&#8217;t work yet but might do so in the future <img src='http://www.adztec-independent.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://www.adztec-independent.de/wp-content/plugins/wp-codebox/wp-codebox.php?p=201&amp;download=sample.blk">sample.blk</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p20116"><td class="code" id="p201code16"><pre class="lisp" style="font-family:monospace;"># this is just for demonstration
# there probably won't be the need to require the console module from the
# standard library every time you want to print something to the screen <span style="color: #808080; font-style: italic;">;)</span>
System require<span style="color: #66cc66;">:</span> <span style="color: #ff0000;">&quot;console&quot;</span>
&nbsp;
# we support ruby-style blocks with <span style="color: #b1b100;">do</span> <span style="color: #66cc66;">...</span> end <span style="color: #b1b100;">and</span> curly braces <span style="color: #66cc66;">&#123;</span> <span style="color: #66cc66;">...</span> <span style="color: #66cc66;">&#125;</span>
File open<span style="color: #66cc66;">:</span> <span style="color: #ff0000;">&quot;test.txt&quot;</span> mode<span style="color: #66cc66;">:</span> <span style="color: #ff0000;">&quot;w&quot;</span> <span style="color: #b1b100;">do</span> <span style="color: #66cc66;">|</span>f<span style="color: #66cc66;">|</span>
  f puts<span style="color: #66cc66;">:</span> <span style="color: #ff0000;">&quot;what's up, dog?!&quot;</span>
  f puts<span style="color: #66cc66;">:</span> <span style="color: #ff0000;">&quot;crazy shit, yo!&quot;</span>
  f puts<span style="color: #66cc66;">:</span> <span style="color: #ff0000;">&quot;hahaha!!&quot;</span>
end
&nbsp;
10 to<span style="color: #66cc66;">:</span> 0 <span style="color: #b1b100;">do</span> <span style="color: #66cc66;">|</span>i<span style="color: #66cc66;">|</span>
  Console puts<span style="color: #66cc66;">:</span> <span style="color: #555;">i</span>
end
&nbsp;
i <span style="color: #66cc66;">=</span> 0
<span style="color: #66cc66;">&#40;</span>i <span style="color: #66cc66;">&lt;</span> 10<span style="color: #66cc66;">&#41;</span> while_true<span style="color: #66cc66;">:</span> <span style="color: #b1b100;">do</span> <span style="color: #66cc66;">|</span>i<span style="color: #66cc66;">|</span>
  Console puts<span style="color: #66cc66;">:</span> <span style="color: #555;">i</span>
  i incr
end
&nbsp;
numbers <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span>1<span style="color: #66cc66;">,</span>2<span style="color: #66cc66;">,</span>3<span style="color: #66cc66;">,</span>4<span style="color: #66cc66;">,</span>5<span style="color: #66cc66;">&#93;</span> select<span style="color: #66cc66;">:</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">|</span>i<span style="color: #66cc66;">|</span> i <span style="color: #66cc66;">&lt;</span> 3<span style="color: #66cc66;">&#125;</span>
numbers each<span style="color: #66cc66;">:</span> <span style="color: #b1b100;">do</span> <span style="color: #66cc66;">|</span>i<span style="color: #66cc66;">|</span>
  puts i
end
&nbsp;
<span style="color: #66cc66;">&#40;</span>1 <span style="color: #66cc66;">..</span> 100<span style="color: #66cc66;">&#41;</span> each<span style="color: #66cc66;">:</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">|</span>i<span style="color: #66cc66;">|</span> Console puts<span style="color: #66cc66;">:</span> <span style="color: #555;">i</span><span style="color: #66cc66;">&#125;</span>
&nbsp;
squares <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#40;</span>1 <span style="color: #66cc66;">..</span> 100<span style="color: #66cc66;">&#41;</span> collect<span style="color: #66cc66;">:</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">|</span>i<span style="color: #66cc66;">|</span> i<span style="color: #66cc66;"> * </span>i<span style="color: #66cc66;">&#125;</span>
&nbsp;
# define a square method
square <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #66cc66;">|</span>x<span style="color: #66cc66;">|</span>
  x<span style="color: #66cc66;"> * </span>x
<span style="color: #66cc66;">&#125;</span>
&nbsp;
# <span style="color: #b1b100;">or</span> like this<span style="color: #66cc66;">:</span>
<span style="color: #b1b100;">abs</span> <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #66cc66;">|</span>num<span style="color: #66cc66;">|</span>
  <span style="color: #66cc66;">&#40;</span>num <span style="color: #66cc66;">&gt;</span> 0<span style="color: #66cc66;">&#41;</span> if_true <span style="color: #66cc66;">&#123;</span>
    <span style="color: #b1b100;">return</span> num
  <span style="color: #66cc66;">&#125;</span>
&nbsp;
  num<span style="color: #66cc66;"> * </span>-<span style="color: #cc66cc;">1</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>I&#8217;m still tweaking the syntax and haven&#8217;t decided upon all things completely yet, but I guess I&#8217;ve found the pretty basic &#8220;feel&#8221; of it.</p>
<p>While I haven&#8217;t shown you any code that defines a class or modules, it still does show a little of the languages syntax.  I&#8217;ve started the parser today and it successfully parses the code above, meaning, that since the syntax isn&#8217;t too complicated, I expect to be able to parse all the remaining stuff (classes &#038; modules and some minor other things) pretty soon. I then intend to start writing the actual implementation &#8211; an interpreter written in Ruby. While I could come up with my own runtime, class library etc, I want to make use of the Ruby infrastructure as much as possible. For one reason, it makes it easier to actually implement something useful, on the other hand, since the language is very close to Ruby&#8217;s object model and semantics, I hope I can use most of Ruby&#8217;s code directly. This also would mean, that the interpreter could also run on other Ruby implementations like JRuby, IronRuby etc. And maybe, some day, it could also run natively compiled with the Ruby compiler I&#8217;ve been working on recently as well &#8211; but that&#8217;s still far into the future, since the compiler isn&#8217;t finished yet.</p>
<p>I guess that&#8217;s it for now. More to come soon <img src='http://www.adztec-independent.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.adztec-independent.de/2009/05/parser-generation-with-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a simple game in Ruby &#8211; Episode 5</title>
		<link>http://www.adztec-independent.de/2009/05/creating-a-simple-game-in-ruby-episode-5/</link>
		<comments>http://www.adztec-independent.de/2009/05/creating-a-simple-game-in-ruby-episode-5/#comments</comments>
		<pubDate>Tue, 19 May 2009 02:29:10 +0000</pubDate>
		<dc:creator>Christopher</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Ruby Screencast]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[hobbies]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[screencast]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.adztec-independent.de/?p=195</guid>
		<description><![CDATA[This is the 5th episode on creating a simple game in Ruby. In this episode, we&#8217;ll add some automated testing via the BDD framework RSpec. We&#8217;ll also start to implement the Character class.

]]></description>
			<content:encoded><![CDATA[<p>This is the 5th episode on creating a simple game in Ruby. In this episode, we&#8217;ll add some automated testing via the BDD framework RSpec. We&#8217;ll also start to implement the Character class.</p>
<p><embed src="http://blip.tv/play/gq94gYLNTgA" type="application/x-shockwave-flash" width="525" height="303" allowscriptaccess="always" allowfullscreen="true"></embed></p>
]]></content:encoded>
			<wfw:commentRss>http://www.adztec-independent.de/2009/05/creating-a-simple-game-in-ruby-episode-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
