<?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>A Lexical Mistake &#187; Haskell</title>
	<atom:link href="http://alexicalmistake.com/category/haskell/feed/" rel="self" type="application/rss+xml" />
	<link>http://alexicalmistake.com</link>
	<description>Languages; Past, Present and Future</description>
	<lastBuildDate>Sun, 06 Sep 2009 22:00:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Haskell and Game Development</title>
		<link>http://alexicalmistake.com/2008/10/haskell-and-game-development/</link>
		<comments>http://alexicalmistake.com/2008/10/haskell-and-game-development/#comments</comments>
		<pubDate>Mon, 20 Oct 2008 09:11:15 +0000</pubDate>
		<dc:creator>Lorenz Pretterhofer</dc:creator>
				<category><![CDATA[Haskell]]></category>
		<category><![CDATA[Gamedev]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://alexicalmistake.com/?p=50</guid>
		<description><![CDATA[Like many gamedev enthusiasts, I&#8217;ve only finished a handful of computer games and, perhaps not surprisingly, most of those were never released even on my homepage either. Usually the point of game development at an enthusiast or hobbyist level is not to create gaming masterpieces anyway, but rather to simply learn about the process and [...]]]></description>
			<content:encoded><![CDATA[<p>Like many gamedev enthusiasts, I&#8217;ve only finished a handful of computer games and, perhaps not surprisingly, most of those were never released even on my homepage either. Usually the point of game development at an enthusiast or hobbyist level is not to create gaming masterpieces anyway, but rather to simply learn about the process and have fun working the code (or graphics, design, et cetera), and maybe even develop a few reasonably simple games.</p>
<p>Over the years I&#8217;ve spend quite a bit of time learning the gamedev concepts and recently I was able to apply some of them in a project, intended to test Haskell&#8217;s gamedev capabilities for hobbyist or small team game development (<a href="http://alexicalmistake.com/2008/06/language-design-and-small-team-game-development/">related post</a>). Specifically I was interested to see how the difference between Haskell and Object-Oriented languages changed the design and implementation of the game code and engine, hopefully lending itself to the eventual development of languages tailored towards game development.</p>
<p>I set out to develop one of my favorite arcade remakes&#8211;yet another variation of Geometry Wars. The premise would be to keep the game as simple as possible, only the basic gameplay would be present with a couple of levels of progression. Enough to test all of the simple elements of gameplay ready for a more substantial project. As you may have guessed from the absence of the obligatory screenshot it didn&#8217;t work out as well as I expected.</p>
<p>Luckily I did pick up a couple of things while working on the game, and better yet I may even be able to rewrite the code and find that screenshot yet. It all comes down to a couple of quirks in Haskell&#8217;s syntax which didn&#8217;t blend well with my usual game architecture. Obviously the architecture would need to be modified to suite the idiomatic style of Haskell, but I was reasonably certain (and still are) that the architecture is the simplest implementation for both Object-Oriented languages as well as functional languages, based almost solely on the requirements of the high level game data structures.</p>
<p>The Haskell code for these structures was essentially based directly on records. The records originally contained only functional values, but I quickly realized how crazy that was, which lead me to the current design which uses records full of IORefs, at least for the mutable slots. (If its not immediately obvious why the IORefs are needed, it might help to know that game objects quite often need to reference each other simply because the operations are related between the two&#8230;bullets from the player ship for example.)</p>
<p>Finally, after working with this approach for a while it eventually sunk in that I could probably write the same code in Python in not only half the time, but also quicker for the same number of overall bugs. Not because the bugs are easier to catch in Python&#8230;they really, really aren&#8217;t. But because Python allows me to test many more variations of the game. At least more variations than Haskell seems to, all of which makes me wonder if I haven&#8217;t quite tapped into the idiomatic code still.</p>
<p>So I&#8217;m not quite out of ideas yet. I believe I can tweak my accessors to reduce the namespace damage caused by them (at the expense of some verbosity, however&#8230;why the hell hasn&#8217;t this been fixed yet anyway). And there&#8217;s even some clever usage of typeclasses which could simplify the use of common algorithms between game objects. If all goes to plan I&#8217;ll have some code to post next time&#8230;</p>
<p>&#8211; Lorenz</p>
]]></content:encoded>
			<wfw:commentRss>http://alexicalmistake.com/2008/10/haskell-and-game-development/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Monad Actions&#8230; ok&#8230; sure&#8230; whatever&#8230;!?</title>
		<link>http://alexicalmistake.com/2008/07/monad-actions-ok-sure-whatever/</link>
		<comments>http://alexicalmistake.com/2008/07/monad-actions-ok-sure-whatever/#comments</comments>
		<pubDate>Mon, 14 Jul 2008 03:17:02 +0000</pubDate>
		<dc:creator>Lorenz Pretterhofer</dc:creator>
				<category><![CDATA[Haskell]]></category>

		<guid isPermaLink="false">http://krysole.net/2008/07/13/monad-actions-ok-sure-whatever/</guid>
		<description><![CDATA[When I was first learning about OpenGL in Haskell it dawned on me that the example I was reading was doing some pretty crazy hung up things with Haskell style DSL techniques.
White this might make sense for a syntax based DSL (imho), I wasn&#8217;t sure this was absolutely necessary under OpenGL since the entire library [...]]]></description>
			<content:encoded><![CDATA[<p>When I was first learning about OpenGL in Haskell it dawned on me that the example I was reading was doing some pretty crazy hung up things with Haskell style DSL techniques.</p>
<p>White this might make sense for a syntax based DSL (imho), I wasn&#8217;t sure this was absolutely necessary under OpenGL since the entire library is already just a bunch of monadic actions!?</p>
<p>Ok&#8230; that&#8217;s cool, maybe it was just overlooked, and I thus devised a test. Write a small piece of monadic code that re-evaluated an action over and over again&#8230;and it worked!!!</p>
<p>w00t!!!1one</p>
<p>uh&#8230; yeah&#8230; maybe you should just read this instead&#8230; save yourself some time and embarrassment ;)</p>
<p><a href="http://haskell.org/haskellwiki/IO_inside">IO Inside</a></p>
<p>On the upside&#8230; that game is still slowly progressing&#8230;</p>
<p>&#8211; Lorenz</p>
]]></content:encoded>
			<wfw:commentRss>http://alexicalmistake.com/2008/07/monad-actions-ok-sure-whatever/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Haskell Does Concurrency</title>
		<link>http://alexicalmistake.com/2008/07/haskell-does-concurrency/</link>
		<comments>http://alexicalmistake.com/2008/07/haskell-does-concurrency/#comments</comments>
		<pubDate>Sat, 05 Jul 2008 10:07:14 +0000</pubDate>
		<dc:creator>Lorenz Pretterhofer</dc:creator>
				<category><![CDATA[Haskell]]></category>
		<category><![CDATA[concurrency]]></category>
		<category><![CDATA[STM]]></category>
		<category><![CDATA[transactions]]></category>

		<guid isPermaLink="false">http://krysole.net/2008/07/04/haskell-does-concurrency/</guid>
		<description><![CDATA[Ok, by now we all know that Object Oriented programming is likely to go the way of Erlang, or at least inherit an Actor model of language level concurrency.
In fact, I&#8217;ve even got an object system that I&#8217;m planning to implement just to find out how well this style of concurrency works in an Object [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, by now we all know that Object Oriented programming is likely to go the way of Erlang, or at least inherit an Actor model of language level concurrency.</p>
<p>In fact, I&#8217;ve even got an object system that I&#8217;m planning to implement just to find out how well this style of concurrency works in an Object Oriented programming language. The design of the language is even more post-Self/Slate than Newspeak (although I believe that this language will just complement the Smalltalk family of languages in all honesty).</p>
<p>Well then, Haskell&#8230;Haskell is actually very interesting, in this case by being one of the very few to push the limits of locking methods for concurrency rather than using the larger granularity involved in processes and message passing (not by much, but its still something).</p>
<p>The problem is that its impossible to write locking code by hand that doesn&#8217;t have at least one race condition hiding away in the corner. Not the ones you&#8217;ve already tested for, but the ones that would cause transactions to restart&#8230;like multiple threads locking a few items and then deadlocking&#8230;or even just managing the code required to restart deadlocks&#8230;yeah&#8230;lol&#8230;</p>
<p>Haskell provides a novel approach (its actually pretty old now, but it&#8217;s really only just starting to catch on, outside of Haskell anyway)&#8230; <a href="http://en.wikipedia.org/wiki/Software_transactional_memory">Software Transactional Memory</a>.</p>
<p>STM is sometimes used in other areas of computing (OODBs, <em>et ceteral</em>), but the real gem here is that the Haskell type system nicely compartmentalized the side effects involved into a clever transaction form, within our imperative outer program. This makes working with transactions very much like the database stuff, only we&#8217;re only working with individual variables, so no complex table lookups.</p>
<p>Anyway, enough of my rambling, check it out:<br />
<a href="http://channel9.msdn.com/shows/Going+Deep/Programming-in-the-Age-of-Concurrency-Software-Transactional-Memory/">Programming in the Age of Concurrency Software Transactional Memory</a></p>
<p>And if you haven&#8217;t already, remember to look at Erlang too&#8230;after all concurrency isn&#8217;t going away, and there are only two ways to get it right!</p>
<p>&#8211; Lorenz</p>
]]></content:encoded>
			<wfw:commentRss>http://alexicalmistake.com/2008/07/haskell-does-concurrency/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Learning Haskell</title>
		<link>http://alexicalmistake.com/2008/01/learning-haskell/</link>
		<comments>http://alexicalmistake.com/2008/01/learning-haskell/#comments</comments>
		<pubDate>Thu, 17 Jan 2008 09:26:53 +0000</pubDate>
		<dc:creator>Lorenz Pretterhofer</dc:creator>
				<category><![CDATA[Haskell]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Smalltalk]]></category>
		<category><![CDATA[Types]]></category>

		<guid isPermaLink="false">http://krysole.net/2008/01/16/learning-haskell/</guid>
		<description><![CDATA[Well I finally bit the bullet and decided to learn the Haskell programming language. For those in the know, Haskell is a very strictly typed language (like some kind of draconian Java dialect), which uses a type inferencing technique to allow the programmer to write code without excessively typing&#8230; well&#8230; the types really.
What makes the [...]]]></description>
			<content:encoded><![CDATA[<p>Well I finally bit the bullet and decided to learn the Haskell programming language. For those in the know, Haskell is a very strictly typed language (like some kind of draconian Java dialect), which uses a type inferencing technique to allow the programmer to write code without excessively typing&#8230; well&#8230; the types really.</p>
<p>What makes the language interesting however, is that is does this kind of strict typing from within a pure functional syntax (one that is very close to the mathematical lambda notation), and quite literally everything except the bindings themselves are first class values (objects really), and they all have types, which are themselves of some type and all can be fully reasoned with using the full capabilities of the syntax.</p>
<p>What all this means is that unlike Scheme (Lisp), instead of allowing objects of any type as values, all values and expressions must be the the correct type in any given piece of code (or they must be inferred transitively from their surrounding/contained code). Any mismatches are not allowed by the languages semantics and will cause compilation (or interpretation) errors.</p>
<p>This brings me to the point of this post, is a strictly typed language actually less or more capable than a weakly typed language. Also, if this is the case, does is it make the language better, or are other considerations more important (i.e. architectural concerns)?</p>
<p>I find this discussion interesting since it quite effectively contrasts the type system I designed, for Mention. While Mention&#8217;s type-system is effectively not just weakly typed but in many cases not checked at all, it allows arbitrary objects to be used in most situations, as long as they conform to the interfaces requested (in the type annotations or implicitly like Smalltalk).</p>
<p>Already I&#8217;m finding that I miss the more flexible type system when I find the only error messages cryptic type incompatibilities (what do you mean the type &#8216;a -> [a] -> a&#8217; isn&#8217;t compatible with &#8216;Num a&#8217;&#8230; Hell where is that number anyway?). It is slowly getting easier as I understand the impressive type reasoning capabilities of the language, not to mention the ominous Monad magic (think C++ templates on steroids&#8230; although probably very much easier to use effectively)</p>
<p>Presumably as I continue to work with both Haskell, Smalltalk (Squeak), and Mention I can come form a better opinion on the effects of strong vs. weak type systems (in languages with first class function and type objects). Oh&#8230; and they are right&#8230; Haskell does seem to be a language well worth the effort to learn effectively.</p>
<p>&#8211; Lorenz</p>
]]></content:encoded>
			<wfw:commentRss>http://alexicalmistake.com/2008/01/learning-haskell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
