<div class="gmail_quote">On 11 November 2011 05:28, Max Bourinov <span dir="ltr"><<a href="mailto:bourinov@gmail.com">bourinov@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
As a former java programmer i confirm that i became 180% happier when<br>
i started to write code in Erlang.<br>
<br></blockquote><div><br></div><div>At work I still write code in Java, as well as Erlang and a few others. I have the same experience, that when programming in Erlang I enjoy coding a lot more and tend to spend more time and energy focussed on getting the architecture right and representing/understanding the domain properly. I am a productive java developer, but it takes a lot more effort and the tooling is a prerequisite to getting that level of productivity, rather than a choice - in Erlang I *can* choose to use ErlIDE, but vi/emacs will do fine as well. The same isn't true for building large java applications. </div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
All those fansy things like spring, orm, hibernate, jmx, and many<br>
other strange words are absolutelly useles when it comes time to build<br>
a system that "never" fails - memory leaks and unexpected gc ruins all<br>
java advantages, moreover i love parallel programs which is almost<br>
impossible wrire in java.<br>
<br></blockquote><div><br></div><div>Most server side java programs are "parallel" though right? Anything you deploy in a web container (like Tomcat) is running in a multithreaded environment, and despite the difficulties in writing correct multithreaded programs in an imperative language, it is possible to do it. It's just a lot more work for the programmer. Don't forget you can create deadlocks and race conditions in your Erlang code to, unless you think carefully about the design. It's just that these situations come up less often, usually *only* when you've got side effects or global/shared state. By contrast, in java/c++/etc you have side effects and shared state *all* the time (with every line of code), which is why they're harder work to get right.</div>
<div><br></div><div>So let's try and be very clear - in Erlang it is easier to write correct parallel programs.</div><div><br></div><div>I'm under the impression that memory leaks can occur in *any* language that allows dynamic allocation. Java and Erlang both have a VM that does so and incorrect programs can cause this to grow uncontrollably causing the VM to run out of memory. I've seen *plenty* of threads on this list talking about beam "out of memory" problems. And for the record, there is no *perfect* GC that I'm aware of, all of them make trade offs for various reasons.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">11.11.2011, в 9:06, Matti Oinas <<a href="mailto:matti.oinas@gmail.com">matti.oinas@gmail.com</a>> написал(а):<br>

<div class="HOEnZb"><div class="h5"><br>
> People have taken too literally the phrase don't reinvent/reimplement<br>
> the wheel. They will use the wheel even if it is wrong size and is<br>
> triangle shaped instead of a circle.<br>
><br>
</div></div></blockquote><div><br></div><div>Yes this is particularly prevalent in the java/.net world and is often the source of the bloat-ware that Mr O'Keefe witnessed first hand. Having said that, there are some things in the java world that are actually better, not least of which is having some degree of standards around commonly used APIs. Java developers have one official API for database access, logging, instrumentation and monitoring (JMX that was mentioned earlier) and so on. It is, quite frankly, a pain in the backside having to keep rewriting your code when you decide to move from log4erl to lager, or from postgres to mysql - and god forbid that you have to support multiple databases or APIs, because then the pain is really on. We *should* try to fix this IMO.</div>
<div><br></div><div>Also if you're building a product to sell, then your consumers *probably* want to have some level of control over things like logging levels, rolling log files and so on. O&M teams DO NOT want to have to learn 10 million different ways of doing this for every application, and it is there that java applications have an advantage because they pretty much *all* use the same configuration(s). This is also true for profiling and monitoring (i.e., everyone just uses JMX, whether the application is doing anything special or not), though hopefully the super-cool dtrace support for Erlang will eventually standardise that bit for us. </div>
<div><br></div><div>Standardisation can be a good thing and the consistency and standardisation of APIs in java actually drives *down* cost and complexity, which is why so much of the world is still using it, despite the terrible bloat that often comes with it. It is a nod to just how incredible Erlang/OTP is that Erlang programs are still easier (and more fun) to build.   </div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="HOEnZb"><div class="h5">
> --<br>
> /*******************************************************************/<br>
><br>
> try {<br>
>    log.trace("Id=" + request.getUser().getId() + " accesses " +<br>
> manager.getPage().getUrl().toString())<br>
> } catch(NullPointerException e) {}<br>
><br>
> /*******************************************************************/<br>
><br>
> This is a real code, but please make the world a bit better place and<br>
> don’t do it, ever.<br>
><br>
</div><div class="h5"><br></div></div></blockquote><div><br></div><div>Yes well that is just bad code, as you say. I've written some *terrible* Erlang code especially when I was first learning. Abusing the process dictionary, doing far too much local error handling and defensive coding, etc. The secret here is to mentor and educate developers to encourage them to adopt good behaviours. </div>
<div><br></div><div>One of my favorite Dijkstra quotes, describes why I think that Erlang is better, but also perhaps why java is still far more successful: "Simplicity is a great virtue but it requires hard work to achieve it and education to appreciate it. And to make matters worse: complexity sells better".  </div>
<div><br></div></div>