<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
     xmlns:atom="http://www.w3.org/2005/Atom"
     xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:wfw="http://wellformedweb.org/CommentAPI/"
     >
  <channel>
    <title>Macha</title>
    <link>http://blog.initprogram.com</link>
    <description>Gaming, Programming and Random Rants</description>
    <pubDate>Tue, 27 Sep 2011 19:00:05 GMT</pubDate>
    <generator>Blogofile</generator>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>76 IEs? Not Likely.</title>
      <link>http://blog.initprogram.com/2011/09/27/76-ies-not-likely/</link>
      <pubDate>Tue, 27 Sep 2011 19:35:00 IST</pubDate>
      <category><![CDATA[Technology]]></category>
      <category><![CDATA[Programming]]></category>
      <guid isPermaLink="true">http://blog.initprogram.com/2011/09/27/76-ies-not-likely/</guid>
      <description>76 IEs? Not Likely.</description>
      <content:encoded><![CDATA[<p>Paul Irish believes that by 2020, web designers will be forced to
   <a href="http://paulirish.com/2011/browser-market-pollution-iex-is-the-new-ie6/">support 76 variations of Internet Explorer</a> between the nearly annual release schedule IE is on lately and the compatibility modes each of these IEs will have for previous versions of Internet Explorer. <sup id="fnr1-133215864"><a href="#fn1-133215864">1</a></sup>
</p>
<p>IE6's entrenched position came from the fact that (a) it was the latest version of Internet Explorer for a <strong>huge</strong> amount of time and (b) its status as the IE dead end for Win2k and below.
</p>
<p>When IE7 came out, any company that still had any Win2k machines had to keep designing with IE6 in mind if they wanted their new apps to work on all their computers. (I'm making the assumption that if they were relying on IE previously, they couldn't just switch to Firefox or something).
</p>
<p>Now, IE8 I think most people can accept is going to end up in IE6's current place. It's the IE dead end for XP, a hugely popular OS. But IE7? None of those companies that don't upgrade upgraded to IE7. Home users that upgrade will also have installed the IE8 upgrade. So you're left with what? Unpatched Vista installations. These are much rarer than unpatched XP installations simply because Vista had a shorter lifespan, and Windows Vista to 7 is sufficiently undramatic an upgrade for the types of people who would take years to go from XP to Vista.
</p>
<p>So so far we have:
</p>
<ul>
 <li>
     IE6 will drag on as long as XP does.
 </li>

 <li>
     IE7 won't last particularly long. While it's popular now,
       earlier Vista computers will be replaced in the close 
       future (2-3 years), causing it to lose market share to IE8.
 </li>

 <li>
     IE8 will have a long lifespan, although probably not as long as IE6.
 </li>
</ul>
<p>IE9? IE9 has never been shipped by default with any version of Windows. That means anyone who installed it did decide to upgrade. These users will likely upgrade away, meaning in the future, IE9 will be even more of a non-issue than IE7.
</p>
<p>IE10 will likely also go the way of IE7. While it will be installed by default on Windows 8, the amount of dramatic changes in W8 will scare off many of the companies that are slow to upgrade.
</p>
<p>So in 5 years time, what versions of IE will realistically you need to support?
</p>
<ul>
 <li>
     IE6 (maybe - probably, hopefully, enterprise only at this stage)
 </li>

 <li>
     IE8
 </li>

 <li>
     IE10 (enterprise will never use it because Win8 is scary and different to them
       so for home users only)
 </li>

 <li>
     IElatest-1 So IE13 or something?
 </li>

 <li>
     IElatest IE14 or something.
 </li>
</ul>
<p>Needing to support IE6 and IE10 will likely be mutually exclusive, so that's 4 versions for sites targeted at home users and 5 for sites aimed at both enterprise and home users. Still ugly, but far from 76. And all those versions will be dead in the timescale that the article is using. Insofar as IE6 will ever die, anyway.
</p>
<p>IE6 for home users will be dead at that point. Most of those old early XP computers will be "broken" and replaced, even if "broken" is just slow and annoying. Using XP in five years will be like using Win98/Win2k. Yes, people do use them. No, they aren't a large enough group for most to worry about. I even have a small amount of hits from Netscape 6. I haven't a clue what my page looked like for them, and don't care.
</p>
<p>In theory, if even IE is aiming for at least yearly releases from now on, no future IE will end up in the position that IE6 is in, and that IE8 will find itself in, as upgrading your browser frequently becomes a fact of life. The compatibility modes will be much less important too, as the shorter lived the browser, the less likely that the compatibility mode for it will ever be used.
</p>

<div class="footnote"><hr/><ol>
 <li id="fn1-133215864"><p>This post was originally posted as a comment on HN. <a href="http://news.ycombinator.com/item?id=3044428">Check the thread</a> for possible replies.<a href="#fnr1-133215864" class="footnoteBackLink" title="Jump back to footnote 1 in the text">&#8617;</a>
</p>

 </li>
</ol>
</div>]]></content:encoded>
    </item>
    <item>
      <title>Not Invented Here and New Programmers</title>
      <link>http://blog.initprogram.com/2011/05/10/not-invented-here-and-new-programmers/</link>
      <pubDate>Sun, 08 May 2011 19:00:00 IST</pubDate>
      <category><![CDATA[Programming]]></category>
      <guid>http://blog.initprogram.com/2011/05/10/not-invented-here-and-new-programmers/</guid>
      <description>Not Invented Here and New Programmers</description>
      <content:encoded><![CDATA[<p>The general consensus is that the one of the best ways to learn how to program
   better, beyond learning the basic syntax is to
   just go ahead and write some programs on your own. Another consensus is
   that the best type of program to write is one that scratches your own
   itch. Yet another consensus is that it is best to avoid the "Not
   Invented Here" syndrome of writing everything from scratch and instead
   reuse as much code as possible.
</p>
<p>However, for someone learning to program today, for the most part, large
   parts of any
   itch that could be scratched has already been done so by someone else.
   Usually, this is someone who has done a much better job of it than any
   newbie code. This means that if they follow the advice regarding NIH,
   they would be reduced to writing glue code for quite some time, tying
   together libraries written by other people while they program relatively
   boring code.
</p>
<p>The problem with this is twofold:
</p>
<ol>
 <li>
     The newbie doesn't really learn much about designing their own
        programs. Sure, they see how the (hopefully) well written libraries
        do it, but they don't get to see the thought process required, or any
        of the refactoring that removes earlier bad design decisions.
 </li>

 <li>
     Glue code is boring. How many people are driven away from programming
        by this experience?
 </li>
</ol>
<p>One of the first big programs I wrote personally was a PHP social network. I did
   many parts of it from scratch - a database abstraction library, a templating system,
   even a primitive MVC system<sup id="fnr1-837129986"><a href="#fn1-837129986">1</a></sup>, and so on. The code that 
   resulted was horrible, and probably riddled with security problems, but I 
   learned a lot from the process.
</p>
<p>How would a newbie do that nowadays? They'd install cakePHP or Django or
   Rails, getting them a DBA layer, templating, MVC all written for them.
   And sure, the resulting program will probably be cleaner and less buggy, as all the
   hard parts are handled by the framework. But the job of the programmer
   gets relegated to writing some models and a few views that are pretty
   much the same everywhere.
</p>
<p>But then a lot of the benefit from trying to write a
   program for themselves just isn't there. They don't get the benefit of
   finding out why some ideas don't work, as they just use the framework.
   Most of what they learn are the APIs of the framework, not any of the
   thought processes involved in creating the program. Not to mention,
   while people writing more complex programs than anything a newbie might
   be delighted to have that problem taken out of their hands, as they
   figure out how to make their database not fall over with 20k users.
</p>
<p>The fun of programming is solving new problems. That's why Rails and co.
   are so popular. After you've written your second or third wep app, then
   these problems quickly become old problems, and having Rails handle them
   for you is really convenient. But for a new programmer, they haven't
   solved these before. Their programs will not be as ambitious (as
   anything that ambitious will most likely be dismissed by them as too
   hard), so having Rails solve these problems will leave them without any
   problems to solve.
</p>
<p>Of course, another benefit is that when they are finished, they can go
   look at the existing solution to see how it compares to their own
   solution. This can help them to compare the thoughts that led to their
   own solution to the (presumably) better result of the existing solution.
   If they managed to find some itch that hadn't been scratched by someone
   else already, they wouldn't be able to find a sample to compare to their
   own work.
</p>
<p>In short, laying off the avoidance of "Not Invented
   Here" can help newbies learn quicker in many cases than 
   being relegated to writing glue code.
</p>

<div class="footnote"><hr/><ol>
 <li id="fn1-837129986"><p>Before I knew what MVC was, so it ended up as more of a VC system.<a href="#fnr1-837129986" class="footnoteBackLink" title="Jump back to footnote 1 in the text">&#8617;</a>
</p>

 </li>
</ol>
</div>]]></content:encoded>
    </item>
    <item>
      <title>The Magic Layer</title>
      <link>http://blog.initprogram.com/2011/01/16/the-magic-layer/</link>
      <pubDate>Sun, 16 Jan 2011 19:00:00 GMT</pubDate>
      <category><![CDATA[Programming]]></category>
      <guid isPermaLink="true">http://blog.initprogram.com/2011/01/16/the-magic-layer/</guid>
      <description>The Magic Layer</description>
      <content:encoded><![CDATA[<blockquote><p>Any sufficiently advanced technology is indistinguishable from magic.
</p>
<p> <em>Arthur. C. Clarke</em>
</p>
</blockquote><p>As a programmer, and a computer nerd, I obviously know more about
   how they work than if you just grabbed a random person off the street.
   As such, it's always interesting to see how people with less knowledge
   about computers use them.<sup id="fnr1-53263853"><a href="#fn1-53263853">1</a></sup> To a lot of people, they click some
   buttons on the screen, and then the computer does something that may as
   well be magic, and finally results appear on screen.
</p>
<p>However, it's not just those unfamiliar with technology that find that
   at some level, the processes going on may as well be magic. Very few
   people understand the entirety of how things work from top to bottom.
   Moving on from the unfamiliar user and the buttons they click, for many
   poorer developers they type (or copy and paste) in some code they don't
   really understand and somehow it all works. Their magic layer is lower
   than that of the user who doesn't understand how the program actually
   works. After all, they understand that programming code needs to be
   written, but they still don't understand any of what goes on beyond
   that. Their magic layer is off in the function calls, in the syntax on
   the language, in the meaning of the code. They may understand small
   sections, but the entire program as a whole is still magic to them.
</p>
<p>Moving on from the poorer developers, novice developers, who instead of
   incompetence only have the problem of knowledge they don't yet have.
   They understand for the most part how their code works. They know how to
   structure their functions, they know when to use objects (and when not
   to), they can create programs from scratch. But they may not quite
   understand what is going on in the library routines, or what happens
   when the compiler creates a program from their code.
</p>
<p>As you go further up in the skill of the developers, the magic level
   recedes. They realise that the library routines are just like functions
   they create themselves for the most part. Some might make system calls,
   but other than that, there isn't much magic there. They understand that
   the compiler reads their code, and produces machine code which is run by
   the CPU. The magic is banished from their code to the inner workings of
   the compiler/interpreter and the operating system. 
</p>
<p>Finally, once the developer learns how those last few retreats of magic
   work, they can understand pretty much the whole picture, as far as
   software goes. However, this still isn't the final end of the story.
   Sure, the magic might be gone from the software side, but there is still
   the hardware. How do those system calls translate to data being written
   to disk? How does the CPU know that <code>MOV eax, ebx</code> moves data between
   registers? And at this point you're in the hardware layer.
</p>
<p>So, where is your magic layer? Personally I'm at the "inner workings of
   the compiler/OS" stage, and to work on pushing it further back, I've
   found some useful online resources. As a self taught programmer, most of
   the resources I've had up until now glossed over these areas, and it's
   my main aim for this year to push the magic layer back into the
   hardware. For compilers, I've found Jack Crenshaw's <a href="http://compilers.iecc.com/crenshaw/">Let's Build a
Compiler</a> useful to start with, and
   I'm currently reading through that, and for operating systems, a bunch
   of useful articles have actual coincidentally popped up on Reddit and HN
   recently on that topic, though I'm still open for suggestons on other
   resources.
</p>
<p>If you found this article interesting, why not follow me on
   <a href="http://twitter.com/MachaSign">Twitter</a>, leave a comment, or suscribe to
   my <a href="/feed">RSS feed</a>.
</p>
<p>Some further discussion of this post can be found at <a href="http://news.ycombinator.com/item?id=2110021">Hacker News</a> and on <a href="http://www.reddit.com/r/programming/comments/f3dxb/wheres_your_magic_layer/">Reddit</a>.
</p>

<div class="footnote"><hr/><ol>
 <li id="fn1-53263853"><p>Except when they frustratingly do everything in the most
   convoluted way possible.<a href="#fnr1-53263853" class="footnoteBackLink" title="Jump back to footnote 1 in the text">&#8617;</a>
</p>

 </li>
</ol>
</div>]]></content:encoded>
    </item>
    <item>
      <title>A quick, basic guide on the IRC protocol</title>
      <link>http://blog.initprogram.com/2010/10/14/a-quick-basic-primer-on-the-irc-protocol/</link>
      <pubDate>Thu, 14 Oct 2010 15:44:00 IST</pubDate>
      <category><![CDATA[Technology]]></category>
      <category><![CDATA[Programming]]></category>
      <guid>http://blog.initprogram.com/2010/10/14/a-quick-basic-primer-on-the-irc-protocol/</guid>
      <description>A quick, basic guide on the IRC protocol</description>
      <content:encoded><![CDATA[<p>While working on my <a href="http://github.com/Macha/Mbot">Haskell IRC bot</a>, I needed some information on the actual IRC protocol. Much of this information sadly isn't available in any centralised format, and much of the information that is there is just a copy/paste of the RFC. There are two formal descriptions of the IRC protocol, an older one (<a href="http://tools.ietf.org/html/rfc1459">RFC 1459</a>) and a newer one (<a href="http://tools.ietf.org/html/rfc2812">RFC 2812</a>), though the actual protocol as used by most servers doesn't adhere exactly to either of these. So, here is a short summary of the information that I have gathered in my research. This is by no means a comprehensive tutorial, but it is sufficient to write a basic IRC bot.
</p>
<p>The first part of the IRC protocol is the rough layout of messages. The first, optional part, is the source (username and hostmask, or server) preceded by a colon, as in <code>:holmes.freenode.net</code> . Because they only deal with one other part of the network, the server, clients will rarely, if ever send this part, while servers nearly always will.
</p>
<p>The next part of the protocol, seperated by a space is the command name, which is in all-caps. Most of these are pretty much the same as what the user types in after the /. For example, the <code>/join</code> command becomes <code>JOIN</code>. The most notable exception is the <code>PRIVMSG</code> command, which is used for sending a message to a user or channel (it's the same command for both).
</p>
<p>After this come the arguments for the command, again, space seperated. Most of these are limited to one word values. The one exception is the final argument, which can have more than one word, and is started off by a colon.
</p>
<p>There are a few types of channel, but nearly all the channels you will encounter are of the <code>#channel</code> variety, so we will not go into detail on other types.
</p>
<p>Finally, the command is terminated by <code>\r\n</code> not <code>\n</code> according to the spec, though it seems most servers will accept either.
</p>
<p>An example of a full message is as such:
</p>
<pre><code>:Macha!~macha@unaffiliated/macha PRIVMSG #botwar :Test response
</code></pre><p>The first part of any IRC connection is sending the <code>NICK</code> and <code>USER</code> messages. The first of these is simple, just <code>NICK name</code>. The next is the <code>USER</code> message.
</p>
<p>An example of a <code>USER</code> message is:
</p>
<pre><code>USER username 0 * :Real name
</code></pre><p>The * part is a remnant of earlier days, and will not need to be changed. The 0 is a bitmask for the user's mode, but with just one switch. Change it to 8 to be invisible to those not in a channel with you.
</p>
<p>The next part of the protocol we will discuss is the <code>PING</code> message, because some servers need one immediately after these two messages. The server will send you a message in the format <code>PING :message</code> to which it needs a response of <code>PONG :message</code>. This is the most common case of a server not sending a source. Most servers use the server name as the message part, but this isn't consistent.
</p>
<p>For all of the rest of these messages,  there is a source on the other messages from the server side. This is a user and hostmask for a user's message, and a server name otherwise. If you are writing a client, do not send the :source part.
</p>
<p>The next message to deal with is <code>JOIN</code>. The basic format of this message from most servers I've tested is
</p>
<pre><code>:source JOIN :#channel
</code></pre><p>although the <a href="http://tools.ietf.org/html/rfc2812#section-3.2.2">spec says otherwise</a> as regards the need for the colon. This is pretty self explanatory, and works the same as the /join used in an IRC client. The one unintuitive part of this command is that <code>JOIN 0</code> leaves all channels.
</p>
<p>Its counterpart is <code>PART</code>. Its format is
</p>
<pre><code>:source PART #channel :reason
</code></pre><p>The reason part is optional, and some servers (for example Freenode) seem to just cut it off, as it did not exist in <a href="http://tools.ietf.org/html/rfc1459#section-4.2.2">earlier versions</a> of the IRC protocol.
</p>
<p>Both of these messages can also accept a list of channels separated by commas when sent from the client, for example <code>PART #channel1,#channel2</code>. Don't put spaces between the channels in this list.
</p>
<p>The most important command in the IRC protocol is <code>PRIVMSG</code>. This command is used for sending messages both to channels and between users. Its format is
</p>
<pre><code>:source PRIVMSG &lt;target&gt; :Message
</code></pre><p>where the target is either a user's nick, or a channel name. So to send a message to a channel, use <code>PRIVMSG #channel :Hello, World</code> and to send a private message to a user, send <code>PRIVMSG Nick :Hi!</code>
</p>
<p>The final message you will use in basic usage is <code>QUIT</code>. Its format is
</p>
<pre><code>:source QUIT :reason
</code></pre><p>where the reason is optional.
</p>
<p>These commands are sufficient to write a basic IRC bot but are by no means the full list. There are also numeric commands, and you can find more detail on these <a href="http://mirc.net/raws/">here</a>.
</p>
<p>If you found this post interesting and want to hear more from me, you should <a href="http://twitter.com/MachaSign">follow me on Twitter</a>.
</p>]]></content:encoded>
    </item>
    <item>
      <title>A Self-Taught Programmer's Journey</title>
      <link>http://blog.initprogram.com/2010/09/27/a-self-taught-programmers-journey/</link>
      <pubDate>Mon, 27 Sep 2010 20:25:18 IST</pubDate>
      <category><![CDATA[Me]]></category>
      <category><![CDATA[Programming]]></category>
      <guid>http://blog.initprogram.com/2010/09/27/a-self-taught-programmers-journey/</guid>
      <description>A Self-Taught Programmer's Journey</description>
      <content:encoded><![CDATA[<p>I was helping someone who is just beginning to program over the past few weeks, and it led me to actually write a blog post I'd been saying I should write for a long time, about how I got where I am today as a programmer. This is mostly from memory, so some of the timing may be wrong.
</p>
<p>My first experience with anything even close to programming was when I was around 12. I had gone through all my mum's ECDL stuff for MS Office years before, and there was one program in Office on my then computer that wasn't even mentioned - Frontpage. So I got bored one day, and decided to check what it was. I gathered quickly enough that is was for making websites, and I sort of got parts of it, but I had to get a book from the library to figure it out fully. Armed with this newfound knowledge, I managed to make a basic website, a horribly primary-coloured frame-filled website, but a website nonetheless.
</p>
<p>Of course, my instinct was to show it to people, so I found out about Angelfire for hosting from an even older book, and uploaded it, then showed it to people online. Needless to say, people didn't like it very much. But a few people did give me some somewhat useful advice, to drop Frontpage. They mentioned something called Dreamweaver as being better, and also suggested learning HTML. Which I did, until eventually I was using Dreamweaver as a glorified text editor.
</p>
<p>Meanwhile, looking for the next thing to do, I decided to learn actual programming, in the form of Java. In retrospect, not the best choice of language for starting out, but it was one of the few that my local library had books for. The other alternative if I was to stick to library books was Visual Basic 6.0, so it was definitely the better of the two options. I went through the whole book of Java All-In-One for dummies, went through it, did all the examples, got to the end, and wrote a little Java clock applet for my website. I was so happy with myself, that I decided to go even further, and my next plan of a project was to make a Simcity clone in Java. Unsurprisingly, that didn't work out too well, and the failure put 13 year old me off programming for a while.
</p>
<p><img class="   " title="Finally learning it's not that easy" src="http://blog.initprogram.com/blog/wp-content/uploads/2010/09/l_259_194_71000F94-07FF-4E75-A0D4-2F7458A0F93E.jpeg" alt="" width="259" height="194" /><br />
By this stage, I had long cured any illusions of coding being anything like the Matrix
</p>
<p>The next time I came into contact with programming was when I was running a forum with a few friends. It ran off phpBB, and when installing mods, I noticed that all I was doing was editing programming code, which was kind of familiar. I looked into it a bit more, found out about PHP, and then quickly learned that. It was significantly easier to learn, both because it was my second language to learn, and also because languages with weak dynamic types are easier to learn in my opinion.
</p>
<p>Of course, the problem with learning PHP, especially if you use the phpBB 2 code base as your example is you pick up bad habits. Now there's nothing inherently wrong with the language nowadays, but this was the PHP 4 days, with it's half-assed attempts at OOP. On top of that, something that is still a problem today is the amount of bad material floating around. Now, this is a problem with <a href="http://www.codinghorror.com/blog/2009/05/the-bathroom-wall-of-code.html">any language</a>, but given PHP's large userbase, and popularity with hobbyist coders, it's far more pronounced in PHP than others I have used. So code found on the internet is ripe with a lack of care towards seperating output and processing, full of SQL injection holes, and often even relying on register_globals.<noscript>_</noscript> But this isn't anything new. But it does lead me to recommend to everyone trying to get a good book. I started with <a href="http://www.everythingphpmysql.com/">this one</a>, and while it did help me learn PHP, it set me back a long distance in terms of proper coding practices. Eventually, I got <a href="http://apress.com/book/view/9781590598627">this book</a> to learn how to code <strong>properly</strong> in PHP.
</p>
<p>Around that time I started reading programming blogs, and found out about source control, in the form of <a href="http://www.codinghorror.com/blog/2008/04/setting-up-subversion-on-windows.html">Subversion</a>, a rather important topic that no programming book seems to mention. Seriously, apart from Code Complete, which mentions it in glancingly a few times, the only book on my shelf that explains source control at all is the Linux Bible, 2009 edition. And that's talking about CVS. Now for all Subversion's faults, any source control is better than no source control. Later I was introduced to git and DVCS in general by some friends, and it's now my preferred form of source control (git for all Linux projects, hg if I have to work with Windows users). It didn't exist at the time, but for anyone looking for a good DVCS tutorial now, I reccomend Joel Spolsky's <a href="http://hginit.com">hginit</a>. Even if you plan on using git or another program afterwards, it's the best basic explanation of the concepts of DVCS I've seen.
</p>
<p><a href="http://blog.initprogram.com/blog/wp-content/uploads/2010/09/linux-bible.jpg"><img class="size-full wp-image-270" title="linux-bible" src="http://blog.initprogram.com/blog/wp-content/uploads/2010/09/linux-bible.jpg" alt="Linux Bible 2009" width="300" height="376" /></a><br />
This was the only book to mention version control.
   Going back to my own journey, after that time in PHP, and several ill-fated projects, countless attempts at building a forum, a incomplete social network, and a completed, if basic, social network that I failed to get anyone to join, I moved on to Javascript. I spent ages messing about in that, making small scripts to move things around, before getting more ambitious. Yet again, I returned to the idea of a simcity clone. Given that this was before canvas became well supported or known about, the core of the program used a 200x200 table for the game's grid. It was every bit as slow as that sounds.
</p>
<p>After a while of this, I returned to trying to make GUI desktop apps. I know, I know, many considering this a step backwards from web apps, but at the time, I couldn't think of many examples of web apps that had progressed of the "Oh, that's mildly interesting" stage. I had used Swing before, in my failed Simcity game, but wasn't particularly impressed by it. I gave SWT a go, before giving up again. I guess my problem with GUI apps resolves from my desire to control every last detail, compared to the designer-tool-centric design of most of the GUI toolkits. Somewhat bored with GUI apps again, but also bored of the general dislike of my main language, PHP, I went on a quick tour of several languages, including C#, C++, Ruby, Python, Ruby again, before finally deciding on Python as my new favourite.
</p>
<p>Around this time, I switched to Linux as my primary OS. I'd tinkered with Linux for a while before this, but had always been too used to Windows to actually make the switch until then. Since then, Windows has been mostly relegated to use for gaming and iTunes.
</p>
<p>I spent a while coding in Python, before going on a short hiatus from programming for a while, being somewhat bored as all the languages I learned being roughly the same at this stage, and no new ideas for a project to keep me interested. Projects are another thing I recommend to anyone starting to teach yourself programming, as even the failed ones or ones you get bored of are a good learning experience, especially if you have others looking over the code.
</p>
<p>After a while, I decided to learn a less mainstream programming language, and after a quick straw poll on Twitter, Haskell emerged the winner. Luckily for me, Haskell has a good beginner's tutorial, <a href="http://learnyouahaskell.com">Learn You a Haskell</a>. I've heard it described as like Why's Poignant Guide, but it's not really. It's much more to the point which works for me (I'm sorry to say I found Why's Guide a rather boring read, having too much unneeded meandering with stories. But I accept it's good for others). It is a rather basic tutorial, but there is also <a href="http://realworldhaskell.org">Real World Haskell</a> for when you need to go further, even if it isn't as well done.
</p>
<p>And now, my current project is to write an <a href="http://github.com/Macha/Mbot">IRC bot in Haskell</a> to learn Haskell better. I'm still learning and improving, and it's going to be a handy headstart for college that I have all this done already, so the story goes on. If you want to hear more about me, you can always read more of this blog, or <a href="http://twitter.com/MachaSign">follow me on Twitter</a>.
</p>]]></content:encoded>
    </item>
    <item>
      <title>Programming Books</title>
      <link>http://blog.initprogram.com/2010/08/21/programming-books/</link>
      <pubDate>Sat, 21 Aug 2010 14:41:48 IST</pubDate>
      <category><![CDATA[Programming]]></category>
      <guid>http://blog.initprogram.com/2010/08/21/programming-books/</guid>
      <description>Programming Books</description>
      <content:encoded><![CDATA[<p>It used to be the case that when I wanted to learn more about programming, I would go down to the book store, buy a book about the language I was using and read it through. However, the problem with these books is that after a while, you only really want the last 5 or so chapters, detailing the bits of the standard library you are going to use. The language docs are usually a pretty good explanation of the syntax. You definitely don't need a full chapter devoted to if statements and loops, for the fiftieth time.
</p>
<p>What you need on if statements after the first language is just a small paragraph like:
</p>
<blockquote>Python if statements are done like so:

if condition:
        doStuff()
    elif other_condition:
        doOtherStuff()
    else:
        doOtherOtherStuff()

</blockquote>

<p>Seven lines, not a whole chapter. Oh look, <a href="http://docs.python.org/tutorial/controlflow.html">the language docs</a> do that. Never mind then. Those chapters are now totally redundant. Spending €40+ for the last 5 chapters really doesn't make sense.
</p>
<p>The other problem is one of quality. Several books promise to teach you everything about something, yet obviously fall far short of it. An extreme case can be seen in the two books I bought around 2-3 years ago, when I was first learning PHP.
</p>
<p><a href="http://blog.initprogram.com/blog/wp-content/uploads/2010/08/books-small.jpg"><img class="size-full wp-image-246 " title="PHP Books" src="http://blog.initprogram.com/blog/wp-content/uploads/2010/08/books-small.jpg" alt="1300 page long &quot;Beginning PHP and MySQL&quot;, 200 page long &quot;How to do everything with PHP &amp; MySQL&quot;" width="576" height="353" /></a><br />
Which title do you think is more accurate?
</p>
<p>Even apart from the amount of extra information in the Apress book, the quality of that information is far better. The smaller book doesn't even mention how to create a class. And it would have you believe that the only way to interact with a database is through the old mysql library, using functions like mysql_fetch_assoc(). Oh, and to really rub it in, it does actually mention MySQLi, but basically as a slightly faster version of the MySQL functions that needs to you put an i in your function calls, and nothing else. The example code in it always mixes code and markup, and then you wonder why PHP has such a bad reputation, when there are so many books like this floating around.
</p>
<p>The problem is, many people will look at these books, and see the Apress book looking much more formal, and presume that's it's full of unnecessary detail. I did at first (hey, I was just starting out), which is why I initially bought the second book, then had to go back and buy the other one when I finished the first one, and realised I could of learned the same amount of stuff from 2 hours and an internet connection.
</p>
<p>Of course, eventually, every programmer moves on from these books to more general ones about coding in general, rather than specific technologies and languages. The problem is, many book stores don't bother selling anything more advanced. And the only computer shop where I live, PC World, has an even more pathetic collection. So you have to wait ages for something to turn up. Or have someone recommend a book, and then buy it online. You can't browse through books, flicking through a chapter of each to see which looks better, on eBay or Amazon unfortunately, which rather limits the options for just looking around for something good.
</p>
<p><img title="Code Complete" src="http://ecx.images-amazon.com/images/I/51PPS4C6i8L.jpg" alt="" width="410" height="500" /><br />
Moving on to better books, like this one.
</p>
<p>The first proper programming book I got was Code Complete, second edition, which I bought roughly a year ago. I'd heard a few people recommend it before, but hadn't went to buy it. I was amazed when one day, among all the copies of <em>Excel for Dummies</em> and <em>iPhone for Seniors, </em>there was a copy of Code Complete in the book store. I presume someone had ordered it in, and the store had just got a few of them, because it's sadly not the kind of book they usually get. I suppose they rather books that don't require the customer to have some knowledge already. (Which is odd, because surely they'd be able to sell two books with an offer like "Buy this book to learn how to program, and this book to learn how to program better.")
</p>
<p>Unfortunately, even when you know what book you want, the book stores don't do themselves any favours. Around this February, I had €30 in book vouchers for the local bookstore left from Christmas, and decided to buy <em>Design Patterns</em> with them. I had the PDF version, but I still read best from dead trees, so I had a look. Unsurprisingly, they didn't have it there, as most of their books are of the <em>Language x</em> for dummies/<em>Buzzword y</em> in 24 hours variety. Oh, and they have Code Complete again as well, but I already have that. So, as I had expected, they would need to order it in. I had checked beforehand, and the book was €30 delivered from Amazon. I expected it might be maybe €40 in the bookshop, cheaper once you factored in the vouchers I already had. It wasn't €40. It was <strong>€82</strong>. I don't know what planet they are on in the bookstore, but needless to say it's led to Amazon being €30 richer.
</p>
<p>A welcome development is the trend towards free online books. Examples such as <a href="http://diveintopython.org">Dive Into Python</a>, <a href="http://ruby-doc.org/docs/ProgrammingRuby/">Programming Ruby</a>, <a href="http://diveintohtml5.org">Dive into HTML5</a> and <a href="http://book.realworldhaskell.org/read/">Real World Haskell</a> do help with their respective languages. And the fact that they tend to be more concise than the usual books on the shelf (I know they come on dead trees too, but nowhere near me sells any of them) also makes them more useful, even despite my preference for reading from a physical book.
</p>]]></content:encoded>
    </item>
    <item>
      <title>VPS</title>
      <link>http://blog.initprogram.com/2010/03/09/vps/</link>
      <pubDate>Tue, 09 Mar 2010 17:36:39 GMT</pubDate>
      <category><![CDATA[Me]]></category>
      <category><![CDATA[Programming]]></category>
      <guid>http://blog.initprogram.com/2010/03/09/vps/</guid>
      <description>VPS</description>
      <content:encoded><![CDATA[<p>During the last week, I finally did something I've been meaning to do for the last while, and bought myself a VPS as up until now, I've been on shared hosting. On the advice of <a href="&lt;a href=">compwhizii</a>, I went with <a href="http://linode.com">Linode</a>. While there was nothing wrong with my previous web host, <a href="http://webhostingbuzz.com">Web Hosting Buzz</a>, they were a full $5 a month dearer for their entry level VPS packages, and unlike Linode, did not give you a choice of a UK data centre. My site, and most of it's visitors are in Europe, so that was quite helpful.
</p>
<p>So, after purchasing the VPS, I set it up with the basics: DNS, Apache, MySQL, PHP (my blog runs on Wordpress which uses PHP, which is why it got in ahead of Python). Very simple, just use the package manager and Control Panel to set it up. There was a slight mishap where my DNS changes were propagated before I fixed them, leaving my blog not set up yet. But that was soon resolved.
</p>
<p>After about a day, I noticed Apache was getting random segfaults serving static pages. Rather than spending ages to debug the problem, I decided to try out nginx, which I had heard good things about. It was quite simple to set up, with <a href="http://library.linode.com/web-servers/nginx/">Linode providing a guide </a>with most of the steps. All well and good. Until, about two days later, nginx started reporting a 502 bad gateway error. A problem with a new web server? Nope. The fault lies with php-cgi, and it was compwhizii's blog to the rescue again. His <a href="http://compwhizii.net/index.php/2010/nginx-php-cgi-and-url-shorteners/">post about using nginx</a> provided a link to <a href="http://blog.taragana.com/index.php/archive/how-to-stop-crashing-hanging-of-php-cgi-spawn-fcgi-with-nginx-lighttpd/">this page</a> explaining how to solve it. The short version? Set the  PHP_FCGI_MAX_REQUESTS environment variable, so the php-cgi process gets restarted every so often.
</p>
<p>The VPS is, unsurprisingly much better than the shared hosting. SSH is much better for administration than the old Control Panels. The first project I'm doing to really make use of that, is something I have planned using Django. More on that later, if it comes to anything.
</p>]]></content:encoded>
    </item>
    <item>
      <title>Vim</title>
      <link>http://blog.initprogram.com/2010/02/28/vim/</link>
      <pubDate>Sun, 28 Feb 2010 18:18:45 GMT</pubDate>
      <category><![CDATA[Programming]]></category>
      <guid>http://blog.initprogram.com/2010/02/28/vim/</guid>
      <description>Vim</description>
      <content:encoded><![CDATA[<p>On the advice of <a href="http://blog.sirupsen.dk">Sirupsen</a>, I have been trying out vim during the last few weeks. Up until now, my editor of choice has been gedit on Linux, or Notepad++ on Windows for most stuff. I have also used VS on Windows, which while good for C#, it doesn't really help writing multi-platform programs. And I've used Eclipse a bit, back when I used Java for a while. But, most of my programming is done in languages such as Python, PHP and Javascript, and for the small size of my projects, IDEs tend to get in the way, and they also aren't quite as good for dynamically typed languages anyway.
</p>
<p>So first of all, to quote one of my <a href="http://twitter.com/MachaSign/status/8689386342">tweets</a>:
</p>
<blockquote>After using it a while, I apologise to vim users. It isn't weird and crap, it's just weird.</blockquote>

<p>I haven't exactly been the most positive of vim. After all, as a Linux user, it's nigh impossible to use many of them without one of them using vim or a vim-like interface for something. And while nano manages to be relatively easy to understand, vim does not. Because vim is weird.
</p>
<p>But after a while of using it, I realise it's weird for a reason. Want to get rid of a line? In other text editors it's:
</p>
<ul>
	<li>Left arrow to start of line</li>
	<li>Hold shift</li>
	<li>Hold right arrow to end of line</li>
	<li>Press delete</li>
</ul>

<p>In vim it's:
</p>
<ul>
	<li>Type dd</li>
</ul>

<p>Don't like that 13 line function anymore, and want to delete it?
</p>
<p>In normal editors it's:
</p>
<ul>
	<li>Up and left arrows to start of function</li>
	<li>Hold shift</li>
	<li>Down and right arrows to end of function</li>
</ul>

<p>Vim is:
</p>
<ul>
	<li>Type 13dd</li>
</ul>

<p>Weird, obtuse, but once you learn it, it's far more efficient. A final example. Suppose you want to rename that variable from $car to $vehicle:
</p>
<p>A normal text editor?
</p>
<ul>
	<li>Edit</li>
	<li>Search and Replace (somethings this is part of search anyway and under Ctrl-F, other times it's its own menu, under Ctrl-H)</li>
	<li>Type in $car.</li>
	<li> Type in $vehicle</li>
</ul>

<p>Vim?
</p>
<ul>
	<li>Type :%s/$car/$vehicle/</li>
</ul>

<p>At this stage, I'm still not getting the most out of vim. After all, I only know a few basic commands (and even then I'm missing a few. Any vim users care to tell me how to Select All?). Yet I'm already finding it easier and faster than I did in other editors. vim is also cross platform, unlike the Windows-only Notepad++ and Linux-only gedit, which means I can use the one editor across all OSes. For that matter, it's even available on my jailbroken iPod touch.
</p>
<p>Another useful feature of it is it's huge styling and plugin community. Again, Sirupsen pointed me to BusyBee. I didn't quite like that, so I found <a href="http://hcalves.deviantart.com/art/Mustang-Vim-Colorscheme-98974484">Mustang</a>, the theme it was based on. I haven't yet found plugins that I'd reccomend, but the choice is huge. One of the inbuilt ones, allows you to set different options per language. I'm doing a project in Ruby atm, and in any other editor I'd have to change my settings to and from my personal preference of tabs and Ruby style of double spaces. With vim, I can set it to do tabs with all other files, and just do the silly double space thing with Ruby.
</p>]]></content:encoded>
    </item>
    <item>
      <title>First projects</title>
      <link>http://blog.initprogram.com/2010/02/05/first-projects/</link>
      <pubDate>Fri, 05 Feb 2010 09:40:37 GMT</pubDate>
      <category><![CDATA[Programming]]></category>
      <guid>http://blog.initprogram.com/2010/02/05/first-projects/</guid>
      <description>First projects</description>
      <content:encoded><![CDATA[<p>One of my online friends has started learning programming in C++ and Python a few months ago. While he seems fairly competent in it, he was complaining that he feels he hasn't acheived anything worthwhile in it. He said he just can't think of anything useful to make.
</p>
<p>This reminded me of when I was starting out (and again when I was starting out with Javascript, and again with PHP, and again with... you get the picture). Like him, I also struggled to think of something to make. My first trivial program was a Java clock applet when I was 13. I saw one on another site and decided to make one for my own. My first non-trivial program was a social network, written in PHP when I was 15. Two years to think of an decent idea that I could keep working on until completion.
</p>
<p>I think the problem with beginners projects by self-learners is one of overreaching. I've certainly done it a lot. If they try to write a social network, they want to write Facebook. If they write a forum, they want to write vBulletin. If they write a game, they want to write Fallout 3. All of these were written over a significant amount of time by large groups of people.
</p>
<p>My advice is this: Start small. Reduce whatever you plan to build to it's basics. A social network can be reduced to users who can add friends, edit profiles and leave comments on other's profiles. A forum can be reduced to users creating threads and posts. A game can be something like Pacman. Implement these basics. When you have them done, you will have enough motivation to get the <a href="http://www.codinghorror.com/blog/archives/001284.html">rest of the stuff</a> done (login, logout, etc.). While you can't assume designing a successful product is as simple, as the linked blog post shows, designing a beginners project to practice your coding is easier than designing a product to base a business around.
</p>
<p>Despite not being quite that simple, many successful products are based on simplicity. Compare Twitter to Facebook, punbb to vbulletin, Google Chrome to Firefox. Simple and fully-featured are two equally valid design strategies (although I tend to favour simple products myself), but simple ones are much easier to get going.
</p>
<p>Once you have your basic program written, you can then add features to it. You could add image uploads to your social network, bbcode to your forum or extra enemies to your game. Further again, you can add groups to your social network, tagging to your forum, and new level types to the game. Since you already have a working base to start from, it's much easier to look at it feature by feature, instead of waiting ages until you have <strong>anything</strong> that works.
</p>]]></content:encoded>
    </item>
    <item>
      <title>Seeing your old code</title>
      <link>http://blog.initprogram.com/2010/01/17/seeing-your-old-code/</link>
      <pubDate>Sun, 17 Jan 2010 19:03:34 GMT</pubDate>
      <category><![CDATA[Programming]]></category>
      <guid>http://blog.initprogram.com/2010/01/17/seeing-your-old-code/</guid>
      <description>Seeing your old code</description>
      <content:encoded><![CDATA[<p>Lately I have been working on one of my oldest pieces of code again. This code is that of a website I created for my school about 2 years ago, when I had just started programming.
</p>
<p>Given that (a) it's written by a beginner (me two years ago) and (b) it's PHP, you wouldn't be surprised to hear that the code is bloody awful. Even for a basic CRD app (I hadn't programmed the U bit), it sucks.
</p>
<p>Hardcoded numbers and categories everywhere, no sign of code organisation, redundant code, copy/paste as a design pattern and inconsistent naming. It's a wonder that information going into the database was even escaped. And let's not talk about character encodings.
</p>
<p>Needless to say, now that I've picked up the code again, it's had a swift rewrite. It's still pretty crap, but at least it doesn't screw up completely if you type a euro sign.
</p>
<p>Has anyone else ever seen some of their first code and gone: "I can't believe I wrote this crap"?
</p>]]></content:encoded>
    </item>
  </channel>
</rss>

