<?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>Merbist &#187; compiler</title>
	<atom:link href="http://merbist.com/tag/compiler/feed/" rel="self" type="application/rss+xml" />
	<link>http://merbist.com</link>
	<description>Random thoughts of a software developer</description>
	<lastBuildDate>Tue, 03 Jan 2012 02:34:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Compiled hello world with MacRuby</title>
		<link>http://merbist.com/2009/07/12/compiled-hello-world-with-macruby/</link>
		<comments>http://merbist.com/2009/07/12/compiled-hello-world-with-macruby/#comments</comments>
		<pubDate>Sun, 12 Jul 2009 19:53:53 +0000</pubDate>
		<dc:creator>Matt Aimonetti</dc:creator>
				<category><![CDATA[macruby]]></category>
		<category><![CDATA[Misc]]></category>
		<category><![CDATA[compiler]]></category>
		<category><![CDATA[experimental]]></category>
		<category><![CDATA[llvm]]></category>

		<guid isPermaLink="false">http://merbist.com/?p=519</guid>
		<description><![CDATA[To celebrate the amazing work being done by Laurent Sansonetti on MacRuby here is a hello world using the new LLVM based compiler. $ echo "p ARGV.join(' ').upcase" &#62; hello_world.rb $ macrubyc hello_world.rb -o macruby_says $ ./macruby_says hello world "HELLO WORLD" Note that to achieve this result, you need to be using the experimental branch of [...]]]></description>
			<content:encoded><![CDATA[<p>To celebrate the amazing <a href="http://lists.macosforge.org/pipermail/macruby-devel/2009-July/002062.html" target="_blank">work being done by Laurent Sansonetti on MacRuby</a> here is a hello world using the new <a id="aptureLink_eiGSNk3xFS" href="http://en.wikipedia.org/wiki/LLVM">LLVM</a> based compiler.<br />
<code><br />
$ echo "p ARGV.join(' ').upcase" &gt; hello_world.rb<br />
$ macrubyc hello_world.rb -o macruby_says<br />
$ ./macruby_says hello world<br />
"HELLO WORLD"<br />
</code></p>
<p>Note that to achieve this result, you need to be using the experimental branch of MacRuby and have LLVM installed. (check the <a id="aptureLink_tkygCbIxtc" href="http://svn.macosforge.org/repository/ruby/MacRuby/branches/experimental/README.rdoc">readme</a> available in MacRuby&#8217;s repo).</p>
<p>Let&#8217;s quickly look at what we just did.<br />
We created a single line ruby script that takes the passed arguments, joins them and print them uppercase.<br />
Then, we compiled our script into a <a id="aptureLink_4duTFQoq7w" href="http://en.wikipedia.org/wiki/Mach-O">Mach-O</a> object file and produce an executable.</p>
<p>Here is an extract from Laurent&#8217;s latest status report:</p>
<blockquote><p>Produced executables embed all the compiled Ruby code as well as MacRuby, statically.<br />
It can be distributed as is and does not depend on anything MacRuby or LLVM at runtime.<br />
The Ruby source code is compiled into native machine code (same process as we do at runtime with the JIT compiler), so it&#8217;s also a good way to obfuscate the source code.<br />
The final binary looks like an Objective-C binary (except that it&#8217;s larger)</p></blockquote>
<p>Don&#8217;t expect to compile Rails just yet, it&#8217;s still in a preliminary stage.</p>
<p>The final release you should let you pick one of the 2 compilation modes:</p>
<p>* <strong>normal mode</strong>: full ruby specs, compile down to machine code and use LLVM at runtime. (recommended for desktop/server apps)<br />
* <strong>full mode</strong>: no full ruby spec support, no runtime code generation, no LLVM. (&#8220;very light application and/or if the environment does not support runtime code generation&#8221; (<em>hint-hint)</em>)</p>
<p>As you can see, <a id="aptureLink_OUswLFtmcb" href="http://macruby.org">MacRuby</a> is moving forward and the experimental branch should soon move to trunk.</p>
]]></content:encoded>
			<wfw:commentRss>http://merbist.com/2009/07/12/compiled-hello-world-with-macruby/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>

