<?xml version="1.0" encoding="UTF-8"?>
<rss version='2.0' xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Steve Bate</title>
    <description>polyglot programmer - passionate, opinionated, cynic, realist</description>
    <link>https://stevebate.silvrback.com/feed</link>
    <atom:link href="https://stevebate.silvrback.com/feed" rel="self" type="application/rss+xml"/>
    <category domain="stevebate.silvrback.com">Content Management/Blog</category>
    <language>en-us</language>
      <pubDate>Wed, 04 Mar 2015 02:53:34 -0700</pubDate>
    <managingEditor>stephencbate@gmail.com (Steve Bate)</managingEditor>
      <item>
        <guid>https://stevebate.silvrback.com/grokking-go-runes#12586</guid>
          <pubDate>Wed, 04 Mar 2015 02:53:34 -0700</pubDate>
        <link>https://stevebate.silvrback.com/grokking-go-runes</link>
        <title>Grokking Go Runes</title>
        <description></description>
        <content:encoded><![CDATA[<p>Something that I didn&#39;t pay much attention to during my first project with Go was the idea of a Rune. Now I&#39;ve got more time to play with the language I thought I&#39;d do some digging and see what came up. It turns out, knowing why Runes exist and how to deal with them is quite important.</p>

<p>A Rune deals with text, as would a string you might think, but a string is all about the bytes and not necessarily the characters within the string. For instance, as it happens &quot;Hello World&quot; contains 11 characters, and as they are English characters, they are represented in  UTF-8, just as they are in ASCII, as 1 byte per character, therefore in this particular case 11 characters equals 11 bytes.</p>

<p>Go is all about UTF-8 encoding meaning you can use characters in your strings that aren&#39;t capable of being represented in ASCII. This also means that a string might contain more bytes than it does characters. For instance, &quot;今日は&quot; is hello in Japanese (or at least one form of it). The string contains three characters but remember characters do not necessarily equal bytes so let&#39;s find out what the length <em>actually</em> is:</p>
<div class="highlight"><pre><span></span>hello := &quot;今日は&quot;
fmt.Println(len(hello))
</pre></div>
<p>The answer is 9. Surprised? Remember Go supports UTF-8 encoding which means it can store much more than ASCII. If you only ever deal with English maybe ASCII is all you&#39;ve ever needed but UTF-8 supports much more. However, it also means it needs more bytes to store those characters outside the range of ASCII. We can see which bytes make up each character of our string with the following snippet:</p>
<div class="highlight"><pre><span></span>for _, c := range hello {
    fmt.Printf(&quot;%c, % X\n&quot;, c, []byte(string(c)))
}
</pre></div>
<p><strong>今, E4 BB 8A<br>
日, E6 97 A5<br>
は, E3 81 AF</strong></p>

<p>Here we loop through each <em>Rune</em> (or character, or code point) in the text meaning each pass results in 3 bytes being read which we print out along with the displayable character. It&#39;s important to realise that the <strong>range</strong> construct knows how to return each character regardless of how many bytes it consumes. If we try to extract say, the first character from the string via an index we wouldn&#39;t get the result you might expect:</p>
<div class="highlight"><pre><span></span>fmt.Printf(&quot;%c\n&quot;, hello[0])
</pre></div>
<p><strong>ä</strong></p>

<p>What happened? Well, instead of trying to get the character how about the byte?</p>
<div class="highlight"><pre><span></span>fmt.Printf(&quot;%X\n&quot;, hello[0])
</pre></div>
<p><strong>E4</strong></p>

<p>Here we only got the first byte of the first character and it looks like <strong>E4</strong> in UTF-8 encoding is represented as <strong>ä</strong>. Not what we wanted because our character is represented by <em>three</em> bytes. However if we convert the string to a rune slice first:</p>
<div class="highlight"><pre><span></span>helloRunes := []rune(&quot;今日は&quot;)

fmt.Printf(&quot;%c&quot;, helloRunes[0])
fmt.Printf(&quot;%c&quot;, helloRunes[1])
fmt.Printf(&quot;%c&quot;, helloRunes[2])
</pre></div>
<p><em>then</em> we get the right result:</p>

<p><strong>今日は</strong></p>

<p>If we want to know the index of where a particular rune starts within a string we can use a function from the <strong>strings</strong> package:</p>
<div class="highlight"><pre><span></span>idx := strings.IndexRune(hello, &#39;日&#39;)
fmt.Printf(&quot;index of %c starts at %d\n&quot;, &#39;日&#39;, idx)
</pre></div>
<p><strong>index of 日 starts at 3</strong></p>

<p>So now we know why a rune exists and when we might want to use it. Worth keeping in mind, especially when you want to start dealing with slices and indexes.</p>
]]></content:encoded>
      </item>
      <item>
        <guid>https://stevebate.silvrback.com/crossroads#10281</guid>
          <pubDate>Fri, 09 Jan 2015 15:35:40 -0700</pubDate>
        <link>https://stevebate.silvrback.com/crossroads</link>
        <title>Crossroads</title>
        <description></description>
        <content:encoded><![CDATA[<p>No, not the ITV (UK) soap from the 70s/80s but rather with the start of the new year an accompanying feeling that I&#39;m at a junction in my software development life and I&#39;m not sure which way to turn.</p>

<p>These last few months have been very busy. I&#39;ve been writing a new web app for work using Go and MongoDB. In the main, it&#39;s been a lot of fun (though the front-end less so), educational, and enlightening. It&#39;s made me realise that I don&#39;t want to be pigeon-holed as a C#/.Net developer any more. I don&#39;t suppose I really ever wanted to be pigeon-holed as <em>anything</em> (who would?) but I never stopped and thought about it before.</p>

<p>Professionally, I was a latecomer to the world of software development though I&#39;d learned to code quite early, first on the ZX Spectrum and C64 followed later by an Atari ST and then an Amiga. I actually started working life as grease-monkey (sometimes known as a car mechanic) but at age 25 I knew I&#39;d wasted my younger years and decided I had to pursue what I&#39;d always loved, so I went back to night school and at 28 years old got my first development job where I stayed for more than 11 years!</p>

<p>Now, at 44 years of age, and feeling like life is passing by faster than ever before, I suddenly feel like I&#39;ve missed out on such a lot of opportunities to grow because, unlike in my day to day development role where I learned to question every action and justify every design decision, I never once questioned my life as a C# developer or Delphi developer before that. I never even questioned my life as a Windows developer. Like many others, I just followed the path of least resistance.</p>

<p>Location has a lot of influence on the way things pan out, career-wise. Where I live, and for many miles around, Windows is the predominant platform, and of course .Net and C# are the obvious development tools to go with it. The only real alternative is Java and well, thanks but no thanks. Either choice is not exactly appealing given the state of most of the enterprise shops I&#39;ve seen. Sadly, finding a good one seems less likely than winning the lottery. </p>

<p>That then doesn&#39;t leave me with a lot of alternatives. I know that I want to ramp up my Linux knowledge whilst continuing to develop in Go when the opportunity presents itself,and luckily my current job at least allows me to fulfil the Go side of things though my use of Linux is confined to home. We are a windows and C# shop. The thing is, my positive experience in Go is the cause of a corresponding drop in my enthusiasm for C# and .Net in general. We all grow tired of things sooner or later and whilst my passion for programming remains intensely high,I feel like I&#39;m stagnating. It could be the enterprise environment that&#39;s making me feel the way I do but I think the worry of being a .Net only developer forever has something to do with my mindset. I want to branch out, learn more things, <em>different</em> things, and Linux and Go are the starting points .</p>

<p>So here I am faced with the sort of  choice I had when I decided to retrain as a developer only this time the direction is more subtle, and less obvious. There&#39;s only so much time in a day and I&#39;m not getting any younger so the question is this: Do I stick or twist? </p>

<p>Do I invest more time and energy in .Net, learning to live with yet more big changes coming down the road from Microsoft and accept being forever damned to work on all the legacy crap that will likely live longer than me? Or do I put heart and soul into Linux, Go, maybe Erlang too, and the plethora of associated open source goodies that come from those worlds <strong>but</strong> at the risk of rendering myself unemployable within a 150 mile radius?</p>

<p>My heart says do it, it&#39;ll be worth the investment and opportunities will come anyway. My head says don&#39;t, better the devil you know.</p>

<p>The thing is, I&#39;ve already kind of started down that path anyway. I&#39;m definitely investing a lot of time and effort in other languages and operating systems, it&#39;s just that I have an inner voice nagging away at me making me feel uneasy about it all. Change is hard to accept and I&#39;m definitely stepping out of my comfort zone but doing nothing is even harder. So in the end what will be will be and all of this is just me getting it off my chest. I just hope I made the right choice and that the road leads somewhere positive but as usual, only time will tell.</p>
]]></content:encoded>
      </item>
      <item>
        <guid>https://stevebate.silvrback.com/change-from-the-inside#9137</guid>
          <pubDate>Fri, 24 Oct 2014 00:48:00 -0600</pubDate>
        <link>https://stevebate.silvrback.com/change-from-the-inside</link>
        <title>Change from the inside</title>
        <description></description>
        <content:encoded><![CDATA[<p>In the U.K. there&#39;s a phrase used to convey the idea that, economically speaking, the south of the country is more prosperous than the north. It&#39;s called the north/south divide. As a software developer based in the north west I often feel the same with regard to career opportunities. Anyone who wants more than an enterprise Microsoft or Java gig will be hard pushed to find it up here. The exciting stuff appears to happen all the way down there in and around London.</p>

<p>I often monitor job trends to see where the future is heading and right now I&#39;m interested to see if Go can break out of the niche phase and find widespread adoption. It will probably take a very long time, and in most cases will also probably never dislodge .Net and Java as the default application language of choice. In the north there are so many companies that are &quot;followers&quot; rather than trend setters that innovation in I.T. is not even on their radar so while the world is moving on, they&#39;ve just discovered NHibernate or Entity Framework.</p>

<p>One things for sure, the only way change will happen is from the inside. It will take one or two developers to start slowly introducing something different, whether that be Go or something else, around the edges of their existing systems to help open the eyes of their colleagues and show them that there are alternatives out there that can make their lives easier, more fun, and benefit their employers too. That&#39;s what I&#39;m trying to do with Go. I hope I&#39;m not the only one or I&#39;m in for a long and lonely existence but to me that&#39;s better than the alternative, a long and frustrated existence.</p>
]]></content:encoded>
      </item>
  </channel>
</rss>