<?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>Endlessly Curious &#187; Programming</title>
	<atom:link href="http://www.endlesslycurious.com/tag/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.endlesslycurious.com</link>
	<description>Programming, Productivity &#38; Software Development.</description>
	<lastBuildDate>Mon, 09 Jan 2012 09:00:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The Evils of Global State and Singletons</title>
		<link>http://www.endlesslycurious.com/2010/06/03/the-evils-of-global-state-and-singletons/</link>
		<comments>http://www.endlesslycurious.com/2010/06/03/the-evils-of-global-state-and-singletons/#comments</comments>
		<pubDate>Thu, 03 Jun 2010 16:53:04 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://www.endlesslycurious.com/?p=1377</guid>
		<description><![CDATA[In this Google Clean Code talk, Miško Hevery presents the evils of global state, how this relates to Singletons, testing and what to do about it. Questions starting at 31:20 are pretty interesting.]]></description>
			<content:encoded><![CDATA[<p>In this Google Clean Code talk, Miško Hevery presents the evils of global state, how this relates to Singletons, testing and what to do about it.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="src" value="http://www.youtube.com/v/-FRm3VPhseI&amp;color1=0xb1b1b1&amp;color2=0xcfcfcf&amp;hl=en_US&amp;feature=player_embedded&amp;fs=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/-FRm3VPhseI&amp;color1=0xb1b1b1&amp;color2=0xcfcfcf&amp;hl=en_US&amp;feature=player_embedded&amp;fs=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>Questions starting at 31:20 are pretty interesting.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.endlesslycurious.com/2010/06/03/the-evils-of-global-state-and-singletons/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using SQLite in Python</title>
		<link>http://www.endlesslycurious.com/2009/06/24/using-sqlite-in-python/</link>
		<comments>http://www.endlesslycurious.com/2009/06/24/using-sqlite-in-python/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 09:00:14 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.endlesslycurious.com/?p=1318</guid>
		<description><![CDATA[Python has had support for SQLite built-in since version 2.5. This is a very convenient pairing as SQLite is an excellent lightweight SQL implementation that I find very useful for a variety of tasks e.g. data mining.  Or any task involving manipulating complex data sets where I&#8217;d otherwise end up resorting to using a full [...]]]></description>
			<content:encoded><![CDATA[<p><a title="Python.org" href="http://python.org/">Python</a> has had <a title="PyDocs" href="http://docs.python.org/library/sqlite3.html">support</a> for <a title="SQLite.org" href="http://sqlite.org/">SQLite</a> built-in since version 2.5.</p>
<p>This is a very convenient pairing as SQLite is an excellent lightweight SQL implementation that I find very useful for a variety of tasks e.g. data mining.  Or any task involving manipulating complex data sets where I&#8217;d otherwise end up resorting to using a full blown SQL server like <a href="http://www.mysql.com/">MySQL</a>.</p>
<p>Here is a simple example of using SQLite in Python using it&#8217;s built-in sqlite3 module:</p>
<pre class="brush: python; title: ; notranslate">
import sqlite3

# craete a connection
con = sqlite3.connect('test.db')

# create a cursor
cur = con.cursor()

# create a test table
cur.execute( &quot;CREATE TABLE testTable (myKey INT, myValue INT)&quot; )

# insert some data
for i in range(0,10):
 cur.execute( &quot;INSERT INTO testTable VALUES ( %d, %d )&quot;%(i,i*i) )

# select the data
for row in cur.execute( &quot;SELECT * FROM testTable&quot; ):
 print row

# destroy (drop) our test table
cur.execute( &quot;DROP TABLE testTable&quot; )

# close the connection
con.close()
</pre>
<p>As you can see Python makes handling SQLite (a C language library) much easier, less error prone, and the resulting code much more compact than SQLite&#8217;s native C.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.endlesslycurious.com/2009/06/24/using-sqlite-in-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fail to succeed!</title>
		<link>http://www.endlesslycurious.com/2009/04/01/fail-to-succeed/</link>
		<comments>http://www.endlesslycurious.com/2009/04/01/fail-to-succeed/#comments</comments>
		<pubDate>Wed, 01 Apr 2009 09:00:41 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Productivity]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.endlesslycurious.com/?p=1229</guid>
		<description><![CDATA[The more experienced I become the more aware I become of what I don&#8217;t know and the more I come to terms with the fact that I make mistakes. The awareness of what I don&#8217;t know helps keep me humble, humility makes working as part of a team easier:  as there is no pressure to [...]]]></description>
			<content:encoded><![CDATA[<p>The more experienced I become the more aware I become of what I don&#8217;t know and the more I come to terms with the fact that I make mistakes.</p>
<p>The awareness of what I don&#8217;t know helps keep me humble, humility makes working as part of a team easier:  as there is no pressure to have to know everything or not make mistakes.  In fact I tend to expect to make mistakes more now than when I first started programming.  Perhaps it is the years I have spent shipping games that finally proved to me that I too write software that contains bugs (the horror!).</p>
<p>I remember a professor at university telling me that the main difference between a professor and a first year student working on a programming task is that the student will start working immediately and also start making mistakes immediately, the professor will think for a while then start work and start making mistakes as well.  I have found this observation to have a surprising amount of truth in it,:whether it is at university, work or even sports.</p>
<p>Mistakes are healthy: without mistakes we would have not reason to every really think about what we are doing e.g. why didn&#8217;t that work?  By continually pushing (or stretching) ourselves to failure we discover our boundaries, once we know where are our boundaries are we can then start to work on pushing them further.  However if we always play it safe and never push ourselves (which can be scary) we will never discover our boundaries which makes improvement much harder and also makes approaching those boundaries harder due to fear (typically of loss of control).</p>
<p>An excellent example of this is people learning to ice skate: young children will tend to fling themselves around the rink with wild abandon falling all over the place (as failure is expected but irrelevant due to lack of social stigma), yet adult beginners typically skate in a much more conservative fashion taking less risks (as there is social stigma against falling as an adult: falling is seen as failure).  Interestingly when observing ice hockey players, it is noticeable that those with the best skating technique are typically falling more than the other the non-beginner players on the ice, as they do not fear falling.</p>
<p>As most of us are not engaged in high risk activities on a daily basis we can easily begin to revise how we think about failure and to learn to embrace it as a powerful tool for self improvement.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.endlesslycurious.com/2009/04/01/fail-to-succeed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>No bad programming languages</title>
		<link>http://www.endlesslycurious.com/2009/03/03/no-bad-programming-languages/</link>
		<comments>http://www.endlesslycurious.com/2009/03/03/no-bad-programming-languages/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 09:00:57 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Programming Languages]]></category>

		<guid isPermaLink="false">http://www.endlesslycurious.com/?p=1143</guid>
		<description><![CDATA[I encountered some truly hideous source code today in a programming language in which I wouldn&#8217;t have thought hideous obscure code was possible:  C#.  It was my first real experience of abject horror when looking at the source code of a C# application. Obviously with hindsight it would seem that you can write hugely, dense, [...]]]></description>
			<content:encoded><![CDATA[<p>I encountered some truly hideous source code today in a programming language in which I wouldn&#8217;t have thought hideous obscure code was possible:  C#.  It was my first real experience of abject horror when looking at the source code of a <a title="Wikipedia" href="http://en.wikipedia.org/wiki/C_Sharp_(programming_language)">C#</a> application. Obviously with hindsight it would seem that you can write hugely, dense, brittle and hard to understand programs in any programming language.  And yet I would not expect a C# source code to be this obtuse or brittle but I would expect a <a title="Wikipedia" href="http://en.wikipedia.org/wiki/Perl">Perl</a> script to be dense and hard to read.</p>
<p>It is not that I have anything against Perl as a programming language: it is a fine language.  I find that Perl&#8217;s motto of `There&#8217;s more than one way to do it.&#8217; means that it is a programming language with (you guessed it) more than one way to implement most operations.  This flexibility is a double edged sword: it allows a lot of creativity in program implementation, yet it also means that a dozen Perl coders will produce a dozen radically different scripts for the same problem.  This makes Perl quite hard on beginners or infrequent maintainers of Perl scripts: as to understand any given Perl script requires an understanding of much more of the Perl programming language than it would for most comparable programming languages.</p>
<p>I digress.</p>
<p>I&#8217;ve known for years that it is possible to write awful obscure code in low level languages like C and C++ but it really hadn&#8217;t occurred to me that a high level language like C# could be abused to the same degree.  Thinking about this some more, it is not the fault of the programming language itself but of the programmer that is using it.</p>
<p>So, brittle obtuse code is the result of a bad programmer not a bad programming language: well except maybe <a title="Wikipedia" href="http://en.wikipedia.org/wiki/Brainfuck">Brain Fuck</a> (but thats kinda the point).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.endlesslycurious.com/2009/03/03/no-bad-programming-languages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>You Aren&#8217;t Gonna Need It!</title>
		<link>http://www.endlesslycurious.com/2009/02/16/you-arent-gonna-need-it/</link>
		<comments>http://www.endlesslycurious.com/2009/02/16/you-arent-gonna-need-it/#comments</comments>
		<pubDate>Mon, 16 Feb 2009 09:00:28 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Design]]></category>

		<guid isPermaLink="false">http://www.endlesslycurious.com/?p=1104</guid>
		<description><![CDATA[A very common trap to fall into while implementing a new system or feature is to add functionality to &#8216;future proof&#8217; your code for a use case that you imagine in may be required in the future.  The future for the purposes of this post is any time that is not in your current development [...]]]></description>
			<content:encoded><![CDATA[<p>A very common trap to fall into while implementing a new system or feature is to add functionality to &#8216;future proof&#8217; your code for a use case that you imagine in may be required in the future.  The future for the purposes of this post is any time that is not in your current development iteration.</p>
<p>This may seem harmless but consider that the future use cases you are imagining are not something you fully understand yet: as most of us will admit we are pretty bad at anticipating the future.  So how can we hope to implement future functionality successfully?  The most likely outcome is that whatever you implement now not be sufficient when you actually try to use it in the future.  This will mean more time will have to be invested in the future to <a title="Wikipedia" href="http://en.wikipedia.org/wiki/Code_refactoring">refactor</a> or replace the functionality with what is actually required.</p>
<p>Unless you also plan to implement a full set of tests for this new functionality then you are adding extra code to your program that will not be correct and will not stay correct.  This can also lead to really weird run time behavior if the flow of program execution goes into your new &#8216;future proof&#8217; functionality unexpectedly: which can be <em>very</em> hard to debug.  Adding functionality for future use without corresponding tests also means that as the rest of your program evolves the future functionality does not evolve with it, this means by the time you actually try to use it that it is most likely hopelessly out of sync with the rest of the code base.</p>
<p>The future functionality is also expanding the size of the source code of your program which leads to unnecessary <a title="Wikipedia" href="http://en.wikipedia.org/wiki/Code_bloat">code bloat</a>.  In some compiled languages (e.g. C++) code bloat will lead to increased memory usage and decreased program performance which is highly undesirable.</p>
<p>Another thing to consider from a business stand point is that you are spending time and money implementing future functionality when you are not being paid for it.  This is a strong indication to me that implementing future functionality makes little business sense.  As it means spending money now paying developers to implement functionality that you can&#8217;t sell right now.</p>
<p>There is a handy acronym for this: it is <a title="Wikipedia" href="http://en.wikipedia.org/wiki/You_Ain%27t_Gonna_Need_It">YAGNI</a> which stands for &#8216;You Aren&#8217;t Gonna Need It&#8217;.  The essence of this concept is to only implement the functionality you need right <em>now</em> and to implement in as simple and robust a fashion as possible.  As simple robust code (preferable with acompaning unit tests) is code that can be easily refactored in the future to meet future needs and that is cost effcient!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.endlesslycurious.com/2009/02/16/you-arent-gonna-need-it/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fail fast, fail cheap!</title>
		<link>http://www.endlesslycurious.com/2008/11/27/fail-fast-fail-cheap/</link>
		<comments>http://www.endlesslycurious.com/2008/11/27/fail-fast-fail-cheap/#comments</comments>
		<pubDate>Thu, 27 Nov 2008 09:00:18 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[productivity]]></category>

		<guid isPermaLink="false">http://www.endlesslycurious.com/?p=852</guid>
		<description><![CDATA[I was explaining this to some junior programmers the other day and it&#8217;s worth repeating.  Failure is fine in software engineering, in fact it is expected: I get nervous if something works first time these days as I know my limits and expect to make mistakes.  However I think that new programmers don&#8217;t always realise [...]]]></description>
			<content:encoded><![CDATA[<p>I was explaining this to some junior programmers the other day and it&#8217;s worth repeating.  Failure is fine in software engineering, in fact it is <em>expected</em>: I get nervous if something works first time these days as I know my limits and expect to make mistakes.  However I think that new programmers don&#8217;t always realise that failure is acceptable and in some cases failure is <em>preferred</em>, this is especially true during research and development tasks.  Consider the following diagram representing three programmers A, B and C working on a task over a period of time, each arrow represents one attempt at a solution.</p>
<p><img class="aligncenter size-full wp-image-853" title="Fail Fast" src="http://www.endlesslycurious.com/wp-content/uploads/2008/11/failfast.jpg" alt="" width="480" height="176" /></p>
<p>Assume the task that has been set is complex and contains some degree of uncertainty which means that the first few attempts will probably fail.  Which programmer would you want working on the task?  If the task is actually impossible then programmer A will be the cheapest from a business standpoint as they fail earliest followed by programmer B and finally programmer C.  Also, programmer A will have five attempts at a solution compared to programmer B&#8217;s two and a half attempts and programmer C&#8217;s single attempt.  As iteration leads to improved quality (<a href="http://www.codinghorror.com/blog/archives/000788.html">Boyd&#8217;s Law</a>) this means that programmer A is also likely to hit on a more superior solution than programmer B or programmer C in the same time period.</p>
<p>The interesting thing here is that in my experience new programmers tend to work like programmer C: they will attempt a single solution working diligently to overcome any hurdles they encounter, no matter how severe the hurdle.  This sounds harmless but remember that few things are impossible in programming, so the more a programmer hammers away at a problem the more likely they are to fudge a solution and that solution (in my experience) is not often of a high quality.  The counter point to this is that more productive programmers will rapidly discard attempts early in each attempt when it becomes clear that the solution though possible is not actually <em>desirable</em> e.g. the dog is hungry and solutions include: A) feed the dog B) kill the dog.</p>
<p>This can also be observed by monitoring how long a programmer will remain stuck for before asking for assistance.  The most productive programmers will get help within minutes of becoming completly stuck.  However the least productive (and often least experienced) programmers will often struggle with the problem for days before actually asking for assistance and this delay is expensive in terms of money, deadlines and product quality.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.endlesslycurious.com/2008/11/27/fail-fast-fail-cheap/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Preemptive optimisation: do not do it!</title>
		<link>http://www.endlesslycurious.com/2008/11/26/preemptive-optimisation-do-not-do-it/</link>
		<comments>http://www.endlesslycurious.com/2008/11/26/preemptive-optimisation-do-not-do-it/#comments</comments>
		<pubDate>Wed, 26 Nov 2008 09:00:47 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Optimisation]]></category>

		<guid isPermaLink="false">http://www.endlesslycurious.com/?p=837</guid>
		<description><![CDATA[Yesterday I wrote about optimisation work flow and in this post I will be discussing why you should not preemptively optimise your program&#8217;s source code.  You may wonder what could possibly be wrong with preemptively optimising the source code, it just makes your program faster right?  And that is the trap: while it does make [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I wrote about optimisation work flow and in this post I will be discussing why you should not preemptively optimise your program&#8217;s source code.  You may wonder what could possibly be wrong with preemptively optimising the source code, it just makes your program faster right?  And that is the trap: while it does make your program faster, if you do not measure the programs performance relative to your performance goals you are effectively taking a shot in the dark with very little real likelihood of hitting your (performance) mark and a real likelihood of unintended consequences in terms of the quality, understandability, complexity and bug count in your program&#8217;s source code.</p>
<p>For example, it faster on the CPU you are targeting to compare an integer to zero than to compare an integer to another integer.  Therefore you have decided to write all your loops so they count down to zero instead of the normal approach of counting up from zero.  This will save you a few cycles per iteration of your loop, but have you considered:</p>
<ul>
<li>Counting down and not up in a loop is not conventional in most programming languages and may result in you making math errors which can result in hard to track down bugs in your loop control logic or code inside your loop.</li>
<li>Pointer arithmetic in languages like C/C++ is hard enough when counting up (e.g, pObj++) but counting down is even harder to understand as it is so incredibly rarely done and requires extra pointer math to set up.</li>
<li>The programmer that comes after you to develop or maintain the source code may not realise you are counting down and not up in your loop and then implement functionality that relies on your loop counting up which would again cause bugs and confusion.</li>
<li>That despite your loop being invoked for thousands or millions of iterations, your loop&#8217;s control logic is no where near as expensive in terms of CPU operations as function call X that comes right in the middle of your loop which costs <em>millions</em> of cycles by itself every iteration!</li>
<li>That it is almost unheard of for loop control logic to be an issue performance wise even when it is in tightest inner loops.</li>
<li>That most optimising compilers are perfectly able to make this optimisation for you during compilation on your target platform with none of the above programmer confusion?</li>
</ul>
<p>My advice here is never optimise without measuring first: as at best you will save a few CPU cycles where it really does not matter at the cost of making your source more complex and harder to understand and at worse you will add subtle bugs to your program and make the source code more complex and harder to understand or maintain!  I have lost count now of how many times I&#8217;ve tracked subtle bugs in programs down to programmers making preemptive optimisations without first measuring to see if any optimisation is required and if the extra level of complexity introduced by the optimisation is a desirable trade off.</p>
<p>Occasionally there will be an exception to this rule but in general if you are going to optimise something should always measure first and then optimise only if it is nessessary.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.endlesslycurious.com/2008/11/26/preemptive-optimisation-do-not-do-it/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Optimisation Workflow</title>
		<link>http://www.endlesslycurious.com/2008/11/25/optimisation-workflow/</link>
		<comments>http://www.endlesslycurious.com/2008/11/25/optimisation-workflow/#comments</comments>
		<pubDate>Tue, 25 Nov 2008 09:00:25 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Optimisation]]></category>
		<category><![CDATA[Visualisation]]></category>

		<guid isPermaLink="false">http://www.endlesslycurious.com/?p=828</guid>
		<description><![CDATA[I believe the key to optimising any program is measurement: not writing l33t code which seems to be what a lot of programmers think optimisation is!  The optimisation process is all about finding the slow parts of your program and speeding those slow parts up by refactoring your source code to meet your target performance [...]]]></description>
			<content:encoded><![CDATA[<p>I believe the key to <a href="http://en.wikipedia.org/wiki/Optimization_(computer_science)">optimising</a> any program is measurement: not writing <a href="http://en.wikipedia.org/wiki/Leet"><em>l33t</em></a> code which seems to be what a lot of programmers think optimisation is!  The optimisation process is all about finding the slow parts of your program and speeding those slow parts up by <a href="http://www.refactoring.com/sources.html">refactoring</a> your source code to meet your target performance goals.  Without measuring the code or having target performance goals optimisation is a waste of time: as programmers are very bad at guessing where the slow parts of the program are and very good at optimising pieces of the program that do not need it.</p>
<p><img class="aligncenter size-full wp-image-829" title="Optimisation Workflow" src="http://www.endlesslycurious.com/wp-content/uploads/2008/11/optimisationflow.jpg" alt="" width="480" height="367" /></p>
<p>This diagram emphasises the importance of measurement in the optimisation process: you cannot begin the process, evaluate your optimisations, even discard your optimistations or honestly finish the process without first measuring the program performance versus your target performance.  As I have mentioned <a href="http://www.endlesslycurious.com/2008/10/07/optimisation-effort-vs-performance-gain/">before</a> the initial optimisations to a program tend to yeild larger returns and then returns drop off until much more time is invested. These initial easy optimisations are not usually the sort of changes new programmers expect: they expect sexy <em>l33t</em> code like inline assembler for big performance wins, not tweaking compiler flags or removing calls to a pure virtual method on a base object in an inner loop.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.endlesslycurious.com/2008/11/25/optimisation-workflow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RE: Teaching students memory managment</title>
		<link>http://www.endlesslycurious.com/2008/11/24/re-teaching-students-memory-managment/</link>
		<comments>http://www.endlesslycurious.com/2008/11/24/re-teaching-students-memory-managment/#comments</comments>
		<pubDate>Mon, 24 Nov 2008 21:00:27 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Programming Languages]]></category>
		<category><![CDATA[Teaching]]></category>

		<guid isPermaLink="false">http://www.endlesslycurious.com/?p=817</guid>
		<description><![CDATA[Jani Hartikainen has written an excellent post in reply to my earlier post about teaching software engineering students memory management, and his post is well worth a read.  I started off writing a comment on his post as a reply but I ended up writing more than I expected as I refined my ideas. I [...]]]></description>
			<content:encoded><![CDATA[<p>Jani Hartikainen has written an excellent <a href="http://codeutopia.net/blog/2008/11/24/programmers-education/">post</a> in reply to my earlier <a href="http://www.endlesslycurious.com/2008/11/20/teaching-students-memory-managment/">post</a> about teaching software engineering students memory management, and his post is well worth a read.  I started off writing a comment on his post as a reply but I ended up writing more than I expected as I refined my ideas.</p>
<p>I agree teaching a higher level language with built in memory management as a first programming language is the more humane option as far as first time students are concerned.  As learning your first programming language and all the associated concepts is hard enough without all the nasty memory related gotchas in a language like C or C++.  Although the nice thing about learning something like C or php (as Jani suggests) is that teaching object orientation can be avoided initially, as that particular concept does seem to be something that some students struggle with a lot the first time they encounter it.</p>
<p>However I do think a low level language that has manual memory management should be at least <em>experienced</em> by every programmer, as it is a fundamental concept of programming effectively.  And I believe that having minimal experience with some form of manual memory management would help most programmers write higher performance programs.  But perhaps I was being a bit over zealous recommending that everyone learns a language like C/C++ as a first language, although I think at least a short course featuring a language with manual memory management would be invaluable to all programmers.  The course would not even need to cover object orientation as you can teach that in higher level languages that are easier to manipulate than C++: the key point of the course would be to teach memory management and its implications for writing fast high quality software.</p>
<p>As much as I go on about knowing assembler, I admit its not something I <em>write</em> very often at all, however it is something that is incredibly handy to be able to <em>read</em> and <em>comprehend. </em>Even the most basic level of understanding of the instructions for loading data from or to memory and registers, branching and basic math operations would allow you to check the compiler has actually generated the assembly code you expected. This is especially useful for debugging unexpectedly slow code in compiler optimised builds.  You also don&#8217;t need to know about all the fancy vendor specific assembly instructions, as I&#8217;ve mentioned the basics are usually sufficient to be able to understand roughly what a slow piece of code is doing to then rewrite the higher level source code in a way that prompts compiler to generate faster assembly code.  Actually writing assembly code should always be the last resort and only done by experts after all other higher level refactorings are attempted, as higher level optimisation or refactoring work is usually more effective and easier to understand.  Also, assembler is not usually easily portable to other hardware platforms and most programmers find it harder to debug assembler than normal C/C++ source code.  Plus as Jani mentions it is scary to find a block of inline assembler in the C++ program you are working as it is much harder to decipher than regular source code unless it is very well documented.</p>
<p>This ability to check what is going on &#8216;under the hood&#8217; of your language is essential for those hard to track down bugs and when optimising your application for performance, especially where the compiler has reordered the program flow or generated unexpectidally slow code. This can also be applied to high level languages as well as C/C++: checking that the IL byte code generated by your C# compiler or the Java byte code generated by the JVM is doing what you expected can be very useful in understanding your program&#8217;s execution and performance.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.endlesslycurious.com/2008/11/24/re-teaching-students-memory-managment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python or Ruby?</title>
		<link>http://www.endlesslycurious.com/2008/10/29/python-or-ruby/</link>
		<comments>http://www.endlesslycurious.com/2008/10/29/python-or-ruby/#comments</comments>
		<pubDate>Wed, 29 Oct 2008 08:00:32 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Programming Languages]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.endlesslycurious.com/?p=549</guid>
		<description><![CDATA[I&#8217;ve really needed to get round to learning a powerful object oriented scripted or interpreted programming language to replace windows batch files (which I currently use) for a while now.  As Microsoft seems determined to gut their functionality with each new Windows release and I find myself wanting more functionality and power than batch scripts [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve really needed to get round to learning a powerful object oriented <a href="http://en.wikipedia.org/wiki/Scripting_language">scripted</a> or <a href="http://en.wikipedia.org/wiki/Interpreter_(computing)">interpreted</a> programming language to replace windows batch files (which I currently use) for a while now.  As Microsoft seems determined to gut their functionality with each new Windows release and I find myself wanting more functionality and power than batch scripts can provide.  So I have been looking for a high level <a href="http://en.wikipedia.org/wiki/Scripting_language">scripted</a> or <a href="http://en.wikipedia.org/wiki/Interpreter_(computing)">interpreted</a> language for platform independent scripting, rapid application prototype and generally messing about with at home.  Ideally the language is scripted or interpreted (so no compilation required), has a unit test harness available, ideally some form of IDE/debugger, some decent solid libraries (e.g, database, visualisation/graphing etc) and is object oriented.</p>
<p>I know I don&#8217;t want to use the following languages mostly for reasons of personal taste:</p>
<ul>
<li><a href="http://www.perl.org/">Perl</a> as I can never remember it&#8217;s syntax and I can&#8217;t seem to read any script I&#8217;ve written in Perl after a week or so.</li>
<li><a href="http://www.php.net/">php</a> as I already use it for web development (and like it a lot) but it does not really seam suitable for scripting or quick application development that is not running on a web server.</li>
<li><a href="http://java.com/en/">Java</a> I&#8217;ve never gotten on with, but that was probably more to do with falling out with my Java lecturer at university.  Although I should probably revisit Java at some point as it seems very popular at the enterprise level.</li>
<li>I also want something not Microsoft specific, as much as I love <a href="http://msdn.microsoft.com/en-us/vcsharp/default.aspx">C#</a> I want something I can use easily on my Mac or Linux boxes at home without compiling.</li>
</ul>
<p>So far I&#8217;ve narrowed it down to either <a href="http://www.python.org/">Python</a> or <a href="http://www.ruby-lang.org/en/">Ruby</a>.  Originally I was going to learn Python as I like its use of white space for scoping, its wide range of libraries and maturity as a language.  However there seems to be a lot of buzz about Ruby these days, especially its <a href="http://www.rubyonrails.org/">Rails framework</a> and all the buzz has piqued my interest.  Further investigation into Ruby has me now leaning towards learning it mostly for the trivial reason (as the languages are equally matched in my mind) that Ruby has the similar concept and syntax of public, protected and private for methods which is familiar to me as a C++ and C# programmer.</p>
<p>In fact I am more then leaning towards Ruby as I bought a copy of &#8216;<a href="http://oreilly.com/catalog/9780596516178/">The Ruby Programming Language</a>&#8216; at lunchtime, mostly as it was getting good reviews online and because the original developer of Ruby was a co-author.  I always enjoyed <a href="http://www.research.att.com/~bs/homepage.html">Bjarne Stroustrup</a>&#8216;s &#8216;<a href="http://www.research.att.com/~bs/3rd.html">The C++ Programming Language</a>&#8216; book, getting the language creators view on their creation is always fascinating and provides valuable insights.</p>
<p>So expect to see more posts about Ruby as I work my way through the book and experiement.  I can even post code snippets with syntax highlighting thanks to the Google <a href="http://code.google.com/p/syntaxhighlighter/">Syntax Highlighter</a> in the form of a handy <a href="http://wordpress.org/extend/plugins/google-syntax-highlighter/">plug-in</a> for WordPress!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.endlesslycurious.com/2008/10/29/python-or-ruby/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

