Live data from Hacker News

What can I only do in Erlang?

erlang.org

131–140 of 173 posts

Re: What can I only do in Erlang?

#131
Someone correct me if I'm wrong, but it seems to me the main advantage of Erlang over something like Go, is that the logic for your entire cluster is contained in Erlang itself, as opposed to in some external scripts or configuration. What I mean specifically is that it seems like you don't need anything like Mesos or Kubernetes to monitor and relaunch processes across the cluster. OTP within Erlang does that for you.

Now whether this is worth the tradeoff of switching to a new language and framework (OTP is a framework even if it is lightweight to use) depends on the team I suppose.

This is just based on my reading of the docs. I hope someone more experienced will correct me if my take is wrong here.

Re: What can I only do in Erlang?

#132

Earlier quoted context omitted.

That about Joe is not strange actually as he has never been a C-programmer. Before coming to the lab he was a fortran programmer.

People in racket are using typep racket, clojure has annotation, in lisp you can declare types and sbcl infers them. Haskell also is fond of types. Perhaps in erlang types are not so important because you try to decompose the problem in small parts and hence is not so important to declare types?

Erlang has Dialyzer, which is an optional type checker and discrepancy analyzer.

Re: What can I only do in Erlang?

#133

Not sure I agree with the conclusions: 1. Binaries: this isn't really an issue. We ship the JVM with anything that we do in Java. Unzip, run, done. Go is probably ideal there but it doesn't support embedded resources without some hideous hacks so you're still going to be deploying more than just a single binary in a lot of cases. CLR is pretty good at this as well. 2. Sockets: 0MQ/WCF/JMS/any stream abstraction wired…

Comparing "features" side-by-side is a naive, "consumer-mindset" approach. Instead one should try to understand design-decisions and how they fit together - the subtleties. Devil is in the details. For example, having an receive expression and pattern-matching and simple typing (like everything is a term - self-evaluating or an expression or a list of terms ) makes your code shorter, self-evident, easy testable. Now…

> Erlang runs on 16Mb RAM

I imagine you are referring to the full stack, as JVM and CLR implementations do exist which require a few hundred KB.

As for the rest I fully agree.

Re: What can I only do in Erlang?

#134
post #92
post #25

Earlier quoted context omitted.

I would take a look at akka instead. Distributed actor concurrency and local STM.. Oh my.

All built on the JVM which has its own set of issues compared to BEAM or natively compiled Go or Rust.

There are commercial JVMs that offer compilation straight to native code ahead of time.

AOT compilation is also being discussed for OpenJDK 9, or 10 depending on the overhaul progress.

Re: What can I only do in Erlang?

#135
post #111

Earlier quoted context omitted.

Yeah, both Java and (currently) Scala are imperfect host languages as well. Global GC is not ideal. Everything's not golden, and it's not better than Erlang in general, but Scala+akka is really awesome for a lot of tasks. For most people looking at Erlang, Scala+akka will be more suitable, I think. Still, if I were to write something powering some really reliability-heavy stuff (like telecom stuff) I would probably g…

Scala+akka may be easier for Java programmers looking at Erlang, and perhaps enough so to make it "more suitable" when you look at net cost/benefit. OTOH, coming from other directions -- particularly dynamic languages -- Erlang may be easier, as well as its other advantages.

For people coming from dynamic languages, especially Ruby, it's worth looking at Elixir. Elixir runs on the Beam VM (same as Erlang) and is fully Erlang compatible while fixing many of Erlang's warts, including offering a Ruby-inspired syntax and macros. Here's a fun introduction: http://howistart.org/posts/elixir/1

Re: What can I only do in Erlang?

#136
post #125

Earlier quoted context omitted.

That about Joe is not strange actually as he has never been a C-programmer. Before coming to the lab he was a fortran programmer.

He learned prolog at the lab?

We all learned prolog at the lab, well at least those of us who used prolog.

Re: What can I only do in Erlang?

#137

Earlier quoted context omitted.

Scala+akka may be easier for Java programmers looking at Erlang, and perhaps enough so to make it "more suitable" when you look at net cost/benefit. OTOH, coming from other directions -- particularly dynamic languages -- Erlang may be easier, as well as its other advantages.

For people coming from dynamic languages, especially Ruby, it's worth looking at Elixir. Elixir runs on the Beam VM (same as Erlang) and is fully Erlang compatible while fixing many of Erlang's warts, including offering a Ruby-inspired syntax and macros. Here's a fun introduction: http://howistart.org/posts/elixir/1

I agree that its worth looking at (and I need to find time to take another swing at it), but I have to admit that when I came into it from Ruby (having also had some experience with Erlang, but not need), I found the Ruby-like syntax with very different semantics an obstacle rather than a help -- it had a kind of "uncanny valley" effect.

Re: What can I only do in Erlang?

#139
here is a daemon that runs forever

    foo()-> 
       foo().
1. processes as tail-recursive functions

it's callstack will never grow. you can have multiple of these running and the scheduler will still split work between them. a process is a tail-recursive function where the argument becomes its state. a process ceases to exist when it stops being tail-recursive. erlang's distributed computing strengths can in ways be attributed to tail-recursive approach to network programming & beginning with concurrency in mind. everything else came as a side-effect.

for anyone interested for more examples of expressiveness/composition, this is from my talk at functionalconf http://www.slideshare.net/bosky101/recursion-and-erlang/43

2. Node's or machine's are first-class citizens.

you can decide to replicate data over to them, make the data on one node location-transparent, or decide to just abstract it all in a distributed system.

3. binary patten matching

you can pattern match not just [A,B] = [1,2] but also contents of A,B. or do gaurds against contents . eg if the contents of this binary variable begin with "foo".

4. you never have to import any header or module. the vm uses all modules available in its (ebin) path. big cyclic dependency headaches good bye.

5. as many schedulers as there are cores in your machine. (configurable)

6. hot code swapping.

albeit little contrived for the beginner on production systems.

7. otp

comes bundled with the fsm,client-server,etc skeletons called "otp", the same that runs 40% of the worlds telecom traffic.

~B

PS: the root link describes more such features you may find useful

Re: What can I only do in Erlang?

#140

Earlier quoted context omitted.

> 1. Binaries: this isn't really an issue. We ship the JVM with anything that we do in Java. Unzip, run, done. Go is probably ideal there but it doesn't support embedded resources without some hideous hacks so you're still going to be deploying more than just a single binary in a lot of cases. CLR is pretty good at this as well. Not sure you read / understood what that point was about, due to its native binary types,…

Yes thank you for the clarification. My point is more that regardless of the syntax, runtime or approach, the same outcome is possible without having to enter a risky niche. PHP does nothing, but if you throw it in a prefork MPM module in apache, it does that. Sure we don't let it physically crash and we handle the exception at the base of the thread and decide what to do, but the outcome is the same. Java error hand…

The difference is that Erlang decouples the handler of the exception (the supervisor) from the caller.

In most other languages, the caller is forced to deal the the exception, which litters the responsibility to resolve the exception across all consumers.

This is qualitatively different from erlang

Post reply on HN