{"id":191,"date":"2009-01-28T13:48:45","date_gmt":"2009-01-28T18:48:45","guid":{"rendered":"http:\/\/alarmingdevelopment.org\/?p=191"},"modified":"2009-02-08T09:48:35","modified_gmt":"2009-02-08T14:48:35","slug":"javascript-is-good-enough","status":"publish","type":"post","link":"https:\/\/alarmingdevelopment.org\/?p=191","title":{"rendered":"JavaScript is good enough"},"content":{"rendered":"<p>For some time now people have been talking about web browsers as an application platform that supplants the PC. So called &#8220;Rich Internet Applications&#8221; use JavaScript or Flash or Silverlight to provide an attractive user interface (unlike HTML) close to that of traditional PC apps. JavaScript has been recently getting more attention because of some new VM&#8217;s that dramatically increase its performance (i.e., TraceMonkey, SquirrelFish, and V8). Dan Ingalls gave a talk at <a href=\"http:\/\/2009.cusec.net\/\">CUSEC <\/a>about the <a href=\"http:\/\/research.sun.com\/projects\/lively\/\">Lively Kernel<\/a>, which is a Smalltalk-style environment for JavaScript, running completely inside the browser. He was initially concerned that JavaScript is just a toy language, but in the end concluded that it is &#8220;good enough&#8221;. That prompted me to take a closer look.<!--more--><\/p>\n<p>Prototypes &#8211; cool. First-class functions &#8211; great. Reflection &#8211; good. Collections &#8211; uhh, where are the collections? Like sets, lists, maps, and so on. JavaScript has exactly one form of structure, the object, which is a hashed map from strings to objects. These strings are typically field names. Arrays are simulated by converting the indices to decimal strings and hashing on them. You can build your own linked lists, but you can&#8217;t iterate over them with <code>for<\/code>. Here is the killer: if you use an object as a hash key, it does a toString on it. And the default implementation of toString returns <code>\"[object Object]\"<\/code>, so all objects are equal as hash keys. There is no equivalent to Java hashcodes based on the memory address of the object. It is impossible to build a hash table in JavaScript that works on arbitrary objects. You would have to manually allocate unique ID&#8217;s for every object and include them in the toString. So no collections in JavaScript.<\/p>\n<p>Adobe provides a true built-in hashtable in ActionScript 3. There are also a few collection classes hiding in Flex&#8217;s database access libraries. There are other goodies for real programming like optional typing, classes, interfaces, modules, and namespaces. But ActionScript is in an awkward position now because it is a snapshot of JavaScript 2, which has been abandoned. JavaScript 2 was shaping up to be a promising and innovative language, but it broke compatibility with JavaScript 1. The forces of ignorance killed it off with the battle cry of &#8220;it breaks the web&#8221;. A great tragedy. The web development community consciously chose to stick with a pathetically crippled technology to avoid having to change.<\/p>\n<p>JavaScript is good enough. It is good enough in exactly the way that MS-DOS was good enough. Like MS-DOS, it was thrown together as a quick and dirty hack, is deeply flawed, and can not be fixed because of compatibility constraints. It is good enough that you can deploy hordes of programmers to produce crappy software that sort of works. And that is good enough for making money.<\/p>\n<p>[Postscript &#8211; I see from the comments on Hacker News that I didn&#8217;t make it sufficiently clear that I am judging JavaScript&#8217;s suitability for building substantial programs, not just adding frills to webpages. JavaScript is fine for the latter.]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For some time now people have been talking about web browsers as an application platform that supplants the PC. So called &#8220;Rich Internet Applications&#8221; use JavaScript or Flash or Silverlight to provide an attractive user interface (unlike HTML) close to that of traditional PC apps. JavaScript has been recently getting more attention because of some &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/alarmingdevelopment.org\/?p=191\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;JavaScript is good enough&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-191","post","type-post","status-publish","format-standard","hentry","category-general"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pfEnU-35","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/alarmingdevelopment.org\/index.php?rest_route=\/wp\/v2\/posts\/191","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alarmingdevelopment.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alarmingdevelopment.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alarmingdevelopment.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/alarmingdevelopment.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=191"}],"version-history":[{"count":8,"href":"https:\/\/alarmingdevelopment.org\/index.php?rest_route=\/wp\/v2\/posts\/191\/revisions"}],"predecessor-version":[{"id":198,"href":"https:\/\/alarmingdevelopment.org\/index.php?rest_route=\/wp\/v2\/posts\/191\/revisions\/198"}],"wp:attachment":[{"href":"https:\/\/alarmingdevelopment.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=191"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alarmingdevelopment.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=191"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alarmingdevelopment.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=191"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}