My professional career mostly consists of using PHP. However I often do a side step to a different language. Lately I have been playing around with ruby The first concept that strikes me as odd, are the modules. They seem to have multiple responsibilities, they have the possibility to be used as mixin, but in the meanwhile supply you with a namespace.
However the language itself is quite interesting, due to its nature in duck-typing, verbosity in the language is a bit suppressed. For example creating a mapper that maps some value:
In PHP it would be something like:
However for ruby, no members, no public or private. And you are able to pass anything to collection, as long as it is consistent with the collection “interface”
When using ruby for a bit, i get the feel that namespaces are not really a defactor standard to use. Because you get something like:
This seems like an aweful lot of indenting, which in itself would be less readable when doing this with loads of namespaces.
While PHP keeps it quite clean
Therefor i don’t think modules are actually ment for namespacing in the traditional OOP way and is more like a side effect of the mixin concept. And due to the mixin concept and duck-typing, it feels ruby is more a functional language then a imperitive language and should probably be used that way.