3 ms·
Ruby might have some qualities but overall it's less polished than python Just as a small example, Edit: .methods, "the Ruby equivalent of 'dir'" doesn't prese
by raverbashing 6y ago
Ruby might have some qualities but overall it's less polished than python
Just as a small example, Edit: .methods, "the Ruby equivalent of 'dir'" doesn't present the results as a sorted list
Also the optionality of parentheses sounds like a good idea but it actually makes things more confusing and less parseable
- jeltz 6y agoI would argue that is a good thing since it allows for performant access when you do not care about order. If you do not care about order you do usually not even have to allocate an array which means lower memory use. And how hard is it to write. Dir[path].sort Ruby lacks polish in certain areas but this is not one. A d I would argue Python can be pretty tough in places too.
- raverbashing 6y agoNot that Dir, I mean as in .methods/.instance_methods (or dir(instance) in python ) I fixed it in my original comment
- jeltz 6y agoThen I understand your complaint even less. I almost never sort the output from methods and I do not think I have ever sorted the output from instance_methods during my over 10 years as a Ruby developer.
- raverbashing 6y agoPython orders it. And when you want to look up a method by name you do a binary search by fact of being a sorted list
- fomine3 6y agoAnyway you can just .sort
- ben-schaaf 6y ago> .methods, "the Ruby equivalent of 'dir'" doesn't present the results as a sorted list This seems like an odd complaint: Both languages use hash maps to look up methods/attributes, which aren't inherently sorted. Looking at the implementation `dir` in python does an explicit sort, which just seems like arbitrary behaviour.
- raverbashing 6y agoIt's not an arbitrary behaviour if you want a well behaved result from it. Same with Python dictionary keys which used to have no intrinsic ordering. Especially when dir() is more used in interactive applications (and sure, sometimes programatically like in plugin architectures, etc)
- dragonwriter 6y agoBecause Ruby uses fairly deep metaprogramming much more, idiomatically, than does Python, while “dir() is more used in interactive applications” may be true, that does not imply that “#methods is more used in interactive applications”. And, anyhow, an interactive application that wants the information it asks for will quite often wan’t to impose an organization other than alphabetic ordering.