Hey, lots of developers already asked about this one in #questions-help category. I have also though about it and I would like to describe a serious problem in
Elixir tools creating process. In some cases like writing code helpers it’s extremely important to have a single, well documented and easy way to traverse AST without losing comments, formatting and code integrity. I have lots of ideas
One of simplest examples could be
Phoenix 1.2.x ->
Phoenix 1.3.x migration tool. Imagine that you can easily traverse AST and replace/update it in a way which is much more faster than doing it manually and will not fail at least up to
2.0.0. Also such tools well written does not allow to make a stupid mistake when changing lots of module names. Simple typo or just forgot to change module name may be really confusing and frustrating.
The problem is that we have not enough easy and well prepared API to do that. Of course other people can say that we can use
grep and just write
BASH scripts in general for that use case. Firstly good luck with that. Secondly: do we really need to use such a nightmare (just take a look at associative arrays syntax in
BASH) instead of our favorite language? Of course we can also write and/or write
grep-like helper functions in
Elixir, but I don’t really feel that’s a good practice to do that.
I would like to remind one issue I have reported and fixed in one simple tool written in
It’s just how
String.contains/2 and regular expressions (i.e.
grep-like way) is working in practice. One change in template could broke whole tool. I’m really thinking if such way is not even worse than using
Private API. Here not only code could change, but even it’s format, number of lines (depends how we are trying to workaround this problem) etc.
I would also remind everyone about something. First
scenic apps and even games (!) are written right now! It’s only a matter of time when really useful solutions would be created. One of first bigger of them would definitely happen even around
Nerves topic. Having that in mind think that we still can’t fetch (in nice way) project details (from
mix.exs) to display in basic
0.0.1 project manager (which I would like to create sooner or later). Does somebody remember plans for
Elixir code editor in
scenic? I would like to not see
Regex (if I remember correctly) based syntax highlighter like we have on our forum.
I believe that adding such way to
Elixir core is best solution, because I don’t believe that random developers (like me) would be able to create their own
AST traverse up-to-date libraries having in mind full
Elixir specification (which is not even documented yet, right?) just to write tool which simply parses few files.
Please let me know what do you think about this idea. I believe that at least some people would be interested in this topic, so I would like to ping them and share their ideas how they would see such API in