A. Because you may reference JavaScript code in your ElixirScript modules that the Elixir compiler may not know about.
For instance, if you are writing an ElixirScript module that references JQuery or React. Since the Elixir compiler won't know about the existence of these, you may end up with some compiler errors. The main purpose is to sort of hide it from the Elixir compiler. You can feed normal .ex files to the ElixirScript compiler and it can turn them into JavaScript however.
In the future, the added file extension may not be needed as much as ElixirScript continues to support more of the Elixir standard library. An eventual goal would be to use standard .ex files in both Elixir and ElixirScript, while leaving exjs files strictly for JavaScript related code.
The compiler to this point has been focused on translating Kernel.SpecialForms and Kernel. Below is a list of what is complete, incomplete, as well as missing
-
Complete
__DIR____MODULE__^var&exprfor%{}{args}<<args>>fn [clauses] endcond(clauses)__block____aliases__unquoteunquote_splicing%left.rightquoteimportcaseleft = rightrequireleft :: rightalias
-
Missing
__CALLER____ENV__super(args)
-
Caveats
<<args>>- not supported in pattern matching yetquote- ignoreslocationandcontextoptionsleft = rightdoes not support full unification yet.a = 1 # works as expected 1 = a # may not work currently, but in some cases it will
* Tuple
* List
* Atom
* Range
* Logger
* Map
* MapSet
* Kernel
* Enum
* Agent
* Integer
* Keyword
* Base
* String
* Bitwise
* Set
* Everything else
You can use ElixirScript on your front ends and have it work and interoperate with JavaScript modules. The problem is since most of the standard library is incomplete, it will not feel the same. It will feel like some basterdized hybrid of Elixir and JavaScript. That is not the goal of the project. The end goal is to have it look and feel like Elixir code with the added availability of JavaScript modules.
A. No, but follow this issue. Any ideas or contributions are appreciated.
One of my demos is an example of using a design similar to redux to accomplish the things that redux does only using the Elixir standard library. Redux is influenced by Elm. The goal is to eventually allow for designs that can be Elm influenced if that is the desire. Similar to the same way the José saya to bring the spirit of projects from other languages to Elixir and not always just a straight port. If processes are added, I believe it will be easier to do those things in an idiomatic Elixir way.
Once processes are added, then we can see about adding OTP similar or specific things to ElixirScript.