Search code examples
language-agnosticprogramming-languagesmixins

What are some languages that currently support mixins?


Well obviously Ruby and Sass, but what are some other ones?


Solution

  • Wiki has a list

    http://en.wikipedia.org/wiki/Mixin#Programming_languages_that_use_mixins

    To quote:

    Programming languages that use mixins

    Other than Flavors and CLOS (a part of Common Lisp), some languages that use mixins are:

    * ColdFusion (Class based using includes and Object based 
      by assigning methods from one object to another at runtime)
    * Curl(with Curl RTE)
    * D (called "template mixins")
    * Factor[citation needed]
    * Fantom
    * Ioke
    * JavaFX Script
    * JavaScript
    * Object REXX
    * OpenLaszlo
    * Perl[3]
    * PLT Scheme (mixins documentation)
    * Python
    * Ruby
    * Scala
    * Smalltalk
    * Strongtalk
    * Vala
    * Visual Dataflex
    * XOTcl/TclOO (object systems for Tcl)[4]
    

    Some languages like ECMAScript (commonly referred to as JavaScript) do not support mixins on the language level, but can easily mimic them by copying methods from one object to another at runtime, thereby "borrowing" the mixin's methods. Note that this is not possible with statically typed languages, where an object's signature is fixed at compile time.