{"id":5516,"date":"2010-09-18T00:03:22","date_gmt":"2010-09-18T00:03:22","guid":{"rendered":"http:\/\/17.28"},"modified":"2010-09-18T00:03:22","modified_gmt":"2010-09-18T00:03:22","slug":"28","status":"publish","type":"post","link":"https:\/\/blog.mozilla.org\/labs\/2010\/09\/28\/","title":{"rendered":"Zaphod\/Narcissus &#8212; tools for JavaScript language research"},"content":{"rendered":"<p>There have been a number of questions about Zaphod and Narcissus.\u00a0 Or perhaps just the one major question:<\/p>\n<blockquote><p>&#8220;Seems cool.\u00a0 Why should I use this?&#8221;<\/p><\/blockquote>\n<p>For day to day browsing, Narcissus does not offer any real advantages over SpiderMonkey.\u00a0 However, Narcissus is an ideal tool for developing new ideas for the JavaScript language itself.<\/p>\n<p>What features should we add to JavaScript?\u00a0 What should the syntax\/semantics be?\u00a0 What practical issues will come up that we have not considered so far?\u00a0 With Narcissus and Zaphod, we can more easily answer these questions.<\/p>\n<p>In programming language (PL) research, we like to write up fancy evaluation rules containing lots of Greek letters. Unfortunately, these rules tend to be inscrutable to anyone who isn&#8217;t a PL researcher. Even for PL researchers, there is something unsatisfying about seeing a bunch of rules on a piece of paper.<\/p>\n<p>We want to be able to try our ideas out with a real implementation &#8212; kick the tires, so to speak. Also, we want to share our ideas as widely as we can.\u00a0 This way, we can get feedback from programmers who experiment with our design.<\/p>\n<p>Unfortunately, this usually means editing a sizable, constantly shifting C++ code base. Anyone who wants to test out our ideas has to build the browser from source, which can be a daunting task.<\/p>\n<p>With Narcissus JavaScript, we have another alternative.\u00a0 Narcissus is both a simpler code base, and also much less affected by the changing browser code base.\u00a0 Once we have made our changes, we can easily distribute the JavaScript files and let others play around with the new feature.<\/p>\n<p>But Narcissus does not by itself integrate smoothly with the browser. That is where Zaphod comes in.<\/p>\n<p>Zaphod looks for scripts with a tag of &#8220;application\/narcissus&#8221; (which SpiderMonkey will ignore) and parses those scripts with Narcissus.\u00a0 This setup allows us to demonstrate a few examples using the new feature.\u00a0 <a title=\"Zaphod\/Narcissus examples\" href=\"http:\/\/www.bias2build.com\/narcissus\/\" target=\"_self\">Here<\/a> are a few simple pages using this technique. Using this, you can show some examples of how your new feature could be used.<\/p>\n<p>But we might also want to see how the implementation would work on a pre-existing page. Click on the mozilla icon in the bottom right corner and Narcissus will be set as the default JavaScript interpreter. After experimenting, click on the icon again and SpiderMonkey will be reset as your JS implementation.<\/p>\n<p>Zaphod\/Narcissus cannot yet handle some of the more JavaScript-heavy pages, but it can handle enough to be a valuable research tool for JavaScript language hackers.\u00a0 I hope you enjoy.\u00a0 And if you use it for some cool experiments, let me know!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There have been a number of questions about Zaphod and Narcissus.\u00a0 Or perhaps just the one major question: &#8220;Seems cool.\u00a0 Why should I use this?&#8221; For day to day browsing, Narcissus does not offer any real advantages over SpiderMonkey.\u00a0 However, &hellip; <a class=\"go\" href=\"https:\/\/blog.mozilla.org\/labs\/2010\/09\/28\/\">Continue reading<\/a><\/p>\n","protected":false},"author":1438,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[926],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/posts\/5516"}],"collection":[{"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/users\/1438"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/comments?post=5516"}],"version-history":[{"count":0,"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/posts\/5516\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/media?parent=5516"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/categories?post=5516"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/tags?post=5516"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}