News for hackers. Stuff that matters.
Re:Why am I interested in Elixir? by inferiorhuman on Thursday July 04, 2019 @05:49PM (#20358081)
Deployments are a mess and as it is interpreted, performance is closer to Ruby than Go. I found the community to be pretty disappointing (but YMMV obviously) — it seemed more alternative oriented than the Rust community (which seems more solutions oriented).
Re:Why am I interested in Elixir? by wolf4earth on Friday July 05, 2019 @02:58AM (#20360424)
Performance is definitely not close to Ruby, this is just blatantly incorrect. Elixir and Erlang can easily hold their ground vs Go.

The BEAM was originally designed to run software for telephone switches. It's often referred to as soft realtime because it is so responsive. It has been battle-tested for now over 3 decades.

Where the BEAM falls flat is pure number crunching but it's blazing fast with binary processing (e.g. string parsing).

A fresh phoenix project where you render a nontrivial template easily reaches sub millisecond response times, without any kind of optimization.

Re:Why am I interested in Elixir? by mtarnovan on Friday July 05, 2019 @03:45AM (#20360620)
For CPU intensive tasks, performance _is_ close to Ruby, while both Ruby and Elixir are far behind Go. Soft realtime doesn't mean fast, it just means good std deviation on response time and not a lot of missed deadlines. Fortunately as the article points out, there's always Rustler if you need to optimize while still keeping BEAM crash proof.

That being said, I agree that performance for certain IO intensive applications like web servers is very good, way better than Ruby. Subjectively Phoenix feels way, way faster than Rails in development and is much more performant in production.

Re:Why am I interested in Elixir? by enraged_camel on Friday July 05, 2019 @02:31PM (#20364668)
>>For CPU intensive tasks, performance _is_ close to Ruby, while both Ruby and Elixir are far behind Go.

Yeah, but how many companies do you know of that perform heavy computations in such large scale that their choice of programming language has a noticeable effect on the result?

I mean, it might matter for tech giants like Google, who need to squeeze every bit of processing power out of their CPUs. For almost everyone else, it will be a non-issue.

Re:Why am I interested in Elixir? by mtarnovan on Friday July 05, 2019 @05:40PM (#20366100)
It's just that when you say "performance on par with Go", people might imagine you could write a 3D engine in Elixir, which obviously isn't the case.
Re:Why am I interested in Elixir? by inferiorhuman on Saturday July 06, 2019 @07:18PM (#20372621)
A fresh phoenix project where you render a nontrivial template easily reaches sub millisecond response times, without any kind of optimization.

Going from Phoenix to Rocket.rs I saw a pretty dramatic speedup on even simple pages. Phoenix was faster than the Rails version of the app, but still slower than a compiled language.

Re:Why am I interested in Elixir? by Existenceblinks on Thursday July 04, 2019 @06:12PM (#20358212)
It's not a mess. Mostly It was just unclear mixed of runtime and compile time configuration that contribute the inconvenience. Elixir 1.9 just comes up with a simple built-in release mechanism with more clear on how you put configuration.
Re:Why am I interested in Elixir? by inferiorhuman on Saturday July 06, 2019 @07:24PM (#20372643)
It's not a mess. Mostly It was just unclear mixed of runtime and compile time configuration that contribute the inconvenience. Elixir 1.9 just comes up with a simple built-in release mechanism with more clear on how you put configuration.

From the sound of it things have gotten better (by throwing out oft-touted features), but Elixir deployments are inherently far too complicated. With Go and Rust you get a single binary and a single program to run. With Java (and other languages targeting the JVM) you get a single jar archive. With Elixir you get to bundle the whole runtime and spawn a few separate supervisor processes to run even a hello world app. Lord help you if the only maintainer for the deployment tooling takes an unannounced vacation or if the various BEAM processes stop talking to each other because the stars are misaligned (and the deployment tools are minimally tested) and you can't even run an Elixir based database migration as a result.

When I started toying around with Elixir and Phoenix I'd just come off of a Clojure kick. You can get most, if not all, of the syntactical sugar that Elixir promises with other languages that all offer infinitely simpler deployments with more mature tooling. In the case of Clojure you get whatever JVM tooling you'd like.

Re:Why am I interested in Elixir? by foobarbecue on Thursday July 04, 2019 @07:44PM (#20358734)
Sounds compilicated.
Re:Why am I interested in Elixir? by TylerE on Thursday July 04, 2019 @07:59PM (#20358816)
Aren't most things that actual survive encounters with the real world?

Make it as simple as possible, but no simpler.

Re:Why am I interested in Elixir? by foobarbecue on Friday July 05, 2019 @12:38AM (#20359878)
It was a pun.
Re:Why am I interested in Elixir? by owens99 on Friday July 05, 2019 @05:28AM (#20361084)
For web development the performance is within a breath of Go and a kilometer ahead of Ruby on Rails.
Re:Why am I interested in Elixir? by erokar on Thursday July 04, 2019 @05:53PM (#20358099)
Elixir is compiled, not interpreted.
Re:Why am I interested in Elixir? by inferiorhuman on Thursday July 04, 2019 @06:06PM (#20358183)
Compiled into bytecode to be interpreted by the Erlang (BEAM) VM.
Re:Why am I interested in Elixir? by erokar on Thursday July 04, 2019 @06:14PM (#20358224)
Are we doing semantics now? Java is also compiled into bytecode, executed by the JVM. Do you consider Java an interpreted language also?
Re:Why am I interested in Elixir? by ralusek on Thursday July 04, 2019 @07:18PM (#20358583)
I think most people consider Java to be an interpreted language, it's interpreted by JVM. It's obviously somewhere in between, in the same way that JIT languages are, but it's still not native.
Re:Why am I interested in Elixir? by didibus on Thursday July 04, 2019 @08:40PM (#20359021)
Not sure about the BEAM, but Java isn't considered an interpreted language at all.

First, discerning the compilation step to IR is relevant, which is why for example, Python can be compiled or interpreted. That distinction matters. Even though it is compiled to intermediate representation, it is still compiled.

Now, with regards to the intermediate representation, Java Byte Code is also not interpreted. Java Byte Code is compiled to native machine code either Just in Time by the JVM, or Ahead of Time by the SubstrateVM. Both of these make it a compiled language.

An interpreted language never gets translated into native machine code, it gets executed by a native interpreter, and that's very different. It is more akin to using a language where you read and parse texts, and based on the text, you might execute one or more things. Now if that parsing to execution branching is powerful enough to allow Turing complete behavior, you have yourself a full blown interpreted computer language. This is not what happens in the JVM. The JVM translates Java Byte Code to native machine code Just in Time, and then the native code is run.

Re:Why am I interested in Elixir? by james-mcelwain on Friday July 05, 2019 @12:05AM (#20359755)
We should be more precise: the JVM may or may not have an interpreter. This is implementation dependent. There are JVMs that are interpreted fully and AOT compilers as well.

Hotspot includes an interpreter -- your code may be interpreted until it gets hot and gets compiled.

Still, I don't think it's fair to call Java an interpreted language since the parts that are interpreted are only during warm up or slow enough not to matter.

Re:Why am I interested in Elixir? by didibus on Friday July 05, 2019 @11:27AM (#20363255)
Yes you are right. Someone could argue Java Byte Code is interpreted, but I think colloquially, that's leading people to misunderstand the nature of modern JVMs, which as you say, will choose to either run the code in an interpreted manner, or compile it first (possibly with optimizations) dynamically at runtime. Those choices are made based on what will result in best performance and safety.

Java on the other hand is 100% compiled (to bytecode). And byte code is machine code for a non existent machine. Actually, I think Sun had built machines that could natively execute Java Byte Code. Someone could build an interpreter for it, but I'm not aware of one.

Re:Why am I interested in Elixir? by true_religion on Thursday July 04, 2019 @10:23PM (#20359406)
Java is an interpreted language because you always need a JVM to run it. I even if you distribute the runtime with your code as one package, that’s just an artificial distinction.

Regardless, interpreted does not mean bad, or poor performance for your task.

It’s a technical notion.

Most people would say Python is interpreted, even if you are only running compile python bytecode on a JIT like PyPy. That’s exactly the same situation as Java.

Re:Why am I interested in Elixir? by didibus on Friday July 05, 2019 @03:54PM (#20365333)
Java is compiled to Java byte code. It cannot be interpreted in its source form. There's nothing preventing it to be, but as far as I know, there are no interpreters for it. Python on the other hand can be interpreted from source, and that's the default behavior, making Python an interpreted language.

This makes Java a compiled language, even though it is compiled to machine code for a machine that doesn't exist. Java Byte Code is an assembly language, and in fact, Sun had at one point machines that were natively using Java Byte Code instruction sets.

Now Java Byte Code is trickier. You could consider it to be interpreted or compiled or both. It is fair to say that in general it is interpreted, but it is just as fair to say it is in general compiled.

What matters most though is to understand that modern JVMs make use of a JIT compiler and optional AOT compilers.

In the latter mode, you can compile Java Byte Code to native machine executables ahead of time or pre-runtime and no JVM beyond that point is required. So you can distribute the app as a self-contained executable. In most cases though, this will be less performant in the average and peak performance, but it will speed up the worst case, such as start time.

In the former mode, the JVM will analyze runtime behavior and based on the frequency of use of various code paths, it will either compile the code to native machine code (cache the compiled code), and then run the freshly compiled code block, or it will choose to interpret the byte code directly. This allows aggressive optimization from information which is only available or easily available at runtime when performing compilation.

Re:Why am I interested in Elixir? by TylerE on Friday July 05, 2019 @11:34PM (#20367627)
That is incorrect. I don't know of any mainstream Python implementation that has ever interpreted the code directly, except perhaps in a context like evasl(). CPython has all ways compiled to byte-code first.

Actual sourced-based interpretation is _very_ slow, and pretty rare in anything that sees meaningful real world use. Ruby was, back when it was an order of magnitude slower than Python, but no other example jumps readily to mind, and Ruby went bytecode with the release of 1.9 in 2007.

Re:Why am I interested in Elixir? by didibus on Sunday July 07, 2019 @08:23PM (#20378947)
Ah you are right, I didn't know that about Python. Since it can compile to IR on the fly though, I think it gets more tricky as well. Probably fair to consider that interpreted or compiled both. Like they say in their doc:

> Python is an interpreted language, as opposed to a compiled one, though the distinction can be blurry because of the presence of the bytecode compiler. This means that source files can be run directly without explicitly creating an executable which is then run.

OpenJDK can't do that. You need to pre-compile the source to byte code first.

Re:Why am I interested in Elixir? by TylerE on Thursday July 04, 2019 @11:38PM (#20359652)
There is nothing about Java that requires a VM. That is just how Sun decided to implement it.

GCJ, for instance, allows AOT compilation of a Java program that requires no JVM.

Re:Why am I interested in Elixir? by datashaman on Friday July 05, 2019 @01:31AM (#20360070)
It can be both. .ex files are compiled, .exs files are interpreted.