LibraryAndPrimitivesBlurring

Last edit April 21, 2013
One technique that makes for a powerful dynamic or meta-language is blurring the distinction between what are "primitives" (built-in operations) and libraries (add-on-able functions, classes, and APIs).

LispLanguage and SmalltalkLanguage are known for this more or less. Some questions:

  • What other languages fall into this category, fully or partially?
    • ForthLanguage is perhaps the quintessential example of this concept, where all Forth operations (aka "words") are library operators and vice versa.
    • HaskellLanguage allows you to define your own operators, and some operators are defined in the Prelude (which is the standard base library).
    • RubyLanguage is known for nearly arbitrary manipulation of objects, be they built-ins, standard library, or user-defined.

  • How far can this concept be taken?

  • Are there "social" problems with being too flexible? (LispIsTooPowerful)
    • Possibly. Whether or not the cost for a developer to learn and maintain (or define) what is essentially a sublanguage defined by library-defined constructs is greater or less than that for an "ordinary" function/class library -- and to what degree this is a general principle, or library-specific or language-specific or developer-specific -- is a matter of debate and/or research.


If the distinction is blurred (LibraryAndPrimitivesBlurring) this gives developers less chance to specialize - and in a recognizable way so.

Forces:
  • A human can only learn a master only so much.
  • A known and well-defined set of domains (each of a size that can be mastered) allows for coordination of experts.

AntiPattern: TooPowerfulForItsOwnGood

So a clear separation between library and primitive is one means to ensure defined domains. There may be other differentiations.

This seems to be an instance of AlternateHardAndSoftLayers.


CategoryMetaprogramming