3 ms·
I’m a huge fan of all the features this person is complaining about.
by whalesalad 8y ago
I’m a huge fan of all the features this person is complaining about.
- rlue 8y agoI like them too, but only because I've been programming Ruby for a while now, and enjoy picking up new tidbits as I go. If I were new to Ruby (or programming in general), I think this would reasonably constitute feature bloat that would make it a less approachable language. Also, bear in mind that "this person" is not just any Joe Blow but Bozhidar Batsov, maintainer of Rubocop and (as an author of the Ruby Style Guide) something of an authority in the Ruby community.
- olingern 8y agoBut do any of these features progress the language or provide any performance benefits? Most read as syntactic-sugar (I understand Ruby is about developer happiness) and unnecessary.
- prophetjohn 8y agoThey progress the language by adding syntactic sugar. Many Ruby programmers aren't waiting around for Ruby to suddenly become fast. If that happened it'd be great, but most code I write isn't performance critical, so it's okay if they just give me a feature where i can write `user&.name` instead of `user && user.name`
- omaranto 8y agoReally? Including the @1, @2, positional arguments? Why are you a big fan of them? Maybe I'm missing something that makes them great.
- barrkel 8y agoI almost invariably use x for @1 in existing code; for manipulating hashes, I almost always use |k, v|. If I'm working with pairs, |x, y|. What's the big difference between x and @1? y and @2? It doesn't really feel that significant to me. I'm a bit meh on the feature. I'm suspicious of lambdas / blocks that take more than three parameters, and for three parameters I'm good with |x, y, z| or |a, b, c|. I do think that giving them meaningful names is usually obscures intent more than it clarifies; |k, v| for maps and |i| for loops self-document well enough.
- jimbokun 8y ago"for manipulating hashes, I almost always use |k, v|. If I'm working with pairs, |x, y|" Those are massive improvements over "@1 @2". You make the case yourself. Using "k, v" as a convention immediately signifies these are a key and its value. Using x, y indicate this is a pair (and x and y are of the same type, I assume?).
- dragonwriter 8y ago> What's the big difference between x and @1? No more stuttering in single-line blocks.