Mixin

Python

Python中，除了使用protocol以外，也可以用多继承的形式来实现Mixin。为了区分普通的多继承，mixin类的类名一般都会带上后缀：“Mixin”，比如Python 2中的类UserDict.DictMixin。DictMixin类包括部分实现，使用者的类只要实现几个必须的函数接口，如：__getitem__(), __setitem__(), __delitem__(), keys()。
Python的SocketServer模块提供了UDPServer类与TCPServer类，作为UDP与TCP的socket服务器。有两个mixin类：ForkingMixIn与 ThreadingMixIn。通过如以下代码的方式使用ThreadingMixIn扩展TCPServer：
class ThreadingTCPServer(ThreadingMixIn, TCPServer):
  pass
ThreadingMixIn类为TCP服务器添加了新功能，使每个新连接都会创建出新线程。而如果是ForkingMixIn，则会使每个新连接fork出新的进程。

Ruby

在ruby中，并不直接使用Mixin这个单词，而是使用在类的声明中include一个module的办法。

接口与trait

已隐藏部分未翻译部分，欢迎参与翻译。
Java 8 introduces a new feature in the form of default methods for interfaces. Basically it allows a method to be defined in an interface with application in the scenario when a new method is to be added to an interface after the interface class programming setup is done. To add a new function to the interface means to implement the method at every class which uses the interface. Default methods help in this case where they can be introduced to an interface any time and have an implemented structure which is then used by the associated classes. Hence default methods adds a possibility of applying the concept in a mixin sort of a way.
Interfaces combined with aspect-oriented programming can also produce full-fledged mixins in languages that support such features, such as C# or Java. Additionally, through the use of the  marker interface pattern, generic programming, and extension methods, C# 3.0 has the ability to mimic mixins. With C# 3.0 came the introduction of Extension Methods[2] and they can be applied, not only to classes but, also, to interfaces. Extension Methods provide additional functionality on an existing class without modifying the class. It then becomes possible to create a static helper class for specific functionality that defines the extension methods. Because the classes implement the interface (even if the actual interface doesn’t contain any methods or properties to implement) it will pick up all the extension methods also.
ECMAScript (in most cases implemented as JavaScript) does not need to mimic object composition by stepwise copying fields from one object to another. It natively supports Trait and Mixin based object composition via function objects that implement additional behavior and then are delegated via call or apply to objects that are in need of such new functionality.

Scala

Scala has a rich type system and Traits are a part of Scala’s type system which help implement mixin behaviour. As their name reveals, Traits are usually used to represent a distinct feature or aspect that is normally orthogonal to the responsibility of a concrete type or at least of a certain instance.
For example, the ability to sing is modeled as such an orthogonal feature: it could be applied to Birds, Persons, etc.
trait Singer{
  def sing { println(" singing … ") }
  //more methods}class Birds extends Singer
Here, Bird has mixed in all methods of the trait into its own definition as if class Bird had defined method sing() on its own.
As extends is also used to inherit from a super class, in case of a trait extends is used if no super class is inherited and only for mixin in the first trait. All following traits are mixed in using keyword with.
class Personclass Actor extends Person with Singerclass Actor extends Singer with Performer
Scala allows mixing in a trait (creating an anonymous type) when creating a new instance of a class. In the case of a Person class instance, not all instances can sing. This feature comes use then:
class Person{
  def tell {  println (" Human ") }
  //more methods}val singingPerson = new Person with SingersingingPerson.sing

Swift

Mixin can be achieved in Swift by using a language feature called Default implementation in Protocol Extension. 
 1 protocol ErrorDisplayable { 2     func error(message:String) 3 } 4  5 extension ErrorDisplayable { 6     func error(message:String) { 7         // Do what it needs to show an error 8         //... 9         print(message)10     }11 }12 13 struct NetworkManager : ErrorDisplayable{14     func onError() {15         error("Please check your internet Connection.")16     }17 }