{"id":10355,"date":"2022-02-26T13:52:24","date_gmt":"2022-02-26T18:52:24","guid":{"rendered":"https:\/\/irreal.org\/blog\/?p=10355"},"modified":"2022-02-26T13:52:24","modified_gmt":"2022-02-26T18:52:24","slug":"scheme-as-a-prototyping-language","status":"publish","type":"post","link":"https:\/\/irreal.org\/blog\/?p=10355","title":{"rendered":"Scheme as a Prototyping Language"},"content":{"rendered":"<p>The other day I saw a link to this short essay on <a href=\"https:\/\/web.archive.org\/web\/20100310163003\/https:\/\/www.cs.indiana.edu\/%257Ejsobel\/c455-c511.updated.txt\">using Scheme as a prototyping language<\/a> by Jonathan Sobel. The TL;DR is that Sobel was taking an Algorithms class and was assigned a project to implement the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Multiplication_algorithm\">fast multiplication algorithm<\/a> with part of the grade based on fast it ran.<\/p>\n<p>Most of Sobel\u2019s classmates started writing in C. A few of them went directly to assembly language. They spent a lot of time debugging their highly optimized C and assembly code. Sobel pursued a different track; he started writing in Scheme. He began with a naive implementation of the algorithm and iteratively refined it.<\/p>\n<p>Scheme is ideal for this. The language allows one to make correctness-preserving transformations to the code that eliminates function calls and allowed the caching of execution context. Once Sobel had his Scheme implementation optimized, he translated the code into C.<\/p>\n<p>The results were impressive. Sobel\u2019s implementation was the second fastest in the class, beaten only by an implementation written predominantly in assembly language. Sobel says that if he\u2019d known a bit more about Scheme, his implementation would have come in first.<\/p>\n<p>For almost all projects, I find writing in some sort of Lisp gets the job quickly, more accurately, and with a result efficient enough for a final product. In those rare cases where more speed is needed, Sobel\u2019s strategy of writing in a Lisp, debugging and optimizing the program, and finally translating into C is a good strategy.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The other day I saw a link to this short essay on using Scheme as a prototyping language by Jonathan Sobel. The TL;DR is that Sobel was taking an Algorithms class and was assigned a project to implement the fast &hellip; <a href=\"https:\/\/irreal.org\/blog\/?p=10355\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[17,10],"class_list":["post-10355","post","type-post","status-publish","format-standard","hentry","category-programming","tag-c","tag-scheme"],"_links":{"self":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/10355","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10355"}],"version-history":[{"count":1,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/10355\/revisions"}],"predecessor-version":[{"id":10356,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/10355\/revisions\/10356"}],"wp:attachment":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10355"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10355"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10355"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}