{"id":383,"date":"2008-03-02T00:19:00","date_gmt":"2008-03-02T00:19:00","guid":{"rendered":"http:\/\/sdi.thoughtstorms.info\/?p=383"},"modified":"2008-03-02T00:19:00","modified_gmt":"2008-03-02T00:19:00","slug":"383","status":"publish","type":"post","link":"https:\/\/sdi.thoughtstorms.info\/?p=383","title":{"rendered":""},"content":{"rendered":"<p>Here&#8217;s a question &#8230; why is Erlang so ugly?<\/p>\n<p>I don&#8217;t mean that in a pejorative way (not much, anyway). I mean, I really love what it does. I&#8217;m totally impressed with Erlang&#8217;s power and simplicity. I&#8217;m writing simulations which are about a quarter of the size of the Python equivalent. So this is not to be taken as a criticism of Erlang which I&#8217;m definitely committing myself to, this year. Rather this is some random speculation about programming language aesthetics.<\/p>\n<p>Erlang is wonderfully concise. And yet, somehow, unlike Python, unlike Haskell, it just doesn&#8217;t come across as beautiful. It&#8217;s confusing. It looks cluttered.<\/p>\n<p>A couple of lines look fabulous. But the <b>simplicity doesn&#8217;t scale<\/b>.<\/p>\n<p>At first guess, there seem to be three issues.<\/p>\n<p>a) As people have noted, the record type is ugly. It is. And counter-intuitive to use in patterns (although I may just be stupid).<\/p>\n<p>b) In general I think it&#8217;s good and brave thing to take a stance *against* objects. But I haven&#8217;t figured out how to do encapsulation (data-hiding, abstract types)<\/p>\n<p>Sure, I can define polymorphic functions (one clause at a time per input type) which is a lot shorter and more powerful than overloaded methods in Java. But it has the effect of jumbling all my data-types together. Which just feels *wrong* to me. (Of course, maybe that&#8217;s some residual OOness in my thinking.)<\/p>\n<p>But I think that may be part of the bigger issue :<\/p>\n<p>c) erlang doesn&#8217;t seem to have resources for &#8220;programming in the large&#8221;. And, ironically, because erlang is so powerful, that problem becomes visible at a smaller scale &#8211; precisely because in erlang &#8220;large&#8221; programs are actually &#8220;small&#8221;.<\/p>\n<p>Or rather, the only resource is &#8220;modules&#8221; (which means breaking up into multiple files &#8211; always an extra overhead.)<\/p>\n<p>But if you avoid breaking things up into files, the opposite problem becomes apparent. I can do the equivalent of a small Java class (let&#8217;s say something around 50-80 lines) in about 6 to 10 lines of Erlang. But 10 lines of erlang is too small for a separate file. So I&#8217;ll add the next 10 line packet of functionality to the same file. By the time I&#8217;m up to 4 or 5 packets that would be handled as different classes in Java or Python I may have written only about 50 lines of code &#8230; but it&#8217;s all running together!<\/p>\n<p>There&#8217;s no higher level of organization to distinguish and separate the code. In Python I often put 5 or 6 small-medium classes in a single file or around 300-500 lines. But the indentation and editor make these reasonably distinct and identifiable. In contrast, my equivalent 200 lines of Erlang have no visual cues to break them up. I can&#8217;t use functions as a visual element because pretty much every line is a new function  (except when I&#8217;m doing I\/O, which has its own &#8220;issues&#8221;).<\/p>\n<p>I&#8217;m left with using comments but my editor (Komodo), excellent in many ways, doesn&#8217;t actually know Erlang and so doesn&#8217;t colour them differently. And, in general, because functions are powerful, they *are* short : one or two lines. But those lines are typically much denser than Python. Even if a dedicated editor would colourize them, I&#8217;m not convinced that&#8217;s such a big win at this density. On the other hand, I don&#8217;t want to artificially scatter them out into multiple lines. I&#8217;m not trying to recreate Python with a slightly less appropriate syntax. I want to take advantage of Erlang&#8217;s power and conciseness. <\/p>\n<p>But I wonder what the right aesthetics for a language as high level, dense and abstract as Erlang is. Haskell looks cleaner to me &#8211; maybe because it does abstract data-types right. But can it solve the problem of organizing your larger-scale things? Lisp is no role-model. ML and its offspring have always repelled me visually. (Nothing can be more ugly, dispiriting and patronizing in a programming language than an explicit &#8220;begin&#8221; statement.)<\/p>\n<p>Suggestions, anyone?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s a question &#8230; why is Erlang so ugly? I don&#8217;t mean that in a pejorative way (not much, anyway). I mean, I really love what it does. I&#8217;m totally impressed with Erlang&#8217;s power and simplicity. I&#8217;m writing simulations which are about a quarter of the size of the Python equivalent. So this is not [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[11,105,135,164,238],"class_list":["post-383","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-aesthetics","tag-design","tag-erlang","tag-functional-programming","tag-language-design"],"_links":{"self":[{"href":"https:\/\/sdi.thoughtstorms.info\/index.php?rest_route=\/wp\/v2\/posts\/383","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sdi.thoughtstorms.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sdi.thoughtstorms.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sdi.thoughtstorms.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sdi.thoughtstorms.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=383"}],"version-history":[{"count":0,"href":"https:\/\/sdi.thoughtstorms.info\/index.php?rest_route=\/wp\/v2\/posts\/383\/revisions"}],"wp:attachment":[{"href":"https:\/\/sdi.thoughtstorms.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=383"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sdi.thoughtstorms.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=383"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sdi.thoughtstorms.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=383"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}