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

roshan
Hi everyone, I’m looking for a book on Phoenix server hosting / deployment like the following books for Rails, Docker for Rails Develop...
New
zeroexcuses
Besides Basic types - The Elixir programming language are there any other well recommended “elixir by example” style resources / books ? ...
New
lc0815
hello from a real frustrated newbe… I’m reading this article Full-Stack React With Phoenix (Chapter 3 | Introduction to Phoenix) by mich...
New
shansiddiqui94
Hello all, I recently did my first app in Phoenix and Liveview, many thanks to all the users who assisted me. I found that the tutorial ...
New
KSingh1980
How to run the random query and get the result in JSON format and send it as a response. The query will be in the following form DB Name...
New
Chawki
hi,i’m new to programming world i had learned front-end( javascript,react.js) and i wanna learn a back-end programming language i thought...
New
stevensonmt
I’d like to provide my review of the Elixir Course module from Groxio. I have some criticisms but I’d like to start with the positives. ...
New
Nopp
Hey guys and girls, i am completely “new” to programming, recently played a bit with Python, Ruby and PureBasic, but i want to try somet...
New
logesh
Could someone provide a learning path for functional programming for who came from oops background.? Thanks in advance
New
SavagePixie
I was wondering if there are any beginner-friendly, exercise-based resources for learning Elixir out there. I’m looking for something lik...
New

Other popular topics Top

shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
Nvim
Elixir appears to be a superior language to Python. I don’t see any advantage of Python over Elixir. Are there any?
New

We're in Beta

About us Mission Statement