Friday, July 11, 2008

Yet Another Java vs Erlang Comparison

When i meet the Erlang first time I ask myself "Can I write same applications using Java?" and answer was "Yes, of course, no problem". At those time Java was my favorite language, i know it very well, and don't understand what for and why i should use another programming language.
But the time is changing, now my answer is "It depends on tasks". You can write any program using any language, maybe it will be Java, C#, C, maybe some of Python or Ruby magic, and yes, you can always use Lisp, Erlang, Haskell, Q and any other Turing complete language.

All software you can done with Java you can rewrite with Erlang, and vice versa. The difference there is inside the conception, inside the main approach of architecture of this languages.

Java is easy to read, easy to write language, but totally overloaded language :( Do you remember this megabytes of simple classes with setters and getters only? All this deep hierarchy of interfaces, abstract classes and so on.
The big plus of Java that it have big army of developers, tons of books and gigabytes of additional libraries and frameworks. Some tasks you can do faster in comparison with any other programming language. It's easy to start project using java, it's enterprise standard, like COBOL was some time ago.

Erlang, in other hand, is harder to understand, because of different paradigm. But it requires less code for equal functionality, and less debug. With Erlang you just write what you want, just algorithm of your program, no more, forget about this classes, which you really don't need, just use tuples and lists where you need. And the main feature is not a concurrency, the main is a fault tolerance.

Okay, using any other programming language you can write fault tolerant system, but with Erlang you can't write weak and fragile code :) Of course using only Java you can write system better than written on Erlang, but Erlang just give right tool for doing that easier, and nothing more. It's the reason why sometimes Java equivalent of an Erlang system requires too much time to develop, and too much PC resources to run.

Choose programming language which best fits for your needs, for current tasks. If it's easier to use Java - use Java. If it best fits for Erlang - use Erlang. And remember that you can always mix both of them in one application.

No comments: