DSL is evil #288
Replies: 2 comments
-
Meanwhile, I chose Alba because the DSL makes sense to my brain for some reason. I find it very easy to reason about, and it helps me work quickly. I think different people like different things, so it's nice to have many options. Of course you can also just build a Ruby hash and output that to json without any extra gems at all. In any case, I don't think it's nice to say that DSLs are evil. They provide a lot of good in the world for lots of people, but it's also fine if you want to choose a different path. |
Beta Was this translation helpful? Give feedback.
-
I think generating JSON is a small, well-defined domain where Domain Specific Language works well. I kind of agree that in some areas domains are just too big for proper set of DSL, but in case of Alba, DSL is a good solution. After all, it depends. One of the good thing about Ruby is that there are so many solutions already available. For example, if you build JSON just by using Hash but in jbuilder's fashion, you can use jb gem. In Ruby, as you already know, it's "possible" to build a complex Hash and then dump it as a JSON string. However, it's not always easy to do so, and we want some "better" solution. We can agree that almost of all of the existing solutions use DSL because using DSL is "better" than building a Hash without it.
Finally, did you take a look at the source code of Alba? The amount of metaprogramming it involves is relatively small and the code is (at least for me) easy to read. Yes, you can abuse metaprogramming, but it's not related to DSL. |
Beta Was this translation helpful? Give feedback.
-
Personally I hate (and avoid using) gems rich of DSL. I don't know why, but gem writers like and tend to add their own DSL though in many cases it results in a mess. For example Trailblazer, Dry hell, Grape, and many many more.
Why not stop abuse DSL? As a matter of fact for the most part DSL are not documented, add more complexity, and needlessly extend Ruby. This is not about this particular project, but Ruby society in general. Please stop abuse metaprogramming by introducing DSLs.
Beta Was this translation helpful? Give feedback.
All reactions