Elixir on vm R16

97 views
Skip to first unread message

Damien Krotkine

unread,
May 14, 2016, 4:54:41 PM5/14/16
to elixir-l...@googlegroups.com
Hi,

I'm currently coding quite a lot of things as Erlamg hooks in Riak for work ( Booking.com ). Riak currently runs on R16. These hooks have to be loaded and running under the same VM as Riak, so 16.

I'd like to code them in elixir instead, but Elixir requires 18. I thought about:

- using an old Elixir, but it doesn't sound right.
- try to compile Elixir on R16, and violently discard what doesn't compile, or replace it by older versions. But that sounds like a lot of work.
- use current Elixir, don't use features and modules that won't work on R16, and hope for the best.

Then, after attending ElixirConf EU in Berlin, having a lot of talks with various people, I thought maybe there are better ways to do it, that I'm unaware of.

So is there an easy way to use latest Elixir to produce beam bytecode that runs properly on an older beam VM?

Also, what is the Elixir philosophy about backward compat, in term of bytecode, feature and syntax?

Finally, maybe I'm completely wrong about all this. In this case let me know, as I'm quite new to Elixir and I have no idea what I'm doing.

Thanks,
Dams

Peter Hamilton

unread,
May 14, 2016, 8:26:06 PM5/14/16
to elixir-l...@googlegroups.com

Elixir is heavily dependent on Maps, which didn't show up until Erlang 17.

That means most of the ecosystem is not available to you, regardless of which path you choose. The benefit of Elixir at that point is basically syntactic sugar and macros. (Protocols are only partially useful without Structs, and structs require maps.)

If you plan on doing heavy macro work I'd recommend LFE. If you just want syntactic sugar, I'd say forget it and just do Erlang.


--
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/FC47A718-6C04-4FFC-8C48-767651B29DE5%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Eric Meadows-Jönsson

unread,
May 15, 2016, 1:03:17 PM5/15/16
to elixir-l...@googlegroups.com
So is there an easy way to use latest Elixir to produce beam bytecode that runs properly on an older beam VM?

There is not, Elixir uses features of OTP 17 and 18 both when compiling and running Elixir code.

> - try to compile Elixir on R16, and violently discard what doesn't compile, or replace it by older versions. But that sounds like a lot of work.
> - use current Elixir, don't use features and modules that won't work on R16, and hope for the best.

Both of these options would be very fragile and I would be very surprised if you were able to make it work.

It's very unfortunate that Basho have not yet upgraded Riak from an OTP version that is 3 years old. I think you have to wait until they do so or use an Elixir version that works on OTP 16.

Also, what is the Elixir philosophy about backward compat, in term of bytecode,  feature and syntax?

Breaking changes in the language (features and syntax) only happen on major version changes, the next major version is Elixir 2.0.0.

Regarding bytecode compatability you have to consider both version changes in OTP and Elixir. For OTP version changes Elixir gives the same guarantees as OTP itself; bytecode generated with version N of OTP will also run on version N+1, i.e. code compiled with OTP 17 will run on OTP 18. For Elixir version changes there are less guarantees, we try to keep bytecode compatibility between minor version changes but there is no promise. To be safe you should only run code with the same Elixir version it was compiled with and Mix automatically handles this for you.



For more options, visit https://groups.google.com/d/optout.



--
Eric Meadows-Jönsson

Norbert Melzer

unread,
May 15, 2016, 2:57:20 PM5/15/16
to elixir-l...@googlegroups.com
Eric Meadows-Jönsson <eric.meado...@gmail.com> schrieb am So., 15. Mai 2016 um 19:03 Uhr:
It's very unfortunate that Basho have not yet upgraded Riak from an OTP version that is 3 years old. I think you have to wait until they do so or use an Elixir version that works on OTP 16.

I haven't found anything on riaks product page mentioning that it has to be run on OTP 16, but as someone who wants participates in a programming contest regularly I do also know about some of the pitfalls with distributions… OTP 16B3 is in Ubuntu 14.04 LTS standard repositories, unless this changes the world outside of Elixir will probably consider OTP 16 the most current :( I do hope the best for 16.04 LTS but my university will not do the switch before next sommer.


Scott Ribe

