{"id":764,"date":"2008-10-13T16:00:17","date_gmt":"2008-10-13T23:00:17","guid":{"rendered":"https:\/\/www.reenigne.org\/blog\/?p=764"},"modified":"2008-10-13T17:49:13","modified_gmt":"2008-10-14T00:49:13","slug":"javascript-vs-php","status":"publish","type":"post","link":"https:\/\/www.reenigne.org\/blog\/javascript-vs-php\/","title":{"rendered":"JavaScript vs PHP"},"content":{"rendered":"<p>In order to implement <a href=\"https:\/\/www.reenigne.org\/blog\/tet4-implemented-in-javascript\">Tet4<\/a> I learnt two new languages - JavaScript (or JScript, or ECMAScript - the language has a bit of an identity crisis) and PHP. Why PHP? It's installed on my web hosting server and seems to have a huge community of people writing code in it and pre-written scripts. It may not be the ideal language for writing web server apps, but it does seem to be the most well-supported.<\/p>\n<p>JavaScript seems to be a very clean, pretty language. The whole closure thing seemed a bit weird at first but once I understood that \"class\" is spelled \"function\" and \"public\" is spelled \"this.\" I got to rather liking it. I especially like how each scope has access<br \/>\nto the variables from all the outer scopes - that saves a lot of messing about. It's very well integrated with the browser - manipulating the DOM feels very natural and not tacked on.<\/p>\n<p>PHP on the other hand is a bit of a mess. It is as if its designers had a little spinner with markings \"C, C++, Perl\" which they spun each day to decide what languages features to copy that day. If JavaScript was sent by God, surely PHP was sent by the devil.<\/p>\n<p><a href=\"http:\/\/www.w3schools.com\/sitemap.asp\">W3Schools<\/a> has been an excellent reference for learning all this.<\/p>\n<p>I have to say though that automatically promoting integers to double-precision floating point numbers on overflow is weird. On IE7, computing the value of 1111111111*1111111111 gives 1234567900987654400 (you can easily see this is wrong because it's even). This caused a rather hard-to-debug problem with my random number generator (which assumed that when multiplying two 32-bit integers together, at least the low 32 bits of the result should be correct). If you're going to automatically promote numbers, at least have the decency to use a multiple-precision integer library - there are lots around.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In order to implement Tet4 I learnt two new languages - JavaScript (or JScript, or ECMAScript - the language has a bit of an identity crisis) and PHP. Why PHP? It's installed on my web hosting server and seems to have a huge community of people writing code in it and pre-written scripts. It may [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[],"class_list":["post-764","post","type-post","status-publish","format-standard","hentry","category-language"],"_links":{"self":[{"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/posts\/764","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/comments?post=764"}],"version-history":[{"count":4,"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/posts\/764\/revisions"}],"predecessor-version":[{"id":798,"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/posts\/764\/revisions\/798"}],"wp:attachment":[{"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/media?parent=764"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/categories?post=764"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.reenigne.org\/blog\/wp-json\/wp\/v2\/tags?post=764"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}