4 ms·
Iunno, what's unique to ruby? I can only think of module mixins. Everything else (blocks, anonymous functions, syntax sugar) can be roughly approximated (i.e.
by phillmv 10y ago
Iunno, what's unique to ruby?
I can only think of module mixins. Everything else (blocks, anonymous functions, syntax sugar) can be roughly approximated (i.e. generics), since I strongly doubt the book would use any of the metaprogramming features.
- superswordfish 10y agoOne objection I can think of is that Ruby is dynamically typed. Something that is elegant in Ruby might be a horror in Java.
- tln 10y agoRuby uses messages for methods, allowing cheap delegation; classes can be extended (monkey patched) after definition. I doubt Ruby OOP code would avoid using all metaprogramming, at the very least attr_accessor!
- titanomachy 10y agoTo me, metaprogramming means writing new macros/templates, not just using the "standard" ones.
- ryanbrunner 10y agoHaving taken Sandi's in-person course (which sounds like it covers a lot of the same territory as this book), the vast majority of it would be perfectly applicable to Javascript. Ruby lets you get away with some neat tricks, like dynamically loading classes by name to avoid ugly switch statements, or the occasional bit of monkey patching, but it's not the focus at all and it's easy to see how you could accomplish it in a more "traditional" way.