<?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>Strings &#38; Ints</title>
	<atom:link href="http://stringsandints.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://stringsandints.com</link>
	<description>Ben's blog &#62;&#62; This is where I insult the world.</description>
	<lastBuildDate>Thu, 10 Jun 2010 19:42:04 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Building a Lego gearbox &#8211; and then breaking it</title>
		<link>http://stringsandints.com/?p=46</link>
		<comments>http://stringsandints.com/?p=46#comments</comments>
		<pubDate>Thu, 10 Jun 2010 19:42:04 +0000</pubDate>
		<dc:creator>elbekko</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://stringsandints.com/?p=46</guid>
		<description><![CDATA[So, today we decided to build the AeroShift gearbox. It&#8217;s pretty nicely done, and we quickly had it whipped up (first in LDD for the building guide, although it&#8217;s so simple that really wasn&#8217;t necessary). After a bit of almost-careful initial testing, we made up a gearshift lever (that thing is sturdier than the rest [...]]]></description>
			<content:encoded><![CDATA[<p>So, today we decided to build the <a href="http://sariel.pl/2009/11/aeroshift-gearbox/">AeroShift gearbox</a>. It&#8217;s pretty nicely done, and we quickly had it whipped up (first in LDD for the building guide, although it&#8217;s so simple that really wasn&#8217;t necessary). After a bit of almost-careful initial testing, we made up a gearshift lever (that thing is sturdier than the rest of the gearbox I bet), and then it looked like this:<br />
<span id="more-46"></span><br />
First gear:<br />
<img src="http://sphotos.ak.fbcdn.net/hphotos-ak-ash1/hs319.ash1/28099_401699664662_792049662_3973483_8214738_n.jpg" alt="First gear" /><br />
Overview:<br />
<img src="http://sphotos.ak.fbcdn.net/hphotos-ak-ash1/hs319.ash1/28099_401699694662_792049662_3973484_3146644_n.jpg" alt="Overview" /><br />
Second gear:<br />
<img src="http://sphotos.ak.fbcdn.net/hphotos-ak-snc3/hs289.snc3/28099_401699709662_792049662_3973485_2225552_n.jpg" alt="Second gear" /><br />
Neutral:<br />
<img src="http://sphotos.ak.fbcdn.net/hphotos-ak-ash1/hs319.ash1/28099_401699719662_792049662_3973486_6044548_n.jpg" alt="Neutral" /></p>
<p>And then I had one of my bright moments. The NXT&#8217;s batteries were dead, and I didn&#8217;t feel like waiting ages for the batteries to charge. So I did what any sane person (read: redneck) would&#8217;ve done, and got out the power drill. First gear worked beatifully, but second gear had a tendency to&#8230; destroy things. As can be seen in the following carnage pics:</p>
<p>The first broken gear:<br />
<img src="http://sphotos.ak.fbcdn.net/hphotos-ak-snc3/hs289.snc3/28099_401697114662_792049662_3973395_7528648_n.jpg" alt="Broken gear" /><br />
The first and second broken gear:<br />
<img src="http://sphotos.ak.fbcdn.net/hphotos-ak-ash1/hs319.ash1/28099_401697139662_792049662_3973396_7697465_n.jpg" alt="Both broken gears" /><br />
A gear cutting into the supporting beam o.O:<br />
<img src="http://sphotos.ak.fbcdn.net/hphotos-ak-ash1/hs319.ash1/28099_401697174662_792049662_3973397_3542764_n.jpg" alt="Supporting beam" /></p>
<p>So after wasting two gears on that, we decided to call it a day and try with the NXT motors hooked up. No more breakage (what a surprise eh?)!</p>
<p>Oh, and I think I found my next project on the same site:<br />
<a href="http://sariel.pl/2010/04/tatra-t815/">Tatra 6&#215;6</a></p>
]]></content:encoded>
			<wfw:commentRss>http://stringsandints.com/?feed=rss2&amp;p=46</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Greasemonkey script for reddit users.</title>
		<link>http://stringsandints.com/?p=43</link>
		<comments>http://stringsandints.com/?p=43#comments</comments>
		<pubDate>Thu, 24 Dec 2009 00:29:57 +0000</pubDate>
		<dc:creator>elbekko</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://stringsandints.com/?p=43</guid>
		<description><![CDATA[I wrote this little script to convert imgur links into their fast version, because the imgur site often loads very slowly for me (don&#8217;t ask me why, I have no clue).
So, behold:

// ==UserScript==
// @name           Reddit Pics
// @namespace      http://www.reddit.com/r/
// @description  [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote this little script to convert imgur links into their fast version, because the imgur site often loads very slowly for me (don&#8217;t ask me why, I have no clue).</p>
<p>So, behold:</p>
<pre class="code">
// ==UserScript==
// @name           Reddit Pics
// @namespace      http://www.reddit.com/r/
// @description    Makes imgur links into the proper link
// @include        http://www.reddit.com/r/
// ==/UserScript==

var entries = document.getElementsByTagName("a");

for(var i = 0; i != entries.length; i++)
{
	var link = entries[i];

	// Is link to imgur
	if(/*link.className.indexOf("title loggedin ") != -1 &#038;&#038; */link.href.indexOf("imgur.com") != -1)
	{
		if(link.href.split(".").length < 3)
		{
			link.title = "Original at: " + link.href;
			link.href += ".png";
			link.href = wtf_replace(link.href, "imgur.com", "i.imgur.com");
		}
		else if(link.href.indexOf("i.imgur.com") == -1)
		{
			link.title = "Original at: " + link.href;
			link.href = wtf_replace(link.href, "imgur.com", "i.imgur.com");
		}
	}
}

function wtf_replace(str, text, rwith)
{
	return str.substr(0, str.indexOf(text)) + rwith + str.substr(str.indexOf(text) + text.length);
}
</pre>
<p>Don't mind the custom replace function, it was to debug the regex, but I figure this could well be faster and I can't be arsed removing it.</p>
<p>Just set it to work on all of Reddit, and every link to imgur will be turned into the fast version.</p>
]]></content:encoded>
			<wfw:commentRss>http://stringsandints.com/?feed=rss2&amp;p=43</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RobotMC Team Building Day</title>
		<link>http://stringsandints.com/?p=40</link>
		<comments>http://stringsandints.com/?p=40#comments</comments>
		<pubDate>Thu, 24 Sep 2009 08:26:32 +0000</pubDate>
		<dc:creator>elbekko</dc:creator>
				<category><![CDATA[Robots]]></category>

		<guid isPermaLink="false">http://stringsandints.com/?p=40</guid>
		<description><![CDATA[On the 19th of September 2009, RobotMC organised its second Team Building Day.
In the months before the contest, a few hints are given out, like telling you which sensors you&#8217;ll be needing lots of. On the day itself though, you have around 6-7 hours of time to build and program your robot. And in my [...]]]></description>
			<content:encoded><![CDATA[<p>On the 19th of September 2009, RobotMC organised its second <a title="Warning: Dutch" href="http://wiki.robotmc.org/index.php?title=Team_Building_Day">Team Building Day</a>.</p>
<p>In the months before the contest, a few hints are given out, like telling you which sensors you&#8217;ll be needing lots of. On the day itself though, you have around 6-7 hours of time to build and program your robot. And in my case an hour or so of that was wasted on reading a tutorial, as it had been a rather long time since I last worked with NXC.</p>
<p><span id="more-40"></span></p>
<p>Of course the base of your robot doesn&#8217;t have to be built that day, such a rule would just kill off all the non-Lego competitors.</p>
<p>I&#8217;d like to believe our team, At Random, didn&#8217;t do that badly with a second place, mainly because of a glitch that we still haven&#8217;t confirmed (but it is believed to be the afterglow of one of the lamps that gave too high a reading on the light sensor).</p>
<p>And in the name of team spirit and open-source software, have some code.<br />
All of this code is written in NXC using the BricxCC IDE.</p>
<h3>The first assignment &#8211; Go towards a random light source</h3>
<p>The goal of this assignment was to break a beam of light (as done by our legendary pirate flag, it was <a href="http://www.talklikeapirate.com/">talk like a pirate day</a> anyway), and then either go left or right towards a light source. Which direction to go in was randomly selected.</p>
<pre class="code">
/* Motor defs */
#define LMOTOR OUT_B
#define RMOTOR OUT_C
#define MOTORS OUT_BC

/* Motor control defs */
#define Fwd(motor, speed) OnFwdReg(motor, speed, OUT_REGMODE_SYNC)
#define Rev(motor, speed) OnRevReg(motor, speed, OUT_REGMODE_SYNC)
#define TFwd(motor, speed) OnFwd(motor, speed)
#define TRev(motor, speed) OnRev(motor, speed)

/* Sensor defs */
#define LIGHTLEFT IN_2
#define LIGHTRIGHT IN_3

/* Other defs */
#define STOPAT_1 40
#define STOPAT_2 25
#define LIGHTSOURCE 95

#define rotationspeed 60
#define rot90deg 420

int rotcount = 0;
bool side = false; // false = left, true = right

void turnLeft()
{
    RotateMotor(RMOTOR, rotationspeed, rot90deg);
}

void turnRight()
{
    RotateMotor(LMOTOR, rotationspeed, rot90deg);
}

task main()
{
     /* Sensor init */
     SetSensorLowspeed(IN_4);
     SetSensorLight(LIGHTLEFT);
     SetSensorLight(LIGHTRIGHT);

     /* Move to middle */
     Fwd(MOTORS, 65);
     until(SensorUS(IN_4) &lt;= STOPAT_1);
     Off(MOTORS);

     /* Scan light source */
     if(Sensor(LIGHTLEFT) &gt;= LIGHTSOURCE)
     {
         /* Turn left */
         turnLeft();
         Off(MOTORS);

         side = false;
     }
     else if(Sensor(LIGHTRIGHT) &gt;= LIGHTSOURCE)
     {
         /* Turn right */
         turnRight();
         Off(MOTORS);

         side = true;
     }

     ResetAllTachoCounts(MOTORS);
     ResetRotationCount(MOTORS);

     Fwd(MOTORS, 75);
     until(SensorUS(IN_4) &lt;= STOPAT_2);
     Off(MOTORS);

     // Left
     if(side == true)
     {
         turnRight();
         turnRight();
         Off(MOTORS);
     }
     else
     {
         turnLeft();
         turnLeft();
         Off(MOTORS);
     }

     Fwd(MOTORS, 75);
     until(SensorUS(IN_4) &lt;= 180);
     Off(MOTORS);

     if(side == true)
     {
         /* Turn left */
         turnLeft();
         Off(MOTORS);
     }
     else
     {
         /* Turn right */
         turnRight();
         Off(MOTORS);
     }

     Fwd(MOTORS, 75);
     until(SensorUS(IN_4) &lt;= STOPAT_2);
     Off(MOTORS);
}
</pre>
<h3>The second assignment &#8211; line following</h3>
<p>This is actually the assignment we kept as last, as it seemed to be the hardest one&#8230; boy were we wrong. We did it in about half an hour, and had to add an extra sensor to the robot for the sharp turns, and it worked. I proclaim another victory against the laws of physics and logic.<br />
The most special bit about this code is the multithreading, which worked great, even without mutexes, probably because it&#8217;s only written once and read many times.<br />
We had to up the light threshold in this bit, because the rear sensor didn&#8217;t have the special cardboard magic to stop other light from affecting it, but in the end it didn&#8217;t seem to make that much of a difference.</p>
<pre class="code">
/* Motor defs */
#define LMOTOR OUT_B
#define RMOTOR OUT_C
#define MOTORS OUT_BC

/* Motor control defs */
#define Fwd(motor, speed) OnFwdReg(motor, speed, OUT_REGMODE_SYNC)
#define Rev(motor, speed) OnRevReg(motor, speed, OUT_REGMODE_SYNC)
#define TFwd(motor, speed) OnFwd(motor, speed)
#define TRev(motor, speed) OnRev(motor, speed)

/* Sensor defs */
#define LIGHTLEFT IN_2
#define LIGHTRIGHT IN_3
#define LIGHTBACK IN_1

/* Other defs */
#define SPEED 35
#define TURNSPEED 20

#define LINE_lower 25
#define LINE_upper 50

int leftSpeed = 0;
int rightSpeed = 0;

task leftWheel()
{
    while(true)
    {
        TFwd(LMOTOR, leftSpeed);
    }
}

task rightWheel()
{
    while(true)
    {
        TFwd(RMOTOR, rightSpeed);
    }
}

task checkSensors()
{
    while(true)
    {
        if(Sensor(LIGHTLEFT) &gt; LINE_upper &amp;&amp; Sensor(LIGHTRIGHT) &gt; LINE_upper)
        {
            leftSpeed = SPEED;
            rightSpeed = SPEED;
        }
        else if(Sensor(LIGHTLEFT) &lt;= LINE_upper &amp;&amp; Sensor(LIGHTRIGHT) &gt; LINE_upper)
        {
            leftSpeed -= TURNSPEED;
            rightSpeed = SPEED;

            if(Sensor(LIGHTBACK) &lt;= LINE_upper)
            {
                leftSpeed = -100;
                PlayTone(500, 250);
            }

            if(leftSpeed &lt; 0)
                leftSpeed = 0;
        }
        else if(Sensor(LIGHTLEFT) &gt; LINE_upper &amp;&amp; Sensor(LIGHTRIGHT) &lt;= LINE_upper)
        {
            leftSpeed = SPEED;
            rightSpeed -= TURNSPEED;

            if(Sensor(LIGHTBACK) &lt;= LINE_upper)
            {
                rightSpeed = -100;
                PlayTone(500, 250);
            }

            if(rightSpeed &lt; 0)
                rightSpeed = 0;
        }
    }
}

task main()
{
    SetSensorLight(LIGHTLEFT);
    SetSensorLight(LIGHTRIGHT);
    SetSensorLight(LIGHTBACK);

    Precedes(checkSensors, leftWheel, rightWheel);
}
</pre>
<h3>The third assignment &#8211; line detection</h3>
<p>This was the simplest <b>and</b> hardest of all. A contradiction you say? Pah!<br />
The premise was dead easy: drive in a straight line and back again, crossing 3 black lines, but not a fourth. At the detection of each black line, but not the gray lines, you had to beep. When going back, you had to detect both lines (to see when to stop), but only beep on the gray lines. This proved tricky for many teams as white + black = gray, and of course there&#8217;s this very tiny bit of a black line that the sensor sees as being gray. We solved this by waiting a bit before the final sensor poll that&#8217;d have to tell us which colour the line was, to make sure the robot wasn&#8217;t in that pesky gray area.</p>
<pre class="code">
/* Motor defs */
#define LMOTOR OUT_B
#define RMOTOR OUT_C
#define MOTORS OUT_BC

/* Motor control defs */
#define Fwd(motor, speed) OnFwdReg(motor, speed, OUT_REGMODE_SYNC)
#define Rev(motor, speed) OnRevReg(motor, speed, OUT_REGMODE_SYNC)
#define TFwd(motor, speed) OnFwd(motor, speed)
#define TRev(motor, speed) OnRev(motor, speed)

/* Sensor defs */
#define LIGHTLEFT IN_2
#define LIGHTRIGHT IN_3

/* Other defs */
#define SPEED 65
#define WAITTIME 200

/* Line defs */
#define DARKLINE_lower 25
#define DARKLINE_upper 35

#define GRAYLINE_lower 39
#define GRAYLINE_upper 43

int blackcount = 0;
int graycount = 0;
int sensorvalue = 100;

task main()
{
    /* Sensor init */
    SetSensorLowspeed(IN_4);
    SetSensorLight(LIGHTLEFT);
    SetSensorLight(LIGHTRIGHT);

    /* Run 1 */
    while(blackcount &lt; 3)
    {
        Fwd(MOTORS, SPEED);
        until(Sensor(LIGHTLEFT) &lt;= DARKLINE_upper);

        if(blackcount &lt; 2)
            Wait(WAITTIME);
        Off(MOTORS);

        PlayTone(500, 250);
        blackcount++;
    }

    Rev(MOTORS, SPEED);
    Wait(WAITTIME);

    /* Run 2 */
    blackcount = 0;
    while(blackcount &lt; 3)
    {
        Rev(MOTORS, SPEED);
        until(Sensor(LIGHTLEFT) &lt;= GRAYLINE_upper);

        Wait(20);
        sensorvalue = Sensor(LIGHTLEFT);

        NumOut(1, 1, sensorvalue, 0);

        if(blackcount &lt; 2)
            Wait(WAITTIME);
        Off(MOTORS);

        if(sensorvalue &gt;= DARKLINE_lower &amp;&amp; sensorvalue &lt;= DARKLINE_upper)
        {
            blackcount++;
            Wait(WAITTIME);
        }
        else if(sensorvalue &gt;= GRAYLINE_lower &amp;&amp; sensorvalue &lt;= GRAYLINE_upper)
        {
            PlayTone(800, 250);
            graycount++;
        }
    }

    Rev(MOTORS, SPEED);
    Wait(500);
    Off(MOTORS);
}
</pre>
<p>I hope the code is of use to you, and it&#8217;s as much fun for you figuring out what it does as it was for me figuring out how to make it do it.</p>
<p>Keep an eye on <a href="http://groups.google.com/group/hcc_robotmc/browse_thread/thread/184318939d15d6ee#">this thread</a>, it&#8217;ll have more videos of the action cam on our robot, and probably pictures too.</p>
]]></content:encoded>
			<wfw:commentRss>http://stringsandints.com/?feed=rss2&amp;p=40</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CTFBot 1: The Beginnings</title>
		<link>http://stringsandints.com/?p=33</link>
		<comments>http://stringsandints.com/?p=33#comments</comments>
		<pubDate>Sun, 19 Apr 2009 18:34:23 +0000</pubDate>
		<dc:creator>elbekko</dc:creator>
				<category><![CDATA[Robots]]></category>

		<guid isPermaLink="false">http://stringsandints.com/?p=33</guid>
		<description><![CDATA[At my robot club&#8217;s meeting on the 18th, I threw around the idea of making a capture the flag game using the Lego NXT.
There was at least one person who liked the idea, Xander, and we agreed to make some plans (and robots ofcourse) for it. So yesterday I got cracking in Lego Digital Designer, [...]]]></description>
			<content:encoded><![CDATA[<p>At my <a href="http://wiki.robotmc.org/" title="Warning, Dutch">robot club</a>&#8217;s meeting on the 18th, I threw around the idea of making a <a href="http://en.wikipedia.org/wiki/Capture_the_flag">capture the flag</a> game using the Lego NXT.</p>
<p>There was at least one person who liked the idea, <a href="http://mightor.wordpress.com/">Xander</a>, and we agreed to make some plans (and robots ofcourse) for it. So yesterday I got cracking in Lego Digital Designer, and poked something together. And today I got out the Lego and started building. Thanks to LDD&#8217;s building guide, it was done rather quickly, although I spent 90% of my time reordering my Lego in order to find the components I need. It&#8217;s very small, and hopefully quite agile.<br />
<span id="more-33"></span><br />
Front view:<br />
<div id="attachment_34" class="wp-caption alignnone" style="width: 310px"><img src="http://stringsandints.com/wp-content/uploads/2009/04/picture-18-300x225.jpg" alt="Front view of CTFBot 1" title="picture-18" width="300" height="225" class="size-medium wp-image-34" /><p class="wp-caption-text">Front view of CTFBot 1</p></div><br />
Other front view:<br />
<div id="attachment_35" class="wp-caption alignnone" style="width: 310px"><img src="http://stringsandints.com/wp-content/uploads/2009/04/picture-19-300x225.jpg" alt="Other front view" title="picture-19" width="300" height="225" class="size-medium wp-image-35" /><p class="wp-caption-text">Other front view</p></div></p>
<p>As you may have noticed, the part for picking up the flag isn&#8217;t quite done. That&#8217;s mostly because I&#8217;m not sure yet how that&#8217;ll be achieved. I was thinking of attaching a magnet to it, and hopefully holding on the the flag that way (and just drive against the wall or so to shake off the flag).</p>
<p>Well, this was the easy part. What I need to do now is write the code to find the *right* flag, bring it to the *right* base, and then stop.<br />
For the first incarnation anyway, because the goal is to eventually be able to steal the flag from an opponent, bring it back to your base, etc.</p>
<p>More information on the CTF game will follow soon (I hope).</p>
]]></content:encoded>
			<wfw:commentRss>http://stringsandints.com/?feed=rss2&amp;p=33</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Ogame style corrections</title>
		<link>http://stringsandints.com/?p=27</link>
		<comments>http://stringsandints.com/?p=27#comments</comments>
		<pubDate>Thu, 12 Mar 2009 17:54:18 +0000</pubDate>
		<dc:creator>elbekko</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://stringsandints.com/?p=27</guid>
		<description><![CDATA[Not too long ago I was asked to join in playing Ogame with a few classmates. But the first pageload was already a huge facepalm, a style so horrendous it nearly made me cry. Nearly. What it did make me do, is whip out Stylish and Firebug, and get cracking.

After a bit of refining, I [...]]]></description>
			<content:encoded><![CDATA[<p>Not too long ago I was asked to join in playing <a href="http://ogame.nl">Ogame</a> with a few classmates. But the first pageload was already a huge facepalm, a style so horrendous it nearly made me cry. Nearly. What it did make me do, is whip out Stylish and Firebug, and get cracking.<br />
<span id="more-27"></span><br />
After a bit of refining, I went from:<br />
<img src="http://stringsandints.com/wp-content/images/ogame_before_small.png" alt="Before" /><br />
To:<br />
<img src="http://stringsandints.com/wp-content/images/ogame_after_small.png" alt="After" /></p>
<p>And all of this with just a little bit of CSS:</p>
<pre class="code">@namespace url(http://www.w3.org/1999/xhtml);

@-moz-document domain("uni16.ogame.nl") {
body { height: 100% !important; width: 100% !important; margin: 0 !important; overflow: auto !important; }
#header_top, #content { width: auto !important; }
#content center { text-align: -moz-left !important; }

#content, #header_top { height: auto !important; left: 0 !important; position: relative !important; margin-left: 125px; margin-right: 5px !important; }
#content { top: 0 !important; margin-right: 30px; }
#header_top { overflow: auto !important; }

#content center table { width: 100% !important; }

center #combox_container { display: none !important; }

#content center td.b { background-color: #445576 !important; }

td.l { background-image: none !important; }
td.l:last-child { background-color: #3F5277 !important; }

td.k input { font-size: 1.3em !important; }

form#ressourcen td.k { font-weight: bold; }

td.header font { font-style: normal !important; }
#header_top * { text-align: -moz-center !important; }

#menu { width: 115px !important; margin-left: 5px; }
#menu nobr { display: none; }

/* */
#ResourcesDiv { position: relative !important; }

#errorbox { top: 12px !important; position: absolute !important; background-color: #BB0000; width: 80px !important; left: 170px !important; }
}</pre>
<p>This should work on all Ogame sites using the &#8216;old&#8217; layout. When the new layout comes, I&#8217;ll quit for sure, as it&#8217;s obviously been made by a madman on LSD.</p>
]]></content:encoded>
			<wfw:commentRss>http://stringsandints.com/?feed=rss2&amp;p=27</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A love/hate relationship</title>
		<link>http://stringsandints.com/?p=15</link>
		<comments>http://stringsandints.com/?p=15#comments</comments>
		<pubDate>Mon, 02 Mar 2009 18:59:21 +0000</pubDate>
		<dc:creator>elbekko</dc:creator>
				<category><![CDATA[Rants]]></category>

		<guid isPermaLink="false">http://stringsandints.com/?p=15</guid>
		<description><![CDATA[This could apply to many things, but today it shall apply to&#8230; PHP.
I know, I know, I&#8217;m not the first one to rant about this, and I most certainly won&#8217;t be the last.
PHP is pretty much the only language I know deeply, and I&#8217;ve been working with it for ages. About 6-7 years I think, [...]]]></description>
			<content:encoded><![CDATA[<p>This could apply to many things, but today it shall apply to&#8230; <strong>PHP</strong>.</p>
<p>I know, I know, I&#8217;m not the first one to rant about this, and I most certainly won&#8217;t be the last.</p>
<p>PHP is pretty much the only language I know deeply, and I&#8217;ve been working with it for ages. About 6-7 years I think, I&#8217;m never sure. It&#8217;s an excellent tool for building websites, but it has a dark side. And this side is very dark indeed; it&#8217;s called simplicity. PHP is so simple every idiot with a keyboard can slap his hand onto it and find a functional piece of code.<span id="more-15"></span></p>
<p>And here is where I like to make a rather important distinction between <em>functional</em> and <em>working</em>. A functional page does the job, but doesn&#8217;t necessarily do it properly. A working page on the other hand does the job, does it properly, and tries to do it as efficiently as possible.</p>
<p>You can probably guess where I&#8217;m going with this: in PHP, the difference between a functional and a working page is humongous. The smallest child can hack something together and call it his homepage, but not a lot of people actually know the intricacies and best practices that can make PHP a rather nice and powerful language.</p>
<p>This is why PHP needs developers with experience and a will to do the right thing, to optimise away and to see the errors in their ways. There are saddeningly little of these people. In fact, off the top of my head, the ones like this I can count on one hand. The rest more often than not say &#8220;but it works!&#8221;. But it doesn&#8217;t.</p>
<p>Of course, the same can be said for many other languages, including CSS: easy to cock about in, but hard to master.</p>
<p>You shouldn&#8217;t think that this is the only problem though; there are many others. And the problem just keeps on growing and growing. There have been a great many bad design decisions in PHP; register_globals, safe_mode, magic_quotes_gpc, short tags, just to name a few.</p>
<p>And now they&#8217;re doing more! Sure, they&#8217;re removing the previous design cockups, but they&#8217;re adding new ones. New ones that could be worse than ever, and with a reasoning even someone on LSD wouldn&#8217;t even be able to follow. If you&#8217;re been following the evolution of PHP lately, you&#8217;ll probably know what I&#8217;m going at: the new <a title="PHP.net RFC" href="http://wiki.php.net/rfc/namespaceseparator">namespace separator</a>. This is in my eyes one of the biggest atrocities they could&#8217;ve done to a decent language.</p>
<p>I mean, seriously, a backslash? That&#8217;s about on par with a smiley face (note: also suggested in that article). I see it going horribly wrong on so many levels it wants to make me cry (a namespace called &#8216;n&#8217; called inside a double quote string anyone?).</p>
<p>Ever since they&#8217;ve been talking about namespaces in PHP, I&#8217;ve had my mind set on a decent way to do it: namespace inclusion. Sure, it wouldn&#8217;t be as pretty as in some other languages, but atleast it wouldn&#8217;t break backwards compatibility. I&#8217;ll set out my original idea to you.</p>
<p>Basically, it&#8217;d use the commonly ignored comment character #. Right now, <em>#</em> is a character used for single-line comments, just like <em>//</em>. I&#8217;ve perhaps come across <strong>one</strong> script that uses it, and I&#8217;ve seen my share of scripts. So no harm done if it gets a different meaning I&#8217;d say.</p>
<p>A meaning used in the form of:</p>
<pre class="code">
&lt;php
#using mynamespace

myFunction(); // It's really mynamespace::myFunction();
?&gt;
</pre>
<p>And you could take that even further, using the <em>#using</em> directive as a way to signal to the interpreter &#8220;this namespace will be called upon, reserve it&#8221;.</p>
<p>So then it could be used in the way of:</p>
<pre class="code">
&lt;php
#using mynamespace

mynamespace::myFunction();
anothernamespace::aFunction(); // Would throw an error

class mynamespace { } // Would also throw an error
?&gt;
</pre>
<p>This way the interpreter could reserve the name of that namespace and throw an error if any class tries to declare itself as that namespace.</p>
<p>I know, perhaps not the prettiest of ways, but it&#8217;s work, and we&#8217;d be able to keep the :: operator.</p>
<p>Or, you know, they could just make a namespace a <em>static class</em> and allow the nesting of classes. Problem (somewhat) solved!</p>
]]></content:encoded>
			<wfw:commentRss>http://stringsandints.com/?feed=rss2&amp;p=15</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>On functional programming</title>
		<link>http://stringsandints.com/?p=13</link>
		<comments>http://stringsandints.com/?p=13#comments</comments>
		<pubDate>Fri, 27 Feb 2009 23:11:14 +0000</pubDate>
		<dc:creator>elbekko</dc:creator>
				<category><![CDATA[Contemplations]]></category>

		<guid isPermaLink="false">http://stringsandints.com/?p=13</guid>
		<description><![CDATA[I&#8217;ve been thinking a bit about the subject of functional programming lately, especially since it seems to be quite popular nowadays.
So naturally I look up guides and wiki pages and whatnot about the subject, research a language (I took Haskell because everyone says it&#8217;s awesome), etc. But every time I do so I just scratch [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been thinking a bit about the subject of functional programming lately, especially since it seems to be quite popular nowadays.</p>
<p>So naturally I look up guides and wiki pages and whatnot about the subject, research a language (I took Haskell because everyone says it&#8217;s awesome), etc. But every time I do so I just scratch my head and have a rather blank stare&#8230; It seems completely alien to me, and there&#8217;s hardly any aspect of it that I understand or even find remotely logical.<span id="more-13"></span></p>
<p>Some people have been trying to convince me it&#8217;s just because I&#8217;m unwilling to learn it properly. I disagree with that. And here start my contemplations on the subject.</p>
<p>I have problems with maths, I even have a proven learning disability called <a href="http://en.wikipedia.org/wiki/Dyscalculia">dyscalculia</a>, which causes me to be very bad at calculating things and remembering formulas amongst others. And I believe this is why I have difficulty grasping most of functional programming: everything seems to have its roots in maths, and to truly understand it you have to understand its roots. Which I can&#8217;t. Which is a problem.</p>
<p>Now, &#8216;regular&#8217; programming, AKA imperative programming, I have absolutely no problems with. And I like to believe this is because my brain seems to be geared rather towards logic, on which all imperative languages are built. Describing what to do to a computer by telling it how to do so seems much more logical to me than the functional programming approach, which just tells the computer what to do, with seemingly little control of the how.</p>
<p>To prove my point further: I recently found my true love to be with Assembly, because I find it to be so awesomely logical. I finally know how everything is done at the lowest level I can comprehend (no, I don&#8217;t have a built in hex translator), and it helps me write better imperative code in other languages. Functional programming just doesn&#8217;t give me the idea that I&#8217;m programming and making the best and most performant piece of code I can, as I don&#8217;t control what the compiler thinks I mean with a certain command.</p>
<p>So, to sum it up:<br />
<code>1 xor 0 = &lt;3</code><br />
<code>1 !^=&lt; 0 = the hell?</code><br />
<small>Note: this may or may not be an actual Haskell operator, but I wouldn&#8217;t be surprised if it was.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://stringsandints.com/?feed=rss2&amp;p=13</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A first contemplation</title>
		<link>http://stringsandints.com/?p=10</link>
		<comments>http://stringsandints.com/?p=10#comments</comments>
		<pubDate>Thu, 26 Feb 2009 22:30:32 +0000</pubDate>
		<dc:creator>elbekko</dc:creator>
				<category><![CDATA[Contemplations]]></category>

		<guid isPermaLink="false">http://localhost/stringsandints/?p=10</guid>
		<description><![CDATA[Is contemplation really a good title for this category?
I suppose only time will tell&#8230;
]]></description>
			<content:encoded><![CDATA[<p>Is contemplation really a good title for this category?</p>
<p>I suppose only time will tell&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://stringsandints.com/?feed=rss2&amp;p=10</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>First post!</title>
		<link>http://stringsandints.com/?p=5</link>
		<comments>http://stringsandints.com/?p=5#comments</comments>
		<pubDate>Thu, 26 Feb 2009 21:50:19 +0000</pubDate>
		<dc:creator>elbekko</dc:creator>
				<category><![CDATA[Rants]]></category>

		<guid isPermaLink="false">http://localhost/stringsandints/?p=5</guid>
		<description><![CDATA[This is starting to look good, actually.
Well done Wordpress, you&#8217;ve certainly improved!
]]></description>
			<content:encoded><![CDATA[<p>This is starting to look good, actually.</p>
<p>Well done Wordpress, you&#8217;ve certainly improved!</p>
]]></content:encoded>
			<wfw:commentRss>http://stringsandints.com/?feed=rss2&amp;p=5</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
