TwistingTwists

TwistingTwists

Best resource to learn DSL?

I want to learn DSL. Don’t know how to write one. What;s the best introductory resource?

I see some macro being used here.

Is DSL only about using Macros to help write other functions easily?

Most Liked

kartheek

kartheek

DSL are used in runtime and compile time. At runtime they help customising the software through scripts or rules. Systems expose ability to customise the functionality/behaviour through the DSLs. For example rules editor in a firebase - Lenguaje de las reglas de seguridad  |  Firebase Documentation . Quite a lot of google cloud services use Common Expression Language - GitHub - google/cel-spec: Common Expression Language -- specification and binary representation

The complete guide to (external) Domain Specific Languages - Strumenta covers a lot of things about DSLs.

Elixir has metaprogramming through macros which is compile time.Ecto has DSL for simplifying queries for accessing the data. If your use case is writing a compile time DSL - elixir metaprogramming makes it easy. Runtime DSL in elixir needs a lot of things - like interpreter, etc to be implemented.

Implementing a DSL needs grammar to be formalised as language spec.

What are you trying to achieve with DSL in your application? Is it runtime or compile time ?

dimitarvp

dimitarvp

More or less, yep. You can’t really learn DSL per se, DSLs are custom languages that you build yourself. For that you need to know Elixir macros.

I recently started the Metaprogramming Elixir book and I enjoy what I saw and tried so far, so that’s one possible resource for you.

csadewa

csadewa

DSL is a concept closely associated with Domain Driven Design, the idea is to have a way to easily express things inside a particular domain. For the technical part, you could learn (like dimitarvp said) Metaprogramming Elixir / Elixir Macro. For the design part, you could learn Domain Driven Design (i would recommend Implementing Domain Driven Design for more easier time of reading DDD).

crispinb

crispinb

That book is generally highly recommended, but if you want something shorter to start off with there’s also Saša Jurić’s blog series starting here . I haven’t gone through it yet, but I’ve found Jurić’s other writings lucid.

kartheek

kartheek

Thank you. Like @crispinb pointed out Sasa Juric’s blog post series is a good place to start.

Metaprogramming Elixir -Metaprogramming Elixir: Write Less Code, Get More Done (and Have Fun!) by Chris McCord is a book which is completely about Metaprogramming. You will find a coupon code in this forum for most of the elixir books.

One thing about metaprogramming is - it may not be needed most of the time. Using import and functions might solve the problem. Chapter 6 of Metaprogramming Elixir book explains more about it.

I learnt a lot by searching about how elixir, ecto and phoenix use defmacros in their code base:

Where Next?

Popular in Chat/Questions Top

Iex.new
Hello!, I just started this week to discover Elixir. I’m a PHP-Programmer and did some sutff in Go too. The more I read about Elixir t...
New
Fl4m3Ph03n1x
I am doing some exercises while learning Elixir using Exercism.io. Now, my objective is to do all exercises, extras included. This shoul...
New
Lincxx
Hello, I’m sure this has been asked a bunch, but where to start. I do prefer vodeos over books, but recently I have found books to be mor...
New
zeroexcuses
Besides Basic types - The Elixir programming language are there any other well recommended “elixir by example” style resources / books ? ...
New
LegitStack
I’m not a hugely experienced programmer, just a few years. So I’m looking for resources to learn about a topic but I can’t seem to find m...
New
wolfiton
Question: Can someone recommend me some good resources on learning performance for phoenix elixir applications and a design pattern I sh...
New
Nvim
Anybody know of a Pragmatic Studio 40% off coupon code for video course like Phoenix?
New
aswinmohanme
I recently finished the Udemy course on Elixir and Phoenix and I am thinking about using it for the next project. But I am stuck as how t...
New
Twfo326
As a novice dev I’m trying to keep the curriculum as lean as possible. My requirements are modest: build simple CRUD apps with Phoenix...
New
younes-alouani
I'm studying Phoenix Framework but I want to understand basics first. Which book/mooc explains better the Design of Network-based Softwar...
New

Other popular topics Top

chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30048 115
New
sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New

We're in Beta

About us Mission Statement