views:

2709

answers:

13

Have you actually "tried" (means programmed in, not just read an article on it) Erlang and decided against it for a project? If so, why? Also, if you have opted to go back to your old language, or to use another functional language like F#, Haskell, Clojure, Scala, or something else then this counts too, and state why.

+12  A: 

A number of reasons:

  • Because it looks alien from anyone used to the C family of languages

  • Because I wanted to be able to run on the Java Virtual Machine to take advantage of tools I knew and understood (like JConsole) and the years of effort which have gone into JIT and GC.

  • Because I didn't want to have to rewrite all the (Java) libraries I've built up over the years.

  • Because I have no idea about the Erlang "ecosystem" (database access, configuration, build etc).

Basically I am familiar with Java, its platform and ecosystem and I have invested much effort into building stuff which runs on the JVM. It was easier by far to move to scala

oxbow_lakes
Did you try any of the Java/Erlang bridges out there?
Zubair
Nope! I really liked scala from the start so saw no need to look further afield
oxbow_lakes
I'd looked at Ruby and Groovy a little. Erlang looks so alien to anyone used to the C language-family; I discounted it early on
oxbow_lakes
A lot of languages don't look like C. How is that a real pro or con in any case? I certainly understand syntactical preferences, but I'm not sure I see how that is a real reason to completely disregard a language.
Rayne
I should have been more explicit - if one has been working in C-like languages for >10 years, a completely alien syntax is, um, alien and daunting.
oxbow_lakes
These are good reasons and all, but have you actually programmed in Erlang? The question was directed at people who actually tried it out.
Daniel
It's a fair point - I decided not to because of the reasons above. IMHO they are probably the same reasons most people from a Java background have for not making such a change
oxbow_lakes
@Rayne - I see you are 16. I presume this means you : 1) don't have 10 years worth of legacy code you're not keen on throwing away and 2) aren't afraid of new things, unlike old codgers like me
oxbow_lakes
Some good points there, but the overall answer reads "I decided against it because I really like java" to me.
ZJR
@Rayne Sheesh, cool down. Chris wasn't attacking you. Much on the contrary, he simply stated that, by virtue of being younger, you haven't been doing the same for for as long, and are much adaptable to change. If anything, he is treating your age as an advantage. One which he doesn't share any longer, so his perspective on things are different. Consider, for instance, driving. Someone who has driven in the US for 30 years is going to have much more trouble adapting to driving in the UK than someone who has just started driving.
Daniel
@Daniel - Heh. I misread his 2) point. In my defense, it sounded like an attack the way I read it. I apologize for overreacting. Guess it's my inexperience. ;)
Rayne
Erlang has had years of effort put into it (and it's GC) for 24 years.
Adam Lindberg
@ZJR - the answer is not I really like Java (on the contrary, I now do everything in scala), but I really *understand* the JVM! Java and the JVM are not the same thing!
oxbow_lakes
@Adam - a good point
oxbow_lakes
@oxbow_lakes I see your point. I'm in the same boat, on the other side of the island. People don't understand how one can like the JVM but dislike the language it was created for. Clojure (and Scala for that matter) are great additions to the JVM, and I wouldn't use Java unless forced to at gunpoint. :D
Rayne
+6  A: 

Whilst I haven't, others on the internet have, e.g.

We investigated the relative merits of C++ and Erlang in the implementation of a parallel acoustic ray tracing algorithm for the U.S. Navy. We found a much smaller learning curve and better debugging environment for parallel Erlang than for pthreads-based C++ programming. Our C++ implementation outperformed the Erlang program by at least 12x. Attempts to use Erlang on the IBM Cell BE microprocessor were frustrated by Erlang's memory footprint. (Source)

And something closer to my heart, which I remember reading back in the aftermath of the ICFP contest:

The coding was very straightforward, translating pseudocode into C++. I could have used Java or C#, but I'm at the point where programming at a high level in C++ is just as easy, and I wanted to retain the option of quickly dropping down into some low-level bit-twiddling if it came down to it. Erlang is my other favorite language for hacking around in, but was worried about running into some performance problem that I couldn't extricate myself from. (Source)

Will
Wow, I dod't even know that Erlang ran on the IBM Cell BE processor. So is Erlang best for large memory environments?
Zubair
Erlang is an excellent choice for high-reliability high-transaction environments. Chances are, phone calls you make all go via Erlang-based switches. And its increasingly common in internet servers, such as MQ and Jabber.
Will
MSalters
+5  A: 

I know Erlang since university, but have never used it in my own projects so far. Mainly because I'm mostly developing desktop applications, and Erlang is not a good language for making nice GUIs. But I will soon implement a server application, and I will give Erlang a try, because that's what it's good for. But I'm worring that I need more librarys, so maybe I'll try with Java instead.

Jonas
Didn’t Joe Armstrong specifically write an Erlang adapter for the X windows protocol? I had thought that writing GUIs in Erlang would actually be quite easy.
Konrad Rudolph
Yes, you can write GUI in Erlang. But it's tricky if you want something more advanced like WPF.
Jonas
+7  A: 

For me, the fact that Erlang is dynamically typed is something that makes me wary. Although I do use dynamically typed languages because some of them are just so very problem-oriented (take Python, I solve a lot of problems with it), I wish they were statically typed instead.

That said, I actually intended to give Erlang a try for some time, and I’ve just started downloading the source. So your “question” achieved something after all. ;-)

