MWRC: Jeremy McAnally - Machine Learning

Jeremy McAnally - Machine Learning

Works for entp. His latest app: tweekapp

My Summary

Jeremy was out to convert everyone to doing DSLs the 'right way'. Some salient points were:

  • the point of a DSL ought to be to make the DSL easier to use for the experts.
  • 'external dsls' (i.e., you make up your own language) can be great for simple project, like config-writing code
  • 'internal dsls' (e.g., ruby-code-dsls) get a lot of stuff for free (loop structures, etc)
  • dsl composition (using more than one dsl at a time) can cause namespace issues (he didn't really offer much in the way of solutions here as far as I can remember)


Used by experts, for specific problems.


Different problems have different domains, and they each have their own language.


DSLs that are very generic or look a lot like english don't make sense to him. DSLs are supposed to make the brain-to-code jump much smaller. Also, why waste the keystrokes?

External DSLs

These are DSLs that don't use an existing language (e.g. ruby). Sounds like he doesn't like them as much in general, though there are specific cases where the language structure is simple enough that it makes sense (e.g. puppet).

Internal DSLs

Implemented in an existing language (e.g. ruby). Loops & basic things like that are baked-in and already understood by end-users. External DSLs have to go to a lot of work to create these structures & etc. When to use? Look at the possible complexity of your code, look at what your 'experts' will use.


  • Rails Templates (written by him).
  • Ambition - 'Take the suck out of SQL'
  • Foundry (Another of his).

Designing the DSL

  1. Think about the problem domain
  2. Deconstruct -- remove the cruft. DSLs are not fake English. No Finglish allowed.
  3. Implementation

Method chaining

Approach 1: return a new object every time

Approach 2: return self after changing state

Choosing an approach -- think about which is more concise in your case, also think about how #2 can get ugly & unwieldy.

Dynamic dispatch

He likes using closures. Some extra chrome -- if that's bad maybe look at an external DSL.

Compositon - meshing DSLs. Presents namespace issues.

Decoupled DSLs

In his opinion, the DSL ought to be decoupled from the library behind it. The DSL is just the interface to the logic. Thus, when testing you test them separately.