Skip to content

Comment on Friendly attributes pattern in Rubyparent

Comments

This is a philosophy. One which many people that write Ruby subscribe to. The fundamental idea is: create a DSL that makes it very easy to implement your application. It is what made Rails different when it was created: it is a DSL that makes expressing web applications easy.

I don't know its history well enough, but it seems to originate from Lisp. PG wrote about it before [1].

It can result in code that is extremely easy to read and reason about. It can also be incredibly messy. I have seen lots of examples of both over the years.

It is the polar opposite of Go's philosophy (be explicit & favour predictability across all codebases over expressiveness).

[1]: https://paulgraham.com/progbot.html

If there is one DSL which is a central abstraction of one’s entire app, used in 100s of places—this is fine.

If there is a DSL such as Rails’ URL routing, which will be the same in every app—this is also fine.

When one makes 100s of micro-DSLs for object creation, that are only ever used in one or two places—this is pure madness.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.