{"id":4759,"date":"2015-02-19T03:19:40","date_gmt":"2015-02-19T02:19:40","guid":{"rendered":"http:\/\/emilkirkegaard.dk\/en\/?p=4759"},"modified":"2015-02-19T03:19:40","modified_gmt":"2015-02-19T02:19:40","slug":"java-even-worse-than-php","status":"publish","type":"post","link":"https:\/\/emilkirkegaard.dk\/en\/2015\/02\/java-even-worse-than-php\/","title":{"rendered":"Java, even worse than PHP!"},"content":{"rendered":"<p>I&#8217;m taking a course in object orientated programming (OOP) at university. I always hated OOP, it seemed like an overly difficult way to doing the stuff I wanted. Now, the course I&#8217;m taking is in Java, an old language. It&#8217;s even worse than PHP. It&#8217;s extremely verbose and lacks even basic high-level functions.<\/p>\n<p>There is perhaps no simpler way to show this than to compare Hello World programs:<\/p>\n<p>Java:<\/p>\n<pre>public class javaprogram {\r\n\u00a0\u00a0 \u00a0public static void main(String[] arg) \r\n\u00a0\u00a0 \u00a0{\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0 <strong>System.out.println(\"Java sucks\");<\/strong>\r\n\u00a0\u00a0 \u00a0}\r\n}<\/pre>\n<p>I&#8217;ve highlighted the extreme verbose print command. Compare with the normal print() or echo() in PHP.<\/p>\n<p>R\/Python\/Ruby\/others:<\/p>\n<pre>print(\"R is good!\");<\/pre>\n<p>Luckily, one can be tricky and simply begin writing abbreviated functions for these and then load them every time one<del> willingly uses<\/del> is forced to use Java. E.g.:<\/p>\n<pre>\/\/reduce desire to an hero\r\npublic static void print(Object string) {\r\n\u00a0\u00a0 System.out.println(string);\r\n}<\/pre>\n<p>And so on. One could basically import all the common functions from say Python\/R and make some of the Java go away. :)<\/p>\n<p><strong>Number sequences<\/strong><\/p>\n<p>Another example. I wanted to stop using for loops because Java&#8217;s are overly verbose and annoying. So I think, no problem, I&#8217;ll just switch to the generally smarter foreach loop. All I need is a integer sequence function. In R, this is easy, just &#8220;1:5&#8221; will generate a list with (1,2,3,4,5). Python has range(5) which gives (0,1,2,3,4). Surely there is a built-in function for such an obvious function right? Right? From Googling it, <a href=\"http:\/\/stackoverflow.com\/questions\/10242380\/short-and-sweet-sequence-of-integers-in-java\">it appears not<\/a>.<\/p>\n<p><strong>One good thing<\/strong><\/p>\n<p>Reading the book has made me understand the kind of things OOP can be good for, making games where the inheritance stuff is very useful.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m taking a course in object orientated programming (OOP) at university. I always hated OOP, it seemed like an overly difficult way to doing the stuff I wanted. Now, the course I&#8217;m taking is in Java, an old language. It&#8217;s even worse than PHP. It&#8217;s extremely verbose and lacks even basic high-level functions. There is [&hellip;]<\/p>\n","protected":false},"author":17,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2089],"tags":[2092,1529],"class_list":["post-4759","post","type-post","status-publish","format-standard","hentry","category-programming","tag-java","tag-suicide","entry"],"_links":{"self":[{"href":"https:\/\/emilkirkegaard.dk\/en\/wp-json\/wp\/v2\/posts\/4759","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/emilkirkegaard.dk\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/emilkirkegaard.dk\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/emilkirkegaard.dk\/en\/wp-json\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/emilkirkegaard.dk\/en\/wp-json\/wp\/v2\/comments?post=4759"}],"version-history":[{"count":1,"href":"https:\/\/emilkirkegaard.dk\/en\/wp-json\/wp\/v2\/posts\/4759\/revisions"}],"predecessor-version":[{"id":4760,"href":"https:\/\/emilkirkegaard.dk\/en\/wp-json\/wp\/v2\/posts\/4759\/revisions\/4760"}],"wp:attachment":[{"href":"https:\/\/emilkirkegaard.dk\/en\/wp-json\/wp\/v2\/media?parent=4759"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/emilkirkegaard.dk\/en\/wp-json\/wp\/v2\/categories?post=4759"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/emilkirkegaard.dk\/en\/wp-json\/wp\/v2\/tags?post=4759"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}