{"id":301,"date":"2011-12-24T12:47:05","date_gmt":"2011-12-24T17:47:05","guid":{"rendered":"http:\/\/littlesvr.ca\/grumble\/?p=301"},"modified":"2012-12-05T00:48:49","modified_gmt":"2012-12-05T05:48:49","slug":"i-knew-there-was-a-good-reason-i-liked-c","status":"publish","type":"post","link":"http:\/\/littlesvr.ca\/grumble\/2011\/12\/24\/i-knew-there-was-a-good-reason-i-liked-c\/","title":{"rendered":"I knew there was a good reason I liked C"},"content":{"rendered":"<p>I think I mentioned earlier how I almost started writing a website in C and quickly realised that wasn&#8217;t the right tool for the job, and switched entirely to PHP.<\/p>\n<p>For the work I did today I needed a good set of data structures:<\/p>\n<ul>\n<li>A set of files\n<ul>\n<li>Each with a set of english strings\n<ul>\n<li>Each with a set of 0 or more translations<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Pice of cake, right? Right, it would have taken me a half an hour in C, took me over six hours in PHP.<\/p>\n<p>One of the problems was a surprise in scoping. Turns out in PHP there is no such thing as block scoping, and they forgot to mention that in the manual (isn&#8217;t it obvious there&#8217;s only per function and per file scope?). This created some very weird bugs that took a lot of printing to figoure out.<\/p>\n<p>Then there&#8217;s the arrays. How can you have a programming language without 0-indexed arrays? PHP forces you to manage the indicees yourself, since their &#8216;array&#8217; is actually a hash table. No vector either, not list, basically only a hash table. Can get used to it I guess but was it really so hard to have something more structured?<\/p>\n<p>Then there are the classes. I needed to use them because there is no concept of a struct and the arrays are so retarded. I won&#8217;t go too much into it, let me just say that I suspect classes in PHP resemble classes in Perl. Sure you can have them, but don&#8217;t expect them to be easy to use.<\/p>\n<p>All this complaining, you say, but didn&#8217;t it take you years to learn how things work in C, what&#8217;s the problem with taking the time to learn how things work in PHP? Well &#8211; I would accept that if it weren&#8217;t for the prevailing opinion that PHP is easy to learn. It isn&#8217;t: you can get started using it very quickly but its similarities to C in syntax make it harder (not easier) to learn it well.<\/p>\n<p>And yeah, the same applies to JavaScript, but whatever. That&#8217;s for when I&#8217;m ready to do something with this same data I mentioned above in the browser. Gonna be fun :)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I think I mentioned earlier how I almost started writing a website in C and quickly realised that wasn&#8217;t the right tool for the job, and switched entirely to PHP. For the work I did today I needed a good set of data structures: A set of files Each with a set of english strings &hellip; <\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,4],"tags":[],"class_list":{"0":"entry","1":"post","2":"publish","3":"author-andrew","4":"post-301","6":"format-standard","7":"category-ostd","8":"category-safeforseneca"},"_links":{"self":[{"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/posts\/301","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/comments?post=301"}],"version-history":[{"count":4,"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/posts\/301\/revisions"}],"predecessor-version":[{"id":304,"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/posts\/301\/revisions\/304"}],"wp:attachment":[{"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/media?parent=301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/categories?post=301"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/tags?post=301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}