Elixir components

40 views
Skip to first unread message

Graeme Defty

unread,
Mar 21, 2015, 9:53:25 AM3/21/15
to chica...@googlegroups.com
As a means of learning Elixir I decided to 'port' the Jade compiler I wrote to the new beam VM language.

I was never really thrilled with the Jaderl compiler I created, partly I think because it generated Erlang source which then had to be compiled. I always intended to cut out that intermediate form, but it looked to me that Elixir had much cleaner internals and it would therefore be easier to generate beam bytecode directly.

This turned out to be exactly the case and the new compiler works beautifully. I have not yet extended it to add any new capabilities, but it works fine as a stand-alone Elixir application and working with Elixir is a joy, so I do intend to enhance this version and support it as a production-ready component of CB (which it never really was before - nor claimed to be).

Now the tricky part . . . integrating it into the CB environment.

My first step was to change boss_template_adapter_jade.erl to call 'Elixir.Jadelix':compile, rather than jaderl:compile.

However, on performing 'make' there is some problem (though no message) compiling Jadelix itself, because no .beam file is produced and as a result, compiling a jade template gives:

<pre>
ERROR: pre_compile failed while processing /home/graeme/projects/egolf/dev/jadelix: {'EXIT',
    {undef,
        [{'Elixir.Jadelix',compile,
             ["src/view/hello/about.jade",jadelix_view_hello_about_jade,
              [{out_dir,"ebin"}]],
             []},
         {boss_template_adapter_jade,compile_file,3,
             [{file,
                  "src/boss/template_adapters/boss_template_adapter_jade.erl"},
              {line,19}]},
         {boss_load,'-load_views_inner/3-fun-1-',5,
             [{file,"src/boss/boss_load.erl"},{line,404}]},
         {boss_load,load_views,3,[{file,"src/boss/boss_load.erl"},{line,395}]},
         {boss_load,'-make_all_modules/3-fun-1-',3,
             [{file,"src/boss/boss_load.erl"},{line,84}]},
         {lists,map,2,[{file,"lists.erl"},{line,1237}]},
         {lists,map,2,[{file,"lists.erl"},{line,1237}]},
         {boss_load,load_all_modules,3,
             [{file,"src/boss/boss_load.erl"},{line,62}]}]}}
</pre>


I compiled Jadelix elsewhere and copied in the .beam file by hand, but when it is used to compile a jade template it raises an error trying to access the Elixir IO module.

<pre>
ERROR: pre_compile failed while processing /home/graeme/projects/egolf/dev/jadelix:
{'EXIT',
    {undef,
        [{'Elixir.IO',puts,[<<"Opening file ${filename}">>],[]},
         {'Elixir.Jadelix',add_file,3,[{file,"lib/jadelix.ex"},{line,187}]},
         {'Elixir.Jadelix',compile,3,[{file,"lib/jadelix.ex"},{line,88}]},
         {boss_template_adapter_jade,compile_file,3,
             [{file,
                  "src/boss/template_adapters/boss_template_adapter_jade.erl"},
              {line,19}]},
         {boss_load,'-load_views_inner/3-fun-1-',5,
             [{file,"src/boss/boss_load.erl"},{line,404}]},
         {boss_load,load_views,3,[{file,"src/boss/boss_load.erl"},{line,395}]},
         {boss_load,'-make_all_modules/3-fun-1-',3,
             [{file,"src/boss/boss_load.erl"},{line,84}]},
         {lists,map,2,[{file,"lists.erl"},{line,1237}]}]}}
make: *** [compile] Error 1
</pre>

I assume that the Elixir modules are not loaded. I have followed the steps for allowing Elixir use in my application and not sure what to try next.

Any thoughts?

g


Tim McNamara

unread,
Mar 21, 2015, 8:55:26 PM3/21/15
to chica...@googlegroups.com

Great work!

--
You received this message because you are subscribed to the Google Groups "ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chicagoboss...@googlegroups.com.
Visit this group at http://groups.google.com/group/chicagoboss.
To view this discussion on the web visit https://groups.google.com/d/msgid/chicagoboss/CAKF5fiAXrGU8DRi5PCp0tdnU_KNmn2e%2BcEkJU_E1tDLOrTMr_A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Graeme Defty

unread,
Mar 22, 2015, 8:09:50 AM3/22/15
to chica...@googlegroups.com
So I decided to start again with a clean install of CB.

The first things was just to get Elixir working for normal stuff - controllers, etc.

I proceeded as follows:

- duplicated the latest repository (0.8.14)
- got deps
- compiled
- created new project to make sure everything was OK
- followed the instructions at https://github.com/ChicagoBoss/ChicagoBoss/blob/master/README_ELIXIR.md
  i.e. - Uncommented {elixir …} in rebar.config
        - Copied priv/elixir to src/
        - ./rebar get-deps
        - ./rebar compile
            and all went OK until...
        - PATH=./deps/elixir/bin:.:$PATH mix deps.get
            which rewarded me with:
          Could not start Hex. Try fetching a new version with `mix local.hex` or uninstalling it with `mix local.uninstall hex`

I tried both of those options but neither led me down a path to success.

Any ideas anyone?

Is anyone using Elixir for anything in CB?

g






David Welton

unread,
Mar 23, 2015, 5:08:15 AM3/23/15
to chica...@googlegroups.com
> Is anyone using Elixir for anything in CB?

My guess is that most people interested in Elixir are using the
Phoenix framework: http://www.phoenixframework.org/

--
David N. Welton

http://www.welton.it/davidw/

http://www.dedasys.com/

kotedo

unread,
Mar 23, 2015, 8:15:15 AM3/23/15
to chica...@googlegroups.com
I started (trying) to use Elixir in CB back when it was first implemented, but the lack of further development left me no choice and I abandoned it for ChicagoBoss.
I still love ChicagoBoss and Erlang even though there is Elixir and PhoenixFramework.  The right tool for the problem as we say.

Regards,
—Kai



Reply all
Reply to author
Forward
0 new messages