
Elchemy – write type safe Elixir using Elm-like syntax - methyl
https://wende.github.io/elchemy/
======
lf-non
Love the concept.

But please don't use fonts with ligatures in code snippets on the homepage.
Especially when these code examples are actually screenshots which people
can't copy.

Ligatures may be "obvious" to developers already familiar with the syntax of
the language, but can make things very confusing for beginners, esp. in FP
languages that lean heavily on operators etc.

I am really glad that the docs/roadmap etc. are on Github. Github is really
the gold standard when it comes to programmer friendly aesthetics.

~~~
qop
Maybe this isn't targeting new users, then.

His preferences supersede your sensibilities since its his website, don't you
think?

~~~
macintux
Parent did say “please”.

~~~
qop
I never said he was rude!

You can politely ask the wrong questions sometimes.

------
the_duke
Why would this target Elixir instead of Erlang or BEAM byte code directly?

Putting a language on top of a language on top of a language does not seem
that smart to me.

~~~
ninjakeyboard
Yeah I would expect to see it compile to bytecode. It seems pretty wild to
transpile to a language to compile to bytecode to run in a vm when there is
already bytecode and a vm to execute against.

Transpiling is common in js only because there isn't/wasn't a standard like
webasm.

~~~
skolemtotem
Similarly, despite the existence of LLVM and the simplicity of the various
assemblies, tons of languages target C, mostly to facilitate easier interop
with native libraries and because pretty much everything has a C compiler.
Perhaps there were similar reasons to compile to Elixir, but I honestly can't
think of any. It might just be for faster compiler development, at least until
the featureset of Elchemy begins to significantly diverge from that of Elixir.

~~~
wende
First of all thanks for all the interest and a good question! While obviously
it would be possible to compile directly to Erlang, or even to Core Erlang it
would just add a lot of additional work to do. Elixir adds a phenomenal amount
of functionality that made making Elchemy easier. And thanks to building it on
such a high level we can leverage most of the Elm tooling goodness as well as
Elixir's. Another very important factor is familiarity. People much rather
like an environment they already know and it would be silly to try to recreate
things like Mix or ExUnit yet again. Another important aspect is the
familiarity of the output. Elchemy's priority is producing fully readable
Elixir code, which not only adds another layer for learning the language's
characteristics as well as a 'belt and braces' for experimenting with it in
existing projects - the time cost of removing Elchemy from a project written
in it is way smaller than rewriting the logic from scratch

~~~
ninjakeyboard
awesome - thanks for the reply. Makes sense. I work with elixir full time and
the type-safety bugs me. I'll check this out when I can find some time.

