Self-hosted Elixir?

387 views
Skip to first unread message

Daniel Azuma

unread,
May 23, 2016, 1:22:31 AM5/23/16
to elixir-l...@googlegroups.com
Hi all,

I've been working off and on for a few months on an Erlang->Elixir transpiler (mostly as an exercise for myself to learn Erlang semantics). I recently had the idea of applying it to the Erlang code in the Elixir core, creating a version of the Elixir compiler written completely in Elixir. Long story short, there are some caveats in the build process and a few bugs in the transpiler to work around, but today I finally got a proof of concept working and passing the tests.

So I was wondering whether the possibility of self-hosting the Elixir compiler had been discussed before. My initial thoughts were that it's often interesting to self-host; however, in this case all the core code would have to remain written in a "bootstrap" style of Elixir without access to the standard library, which might be awkward. But I was curious what else might have been discussed and what people's thoughts were.

Thanks,
Daniel

José Valim

unread,
May 23, 2016, 4:34:52 AM5/23/16
to elixir-l...@googlegroups.com
A self-hosted compiler is honestly very low priority. The benefits are very small compared to the complications required for bootstrapping the language, which would likely include keeping a list of precompiled modules in the source so we can bootstrap without having Elixir pre-installed.



José Valim
Skype: jv.ptec
Founder and Director of R&D


--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/76F2675C-E59D-40C1-80F7-D057984781E9%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Eric E.

unread,
May 23, 2016, 2:18:30 PM5/23/16
to elixir-lang-core
Is the code available publically? Would be cool to see! :)

Robert Virding

unread,
May 23, 2016, 3:52:23 PM5/23/16
to elixir-lang-core, jose....@plataformatec.com.br
It would definitely make it more difficult to download the sources and build a release. You would need quite a few pre-compiled modules to do that. Now all you need is Erlang which you need anyway to run the system.

Robert

Daniel Azuma

unread,
May 24, 2016, 12:38:46 AM5/24/16
to elixir-lang-core
José and Robert: That does make a lot of sense. It's probably more practical for languages like Go where a binary distribution is the norm, less so for Elixir where building from source is more the norm.

Eric: Not yet. I'm still trying to fix some issues in erl2ex that I had to hack around (gruesomely) in order to get it to convert Elixir's source properly. Maybe in another week or so I'll be able to post reasonable instructions for how to do it, if anyone wants to tinker with it.

Thanks for the comments!
Daniel

Eric Merritt

unread,
May 24, 2016, 10:45:41 AM5/24/16
to elixir-l...@googlegroups.com, jose....@plataformatec.com.br
Just to reinforce Robert. I did a language on the VM called Joxa a few years ago. Originally the compiler was written in Erlang. At some point we converted it to be self hosting and the cost of maintenance went up considerably. Even worse, it made it *much* harder for folks not familiar with the infrastructure to get up to speed and contribute. There is some upside to being able to say that a language compiles itself. However, in the beam environment I think that upside is vastly outweighed by the downsides. 

Sent from ProtonMail, encrypted email based in Switzerland.


Ólafur Arason

unread,
May 25, 2016, 4:40:04 PM5/25/16
to elixir-lang-core
Hi everybody,

I just wanted to throw my two cents in because I'm working on
something similar to Daniel but a little bit different approach.[1]

I feel like Erlang is the the real heart of the Elixir system and I think
the sentiments that are expressed in this thread really show that. I
feel like there is a lot of flexibility that Elixir get's by having its
bootstrapping in Erlang, since features are introduced in Erlang's
otp first. It get's really when you are conceptually dealing with code
that is making the same code which I've had a bit experience with
keeping my code dogfoodable :) You might also introduce bugs
that go undetected and then fixing them is a pain since you are
using the same code to build everything.

This saying it maybe apt:
Everyone knows that debugging is twice as hard as writing a
program in the first place. So if you're as clever as you can be when
you write it, how will you ever debug it?
- Brian Kernighan

But that doesn't mean that the thought hasn't crossed my mind and
maybe an automatic version would be a nice experiment. But the
beauty is that Erlang is almost the same as Elixir under the hood,
almost :) It's not like Java to Clojure and Scala. An I think it's cool
that Erlang and LFE can do interesting things with Elixir. [1]

If I've read the source code of LFE correctly then lfe_trans has us
two already beat translating Erlang to LFE :) Maybe we should to
a vanilla Beam to anything. Maybe with Behaviours. Though the
problem I'm facing is mostly that it's just a lot of things to implement :)

Regards,
Olaf


[2] A cool project would be making automatic
binding for Elixir code with nice Erlang syntax.
Reply all
Reply to author
Forward
0 new messages