16 ms·
Why Erlang?
- amelius 5y agoErlang does not allow structural sharing. Sending large data structures to other processes always means serialization penalties, even if those processes run on the same CPU. Also, was the Erlang VM written in Erlang? Probably not. So I'm skeptical about the universality claims of the language.
- mehwoot 5y agoAlso, was the Erlang VM written in Erlang? Probably not. So I'm skeptical about the universality claims of the language. The article states the opposite opinion: that you should use the right tool for the right job. Change the requirements... and the spectrum-of-ridiculousness for any option changes drastically. The language matters, deeply.
- mikl 5y agoThe source for Erlang/OTP is 71.6% Erlang: https://github.com/erlang/otp https://github.com/erlang/otp - but yes, some of the lowest-level parts are written in C. As for universality, not sure where you’re getting that. No one’s saying you should use Erlang for writing device drivers or OS kernels, or the lowest-level parts of the VM. Erlang is a medium- to high-level language, and should be evaluated as such.
- tomn 5y agoFurther, there's a meta-interpreter included in the standard library: https://erlang.org/doc/man/erl_eval.html https://erlang.org/doc/man/erl_eval.html https://github.com/erlang/otp/blob/master/lib/stdlib/src/erl_eval.erl https://github.com/erlang/otp/blob/master/lib/stdlib/src/erl... It's not lisp levels of concise, but the language was not designed for that.
- knome 5y ago>Sending large data structures to other processes always means serialization penalties, even if those processes run on the same CPU the trade off is that every thread has its own gc arena that can be freely and quickly cleaned, and even better, often simply dropped entirely when the thread ends there's never a stop the world moment, only the specific greenthread that's used up all its space. OTP setup for managing processes in a standard way is also a big boon to developing in the language. if you need to mangle some giant datastructure concurrently, sure, erlang is likely to not be what you need. but if you're just trying to toss out a cluster of interconnected nodes that can handle tons of concurrency and your interprocess messages are largely queries to threads dedicated to managing some resource or lump of data, it's a great setup.
- im_down_w_otp 5y agoThe original complaint also isn't true. Large binaries sent as messages actually end up reference counted and managed by BEAM that way. This is specifically to avoid expensive memory copies and fragmentation. I don't remember what the size threshold is off the top of my head anymore, but it's "large" by 1980's standards, not by today's. Something like 64 bytes.
- toast0 5y agoHeap binaries are limited to 64 bytes as you guessed, but to be pedantic, the limit isn't only for sending, anytime you make a binary larger than 64 bytes, it will be a RefC binary, which includes the at least 255 byte binaries that can get allocated for the append optimization. [1] This particular optimization can backfire if you're not careful. If you generate short binaries that trigger this optimization and then store them in ets, it references the existing binary which has a lot of extra space. If you hit that binary:copy/1 will return a perfectly sized binary you should store in ets instead. This same kind of thing can happen if you make a sub binary from some large binary (like a service response) and store it. [1] http://erlang.org/doc/efficiency_guide/binaryhandling.html#constructing-binaries http://erlang.org/doc/efficiency_guide/binaryhandling.html#c...
- jake_morrison 5y agoThat's incorrect, there is no serialization when sending messages to processes that are on the same machine. (Otherwise it's transparent to the application, though of course there are performance impacts.) To the programmer, messages are immutable. There are, however, optimizations to reduce the performance impact, particularly for binary data. When you send a binary message that is longer than 64 bytes, it is actually stored in a shared heap and effectively only a reference is passed as a message. Similarly, when you extract a small piece out of a larger binary, you might actually get a reference to the larger data stored on the binary heap. The Erlang VM has had more than 30 years of development, and there are a lot of subtle optimizations like this which were needed to solve real world performance and scaling issues. Lack of serialization is one thing that makes e.g. the ETS key/value store built into the VM nice compared to Redis. You can just use raw data structures as keys and values. Reads and writes are under 1 microsecond.
- dudul 5y agoThis is incorrect. Functional languages are usually really good at data sharing since they promote immutability. When messages are sent to a process, the data is shared as much as possible to avoid duplication.
- toast0 5y agoUnless you do exciting things with NIFs, Erlang can't share any data except for the binary storage for RefC binaries. When you send a message, all the Erlang terms are copied for the new process, but for a RefC binary, that means a new ProcBin that references the same binary storage, not a copy of the binary storage. This copying isn't memory efficient and may not be CPU efficient, but along with immutability, it makes garbage collection simple, fast, and independent per process.
- deleted 5y ago[deleted]
- ramchip 5y agoErlang doesn't share data between processes by default (except large ref-counted binaries) because it would cause GC pauses to be global, rather than per-process.
- di4na 5y agoNot only that, the original reason was that it makes crashing and concurrency far easier. I suppose crashing is a kind of GC
- Zababa 5y agoIs Erlang good for regular web application building? If so, what's the recommended way of doing so?
- 8372049 5y agoMy personal experience is that Elixir, which runs on the Erlang VM, is great for web applications. https://elixir-lang.org/ https://elixir-lang.org/
- Zababa 5y agoI know about Elixir, I played a bit with Phoenix. I was asking about Erlang specifically.
- weatherlight 5y agotheres Chicago Boss. I'm not sure if it's still maintained though. http://chicagoboss.org/ http://chicagoboss.org/
- macintux 5y agoThe original developer was Evan Miller, who stepped away from the Erlang community a few years ago. I think others contribute, but particularly with the rise of Elixir & Phoenix I wouldn't be surprised to learn that it isn't as active as it once was.
- e_proxus 5y agoNova is an up-and-coming new framework http://novaframework.org/ http://novaframework.org/
- slezakattack 5y agoLike most things, it depends what your web application is doing. I've been working in Erlang professionally nearly 6 years, and I'm not super convinced it's great for building web apps. If you want to utilize the Erlang VM, many people have found Elixir/Phoenix to be super helpful in building their web apps. I encourage you to check that out if it piques your interest.
- 8372049 5y agoJust in case anyone hasn't seen the old classic, Erlang: The Movie https://www.youtube.com/watch?v=uKfKtXYLG78 https://www.youtube.com/watch?v=uKfKtXYLG78
- denvaar 5y agoI found this to be an accurate write up, though my experience has been Elixir, which inherits all of the traits of Erlang (to my knowledge), most notably the BEAM / OTP. Side note: That's a really cool graphic that looks to be Joe Armstrong, Robert Virding, Mike Williams with telephones? Where'd that come from?
- tyingq 5y ago>That's a really cool graphic that looks to be Joe Armstrong, Robert Virding, Mike Williams with telephones? I noticed it's 3 separate svg files. He has another post with similar line style drawings[1], no credits there either, so I assume the author did them? [1] https://www.fredrikholmqvist.com/posts/brooks-wirth-go/ https://www.fredrikholmqvist.com/posts/brooks-wirth-go/
- worthless-trash 5y agoThey really are touching tributes, Joe was always kind and courteous in all my interactions with him.
- fredrikholm 5y agoThank you, this means a lot. It was sentimental drawing Joe, despite having never met him.
- fredrikholm 5y agoThis is correct! Cheers :)
- ashton314 5y agoThis is almost certainly a reference to Erlang: The Movie [1] which is the most glorious 11 minutes of some programmers explaining how their creation works you will ever see. In the video, the three call each other to demonstrate what happens real-time in an Erlang system. For the impatient, the telephone conversation starts at about minute 3. [1]: https://www.youtube.com/watch?v=BXmOlCy0oBM https://www.youtube.com/watch?v=BXmOlCy0oBM
- salimmadjd 5y agoI took a mook Erlang class and after that, I couldn’t really get into elixir. Erlang just felt a lot more expressive
- macintux 5y agoI keep trying to learn Elixir, and clearly there are some nice features, but I’ve also found it hard to ignore how much I love Erlang’s syntax.
- ch4s3 5y agoSome people really like the Erlang syntax. Semantically they’re basically interchangeable except that Elixir has macros.
- lostcolony 5y agoAnd sane strings. And I really like Mix. That said, I generally prefer Erlang, for the syntax, for Dialyzer, and for the one less level of abstraction. But recognize the future in the space is probably Elixir, and being fluent with both is probably helpful.
- dnautics 5y agoAnd Task, and Registry. Those don't exist in erlang, and they are fantastic.
- lostcolony 5y agoEh, Task is super easy to build though, and is little more than syntactic sugar for what I rarely did anyway (and it also obfuscates the fact that the asynchronous task may never return; yes, a timeout is thankfully included, and will by default tear the task down, but I still like the explicitness of "I sent a message...I need to receive a response with a timeout"). I agree it's a solid pattern to add, just not really impactful for me. Registry I will admit to never really looking at; I assumed it was the same as Erlang's process registry. Looking at it, yeah, having that as part of the default library seems nice, though in Erlang the few times I needed more than what the process registry gave me I just used a library. Given the evolution in that space just from the time I was in Erlang, I'm actually curious how Elixir's is implemented, but regardless I agree it's nice to include a default one. So, yeah, solid additions, but I don't know if I'd phrase it that way, that they "don't exist in Erlang".
- xiaodai 5y agovery nicely arguued.
- xiaodai 5y agoOne thing that's often not discussed is the time required to understand the pros and cons of another language. If you don't know it well enough, choosing it over something else is a big RISK. The investment required to learning enough to make a decision is often not considered. That's why consultants exist.
- munchler 5y ago> Most commonly, supervisors just restart the crashed process. This effectively prevents stateful Heisenbugs, as restarting a process is cheap. I'm skeptical of this claim. How does easy restarting prevent bugs?
- sb8244 5y agoThe argument here is that the system can get itself into a state that is irreparable (and perhaps very difficult to track / debug). By crashing and having it start into a good state, the system will at least be operational again.
- ch4s3 5y agoAs long as you don’t cause a crash loop you’re golden in my experience.
- zelphirkalt 5y agoA crash loop would indicate something to be fundamentally broken in ones code. That's OK too, because then we know, we have to fix it.
- munchler 5y agoWith all due respect, that does nothing to prevent bugs. In fact, it almost seems to encourage them: "Your process crashed? Don't worry about finding and fixing the bug. We'll just restart it again."
- onlyrealcuzzo 5y agoDepends how the scale you're working on, I suppose. If you running a thousands of programs on hundreds of thousands of machines 24-7, you're bound to run into weird edge cases at the system level. Instead of worrying about and optimizing all of these edge cases, SOMETIMES it is better to just have a system that is tolerant of these edge cases by design.
- rad_gruchalski 5y agoFor me, Erlang was the ladder to functional programming. Once I’ve mastered Erlang to be able to write gossiperl (http://gossiperl.com http://gossiperl.com, not maintained in a long time), all immutable programming became easy. Maps, flat maps, recursion, no side effects, all became clear. After Erlang, I’ve enjoyed Scala a lot. Especially Akka. I do tons of go now and when I need actors in go (not very often because channels are rather straightforward), I use proto.actor: https://github.com/AsynkronIT/protoactor-go https://github.com/AsynkronIT/protoactor-go. Erlang is awesome. I can definitely recommend the “Designing for scalability with Erlang/OTP”: https://www.oreilly.com/library/view/designing-for-scalability/9781449361556/ https://www.oreilly.com/library/view/designing-for-scalabili.... This is the book which finally made me “get it”.
- olah_1 5y agoI have definitely noticed a functional programming to golang pipeline. Multiple people used Haskell and switched to Golang. Interesting anecdotes.
- dcolkitt 5y agoWhen you're dying from the compile time of functional languages, you really appreciate Golang's near instant compiles.
- dwohnitmok 5y agoThat's mainly Haskell and Scala. OCaml and Elm have as fast or faster compile times.
- anuragsoni 5y agoNot all functional languages are made alike. OCaml compile times can rival Go's.
- G4BB3R 5y agoThe cause is not being functional, but having dozens of extra features and multiple syntaxes for the same thing, both Scala and Haskell suffer from that. On the other hand OCaml is very fast and Elm is the fastest compiler I've ever seen. Edit: oops there was already a similar comment when I posted
- butterisgood 5y agoI gotta say I really enjoy these blogs. This and the Go one are really well done. Stylistically I love the look and the art is great too! Then the content is enjoyable, and the length of the posts seems just about right too. Where do I subscribe? Also, technically speaking, having shipped Erlang a few times in 3 different products (although all of them were between 2000 and 2010), that I've had the least amount of trouble developing them the REPL experience is (was?) awesome with all the Emacs integration. The ability to basically shell into a remote node and poke around live was extremely handy. People didn't like the binary logging but it seems systemd forced it down their throats anyway later. Also, I provided really easy tools to read the logs using the runtime, so they didn't care much in the long run. It was really easy to write pipe drivers for programs written in Haskell, Python and C++. I even used the Java integration back then. OTP was like a dream come true, and when you're building out an SNMP MIB, MNesia made that so stupidly easy - I couldn't believe how much faster I was going than the folks trying to plug into NetSNMP. I wish I was still working on that project sometimes. It was my favorite.
- toast0 5y ago> People didn't like the binary logging I worked on an Erlang system for nearly eight years, and don't remember any binary logs. Maybe disk_log? but afaik, we only used that for mnesia transaction logs and I don't recall ever needing to look in there.
- butterisgood 5y agoHmmm it’s been a decade so maybe I’m misremembering, but I remember needing to use the REPL or escript to access the logs of my otp services… were they simple files?
- toast0 5y agoAt least on my systems, they were just files, yeah. Maybe we did something weird, but I ran yaws from debian for something and log files were just files there too.
- 5y ago
- mybrid 5y agoThe key gap in this argument is the blank slate which I'll define to be everyone has the same type of intelligence and same level. 1. Type of intelligence. This piece drove by the functional versus procedural roadblock. Most developers don't like and don't grok functional programming. 2. Level of intelligence. Systems programming and concurrency is not for the faint of heart. When I was a TA in college the threading topics were the ones that challenged the students the most. The functional versus procedural mental capacity is very real and most developers have to fight with functional programming mentally. One cannot just ignore this decades long struggle of functional people bullying us in the procedural camp. One just has to search HK news here for functional programming and most comment sections will have this debate. Amdahl's law can be stated as make the common case fast. Functional programming is not the common case for the human mind.
- Jtsummers 5y agoAt least on (2), that's actually one of the nice things about Erlang. It removes a lot of the kinds of things that make concurrency difficult for people. There are no locks on data. There is no shared data. The model is based on message passing with actors. This means that bad designs that don't fit this model make themselves apparent (they introduce complex bookkeeping overhead or are cripplingly slow due to coordination overhead), but good designs (data flow, a process per connection, processes as isolation mechanism for state) become easy in this language and perform very well. And since processes are so key to Erlang, the green thread mechanism that BEAM provides is very fast and message passing is about the same overhead as a function call (which is to say, not much). This model of concurrency should be teachable to any 3rd year CS major in college (and possibly earlier) without breaking their brains.
- mybrid 5y agoIf one is doing async programming my experience with Promises in JavaScript is that glossing it over only works to the degree the async mostly behaves like synchronous. To quote Albert Einstein, make something as simple as possible, but no simpler. If one is writing programs for asynchronous applications abstracting them away as if the asynchronous behavior environment doesn't exist is problematic. Most developers I work with day-to-day are not designers. Fred Silverman's "The Mythical Man Month" from 1972 has a good take on this. The way I see it, languages like Erlang are amber that locks in dead code because no one except the original author can maintain it. Once code goes into maintenance mode good luck finding Erlang maintainers.
- t0mbstone 5y agoLets restate the question, but this time include Erlang as an option: You’re about to create a basic CRUD server for storing configuration files (JSON, YAML), with a web frontend. This will be used internally, with a few hundred daily users. No single file is greater than one megabyte, total storage is less than one gigabyte. You have today to complete this task. You’re given these language options: Ruby on Rails PHP Erlang C++ x86 Assembly Which one do you choose? Answer: Ruby on Rails. Not Erlang.
- pkulak 5y agoHave you tried Phoenix? It's... amazing.
- weatherlight 5y agoAs a Ruby on Rails Dev of 9 years, and an Elixir/Phoenix/OTP(erlang) dev of 2 years. I'm going to use Phoenix/Live View. Every. Single. Time.
- dudul 5y agoRoR in 2021? Dude, that's just sad.
- joelbluminator 5y agoAs opposed to Erlang?
- yakubin 5y agoMy (outsider's) perception is that Ruby came and went, whereas Erlang came and stayed. Talking about their popularity in their niches. It's also much older than RoR, so in that picture it's also likelier to stay longer, regardless of temporary fluctuations. I'd also like to learn Erlang when I find the time and use it for projects in the future, whereas Ruby was never appealing to me. Each time I had to deal with it, it created a mess in my system.
- 5y ago
- LAC-Tech 5y ago> Erlang enables you to write scalable, concurrent, distributed and fault tolerant systems with soft-realtime latency guarantees (which in my experience describes most online systems out there[3][4]). Beautiful. I do more frontend these days, but if I ever get back to the backend, I hope it's erlang. I want to use tools designed for the problem.
- de6u99er 5y ago>You’re given these language options: > >1. Ruby on Rails >2. PHP >3. C++ >4. x86 Assembly Definitely not 2.
- dreamcompiler 5y agoIt's funny. I'm a functional language bigot who loves Common Lisp, but for prototyping a basic CRUD site quickly given those 4 options I'd probably pick PHP. It's a silly language but it doesn't pretend to be otherwise and for simple stuff it just works.
- decremental 5y agoThat list omits the hidden fifth and correct answer: Python
- pjerem 5y ago> the hidden fifth and second correct answer: Python FTFY :)
- deergomoo 5y agoEh, modern PHP is pretty good. Sure the stdlib still has warts but that’s largely due to a reluctance to break compatibility. Recent versions are plenty fast enough for the majority of web purposes, it does tons of stuff out of the box, it’s share-nothing nature is a good fit for web services, and for a dynamic language it has a surprisingly strong type system.
- jayd16 5y agoMy only production experience with Erlang is trying to maintain some XEPs for ejabberd. True or not I was told this wasn't a great example of good Erlang. This post doesn't have any code at all. What's a good place to look at idiomatic Erlang that will force me to say "yes, this is much cleaner and clearer than my current language of choice"?
- h4kor 5y agoCan't say anything about the quality of the code (not an erlang programmer) but, rabbitMQ is built with Erlang. https://github.com/orgs/rabbitmq/repositories?q=&type=&language=erlang&sort= https://github.com/orgs/rabbitmq/repositories?q=&type=&langu...
- mirekrusin 5y agoRuby on Rails is not a language.
- deleted 5y ago[deleted]
- fredrikholm 5y agoAuthor here. Yesterday was amazing, today continues in the same fashion. To everyone who read and commented, thank you. This means a lot to me.
- dgb23 5y agoI don't know why I felt the urge to praise/critique your work but here we go: I think you're doing many things right! This crowd loves discussing fundamental technologies, including languages and your posts provide a really nice basis. I like the rational, tech focused, "no BS" perspective. I especially like that you bring in some history and the persons behind tech (in Go post), I personally fancy that and think it could even be more. I like posts/books with a ton of footnotes and references. It makes me feel like I'm exploring/discovering something for myself rather than "just" reading some persons opinion (although that is fine sometimes, just not always). Also your blog and posts just look nice! (Mobile could be a bit better. You should maybe scale down the SVGs responsively). The monospace font is immediately familiar and screams "Hi fellow nerd!". The colors and illustrations are warm and friendly.
- chrischen 5y agoSomewhat related: https://caramel.run/ https://caramel.run/ Ocaml on the Erlang VM!
- macintux 5y agoThere are quite a few alternative languages for the Erlang VM. I haven't checked the links in my gist for quite some time, but here's a list: https://gist.github.com/macintux/6349828#alternative-languages-targeting-the-erlang-vm https://gist.github.com/macintux/6349828#alternative-languag...
- rullopat 5y agoTo those of you that know Erlang, is the book "Learn You Some Erlang for Great Good" from 2013 still relevant in 2021?
- macintux 5y agoYes, very much. The language changes relatively slowly and cautiously.
- mro_name 5y agoThe square hole is hilarious.
- zeroc8 5y agoI've dabbled in both Erlang and Elixir. However, betting on either of them in our company would be quite risky, with no one here having real experience with a functional language. That's why we chose Go. While not the greatest language on earth, using it has turned out to be a blessing in our team (statically typed, super easy to learn, easy deployment, fast compile times). That said, I really want to try Erlang on a real project.
- erikbye 5y agoIs Erlang still relevant? Many other languages now have both language features and libraries/frameworks for doing similar things to Erlang's main selling points. Languages that are easier to work with for most, e.g. syntax wise, better tooling, etc. I see little reason to pick Erlang for any greenfield project. "Erlang enables you to write scalable, concurrent, distributed and fault tolerant systems with soft-realtime latency guarantees" Not unique to Erlang. Not even the author realizes he does not actually answer his why.
- e_proxus 5y agoI’ve yet to see a language + framework combination that has everything great from Erlang/OTP. Scala+Akka might come close, but from what I’ve heard it’s not there yet.
- mbrodersen 5y agoYes Erlang is still truly unique.