<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Random Hacks comments</title>
    <link>http://www.randomhacks.net/</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Technology and Other Fun Stuff</description>
    <item>
      <title>"Jim Hefferon's Linear Algebra: A free textbook with fascinating applications" by Anon</title>
      <description>&lt;p&gt;You should also take a look at Gilbert Strang&amp;#8217;s Linear Algebra video lectures on &lt;span class="caps"&gt;MIT&lt;/span&gt;&amp;#8217;s open courseware site. They&amp;#8217;re pure gold.&lt;/p&gt;


	&lt;p&gt;http://web.mit.edu/18.06/www/Video/video-fall-99-new.html&lt;/p&gt;</description>
      <pubDate>Mon, 03 Nov 2008 07:38:50 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:84ff28ea-5098-4549-8c11-48b5a66d6887</guid>
      <link>http://www.randomhacks.net/articles/2007/03/07/hefferon-linear-algebra-review#comment-587</link>
    </item>
    <item>
      <title>"September 8th, 2007" by rajika</title>
      <description>&lt;p&gt;congrats!&lt;/p&gt;</description>
      <pubDate>Sun, 28 Sep 2008 12:29:29 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:fb3505be-9460-4155-b44d-3db4674f165a</guid>
      <link>http://www.randomhacks.net/articles/2007/09/18/just-married#comment-585</link>
    </item>
    <item>
      <title>"McCarthy's Ambiguous Operator" by backtrack</title>
      <description>&lt;p&gt;There&amp;#8217;s also goal directed computation as implemented in the Icon language, though you probably know about it.&lt;/p&gt;</description>
      <pubDate>Tue, 09 Sep 2008 12:40:37 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:365e170d-4cf4-4f79-b509-2a6c77d740df</guid>
      <link>http://www.randomhacks.net/articles/2005/10/11/amb-operator#comment-583</link>
    </item>
    <item>
      <title>"Ubiquitous Hoogle" by Bryan O'Sullivan</title>
      <description>&lt;p&gt;Lovely stuff, thanks!&lt;/p&gt;</description>
      <pubDate>Tue, 02 Sep 2008 23:51:21 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:1433b851-2f0c-4576-8a7a-e66feeaf1201</guid>
      <link>http://www.randomhacks.net/articles/2008/09/01/ubiquitous-hoogle#comment-582</link>
    </item>
    <item>
      <title>"Haskell: Queues without pointers" by Eric Kidd</title>
      <description>&lt;p&gt;kumma: &lt;code&gt;head&lt;/code&gt; and &lt;code&gt;tail&lt;/code&gt; are easy enough (and fast enough, too).  But to implement a queue, you also need some sort of &amp;#8220;enqueue&amp;#8221; operation.  And that can get really slow, if you&amp;#8217;re not careful.&lt;/p&gt;


	&lt;p&gt;Specifically, consider the following implementation:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_haskell "&gt;&lt;span class='keyword'&gt;data&lt;/span&gt; &lt;span class='conid'&gt;Queue&lt;/span&gt; &lt;span class='varid'&gt;a&lt;/span&gt; &lt;span class='keyglyph'&gt;=&lt;/span&gt; &lt;span class='conid'&gt;Queue&lt;/span&gt; &lt;span class='keyglyph'&gt;[&lt;/span&gt;&lt;span class='varid'&gt;a&lt;/span&gt;&lt;span class='keyglyph'&gt;]&lt;/span&gt;

&lt;span class='varid'&gt;newQueue&lt;/span&gt; &lt;span class='keyglyph'&gt;=&lt;/span&gt; &lt;span class='conid'&gt;Queue&lt;/span&gt; &lt;span class='keyglyph'&gt;[&lt;/span&gt;&lt;span class='keyglyph'&gt;]&lt;/span&gt;

&lt;span class='varid'&gt;deq&lt;/span&gt; &lt;span class='layout'&gt;(&lt;/span&gt;&lt;span class='conid'&gt;Queue&lt;/span&gt; &lt;span class='keyglyph'&gt;[&lt;/span&gt;&lt;span class='keyglyph'&gt;]&lt;/span&gt;&lt;span class='layout'&gt;)&lt;/span&gt; &lt;span class='keyglyph'&gt;=&lt;/span&gt; &lt;span class='varid'&gt;error&lt;/span&gt; &lt;span class='str'&gt;"Empty queue"&lt;/span&gt;
&lt;span class='varid'&gt;deq&lt;/span&gt; &lt;span class='layout'&gt;(&lt;/span&gt;&lt;span class='conid'&gt;Queue&lt;/span&gt; &lt;span class='layout'&gt;(&lt;/span&gt;&lt;span class='varid'&gt;x&lt;/span&gt;&lt;span class='conop'&gt;:&lt;/span&gt;&lt;span class='varid'&gt;xs&lt;/span&gt;&lt;span class='layout'&gt;)&lt;/span&gt;&lt;span class='layout'&gt;)&lt;/span&gt; &lt;span class='keyglyph'&gt;=&lt;/span&gt; &lt;span class='layout'&gt;(&lt;/span&gt;&lt;span class='varid'&gt;x&lt;/span&gt;&lt;span class='layout'&gt;,&lt;/span&gt;&lt;span class='varid'&gt;xs&lt;/span&gt;&lt;span class='layout'&gt;)&lt;/span&gt;

