Show HN: es6_maps v1.0.0, new Elixir syntax feature via runtime compiler hacking

github.com

3 points by kzemek 11 hours ago

Hi HN! It’s been a year since I posted a Show HN[0] for the initial release of my Elixir library, `es6_maps`. It enables JS-style "shorthand" map literals (`%{foo, bar}`) in Elixir through runtime compiler modification.

We’ve been using `es6_maps` successfully in production throughout the year. During that time, we identified a couple minor pain points I wanted to fix:

* Other tools working on token or AST level could be surprised by the de-facto invalid syntax.

* `es6_maps` was only active at compilation time, so we couldn't paste-in shorthand code in deployed shells (very useful for debugging!)

This week I released a new version, v1.0.0, that fixes these issues and more. `es6_maps` now amends the Elixir compiler at a different point (`:elixir.string_to_tokens/5`), which improves compatibility with other Elixir tools and happens to be a more stable API. Also, `es6_maps` can now be used at runtime, and includes an ElixirLS plugin to ensure it's active while the language server analyzes the code.

The v1.0.0 release also signals production readiness. `es6_maps` has been battle tested, hasn't had any compatibility issues with new Elixir versions (and is now less likely to), and includes a formatter that can revert your shorthands whenever you'd want to "get out".

Let me know what you think!

[0] https://news.ycombinator.com/item?id=40333500