7 ms·
Erlang looks interesting. However, the only problem I have with starting in Erlang is that on the great computer language shootout, it shows that Erlang is abou
by amelius 12y ago
Erlang looks interesting. However, the only problem I have with starting in Erlang is that on the great computer language shootout, it shows that Erlang is about 10x slower than C++ on most examples. And about 3x slower than Go [1] I know that the problems on this website are not specifically "concurrent" problems, but still, even a distributed web-server must do some non-concurrent stuff at times :) Are my concerns correct/justified?
[1] http://benchmarksgame.alioth.debian.org/u32q/benchmark.php?test=all&lang=hipe&lang2=gpp&data=u32q http://benchmarksgame.alioth.debian.org/u32q/benchmark.php?t...
Edit: even Haskell seems to be about 7x faster than Erlang (according to [1]). Suddenly, Haskell looks like a good candidate for writing a distributed server :) Can somebody comment on this?
- davidw 12y agoYou wouldn't use Erlang for number crunching: you'd write some C code and communicate with that. Same as you'd likely do with Ruby or PHP or whatever.
- amelius 12y agoOkay. But let's take the example of the C++ webserver framework written by Facebook employees, which was discussed here a few days ago, [1]. This project contains lots of protocol-handling logic for HTTP/1.1 and SPDY, and beneath that TLS. Are you saying that such projects are better written in a combination of Erlang and C/C++? [1] https://news.ycombinator.com/item?id=8563199 https://news.ycombinator.com/item?id=8563199
- davidw 12y agoIt's a matter of economics. If you have the resources to throw at a problem and write it in C++, it'll probably be faster, in the end. However, it might also take longer and be less flexible. And with networked stuff, you want to be really careful, too. Facebook has the money to throw at something like that with no problems. Not everyone does.
- lostcolony 12y agoFacebook has two scaling problems. One is the code, sure, but one is also the employees. They need to be able to hire and scale out their teams, and have had to do so quite quickly. It's easier to find C++ people than it is Erlang. That is a consideration. It's why Facebook chat was originally in Erlang, then switched to PHP. Facebook already had a lot of PHP devs, they are a lot easier to find, so rather than having to bring people up to speed, or keep a dedicated team always slightly free to be able to handle issues for chat, they rewrote it in PHP. There is no magic bullet, not even Erlang. You have to weigh a variety of considerations, and pick appropriately based on them. But dismissing Erlang because a benchmark showed it to be slower is likely a mistake; dismissing it because you can't hire fast enough for it is a reasonable business decision.
- deleted 12y ago[deleted]
- tim333 12y ago>It's why Facebook chat was originally in Erlang, then switched to PHP. Facebook already had a lot of PHP devs... You sure about that? I was curious and googled and from the Quora reply below it seems they switched more from Erlang to their own C++ libraries because: "...some of the abstractions Erlang had that allowed one to transparently have a distributed system across multiple machines actually caused reliability problems -- one server in the group would fail and cause cascading issues. Secondly, we found a number of instances where Erlang wasn't scaling well to multiple cores." http://www.quora.com/When-did-Facebook-switch-away-from-using-Erlang-for-Facebook-Chat http://www.quora.com/When-did-Facebook-switch-away-from-usin...
- tegeek 12y agoWhen you say Erlang is slower than C++, You are right. It is also slower than Go. Ruby is also slower than C++ & Go, But Ruby on Rails is not only popular but a very productive web framework which can help you build your app with a productivity that C++ or Go can't match. When you write a high quality, fault tolerate system, the raw speed comes at the end. Erlang shines when you write a concurrent system plus its design is very unique. Erlang I would say isn't only a language but a whole philosophy of Software development. Once learned you can apply to many other platforms. All in its a joy to work with functional languages and Erlang is perhaps the most commercially successful functional language.
- louthy 12y ago> and Erlang is perhaps the most commercially successful functional language. Out of interest, what makes you say that? Looking at the TIOBE rankings (not that this is definitive), Erlang doesn't even make the top 20 languages, when F# and R do: http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html http://www.tiobe.com/index.php/content/paperinfo/tpci/index.... Is there a reason you think it's more successful in the commercial world? (btw, I'm a fan of Erlang - unfortunately I don't get to use it on a regular basis; other than products built on it: RabbitMQ mainly)
- jib 12y agoProbably because it is used in Ericson switches etc? A lot of stuff has been sold on the back of Erlang even though it is probably a niche language in terms of users/popularity.
- tegeek 12y agoErlang is developed by the Ericsson as a product to use for themselves. Its not a research language like Haskell but developed for a niche and when I said commercial I meant that it is designed as a commercial product. I have seen more Erlang systems than any other functional language. Just to mention one, RiakDB, a successful distributed software system is developed on top of Erlang. Actually I've yet to see any other product used by 100s or perhaps 1000s of developers developed on F# or Haskell. Not to mention, almost over 80% of telecom industry is running on Erlang.
- Ixiaus 12y agoErlang's strength is in its virtual machine which has supervision trees built-in, a built-in DNS system, built-in inter-node RPC, hot code reloading, massive concurrency, etc... I still haven't experienced a programming environment that replicates the Erlang/OTP environment. Period. Haskell is amazing, I've built my company on it, but we're also building our company on Erlang - Haskell's tooling around distributed computing is much more immature than Erlang's (although Haskell's concurrency primitives and STM libraries are extremely mature and arguably better than Erlang's actor model).
- felixgallo 12y agoout of curiosity, what's your company and/or field?
- Ixiaus 12y agohttp://plumlife.com http://plumlife.com It's a fun product :)
- lostcolony 12y agoWhich do you need sooner; fast? or correct and scalable? Erlang is built first for fault tolerance, not speed. The decisions that went into that make it also really, really good for concurrency and distribution (and so that's what it often gets touted for). The decisions that went into C++ were for speed, and compatibility with C (and all that entails). If you've got something truly resource intensive, yeah, you're going to need a lower level language. That's largely unavoidable. Erlang.org flat out states don't use it for number crunching. I'd guess that 90% of what is programmed in the wild isn't that resource intensive. And given that, I'd go so far to say that most of what I've coded in Erlang is more performant than what I've coded in Java (haven't done enough C/C++ professionally to have useful data points). Why? Because the abstractions and conventions lead me to writing better code; the tooling lets me profile and find bottlenecks more easily, and even code I tweak for performance is oftentimes cleaner than it started, rather than more arcane. Joe Armstrong, the founder of Erlang, is quoted in OTP in Action as (paraphrasing as I don't have it on hand) - "First, make it correct. Then, make it beautiful. Then, if you need to, make it performant. Chances are once you've made it beautiful you'll find it sufficiently performant". And that's been my experience with Erlang.
- amelius 12y ago> Which do you need sooner; fast? or correct and scalable? Well, if I need all of these options, then Erlang is obviously not the way to go. In that case, Erlang might work as a prototyping language. My impression is, from what I've read here, that Erlang might be the preferred tool for situations in which latency is not of paramount importance. For example, when sending text-messages over the internet, it doesn't hurt if the message takes 1 or 2 seconds longer to reach its destination. However, for a webserver, every second it takes longer to load a webpage means that you lose customers. Do you think that's a fair characterization?
- mononcqc 12y agoI've personally used Erlang in Real Time Bidding scenarios, where soft-real time constraints exist and is on the order of milliseconds. It's a fine tool for this, too.
- rakoo 12y agoI don't think your concerns are justified: the added-value of Erlang is not its speed but its reliability and its tooling to build large, stable softwares. Try to look for something that works at scales you're interested in, break it down to its components and rearrange them into a simple architecture, then only can you consider performance. It turns out the lack of performance you feared at the beginning doesn't actually happen; in the meantime you'll have built a robust software (and, if you want to start the language, you'll have learnt a whole new way to program)
- segmondy 12y agoSo? 1) There are trade offs, sometimes you trade development time for execution time. 2) Erlang is "fast"/scales, ask whatsapp 3) A lot of people worry about execution but have enough spare CPU cycles to compute the universe. 4) Benchmarks mean nothing, you must figure out what is meaningful to you. You won't compare a ferrari and a minivan? Well, you could, but yet, find that a minivan is more practical for your daily needs.
- amelius 12y ago> 2) Erlang is "fast"/scales, ask whatsapp But whatsapp is not a latency-critical application.
- Ixiaus 12y agoBy latency, what do you mean? Erlang excels with Input/Output (the VM's I/O manager is well-tuned) and network applications. I think WhatsApp is latency critical, no user ever said it's okay to have their message show up minutes after it was sent if both parties were on a good internet connection...
- davidw 12y agoIf you're controlling car brakes, no, don't use Erlang. That's called "hard real time" and mostly gets written in C or Ada or those kinds of low level things: http://en.wikipedia.org/wiki/Real-time_computing http://en.wikipedia.org/wiki/Real-time_computing For most other things, Erlang is a fine choice. In your other comments you talking about web pages. People compose those all the time with languages like PHP and Ruby, and things mostly work out. Odds are, with a lot of web stuff, a decent portion of your latency is going to be in the data layer anyway.
- wcummings 12y agoIt's silly to compare Go to Erlang, which is decades older and more mature. Erlang has built-in clusters, a robust actor framework and a powerful pre-emptive VM. It's optimized for High Availability/Low Latency applications, not "raw" speed or throughput.
- seiji 12y agoErlang is about 10x slower than C++ on most examples. damned lies and benchmarks. hipe enabled? VM tuned properly? attempt to use halfword emulator? comparing C++ the compiler optimized down to SSE2 instructions to an emulator VM loop? How much slower is Ruby than C++? Ruby runs every startup in the world. This website is the home of "DO THINGS THAT DON'T SCALE" including using fast to write programming languages at all costs even if 3 months later their "we have modules for every occasion!" design will be inadequate (you are testing your _ideas_ after all, not programming language speed, at least of the majority of use cases for people on this site). a good candidate for writing a distributed server distributed means you need monitoring. monitoring means you need supervision. supervision means you need restart strategies or failover or other promotion mechanisms. all that is built into erlang for free. optimize for _reliability_ not for speed when creating distributed systems.
- igouy 12y agoDamned innuendo. If you'd looked at that web page you'd know the answer to "hipe enabled?"
- igouy 12y agoAlso shown on the benchmarks game website -- "Most (all?) large systems developed using Erlang make heavy use of C for low-level code, leaving Erlang to manage the parts which tend to be complex in other languages, like controlling systems spread across several machines and implementing complex protocol logic." http://benchmarksgame.alioth.debian.org/dont-jump-to-conclusions.html#comparison http://benchmarksgame.alioth.debian.org/dont-jump-to-conclus...
- SkyMarshal 12y ago>Edit: even Haskell seems to be about 7x faster than Erlang (according to [1]). Suddenly, Haskell looks like a good candidate for writing a distributed server :) Can somebody comment on this? One of the best kept secrets of Haskell, it can be very fast, supports multiple concurrency/parallelism options. The Yesod team does interesting performance work on the Warp server: http://www.yesodweb.com/blog/2014/02/new-warp http://www.yesodweb.com/blog/2014/02/new-warp That said, Erlang is really fast at things it was designed for. Try downloading Zotonic or some other Erlang app, get it running, and compare to others like Rails. Sharp, responsive, fast.
- digitalzombie 12y agoThis is correct. I tried Erlang with ProjectEuler and creating prime number via sieves with Erlang takes forever compare to C++. Erlang is not something you want to do for numerical crunching. Erlang is for a very specific set of problems and it's concurrency. For any numerical stuff you can off load it to other languages...
- istvan__ 12y agoI think you raised valid concerns about the single node performance of Erlang. If you have a single node problem or you are looking for raw speed Erlang is not the best option. The fun fact is that most distributed systems don't really care about 7x slower too much. Those care about scalability, reliability and fault tolerance more. One of the most reliable software systems out there was written in Erlang and as far as I know, there are few system can match that sort of uptime[1]. There are few large scale systems in Erlang, including one Amazon AWS service[2], and bunch of others like WatsApp. I also like to mention the VM that is pretty amazing. There is per process (not an OS process) garbage collection that enables Erlang to meet with super tight SLAs in terms of latency. Ideal for high scale websites, doing the routing, but also for moving data from A to B. The concurrency model is also one of the strongest features of Erlang. Message passing is very powerful and enables you writing asynchronous code that is still easy to read and follow. Go can match that probably with channels and go routines though. If you care about single node performance you can either use NIFs[3] or if you not tied to Erlang chose a language that is focusing on that more. 1. http://ll2.ai.mit.edu/talks/armstrong.pdf http://ll2.ai.mit.edu/talks/armstrong.pdf 2. http://web.archive.org/web/20110623221347/http://www.satine.org/archives/2007/12/13/amazon-simpledb/ http://web.archive.org/web/20110623221347/http://www.satine.... 3. http://www.erlang.org/doc/tutorial/nif.html http://www.erlang.org/doc/tutorial/nif.html
- lectrick 12y agoErlang lets you write maintainable, robust code. C++ lets you write fast code. Haskell is interesting. If you want maintainable AND fast, have a look at Rust.