&lt;span class='varid'&gt;enq&lt;/span&gt; &lt;span class='layout'&gt;(&lt;/span&gt;&lt;span class='conid'&gt;Queue&lt;/span&gt; &lt;span class='varid'&gt;xs&lt;/span&gt;&lt;span class='layout'&gt;)&lt;/span&gt; &lt;span class='varid'&gt;x&lt;/span&gt; &lt;span class='keyglyph'&gt;=&lt;/span&gt; &lt;span class='conid'&gt;Queue&lt;/span&gt; &lt;span class='layout'&gt;(&lt;/span&gt;&lt;span class='varid'&gt;xs&lt;/span&gt; &lt;span class='varop'&gt;++&lt;/span&gt; &lt;span class='varid'&gt;x&lt;/span&gt;&lt;span class='layout'&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;Here, &lt;code&gt;deq&lt;/code&gt; uses &lt;code&gt;head&lt;/code&gt; and &lt;code&gt;tail&lt;/code&gt; (in the form of the &lt;code&gt;(x:xs)&lt;/code&gt; pattern match), and it runs in constant time, no matter how big the queue.&lt;/p&gt;


	&lt;p&gt;But &lt;code&gt;enq&lt;/code&gt; uses &lt;code&gt;++&lt;/code&gt;, which is seriously slow, because it makes a complete copy of &lt;code&gt;xs&lt;/code&gt; every time we add an item to the queue. If we keep (say) an average of 1,000 items in the queue, that means we need to copy a 1,000 item list every time we call &lt;code&gt;enq&lt;/code&gt;.&lt;/p&gt;


	&lt;p&gt;The alternate implementation you see above doesn&amp;#8217;t have this problem. In our example, it can &lt;code&gt;enq&lt;/code&gt; an item in a single operation 999 times out of 1000, and only reallocate the entire list 1 time in a 1000, instead of every single time. On average, that works out to O(1) time. For 10 lines of Haskell, it&amp;#8217;s actually a pretty decent queue.&lt;/p&gt;</description>
      <pubDate>Mon, 01 Sep 2008 06:47:15 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:b55e9dfa-54fa-477d-b007-651626ec6be8</guid>
      <link>http://www.randomhacks.net/articles/2007/02/08/haskell-queues-without-pointers#comment-580</link>
    </item>
    <item>
      <title>"Haskell: Queues without pointers" by kumma</title>
      <description>&lt;p&gt;Are tail and head too complex for use or what?&lt;/p&gt;</description>
      <pubDate>Mon, 01 Sep 2008 04:24:42 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:8b4e7406-d46c-4169-a201-d1903ba39aae</guid>
      <link>http://www.randomhacks.net/articles/2007/02/08/haskell-queues-without-pointers#comment-579</link>
    </item>
    <item>
      <title>"Why Hygienic Macros Rock" by Scott</title>
      <description>&lt;p&gt;Daniel: Ok, thanks.&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;m acquainted with Forth. I read both &lt;em&gt;Starting Forth&lt;/em&gt; and &lt;em&gt;Thinking Forth&lt;/em&gt; a few days after posting the above comment, actually; I love the concatenative approach, though I find Forth a bit too low-level for my taste. (My favorite language is currently OCaml, so you can guess how I feel about working without any type system whatsover.) I&amp;#8217;ve also looked a little at Factor, but not in depth.&lt;/p&gt;


	&lt;p&gt;That said, the source to a Forth interpreter in i386 assembly and Forth was one of the single most mind-blowing programming things I&amp;#8217;ve ever read. When I saw that the interpreter had a bit for whether the code was being compiled or evaluated, and immediate functions could toggle it at runtime, everything suddenly made sense. So much flexibility emerging from so few constructs!&lt;/p&gt;


	&lt;p&gt;http://www.annexia.org/_file/jonesforth.s.txt&lt;/p&gt;</description>
      <pubDate>Tue, 15 Jul 2008 22:30:03 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:5306f8c6-4510-4d49-aa1f-5c2ea96606bc</guid>
      <link>http://www.randomhacks.net/articles/2002/09/13/hygienic-macros#comment-578</link>
    </item>
    <item>
      <title>"Why Hygienic Macros Rock" by Daniel</title>
      <description>&lt;p&gt;I have actually read a lot about hygienic vs non-hygienic macros. I just cannot recall what blogs and sites I read them.&lt;/p&gt;


	&lt;p&gt;You might try smuglispweeny and lambda-the-ultimate blogs, though. And wikipedia.&lt;/p&gt;


	&lt;p&gt;The thing is, gensyms handles some of the stuff hygienic macros handle, but not all of the stuff. There are some complex cases which would require heroic efforts in &lt;span class="caps"&gt;LISP&lt;/span&gt;, and very prone to errors at that.&lt;/p&gt;


	&lt;p&gt;On the other hand, hygienic macros can access the runtime context, in a more verbose way.&lt;/p&gt;


	&lt;p&gt;So, really, they each can be used for the same things, with varied levels of complexity depending on the task. But let me advocate hygienic macros a bit here.&lt;/p&gt;


	&lt;p&gt;There once was a language called Forth. Forth was interesting in that not only it was written in itself, but all the internals were available to any programs written in it, and, furthermore, it could be changed at will. You could change the parser, for instance, or you could change how it performed compilation.&lt;/p&gt;


	&lt;p&gt;Needless to say, it was powerful in the way such languages are. The thing is&amp;#8230; Forth lacked abstraction. Yes, you could change the compiler. But, of course, you&amp;#8217;d have to know how the specific compiler you were changing worked&amp;#8212;and I don&amp;#8217;t mean simply dialect differences. The most famous Forth generated indirectly threaded code, quite a few generated directly threaded code, some generated subrouting threaded code, others generated bytecode, and others compiled directly to machine code.&lt;/p&gt;


	&lt;p&gt;So it was very powerful stuff, which had very little portability. Well, let&amp;#8217;s be honest. It had no portability at all.&lt;/p&gt;


	&lt;p&gt;And here is the thing with non-hygienic macros&amp;#8230; the programmers using someone&amp;#8217;s macro also have to know how that macro works. Either that, or you add stuff to your macro until it is, effectively, hygienic.&lt;/p&gt;


	&lt;p&gt;So, by using hygienic macros, you guarantee a level of portability to them similar to library functions.&lt;/p&gt;</description>
      <pubDate>Sun, 22 Jun 2008 21:47:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:569edc73-4167-4cba-bbfa-ef2b1225b0cd</guid>
      <link>http://www.randomhacks.net/articles/2002/09/13/hygienic-macros#comment-577</link>
    </item>
    <item>
      <title>"Why Hygienic Macros Rock" by Eric</title>
      <description>&lt;p&gt;Scott: That&amp;#8217;s a good question, and I don&amp;#8217;t actually know the answer.&lt;/p&gt;


	&lt;p&gt;Most Scheme implementations take a distantly-related approach. They generally have two different hygenic macro systems:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;A &amp;#8220;low-level&amp;#8221; macro system, which works roughly like &lt;span class="caps"&gt;LISP&lt;/span&gt;, but which provides hygiene by default, but also provides the ability to violate hygiene selectively. This tends to be a bit fiddly to use.&lt;/li&gt;
		&lt;li&gt;A &amp;#8220;high-level&amp;#8221; macro system, which is based on hygienic rewrite rules. This is very easy to use, and will work for nearly all common macros.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Of course, using the low-level macro system, you can easily implement Lisp-style non-hygienic macros.&lt;/p&gt;


	&lt;p&gt;The &lt;span class="caps"&gt;PLT&lt;/span&gt; people have recently added another very slick feature to the standard Scheme toolkit: The ability the selectively violate hygiene from inside rewrite rules, in a &lt;a href="http://blog.plt-scheme.org/2008/02/dirty-looking-hygiene.html" rel="nofollow"&gt;carefully controlled&lt;/a&gt; fashion. This is a really nice feature, and we&amp;#8217;ve been using it at work with great success.&lt;/p&gt;</description>
      <pubDate>Fri, 20 Jun 2008 07:40:30 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:1053b2b2-1a16-4305-a516-c8dd0265bd4c</guid>
      <link>http://www.randomhacks.net/articles/2002/09/13/hygienic-macros#comment-576</link>
    </item>
    <item>
      <title>"Why Hygienic Macros Rock" by Scott</title>
      <description>&lt;p&gt;To what extent can hygienic macros be implemented in non- and vice versa? I&amp;#8217;m more familiar with Emacs Lisp-style macros than CL or Scheme macros, but it seems like the hygiene involves automatically writing code with gensyms to avoid variable capture and other compile-time analysis. If one is implemented in terms of the other, it would probably make the most sense to have two different forms, e.g. hmacro for declaring hygienic macros, and macro for when you deliberately want to do things like variable capture.&lt;/p&gt;</description>
      <pubDate>Thu, 19 Jun 2008 20:15:42 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:3d805087-bf74-43a9-aa42-addf5622bbeb</guid>
      <link>http://www.randomhacks.net/articles/2002/09/13/hygienic-macros#comment-575</link>
    </item>
  </channel>
</rss>