------
moomin
Or if you’d rather have typeclasses:
[https://github.com/purerl/purescript](https://github.com/purerl/purescript)

~~~
lf-non
Purescript by example[1] is the most approachable introduction to Functional
programming that I have seen (yet).

Even if you don't intend to ever use Purescript itself for application
development, the book is worth a read, as an introduction to FP concepts,
especially if you are coming from a Javascript/Web-dev background.

[1] [https://leanpub.com/purescript/read](https://leanpub.com/purescript/read)

~~~
dmitriid
I largely agree, but it's not without its warts :)
[https://github.com/paf31/purescript-
book/issues/99](https://github.com/paf31/purescript-book/issues/99)

~~~
moomin
It’s also a bit out of date, but nobody’s perfect. :)

------
methyl
Elchemy looks fantastic, especially if you have some frontend in Elm already
or you use it in Node microservices. The only thing concerns me that it won’t
get enough traction and support and will eventally get abandoned, so here’s
some Q’s.

1\. What’s the genesis of this project?

2\. Do you use it internally, is it backed by any company?

3\. Is it already handling some production code?

Thanks!

~~~
wende
Hi there, First of all, thank you for the post! It really made my day to see
us land on HN I'm glad you like the idea. About the traction, I think I've got
a mentality that makes it a little bit more bearable - even if it turns out
nobody wants to use the project, I know I will so I'll always try to develop
it and spend at least a weekend on it from time to time.

Regarding the questions: 1\. It's quite a long story which I'd be willing to
tell one day, maybe at some conference. Basically, the idea started from
'typed elixir' which was a small POC project of mine. The Idea was to
introduce type inference and annotations using only Elixir's macro system. It
had a type inference algorithm I wrote in Prolog (to this day I'm still amazed
how easy this language made it) and a bunch of hacky macros. However, after
about half a year into development, I realized it's not a project that can be
done singlehandedly and that there is simply too many compromises and
hackishness to it. Half a year later on a LambdaDays 2016 conference in
Kraków, Poland during a rather boring talk I've wrote a simple transpiler of
Elm to Elixir as _a joke_ just to find an entertainment. But the longer I
developed the joke to more apparent it started to be it's actually something
completely doable and with a great potential value.

2\. Unfortunately no, not yet. It is being developed by me and sporadically by
two other members of my company, but it's in no way supported by any big
player. We'd love to get an interest like that though. If by any means some
company representative is reading that and considering, please don't hesitate
to mail me!

3\. Depends on what we mean by production - is it running as a node of a huge
Erlang system? - no, and probably won't be for some time. It's still a
relatively young project with a lot of space to develop, it is slowly
approaching maturity though and I think after we introduce an official way of
handling side effects it's going to get much more traction. If the question is
of "Is there anything big written already in Elchemy?" then kind off. I'm
pretty sure that the biggest project written in Elchemy today is... Elchemy
itself. Being self-hosted was very important to me and it is even a part of
the CI pipeline right now. The moment of it being able to compile itself and
execute in Elixir was a huge milestone in the development and a definite point
in time when the project stopped to be just a Proof of Concept. We are
currently working on a demo game written in Elm on the frontend and Elchemy on
the backend. Its purpose is to demonstrate the maturity of the project, but
also pinpoint some possible shortcomings that we might have missed. That's the
main reason for starting the Elchemt DevBlog on Medium
([https://medium.com/elchemy](https://medium.com/elchemy)) to share on the
progress and possibly discuss different choices we still have to make

As it's already becoming quite long-ish feel free to join our Gitter chat
([https://gitter.im/elchemy-lang/Lobby](https://gitter.im/elchemy-lang/Lobby))
or to mail me!

Cheers

------
matlin
This is awesome and important work! I hope that this project can move
independently of Elm's development once it gets enough interest though.

~~~
wende
We are hoping for that as well. Elm although making an amazing foundation
might cause problems in future when introducing backwards incompatible changes
for instance. We are trying to keep the safe distance from Elm development not
to be too tightly coupled, but still making use of the awesome stuff Elm's
team is doing

------
anthonybullard
Looks like your playground is based off Ellie, which is a great choice.
However, it seems that there is an issue with downloading the Elm compiler.
I'm getting a network failure from ellie's CDN(NAME_NOT_RESOLVED).

Other than that, thank you for this, it is super interesting to me as I am a
huge fan of both languages, and lack of type safety has always been my only
misgiving with Elixir/Erlang. I'll have to take a spin this weekend.

~~~
wende
Sometimes the CDN is acting naughty

That's true. The idea of how Ellie was brought to life is outstanding. Huge
shoutout to Luke Wetsby for letting us use his codebase for Elchemy

Feel free to share your thoughts and concerns on GitHub or by email! We'd love
to hear your opinion and concerns

~~~
lukewestby
<3 thanks

fwiw the latest release moved the compiler back to the server. the ghcjs stuff
proved too difficult to deliver a good experience to everyone. a naughty cdn
was just one of many woes.

------
kenhwang
Looks like it's targeted more towards the Elm crowd with npm install
instructions than the Elixir crowd with no hex/mix install method.

~~~
iraasta
Elchemy creator here. Quite the opposite to be honest. I come from Elixir
background. It's just that npm is much more reliable when it comes to global
system-wide installations

~~~
lytedev
Are you saying Mix/Hex is unreliable or are you saying npm is on more machines
globally?

~~~
thdxr
He's talking about installing a package globally on your system. That's the -g
flag

------
didibus
So I'm confused, is Elchemy its own language that compiles to Elixir? Or a way
to add static types to existing Elixir code?

~~~
wende
The former. It is a language almost identical to Elm that compiles to a
readable Elixir output. It has all of Elm's advantages - the type system,
readable error outputs. On top of that, you can use all of Elm's tools like
editor plugins or elm-format so there is no 'reinvent the wheel' syndrome

------
rs86
What would be interesting is to have a subset with managed side effects and
purity elixir i.e. something like Elm does at the frontend, the Elm experience
is amazing and what annoys me in erlang is having too much effects around

------
tills13
"Beautiful and fully readable output code"

beautiful ... ? readable ... ?

neither ... yes

------
undershirt
Great name!

------
ilovecaching
As someone who writes Erlang for a living, I highly recommend rust as a well
typed alternative to Erlang, that still keeps all of the things that make
Erlang great. I do love Erlang, but working on a large codebase can be
frustrating when nothing is speced or commented, and even when it is speced
it’s usually part of a gradually typed codebase with very non descriptive
types.

~~~
noncoml
Can you recommend a good web framework/micro-framework?

I was using actix-web, but last I heard it has to many unnecessary
`unsafe`s.[0]

[0]
[https://www.reddit.com/r/rust/comments/8s7gei/unsafe_rust_in...](https://www.reddit.com/r/rust/comments/8s7gei/unsafe_rust_in_actixweb_other_libraries/)

~~~
steveklabnik
The author is responding and taking care of many of them. I’m confident this
is a temporary issue, or at least it seems like it’s going correctly to me.

~~~
noncoml
Oh, cool. Good to know

------
he0001
Inception.

