|
|
|
|
|
by philsnow
1320 days ago
|
|
I really, really like Ruby-the-language, and prefer it over python. I don't love that it's joined at the hip with Rails. compared to Python, Ruby has: - first-class symbols (yes python has sys.intern but it would take a PEP giving them a pithy syntax to make them usable, plus python has 25 years of stdlib and libraries using "strings" or enums for constants instead of :symbols)
- procs/blocks and better-than-python lambdas
- "open classes" / monkey-patching of builtins (for better or for worse)
- trivial metaprogramming with method_missing (for better or for worse)
some of these make fun one-off projects easier or faster, some of them would be less welcome in large, mature codebases. |
|
But just to be a bit contrary:
- I don't see a huge value in symbols. In Ruby they are literally just static strings which means they use memory you'll never get back – potentially important if you're e.g. parsing something large into a hash and symbolizing the keys. If you have to put a non-alphanumeric character in a symbol you still need to use quotes.
- Procs, blocks, and lambdas – yes.
- Metaprogramming and monkey patching? dfjasdjldfjkdfjlkfdjldfoh4houfhufl. A double edged sword at best and 100% not something I'd want to see in a larger codebase. Javascript folks largely learned this lesson with the shift from Prototype to jQuery. You can do some really neat-o things but they're almost always unintuitive to the uninitiated.