unread,
May 15, 2016, 3:51:23 PM5/15/16
to elixir-l...@googlegroups.com
On May 15, 2016, at 12:57 PM, Norbert Melzer <timm...@gmail.com> wrote:
>
> I haven't found anything on riaks product page mentioning that it has to be run on OTP 16, but as someone who wants participates in a programming contest regularly I do also know about some of the pitfalls with distributions… OTP 16B3 is in Ubuntu 14.04 LTS standard repositories, unless this changes the world outside of Elixir will probably consider OTP 16 the most current :( I do hope the best for 16.04 LTS but my university will not do the switch before next sommer.

Info I found on their site:

- They made patches to R16 and want Riak to run specifically with their patched version.

- "Most of" their patches have been incorporated into later releases of Erlang.

- But they currently only support Riak on their specific R16.

So it seems that writing Elixir code to integrate with Riak is not a practical option for now. Using it from Elixir, via normal message sends to their normal standalone install, certainly still is viable. But integrating Elixir code into it, not yet.

--
Scott Ribe
scott...@elevated-dev.com
http://www.elevated-dev.com/
https://www.linkedin.com/in/scottribe/
(303) 722-0567 voice





Robert Virding

unread,
May 16, 2016, 11:58:20 AM5/16/16
to elixir-lang-core
I can just say the LFE compiles and runs on R16 as long as you don't use maps.

Robert

damien krotkine

unread,
May 16, 2016, 2:43:39 PM5/16/16
to elixir-lang-core


On Sunday, May 15, 2016 at 7:03:17 PM UTC+2, Eric Meadows-Jönsson wrote:
So is there an easy way to use latest Elixir to produce beam bytecode that runs properly on an older beam VM?

There is not, Elixir uses features of OTP 17 and 18 both when compiling and running Elixir code.

> - try to compile Elixir on R16, and violently discard what doesn't compile, or replace it by older versions. But that sounds like a lot of work.
> - use current Elixir, don't use features and modules that won't work on R16, and hope for the best.

Both of these options would be very fragile and I would be very surprised if you were able to make it work.

It's very unfortunate that Basho have not yet upgraded Riak from an OTP version that is 3 years old. I think you have to wait until they do so or use an Elixir version that works on OTP 16.

I think that they have a branch that compiles on OTP 17, but not considered production ready. Also, there is riak_core that runs on OTP 18, as part of the FIFO project. This is how Ben did his talk. Anyway we kinda have to use the real Riak for now.
 

Also, what is the Elixir philosophy about backward compat, in term of bytecode,  feature and syntax?

Breaking changes in the language (features and syntax) only happen on major version changes, the next major version is Elixir 2.0.0.

Regarding bytecode compatability you have to consider both version changes in OTP and Elixir. For OTP version changes Elixir gives the same guarantees as OTP itself; bytecode generated with version N of OTP will also run on version N+1, i.e. code compiled with OTP 17 will run on OTP 18. For Elixir version changes there are less guarantees, we try to keep bytecode compatibility between minor version changes but there is no promise. To be safe you should only run code with the same Elixir version it was compiled with and Mix automatically handles this for you.

Thanks for the useful info ! 

damien krotkine

unread,
May 16, 2016, 2:50:32 PM5/16/16
to elixir-lang-core


On Sunday, May 15, 2016 at 2:26:06 AM UTC+2, Peter Hamilton wrote:

Elixir is heavily dependent on Maps, which didn't show up until Erlang 17.

That means most of the ecosystem is not available to you, regardless of which path you choose. The benefit of Elixir at that point is basically syntactic sugar and macros. (Protocols are only partially useful without Structs, and structs require maps.)

If you plan on doing heavy macro work I'd recommend LFE. If you just want syntactic sugar, I'd say forget it and just do Erlang.


It's indeed more a "syntactic sugar" thing. I'm fine with using Erlang, but using Elixir here will probably attract more people to try it. Oh well, there will be other opportunities I guess

damien krotkine

unread,
May 16, 2016, 2:57:14 PM5/16/16
to elixir-lang-core
Good to know ! I never tried LFE and so I looked at it just now, it's actually pretty sweet :)
Reply all
Reply to author
Forward
0 new messages