{"id":425,"date":"2007-12-17T23:53:29","date_gmt":"2007-12-18T06:53:29","guid":{"rendered":"http:\/\/www.elbeno.com\/blog\/?p=425"},"modified":"2007-12-29T23:57:04","modified_gmt":"2007-12-30T06:57:04","slug":"lisping-towards-enlightenment","status":"publish","type":"post","link":"https:\/\/www.elbeno.com\/blog\/?p=425","title":{"rendered":"Lisping towards enlightenment"},"content":{"rendered":"<p>Me: a C\/C++ programmer of 12 years (professionally), a Lisp dabbler (programmer is too strong a word to use here) of, let&#8217;s say ~3 months. I&#8217;ve done enough functional stuff to be comfortable with that side, but I haven&#8217;t (hadn&#8217;t) yet written a project big enough to get me used to Lisp syntax.<\/p>\n<p>The project: an LL(1) parser. That is, given a suitable grammar and set of legal lexemes, produce a function that will (top-down predictive) parse legal strings of said grammar. This isn&#8217;t rocket science by compiler standards, and I&#8217;m not sure it&#8217;s even likely that the grammar I have in mind to parse can even be made LL(1), but I have implemented precisely this in C++ before, so it&#8217;s a good test. Straight out of <a href=\"http:\/\/en.wikipedia.org\/wiki\/Compilers:_Principles%2C_Techniques%2C_and_Tools\">the Dragon Book<\/a> section 4.4.<\/p>\n<p>So far I have completed Lisp functions to <a href=\"http:\/\/en.wikipedia.org\/wiki\/LL_parser#Constructing_an_LL.281.29_parsing_table\">produce a parsing table<\/a>, using appropriate algorithms to construct First and Follow sets. This is about 110 lines of Lisp. Looking at the old C++ code (about 5 years ago) it comes to about 230 lines. From this I conclude that even a newb like me can gain immediate benefit from Lisp, and that I don&#8217;t yet know enough Lisp to make this about half the size it is (e.g. I&#8217;ve used no macros).<\/p>\n<p>Time taken to get this far in Lisp: about 2 days. Time taken to get this far in C++: unknown, but the entire thing (grammar design, lexer, parser, bytecode compilation &amp; VM execution) took on the order of a few months. The C++ version is production code that shipped in a real life game. Make of that what you will.<\/p>\n<p>Even after 2 days, I&#8217;m already fine with the brackets. They really do not bother. The code is readable through indentation. I do sometimes run into problems with misplaced brackets when editing code, but it&#8217;s akin to a syntax error which is immediately found and fixed. I expect this to go away as I get more proficient.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Me: a C\/C++ programmer of 12 years (professionally), a Lisp dabbler (programmer is too strong a word to use here) of, let&#8217;s say ~3 months. I&#8217;ve done enough functional stuff to be comfortable with that side, but I haven&#8217;t (hadn&#8217;t) yet written a project big enough to get me used&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,8],"tags":[],"class_list":["post-425","post","type-post","status-publish","format-standard","hentry","category-lisp","category-programming"],"_links":{"self":[{"href":"https:\/\/www.elbeno.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/425","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.elbeno.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.elbeno.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.elbeno.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.elbeno.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=425"}],"version-history":[{"count":0,"href":"https:\/\/www.elbeno.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/425\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.elbeno.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=425"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.elbeno.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=425"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.elbeno.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=425"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}