Geek Logger

Traits is a mechanism for code reuse in single inheritance languages such as PHP. A Trait is intended to reduce some limitations of single inheritance by enabling a developer to reuse sets of methods freely in several independent classes living in different class hierarchies. The semantics of the combination of Traits and classes is defined in a way, which reduces complexity and avoids the typical problems associated with multiple inheritance and Mixins.

They are recognized for their potential in supporting better composition and reuse, hence their integration in newer versions of languages such as Perl 6, Squeak, Scala, Slate and Fortress. Traits have also been ported to Java and C#.

read on

Javascript + Structured Concurrency

stratifiedjs is an interesting approach to introduce concurrency programming to javascript,
first I learned about it in infoQ

It adds a small number of new constructs (waitfor/and, waitfor/or, waitfor()/resume, hold, spawn, using), and it extends the semantics of the constructs of the base JS language (i.e. sequencing, looping, conditionals, exceptions, etc) to work naturally with concurrent code paths. 

the code is pure javascript except for those new semantics like this:

var result;
waitfor {
  result = performGoogleQuery(query);
}
or {
  result = performYahooQuery(query);
}

it executes both functions simultaneously and then waits for them to be completed and upon completion of one, it automatically terminates the other.

you can read/view a quick and well organized demo in their website, they demonstrated it in OSCON2010.

the interesting part is that it works both on client side and server side. in client side all you have to do is to inlcude a small 20k file, called oni Apollo. and in server side they’re poring Apollo to Node.js.