Elixir everywhere?

Why can’t we haz something like Elm in Elixir?
Elixir in the browser, Elixir on the server, Elixir drivers for DBs and be done with it.
Down with JavaScript, down with “learn 50 languages to make a web app” :lifter:

4 Likes

There is ElixirScript available, which seems to be quite active in development, there was also a long blogpost from its creator about a month ago, but can’t find it right now. He mentioned and explained some stuff, about why there is currently no spawn in ElixirScript.

Also if I wasn’t very happy with ElixirScripts documentation and behaviour when I tried it for the last time (half a year ago), I will give it a new chance when I am at the point to actually implement something on the browsers side.

Still, I think that ELM is a valuable gem, since it does give some guarantees that elixir can’t.

  1. We have typesafety in elm, something, that elixir can’t catch for us. But since we are already living with that in the backend, we would overcome that on the frontend as well.
  2. Elm does actually build a bridge between JavaScript stuff and Elm-Stuff, that way no JavaScript can ever corrupt some of Elms data because of some reference still floating around. The Elm/JS bridge actually deep copies and converts arbitrary data into something Elm can handle. For ElixirScript, some external JS could still mutate our data AFTER we received it.
  3. Let it crash is not suitable for a frontend. At least thats my opinion :wink:

After saying this, I do conclude, that one can use ElixirScript for small additions to what is there anyway (Make the progressbar update dynamically instead on refresh only, and similar stuff) while I would choose Elm for a complete frontend application or animations shown as part of the application (something one has used flash for a few years ago).

6 Likes

That’s very interesting, why can’t we have Elixir, with types, in the browser? Maybe bring them over afterwards?
I’m way out of my depth when it comes to language development, but how about using the browser as a platform for developing types for Elixir?
Or it’s impossible to add them due to the Erlang vm?! Sorry if this sounds like a bunch of baloney :blush:

2 Likes

Of course one could have an Elixir with types which transpiles into JavaScript. But since there is much of stuff possible in elixir with its current typesystem it would be hard to actually develop a typelanguage which does not rip away elixirs possibilities just to ensure typesafety. Such a type language might become very powerfull and possibly even cross the border to dependent types. No one really wants that :wink: Another solution where to just try using dialyzers typelanguage, which doesn’t keep up with changes in beem as it seems to me (support for maps will take untill OTP 20 before getting stable I fear).

It does not even matter which approach you choose, at the end you had to learn just another language to code in the web, the type language :wink:

Of course, types are not that necessary for web frontends, JS itself is dynamically typed as well, and if you are not having the correct typed variable at a certain point it will just crash.

It’s just the fact that types can give you some amount of provable safety. And as a personal opinion, there shall be no way that a customer notices crashes in the UI, so the more safety I get from my language, the better it is. And as long as we have ne spawn of new processes in ElixirScript, we can’t restart crashed processes, but have to restart the whole application after a crash. So to avoid this you need to build safety nets into you code which you wouldn’t do in a “real” elixir application.

Also, I already mentioned the bridge between JS and Elms runtime. We could introduce something similar into ElixirScript, but I’m quite unsure about the consequences. At least such a thing really could get something away, which I really disliked that time when I took a look into ES: Server-Client-Communication: Even when elixir is a highly concurrent language and lets you communicate with servers thousands of miles away without letting you notice as a developer, in Elixr/ES-pairing you have to serialyze/deserialyze your data manually and transfer via HTTP. Using that mentioned bridge could reduce the amount necessary for this, but would also need a counterpart on serverside.

But I’ve written far too much again… Does happen always when I’m tired, I think it is best to go to bed now :wink:

4 Likes

Elm is different beast :slight_smile:
Elixir/ Erlang -> strong + dynamic language
Clojure/ClojureScript -> strong + dynamic language
Haskell -> strong + static language

There is effort to bringing safe of types to dynamic languages (during compiling/testing)

3 Likes

For Elixir there is elixir-contracts, and dialyzer of course.

3 Likes

Ok thats nice but … clojure has something like schema.
Maybe something similar in Elixir there is typespec
Can use typespec to catch errors during compilation or tests?

Using typespecs in elixir and checking them, is done after compilation using a tool named dialyzer. There are also packages available that make it wasier to use it.

Also, since it is meant for erlang in the first place, its reports are hard to read when not used to erlang syntax.

Another culprit is, that it has problems getting the type of maps correctly, and as such the types of elixir structs.

1 Like

Ok so it would be nice to have some support for elixir complex types like in clojure. Maybe some specific dialyzer for Elixir. I found this article:

2 Likes

I was very interested about this a couple of months ago when I saw that dev’s talk but they seem to have abandoned it? They’re last commit was 5 months ago and most of the commits before that we’re just README updates. Not sure if the project is ‘complete’ or not.

1 Like