News for hackers. Stuff that matters.
Re:Phoenix 1.0 by mands on Friday August 28, 2015 @01:40PM (#10136820)
Slightly off-topic, but can someone familiar with both Elixir and Erlang explain what Elixir provides in comparison to Erlang.

I'm looking into using Erlang for a new project that requires extensive scaling and concurrency and am coming from a functional background so may be more comfortable with the traditional Erlang syntax. However it seems that perhaps more development and activity is happening on the Elixir side of things and it may be more productive in terms of tooling, libraries (such as Phoenix and Ecto), and support.

Thanks!

Re:Phoenix 1.0 by yellowapple on Friday August 28, 2015 @02:54PM (#10137257)
A lot of Elixir folks try to claim that the syntax doesn't matter. They're lying to themselves: of course the syntax matters. Not only is it much easier and more consistent for the human brain to parse (even more so than Ruby, in my opinion; unlike Ruby, everything that should take a block - like 'def' and 'defmodule' - do (pun intended) take a block), but it also goes above and beyond what Erlang offers with things like its pipe operator ('|>'), macro support, defaulting to binary strings (if you use double-quotes; single quotes are Erlang-style lists of characters, which - while they have their uses (aside from the obvious interoperability with Erlang code) - aren't really as efficient), and (in my observation) greater consistentcy between what you can do in the REPL ('iex') and what you can do in actual source files.

They're both great languages, but I think Elixir is a bit more refined, learning from Erlang's advantages and disadvantages and improving on them. It's basically what you get if you watch "Erlang The Movie II: The Sequel" [0] and actually try to write a language for Ruby hipsters with excellent taste in noserings while humming along to Bananarama :)

[0]: https://www.youtube.com/watch?v=rRbY3TMUcgQ

Re:Phoenix 1.0 by kungfooguru on Friday August 28, 2015 @01:51PM (#10136884)
I'm a long time Erlang programmer and still prefer Erlang. But anyone who asks about web programming I point to Phoenix. So if you are doing a web app, or have a web component, I'd suggest Elixir and Phoenix for that part :)

Erlang developer tooling does need work. But we are getting there, we have a new build tool http://www.rebar3.org/ that also combines forces with Elixir for the package management https://github.com/hexpm/rebar3_hex

Re:Phoenix 1.0 by jake_morrison on Friday August 28, 2015 @10:42PM (#10138839)
Coming from an Erlang background, I found it very easy to get started with Elixir, it has the same underlying concepts and power as Erlang. Elixir takes it to the next level, though. The syntax eliminates annoyances in the Erlang system, e.g. having to fool around with punctuation and work with binary strings. The Elixir standard library gets rid of inconsistencies in the Erlang libraries and it is organized to allow easy chaining via the |> operator. Then it has features like protocols which give the encapsulation and polymorphism of OO without needing objects. And finally we have macros, which are the "right way" to do metaprogramming, allowing ease of use at a Rails level without the mess underneath.

Another big thing is that the Elixir community focuses on ease of use and out of box experience the way the Rails community did. So it's easy to get started and all the pieces generally fit together well, e.g. the mix build tool works great, as does the hex package manager, and relx release builder. With Erlang it's more DIY. We have recently converted a big Erlang project to use mix as the build tool, and it just eliminated a bunch of cruft. The interop between Elixir and Erlang is easy. So you get the best of both worlds, the ease of use of Elixir with the power of Erlang, with the highly mature runtime and libraries. And with Phoenix we get a web framework with world class ease of use.

Re:Phoenix 1.0 by unoti on Friday August 28, 2015 @02:05PM (#10136964)
> can someone familiar with both Elixir and Erlang explain what Elixir provides in comparison to Erlang.

The syntax is nicer, but that's just a bonus. The real game-changer to me about Elixir vs Erlang is its macro system. This gives you runtime code execution and runtime code generation, similar to what makes LISP to powerful.

There's a large amount of boilerplate involved in creating an OTP server, as you know if you've done any Erlang. Elixir's macro capabilities completely eliminate all the boilerplate.

The source to both Elixir and Phoenix are quite elegant and educational to browse, and demonstrate this runtime code generation aspect very well. It's straightforward in Elixir to introspect code, represent that code as data structures, manipulate those data structures, then generate or execute that code, as you can in LISP.

Elixir also gives a number of excellent tools that streamline the support process over vanilla Erlang. For example, Elixir's runtime tooling automatically manages dependencies for you (similar to node's npm), and automatically maintains the application string that you need to provide for all OTP applications. It also has improved capabilities for testing, which are also made possible by the amazing macro generation capabilities.

> I'm looking into using Erlang for a new project that requires extensive scaling and concurrency and am coming from a functional background so may be more comfortable with the traditional Erlang syntax

Elixir's syntax is still just as functional. They support a regular if statement, unlike Erlang, but generally it's just as functional as Erlang. Elixir eliminates a number of needless chores from Erlang, such as having to end some lines of code with a comma, and others with a period, and then shuffling punctuation around whenever you add or remove lines of code. That's a task I used to do literally a hundred times a day in Erlang that I don't have to do at all any more.

Re:Phoenix 1.0 by vezzy-fnord on Friday August 28, 2015 @02:23PM (#10137064)
You can do reasonable metaprogramming in Erlang with the syntax_tools and stdlib interfaces. Most famously was bringing back parameterized modules via a parser transformation for tools like BossDB to support ActiveRecord-like ORM patterns.

I've looked at OTP the Elixir way and I do not see any real boilerplate reduction. The application-project dichotomy and the opinionated integration with a tool like Mix is also policy over mechanism.

rebar3 does fine dependency management given its constraints of having to unify packages coming from disparate sources.

The syntax is not nicer. It is a jarring conceptual mismatch to put Smalltalk-ish Ruby syntax over a language that eschews excessive monkey patching and dynamism like Erlang.

Re:Phoenix 1.0 by haddadell on Friday August 28, 2015 @03:20PM (#10137368)
> You can do reasonable metaprogramming in Erlang with the syntax_tools and stdlib interfaces.

You can also do concurrency in Ruby. It is not the same as doing concurrency in Erlang though. The same way doing metaprogramming with syntax tools, parse transforms and what not is nowhere close to a macro system.

> I've looked at OTP the Elixir way and I do not see any real boilerplate reduction.

So please look again? Take a look at Elixir's agents or tasks and explain how it doesn't lead to more readable and cleaner code than the GenServer equivalent in Erlang for the cases they fit. You could maybe point other criticism but saying "no real boilerplate reduction" just shows you didn't really try or care to give it a try.

> It is a jarring conceptual mismatch to put Smalltalk-ish Ruby syntax over a language that eschews excessive monkey patching and dynamism like Erlang.

This sentence is specially ironic given that Erlang inherits from Prolog, which is quite different semantically from Erlang, instead of using the more tradicional ML families. Also Erlang is pretty much a very dynamic language.

I am a Haskell developer, I hate Ruby syntax and I programmed Erlang for a year. I would still choose Elixir over Erlang any day mostly because of the tooling, typeclass like polymorphism and the new abstractions (Task and Agent).

Re:Phoenix 1.0 by vezzy-fnord on Friday August 28, 2015 @03:55PM (#10137530)
The same way doing metaprogramming with syntax tools, parse transforms and what not is nowhere close to a macro system.

I'd wager that's because no one has written tooling to make it compelling to the common programmer. Same with release management for a long time, and hot code reloading. I'd understand if you said that basic substitution macros are nowhere close to actual AST macros, but Erlang has far more than that.

Take a look at Elixir's agents or tasks and explain how it doesn't lead to more readable and cleaner code than the GenServer equivalent in Erlang for the cases they fit.

Those are sugar. It's not like you can't define your own behaviors in Erlang. People do it all the time, there's so many good libraries that go beyond stock OTP. I should really switch an entire language because of default libraries?

This sentence is specially ironic given that Erlang inherits from Prolog, which is quite different semantically from Erlang

Only traces. The Prolog influence of Erlang is severely overrated by a lot of people these days.

Also Erlang is pretty much a very dynamic language.

It ain't no Smalltalk. The runtime is very dynamic, and the typing is loose, but the Erlang language itself not so much, which I think is a strength.

I am a Haskell developer, I hate Ruby syntax and I programmed Erlang for a year.

Good for you, chap.

Re:Phoenix 1.0 by haddadell on Friday August 28, 2015 @05:11PM (#10137860)
> I'd understand if you said that basic substitution macros are nowhere close to actual AST macros, but Erlang has far more than that.

Fair point.

> Those are sugar. It's not like you can't define your own behaviors in Erlang. People do it all the time, there's so many good libraries that go beyond stock OTP.

There is a very strong point in providing those as default. If Erlang didn't ship with a gen_server, we would see hundreds of different gen_server implementations and no real consensus. By providing one, all Elixir developers are familiar with it.

In a way, you could define everything Elixir provides as a sugar, after all, it runs in the same VM. Sure, an Erlang library could provide all unicode manipulation functions... but having it all sorted out for me is a great deal. The same way Erlang solves many other things which makes it attractive to many.

That leads me to...

> I should really switch an entire language because of default libraries?

No. But if it provides a really good standard library altogether (unicode, structs, enumerable, etc) with an excellent tooling and powerful abstractions (like protocols), then surely yes.

Re:Phoenix 1.0 by vezzy-fnord on Friday August 28, 2015 @05:33PM (#10137966)
But if it provides a really good standard library altogether (unicode, structs, enumerable, etc) with an excellent tooling and powerful abstractions (like protocols), then surely yes.

I can't comment on excellent tooling. Language-specific package managers never tend to be excellent, which is why I appreciate the limited scope of a tool like rebar.

Again, you are overvaluing a language based on the libraries it exports, rather than on its true a priori merits. Some languages are designed for intense extensibility and expressiveness, like Forth. An argument based on laundry listing abstractions to dissuade someone from using it would be rightfully dismissed as nonsense, since it is their prerogative to define the threshold of abstraction they need.

Furthermore, I've noticed that people who tend to promote languages based on the mere reductionist listing of abstractions tend to not understand those abstractions well themselves, treating it as dark wizardry.

Erlang is definitely malleable to reasonable extensibility. See Erlando which adds Miranda/Haskell-like monadic patterns to Erlang.

Re:Phoenix 1.0 by haddadell on Saturday August 29, 2015 @04:35AM (#10139447)
Except I am not. What would be Erlang really without OTP? Would you really want to implement all the building blocks in every new project? You are dismissing the importance behind stdlib while defending a language that is known specially because of its standard library (Erlang/OTP).

Also rebar3 is pretty much the same in scope as Mix (elixir tool). Which proves the point you are criticizing Elixir while using the same criteria to praise Erlang.

I am not saying Elixir is better or worse, just pointing you are extremely biased in your comments.

Re:Phoenix 1.0 by hansihe on Friday August 28, 2015 @01:44PM (#10136854)
I have worked a bit with elixir and erlang lately, but i'm not means an expert. I have to say, the biggest advantage elixir has against erlang for me is the macro system. It seems to manage to combine a ruby-like syntax with lisp-like macros, and it works incredibly well. Because of this it is very easy to create DSLs.
Re:Phoenix 1.0 by sasa555 on Friday August 28, 2015 @03:08PM (#10137318)
I've been doing full-time Erlang for five years, and I personally prefer Elixir.

Elixir is semantically close to Erlang the language, and allows you to take advantage of all the great benefits of Erlang/OTP.

It's benefit is dev's productivity. Creating OTP applications and releases is simpler, and there are tools in the language (e.g. macros, polymorphism via protocols, tidier stdlib), and around it (e.g. Hex package manager, mix tool, doc tests) that make developers' life simpler.

All of this is possible in plain Erlang, but it's more cumbersome, and sometimes requires home-brewed solutions.

Notice that I'm not discussing syntax at all, because it (mostly) doesn't matter. I actually like the Prologness of Erlang. What I dislike is that some chores require more of my time and yak shaving, compared to Elixir.

Re:Phoenix 1.0 by lobster_johnson on Saturday August 29, 2015 @04:16PM (#10141233)
My impression is that Erlang/Elixir is excellent at the kind of decentralized networked services that people usually use it for, but less ideal for many other things. What's your experience with Erlang as a "day to day" language for more mundane stuff?

For example, a lot of my work tends to revolve around working with data. Processing large batches of data, parsing (often it comes in the shape of XML), transforming, filtering, ingesting it into databases, and so on. I can do this easily in Ruby, but performance issues has driven me to use Node.js or Go for new projects. With Go it's ridiculously easy to build efficient pipes that can parallelize each step to my liking, backpressure included. It's also trivial to build small command-line tools as well as specialized daemons. I have a world of libraries (and bindings to C libraries) at my disposal: AWS, image processing, transcoding, PostgreSQL, XML, JSON, it's all there. Go is also decent at Unicode and string manipulation.

I'm not wild about Go's performance, and everything I have seen of Erlang indicates that its performance is closer to that of Ruby or Node.js. Any comments here? Whenever I need to fire up anything related to batch processing in Ruby or Node.js, things take forever. Erlang's advantage here might be that it's easier to spawn remote processes to parallelize the workload.

Re:Phoenix 1.0 by mands on Friday August 28, 2015 @03:05PM (#10137308)
Thanks all for your responses, really helpful!
Re:Phoenix 1.0 by eggy on Saturday August 29, 2015 @02:42PM (#10140947)
Don't forget LFE (Lisp Flavored Erlang), if you prefer a Lisp syntax to a Ruby syntax that runs on the BEAM, as I do, although Elixir has great momentum right now.