<?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>Tim Keller &#187; compiling</title>
	<atom:link href="http://timkeller.me/tag/compiling/feed/" rel="self" type="application/rss+xml" />
	<link>http://timkeller.me</link>
	<description>Thoughts on Technology and the future of Learning</description>
	<lastBuildDate>Sun, 15 Jan 2012 21:14:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Google Go</title>
		<link>http://timkeller.me/2009/11/16/google-go/</link>
		<comments>http://timkeller.me/2009/11/16/google-go/#comments</comments>
		<pubDate>Mon, 16 Nov 2009 03:17:55 +0000</pubDate>
		<dc:creator>Tim Keller</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[10.6]]></category>
		<category><![CDATA[compiling]]></category>
		<category><![CDATA[gcc]]></category>
		<category><![CDATA[Geek]]></category>
		<category><![CDATA[go]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[Opensource]]></category>
		<category><![CDATA[OSX]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[snow leopard]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://timk.co.za/?p=62038201</guid>
		<description><![CDATA[Google is touting its new Go language as a modern systems programming language which is expressive, concurrent, garbage-collected. Go takes the development speed of working in a dynamic language like Python, and combines it with the performance and safety of &#8230; <a href="http://timkeller.me/2009/11/16/google-go/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-62038202 alignright" title="Go Logo" src="http://timk.co.za/wp-content/uploads/2009/11/bumper480x270.png" alt="Go Logo" width="382" height="216" /></p>
<p>Google is touting its new Go language as a modern systems programming language which is expressive, concurrent, garbage-collected. Go takes the development speed of working in a dynamic language like Python, and combines it with the performance and safety of a compiled language like C or C++.</p>
<p>In its Go FAQ, Google explains the main motivations behind the project:</p>
<p>No major systems language has emerged in over a decade, but over that time the computing landscape has changed tremendously. There are several trends:</p>
<ul>
<li>Computers are enormously quicker but software development is not faster.</li>
<li>Dependency management is a big part of software development today but the “header files” of languages in the C tradition are antithetical to clean dependency analysis—and fast compilation.</li>
<li>There is a growing rebellion against cumbersome type systems like those of Java and C++, pushing people towards dynamically typed languages such as Python and JavaScript.</li>
<li>Some fundamental concepts such as garbage collection and parallel computation are not well supported by popular systems languages.</li>
<li>The emergence of multicore computers has generated worry and confusion.</li>
</ul>
<p>Bold words from Google, especially considering the number of new languages which have come and gone over the years. Surely its too risky to put the corporate name behind the project? Not once you hear who&#8217;s on the team.</p>
<p>The project is being staffed by some serious Computer Science heavyweights: Robert Griesemer, Rob Pike (Unix Team, Plan 9 OS, UTF-8, Inferno), Ken Thompson (inventor of B &#8211; forerunner of C, UTF-8, shepherd Unix and Plan 9), Ian Taylor, Russ Cox, Jini Kim and Adam Langley.</p>
<p>Coming from a C/C++ background during my university days, my first Go experience felt quite nostalgic. I grabbed the source via Mercurial, compiled it in the Terminal, and configured some shell environment variables. What I was left with was a native Go compiler for my x64 architecture (6g) and a Go linker (6l). These are the recommended compilation tools until the GCC-based (gccgo) version catches up.</p>
<h2>Installation on Snow Leopard</h2>
<p>Before you follow these steps, you should have <a href="http://developer.apple.com/TOOLS/Xcode/" target="_blank">XTools</a> installed. You should also be running Snow Leopard as your OS. These instructions should also work for 10.5 Leopard, but you may have to use GOARCH=386.</p>
<h3>Environment</h3>
<p>Go needs a couple of shell/environment parameters to be set prior to installation.</p>
<p>Add the following lines to your <strong>~/.bashrc</strong> file:</p>
<pre><code>export GOROOT=\$HOME/Go
export GOOS=darwin
export GOARCH=amd64
export GOBIN=\$HOME/bin
</code></pre>
<p>Now use the <code>source</code> command to apply those changes:</p>
<pre><code>source ~/.bashrc</code></pre>
<p>Next we need to add the bin directory for Go, and map it on the system path:</p>
<pre><code>mkdir -p $HOME/bin
echo "$HOME/bin" &gt; go
sudo mv go /etc/paths.d/
eval `/usr/libexec/path_helper -s`
</code></pre>
<h3>Source Code</h3>
<p>The Go team are currently using Mercurial to handle the source code. If you don&#8217;t already have it installed, you can install it quickly and easily with the following command:</p>
<pre><code>sudo easy_install mercurial</code></pre>
<p>I encountered an issue whereby UTF-8 was not set as my locale language type. While some will not experience this, I had to force this by adding the following lines to your <strong>~/.profile</strong> file:</p>
<pre><code>export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
</code></pre>
<p>Adjust according to your locale, if neccesary. Big thanks to <a href="http://mytechblogdiary.wordpress.com/2009/10/04/mercurial-in-snow-leopard-utf-8-error/" target="_blank">ricafeal</a> for this.</p>
<p>This will use the Python <code>easy_install</code> tool to install the mercurial package on your system. Once complete, its time to checkout a copy of the Go source code:</p>
<pre><code>hg clone -r release https://go.googlecode.com/hg/ $GOROOT</code></pre>
<p>This will place a full directory of Go source in the directory defined in <strong>~/.bashrc</strong> as $GOROOT</p>
<h3>Installation</h3>
<p>All the Mac OS X particulars are done and you can follow the standard installation procedure. That includes:</p>
<pre><code>cd $GOROOT/src
./all.bash</code></pre>
<p>If you get a message stating&#8230;</p>
<pre><code>--- cd ../test
N known bugs; 0 unexpected bugs
</code></pre>
<p>&#8230; you should be good to go (oh the puns).</p>
<h2>Hello World</h2>
<pre><code>package main
import "fmt"
func main() {
fmt.Printf("hello, world\n")
}
</code></pre>
<p>To compile:</p>
<pre><code>$ 6g hello.go
$ 6l hello.6
</code></pre>
<p>To execute:</p>
<pre><code>$ ./6.out
hello, world
</code></pre>
<p>You may also want to check out <a href="http://jeremyhubert.com/articles/installing-google-go-on-osx-snow-leopard.html">Jeremy&#8217;s</a> great little script which lets you compiler (6g) and ink (6l) in one, well, go.</p>
<p>More Go later this week!</p>
]]></content:encoded>
			<wfw:commentRss>http://timkeller.me/2009/11/16/google-go/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

