❯ Guillaume Laforge

Builders in dynamic languages

Groovy introduced the concept of builders a few years ago, and it’s great to see other dynamic languages borrow this concept. Functional languages have even already done things like that for decades! In the past, Groovy borrowed a lot of brilliant ideas to languages like Ruby or Smalltalk, and some times, that’s the reversed situation where others seem to borrow ideas from Groovy.

Grails also makes heavy use of the builder concept by letting users easily create Hibernate criteria queries, define domain classes constraints, or specify AJAX XML fragments. The builder concept is really a creative way to create fluent APIs and DSLs. I’m sure we’ll find other great usage scenarios for it.