How Beautiful is Ruby?
Working with Ruby and in particular Rails, it’s easy to take the beauty inherent in the language for granted. I mean look at this code. If you read it aloud to yourself, it reads like an english sentence that any non programmer can understand.
Forum.categories.map do |category| link_to category.name, category end.to_sentence
Forum categories map do category, link to category name, the category, end and convert to a sentence. The code returns a an english sentence as well.
Fish, French Bread, Coffee and Hamburgers with each linked to the correct resource as well!
Why are PHP5 Namespaces Defined Using a Backslash?
Why are PHP namespaces defined using a backslash? It looks ugly. Unless of course, there is a good reason for the “\”? Does this namespaced code run more efficiently on Windows?
Since namespaces are new in PHP5 why not take the opportunity to use them when requiring a file?
namespace('my_library_dir', 'lib'); // import my_library_dir as lib
$myClass = new lib::MyClass; // use the class w/ namespace
Seems a lot simpler and not as ugly. You could namespace old PHP code this way as well. Please enlighten me if I’m off the mark and the implementation of namespaces in PHP5 is a better design than I have suggested!


