{"id":497,"date":"2011-04-18T22:09:41","date_gmt":"2011-04-18T22:09:41","guid":{"rendered":"http:\/\/www.gmarwaha.com\/blog\/?p=497"},"modified":"2014-09-14T04:47:47","modified_gmt":"2014-09-14T04:47:47","slug":"ceylon-yet-another-jvm-language-yajl","status":"publish","type":"post","link":"https:\/\/www.gmarwaha.com\/blog\/2011\/04\/18\/ceylon-yet-another-jvm-language-yajl\/","title":{"rendered":"Ceylon \u2013 Yet Another JVM Language (YAJL)"},"content":{"rendered":"<p>It is all too familiar, yet surprising; it is all too common, yet shocking; to see <a href=\"http:\/\/en.wikipedia.org\/wiki\/List_of_JVM_languages\">yet another JVM language<\/a> created to scratch an itch that countless other languages are already trying to solve. <\/p>\n<p>Of course Java is not expressive enough, it doesn\u2019t have higher order functions, it doesn\u2019t have modularity as a language feature, it doesn\u2019t have clean way to do meta-programming, it does NOT have so many more features we love and does have so many more features we hate. These are most of what has frustrated Gavin King (the creator of Hibernate) as well and made him think about creating a new language \u2013 <a href=\"http:\/\/relation.to\/Bloggers\/TalkAtQConBeijing\">Ceylon<\/a>. A few days ago, in his presentation at the <a href=\"http:\/\/www.qconbeijing.com\/\">QCon Beijing 2011<\/a> he gave a first glimpse of the language features and a few code snippets showing its beauty. <\/p>\n<p>A lot of people have raised concerns and expressed strong opinions questioning a need for yet another language. <a href=\"http:\/\/www.scala-lang.org\/\">Scala<\/a> fans, the <a href=\"http:\/\/groovy.codehaus.org\/\">Groovy(++)<\/a> camp, <a href=\"http:\/\/gosu-lang.org\/\">Gosu<\/a> and <a href=\"http:\/\/fantom.org\/\">Fantom<\/a> hackers all think that Ceylon does not solve anything that is not solved already or could have been solved by just contributing to one of these modern languages. So, I am not going to be yet another anti Ceylon person but I am not a fan either.<\/p>\n<p>I believe Ceylon is more of a strategic approach from RedHat than a language created out of true necessity. They would like to control a language and its followers like most other giant companies do today. Think about it. Oracle is controlling Java, Microsoft is controlling C# (VB, VC++, etc), Google is controlling Go (and Python?), Apple is controlling Objective C and VMWare is controlling Groovy. RedHat has just joined the party leaving only IBM out of the equation. I am sure they are not far behind. I just sincerely hope that they adopt an existing language (Scala?) instead of creating yet another one. <\/p>\n<p>That said, the language itself looks cool, is very expressive and adds a lot of syntactic sweetness to say the least. I just wanted to highlight a few of them here\u2026 <\/p>\n<p><strong>String Interpolation:<\/strong><br \/>\nIn Java we use a &#8220;+&#8221; sign for string concatenation. There is no concept of string interpolation in either Java or Scala. In Groovy ${} construct is used while Ruby uses #{}. Ceylon\u2019s syntax looks better than either of them though. It uses a &#8220;space&#8221; as the string interpolation operator and the result looks a lot cleaner.  Don\u2019t you think?<\/p>\n<pre class=\"prettyprint\">\r\nString name;\r\nwriteLine(\"Hello \" name \"!\");\r\n<\/pre>\n<p><strong>Getter:<\/strong><br \/>\nIn Java we use getXxx() methods to get a property value. This looks like a method and quacks like a method and does not give the feeling of accessing a property at all. In Ceylon, a very simple innovation has resulted in much more succinct getter methods. They have decided to get rid of paranthesis to both define and call getter methods. Look at the last line of the following snippet. Does it look like a method call? NO. Does it look like accessing a property? Of course it does !!!<\/p>\n<pre class=\"prettyprint\">\r\nclass Counter() {\r\n   variable Natural count := 0;\r\n   shared Natural currentCount {\r\n      return count;\r\n   }\r\n}\r\nCounter c = new Counter();\r\nwriteLine(c.currentCount);\r\n<\/pre>\n<p><strong>Constructor:<\/strong><br \/>\nIn Ceylon there is no separate constructor. The class definition itself acts as a constructor as shown below. Since, there is no concept of method or operator overloading in Ceylon there is no necessity to have a separate method and this syntax induces a &#8220;Why didn\u2019t I think of this before ?&#8221; moment\u2026 The necessity for an overloaded method is handled by optional \/defaulted parameters concept. So, you don\u2019t have to worry too much about it\u2026<\/p>\n<pre class=\"prettyprint\">\r\nclass Customer (String cName, Natural cAge, Date cDob) {\r\n   variable String name :=  cName;\r\n   \u2026\r\n}\r\n<\/pre>\n<p><strong>Builder:<\/strong><br \/>\nWith the support of named parameters and higher-order functions and quite a bit of thought, a syntactic structure as expressive as given below has been achieved in a general purpose and statically typed language like Ceylon.<\/p>\n<pre>\r\nHtml hello {\r\n   Head head { title = \"Squares\"; }\r\n   Body body {\r\n      Div {\r\n         cssClass = \"greeting\";\r\n         \"Hello\" name \"!\";\r\n      }\r\n   }\r\n<\/pre>\n<p>And then there is the rest of the now so common features like array like access to Sequences (equivalent of List in Java), higher-order functions, Closures, Currying, etc<\/p>\n<p>It is not like I loved every single feature of Ceylon. I hated a few, but I am reserving that rant for another post&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It is all too familiar, yet surprising; it is all too common, yet shocking; to see yet another JVM language created to scratch an itch that countless other languages are already trying to solve. Of course Java is not expressive enough, it doesn\u2019t have higher order functions, it doesn\u2019t have modularity as a language feature, it doesn\u2019t have clean way to do meta-programming, it does NOT have so many more features we love and does have so many more features we hate. These are most of what has frustrated Gavin King (the creator of Hibernate) as well and made him... <br \/><a class=\"moretag\" href=\"https:\/\/www.gmarwaha.com\/blog\/2011\/04\/18\/ceylon-yet-another-jvm-language-yajl\/\">Continue reading...<\/a>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26,16,7,3,15,24,21,22],"tags":[],"class_list":["post-497","post","type-post","status-publish","format-standard","hentry","category-ceylon","category-groovy","category-hibernate","category-java","category-modern-languages","category-objective-c","category-ruby","category-scala"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.gmarwaha.com\/blog\/wp-json\/wp\/v2\/posts\/497","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gmarwaha.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gmarwaha.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gmarwaha.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gmarwaha.com\/blog\/wp-json\/wp\/v2\/comments?post=497"}],"version-history":[{"count":10,"href":"https:\/\/www.gmarwaha.com\/blog\/wp-json\/wp\/v2\/posts\/497\/revisions"}],"predecessor-version":[{"id":797,"href":"https:\/\/www.gmarwaha.com\/blog\/wp-json\/wp\/v2\/posts\/497\/revisions\/797"}],"wp:attachment":[{"href":"https:\/\/www.gmarwaha.com\/blog\/wp-json\/wp\/v2\/media?parent=497"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gmarwaha.com\/blog\/wp-json\/wp\/v2\/categories?post=497"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gmarwaha.com\/blog\/wp-json\/wp\/v2\/tags?post=497"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}