Konrad Rudolph
+3  A: 

Used it for a message gateway for a proprietary, multi-layered, binary protocol. OTP patterns for servers and relationships between services as well as binary pattern matching made the development process very easy. For such a use case I'd probably favor Erlang over other languages again.

yawn
+10  A: 

I have used Erlang in a few project already. I often use it for restful services. Where I don't use it however is for complex front end web applications where tools like Ruby on Rails are far better. But for the powerbroker behind the scenes I know of no better tool than Erlang.

I also use a few applications written in Erlang. I use CouchDB and RabbitMQ a bit and I have set up a few EJabberd servers. These applications are the most powerful, easiest and flexible tools in their field.

Not wanting to use Erlang because it does not use JVM is in my mind pretty silly. JVM is not some magical tool that is the best in doing everything in the world. In my mind the ability to choose from an arsenal of different tools and not being stuck in a single language or framework is what separates experts from code monkeys.

PS: After reading my comment back in context I noticed it looked like I was calling oxbow_lakes a code monkey. I really wasn't and apologize if he took it like that. I was generalizing about types of programmers and I would never call an individual such a negative name based on one comment by him. He is probably a good programmer even though I encourage him to not make the JVM some sort of a deal breaker.

Jon Gretar
I think the whole "It doesn't look like C so is therefore bad" was a bit worse than the JVM bit. It's all just a little silly if you ask me. But nobody is asking me, so I should just keep quiet in my corner. ;)
Rayne
+4  A: 

The JVM is not a tool, it is a platform. Although I am all in favour of choosing the best tool for the job the platform is mostly already determined. Unless I am developing something standalone, from scratch and without the desire to reuse any existing code/library (three aspects that are unlikely in isolation already) I may be free to choose the platform.

I do use multiple tools and languages but I mainly targetg the JVM platform. That precludes Erlang for most if not all of my projects, as interesting as some of it concepts are.

Silvio

Silvio Bierman
+17  A: 

I've only written one program in Erlang, about 400 SLOC (real lines, not comments or whitespace) so it would probably take a few thousand SLOC in C++. I'd say that puts it comfortably outside the "toy program" range.

What I learned from that is that the best reason not to use Erlang is when you simply cannot commit to the functional way of programming.

I read an anti-Erlang blog rant a few weeks ago, and one of the author's criticisms of Erlang is that he couldn't figure out how to make a function return a different value each time he called it with the same arguments. What he really hadn't figured out is that Erlang is that way on purpose. That's how Erlang manages to run so well on multiple processors without explicit locking. Purely functional programming is side-effect-free programming. You can arm-twist Erlang into working like our ranting blogger wanted, adding side effects, but in doing so you throw away the value Erlang offers.

Pure functional programming is not the only right way to program. Not everything needs to be mathematically rigorous. If you determine your application would be best written in a language that misuses the term "function", better cross Erlang off your list.

Warren Young
The Erlang approach to `rand()` : http://xkcd.com/221/
MSalters
`rand()` makes for an interesting study in function design. Many standard C library functions are non-reentrant, `rand()` among them. A lot of C library implementations provide reentrant alternatives, for good reason. (The C library on the machine I'm using now provides the purely functional reentrant `rand_r()`, for instance.) Erlang does provide the C-like `random:uniform()`, but also the purely functional `random:uniform_s()`. One should use the version that makes the internal state explicit in both languages.
Warren Young
+27  A: 

I returned to Haskell for my personal projects from Erlang for the simple virtue of Haskell's amazing type system. Erlang gives you a ton of tools to handle when things go wrong. Haskell gives you tools to keep you from going wrong in the first place.

When working in a language with a strong type system you are effectively proving free theorems about your code every time you compile.

You also get a bunch of overloading sugar from Haskell's typeclass machinery, but that is largely secondary to me -- even if it does allow me to express a number of abstractions that would be terribly verbose or non-idiomatic and unusable in Erlang (i.e. Haskell's category-extras).

I love Erlang, I love its channels and its effortless scalability. I turn to it when these are the things I need. Haskell isn't a panacea. I give up a better operational understanding of space consumption. I give up the magical one pass garbage collector. I give up OTP patterns and all that effortless scalability.

But its hard for me to give up the security blanket that, as is commonly said, in Haskell, if it typechecks, it is probably correct.

