138 points · by jacquesm · 13y ago · 43 comments
Further, Jose Valim (the language creator) is incredibly talented as a developer and has made rapid progress in iterating the language, and responds quickly to suggestions. The mailing list is also picking up momentum, folks are contributing ideas for how to make the language great.
Yuri (yrashk) has spearheaded the efforts around a package manager - http://expm.co/ which allows all Erlang Rebar packages plus Elixir packages. Still missing is "binary" package support but that's been a gripe about Erlang for a long time.
I believe in Erlang/OTP and I really believe Elixir has a bright future. In a few years there will be folks who build Elixir apps and don't bother to learn Erlang. This could really freak out the Erlang "old guard" - many are friends of mine - but they don't really care that much, as Erlang has has always been a niche musical instrument and Elixir is Erlang's ticket to Carnegie Hall.
If you're a student, check out our project ideas here: https://github.com/beamcommunity/beamcommunity.github.com/wi...
2) How does Elixir address the problems that Javascript-style metaprogramming (i.e. first-class definitions) cause for automatic program analysis? Erlang has some great analysis tools (e.g. Dialyzer) precisely because it's simple.
3) How is Elixir's first-class definition approach more useful than multi-stage programming (such as MetaOCaml: http://www.metaocaml.org/), principled syntax extension (such as CamlP4: http://pauillac.inria.fr/camlp4/), or second-class higher-order modules (such as OCaml's functors), each of which are inherently more amenable to automatic analysis?
4) Almost every "old" computer language has slowly moved away from unprincipled metaprogramming precisely because it's difficult to reason about, for both humans and computers. (C, JavaScript, and Python, to name a few, all have unprincipled metaprogramming facilities, which have been, over time, relegated to specific use patterns to maintain coder sanity.) What do we hope to gain from a new language whose raison d'être is based on this feature?
(P.S. All these points seem to apply equally well to Joe Armstrong's "erl2".)
This complaint makes little sense, because macros are expanded entirely at compile-time. Reasoning about a macro is no harder than reasoning about a higher-order function: you reason about the macro function (which is a simple transformation on some tree data structure), and the generated function. Because a macro is always expanded at compile-time, you can always expand it and inspect the generated function.
I wouldn't use Javascript and Python as examples here--those languages, suffering from their lack of meta-programming, instead encourage heinous things like monkey-patching and runtime introspection, which are insanely difficult to reason about.
Compare: what I might do in Common Lisp by writing a set of macros (and checking the expansions--just a hotkey away in my IDE) I'd do in Python by adding fields and methods to objects at runtime.
Except that C-style macro functions aren't "simple transformations on some tree data structure". They are textual transformations. Hygienic macros (à la Racket) I agree are useful and easy to reason about.
I wouldn't use Javascript and Python as examples here--those languages, suffering from their lack of meta-programming, instead encourage heinous things like monkey-patching and runtime introspection, which are insanely difficult to reason about.
I agree that the mechanism underlying their meta-programming facilities is treacherous. What I mean (and didn't state clearly) is that over the decades, these languages have developed patterns for reining in the power of their facilities (decorators in Python, and a fairly standard pattern for emulating class-bassed OO in Javascript).
Elixir uses the latter; am I missing something?
2) Dialyzer works fine on Elixir beam files. You can specify type & spec attributes just like in Erlang.
If macros worry you unduly, then Elixir is not for you. I personally prefer to use macros than type lots of boilerplate code, but yes there are some downsides.
edit: Actually I should have said reading and typing - reading boilerplate is much worse than writing it. Judicious use of macros can clarify intent for someone reading the code.
2) Dialyzer is a complete, not sound program analyzer. i.e. it will never produce a false positive, but it may allow incorrect programs through. By making definitions first-class, Elixir's module language becomes Turing-complete, moving a whole new class of bugs into Dialyzer's "false negative" category.
This problem doesn't exist with second-class definition systems such as OCaml's, because the definition language is not Turing-complete: all definitions and modules may be checked at compile time.
3) I'm not sure where macros come into play? Are you using "macros" to mean "higher-order programming tools"? If so, you're misunderstanding me -- I use metaprogramming tools all the time; I simply prefer ones which aren't Turing-complete and are therefore amenable to analysis.
It sounds like you are more interested in "CS friendly" languages, rather than "get stuff done" languages. Erlang and Elixir tend toward the latter category.
I'm generalizing a lot, and that's not to say a language can't be both, but Erlang was born of a practical need, and I think that Elixir is similar: it's not meant to be the most beautiful language out there, it's meant to be a bit more user-friendly way of utilizing the power of Erlang and OTP.
In terms of a specification, have a look at Elixir's test suite. Given that it's still being hacked on, it's probably not set in stone.
Really? It seems interesting, but I'd simply choose not to use macros in my own code. Seems like they can be avoided in most situations. There's even a heading in the introduction that says 'Don't write macros': http://elixir-lang.org/getting_started/5.html
* unprincipled metaprogramming: any metaprogramming facility whereby module-level elements (e.g. delcarations, code, modules themselves) may partake in Turing-complete transformations (hence precluding complete analysis), may generate unsound code (i.e. what would be a compile-time error), or may modify code at run-time (i.e. through dynamic scope or global mutation).
* principled metaprogramming: not the above; i.e., all code transformations terminate (allowing automatic analysis), all generated code is syntactically sound (mostly this means not having to worry about escaping stuff), and code transformations don't modify existing code.
There are probably other things and some exceptions, but that's the jist of it.
eval(), C++ templates, C macros, and prototypes are all examples of unprincipled metaprogramming.
Parametric modules (OCaml), hygienic macros (Racket), and multistage programming (MetaOCaml almost) are all examples of principled metaprogramming. (I say "almost" for MetaOCaml because code generation expressions may not terminate; but this is neither required nor encouraged, and it is easy to guard against.)
I think only OCaml functors really qualify to what you call "principled", but then - it's not the most powerful kind of metaprogramming I've seen.
The language is documented extensively under the Getting Started section of the website. It's a pretty easy read and really helps to understand the pieces of the language that make Elixir so powerful.
Why? Once it's no longer syntactically clear what's written in the host language and what's written in the DSL, it requires a very thorough understanding of both languages and their interactions to comprehend any given piece of code. And in a language where definitions can be modified at run time or have dynamic scope (it's not clear which of these two methods Elixir uses), it's often hard to tell what is or is not DSL code in the first place.
(Note: I write DSLs for a living. Except, they live apart from any host language, and thus don't allow arbitrary syntactic and semantic mixing and are thus highly amenable to automatic analysis, which is one of, if not the, primary benefit of a DSL.)
Is it wise/advisable to start with Elixir without knowing erlang, or is it better to learn erlang first?
I've been mainly doing web programming with Ruby and want to understand how Elixir is useful and why I would choose it over something else.
A secondary reason might be if you're doing pretty much everything in Javascript on the front end, a lighter server process is probably going to work out better in terms of resource usage. Myself, I'd probably still opt for Rails while developing, just because it's so fast to get something up and running with, and you're going to need to do stuff like authentication server side anyway.
If you want something that's vaguely familiar, you might have a look at Chicago Boss. It doesn't do as much as Rails, but it's fairly easy to get up and running, and the guy who built it is very friendly and helpful: http://www.chicagoboss.org/
Big runtime, VM, no mutable state (really), no direct access to memory, pattern matching, exceptions, no side effects other than sending messages, no destructive assignment, single assignment variables - that's an incomplete and subjective list of Erlang features. How much of it is even comparable to what Go offers?
I would be interested in knowing the downsides of using Elixir and its comparison with Go-lang.
It's a web framework developed and maintained by the Elixir core team, and I've had fun playing with it recently. It already supports a lot of the most common tasks when doing web development including request routing, parsing of parameters and cookies, and pre/post-request hooks.
I get the impression that the underlying VM is fairly Erlang specific, so that it's going to be difficult to do a language that doesn't come out looking at least something like Erlang, but I've never looked closely.