Edward Kmett
Notice that Haskell doesn’t even need the write-compile-execute cycle since it supports REPL (e.g. via `ghci`). For me, that unites the best from the worlds of static (~ally typed) and dynamic languages.
Konrad Rudolph
@Konrad Haskell's REPL has limits, however. For one thing, you can't write `data` definitions in it. You need to write it to a file, and have the REPL process that. Both ghci and hugs.
Daniel
@Daniel Fortunately, given the nature of what I do, most of the time when I want to work in a REPL, I can turn to a bunch of Functor/Bifunctor combinators from category-extras to build up the data type I need. That said, there is at least one set of ghci macros out there that can load data definitions dynamically during the session by appending to a temporary Haskell source file for you and reloading it.
Edward Kmett
Good point! I have heard that it's tricky to add a type system to Erlang, mainly because of the Hot Code Swap. Armstrong and Peyton Jones talk about types in Haskell and Erlang in this interview: http://www.infoq.com/interviews/armstrong-peyton-jones-erlang-haskell
Jonas
@Sanoj: thanks for linking the interview, it rocks. I’m reading Seibel’s “Coders at Work” at the moment where both have a say but having them next to each other is just incredible. To quote a /. limerick: +5 (insightful) – http://xkcd.com/301/
Konrad Rudolph
What's your opinion on dialyzer and TypEr when it comes to having a type system in Erlang? Granted it's not the same (Success Typings rather than Hindley-Milner Type inference), but in my experience it does a good job on preventing software defects.
I GIVE TERRIBLE ADVICE
The success typing approach is something I've been spending a lot of time playing with in another environment -- the concepts are weakly similar to Dana Xu's ESC/Haskell or Neil Mitchell's Catch. They are definitely better than nothing! Any time you add a type check/inference pass you prove theorems (even weak ones) about your code and most broken code will fail even fairly simple checks. My general opinion of them is that they are useful and fit the flavor of the language, but due to the platform they can't go far enough for me to feel the same level of safety.
Edward Kmett
+19  A: 

We use Haskell, OCaml and (now) F# so for us it has nothing to do with lack of C-like syntax. Rather we skip Erlang because:

  • It's dynamically typed (we're fans of Haskell's type system)
  • Doesn't provide a 'real' string type (I understand why, but it's annoying that this hasn't been corrected at the language level yet)
  • Tends to have poor (incomplete or unmaintained) database drivers
  • It isn't batteries included and doesn't appear to have a community working on correcting this. If it does, it isn't highly visible. Haskell at least has Hackage, and I'd guess that's what has us choosing that language over any other. In Windows environments F# is about to have the ultimate advantage here.

There are probably other reasons I can't think of right now, but these are the major points.

Shaun
But have you tried to use it?
Daniel
Oh yes, plenty - though never for a production application. When evaluating a new technology, it helps to build some in-house tools with it first. We like Erlang, and have no problem running products that use it such as RabbitMQ, but prefer the technologies listed above for the reasons already outlined.
Shaun
+6  A: 

I Decided against using Erlang for my project that was going to be run with a lot of shared data on a single multi-processor system and went with Clojure becuase Clojure really gets shared-memory-concurrency. When I have worked on distributed data storage systems Erlang was a great fit because Erlang really shines at distributed message passing systems. I compare the project to the best feature in the language and choose accordingly

Arthur Ulfeldt
+4  A: 

While I liked many design aspects of the Erlang runtime and the OTP platform, I found it to be a pretty annoying program language to develop in. The commas and periods are totally lame, and often require re-writing the last character of many lines of code just to change one line. Also, some operations that are simple in Ruby or Clojure are tedious in Erlang, for example string handling.

For distributed systems relying on a shared database the Mnesia system is really powerful and probably a good option, but I program in a language to learn and to have fun, and Erlang's annoying factor started to outweigh the fun factor once I had gotten past the basic bank account tutorials and started writing plugins for an XMPP server.

+1  A: 

I love Erlang from the concurrency standpoint. Erlang really did concurrency right. I didn't end up using erlang primarily because of syntax.

I'm not a functional programmer by trade. I generally use C++, so I'm covet my ability to switch between styles (OOP, imperative, meta, etc). It felt like Erlang was forcing me to worship the sacred cow of immutable-data.

I love it's approach to concurrency, simple, beautiful, scalable, powerful. But the whole time I was programming in Erlang I kept thinking, man I'd much prefer a subset of Java that disallowed data sharing between thread and used Erlangs concurrency model. I though Java would have the best bet of restricting the language the feature set compatible with Erlang's processes and channels.

Just recently I found that the D Programing language offers Erlang style concurrency with familiar c style syntax and multi-paradigm language. I haven't tried anything massively concurrent with D yet, so I can't say if it's a perfect translation.

So professionally I use C++ but do my best to model massively concurrent applications as I would in Erlang. At some point I'd like to give D's concurrency tools a real test drive.

caspin