4 ms·
I consider Ruby to be quite similar to Python. However, it's kind of like Python's weird brother, with optional parentheses for calls without arguments, auto-re
by Simran-B 4y ago
I consider Ruby to be quite similar to Python. However, it's kind of like Python's weird brother, with optional parentheses for calls without arguments, auto-returning the result of the last expression, and some odd-ball syntaxes. It manages to be even less efficient, though.
- quesera 4y agoAs someone who probably has more experience with Ruby than you do, and probably less with Python, I'd characterize the relationship as inverted -- Ruby is more consistent than Python. In Ruby, parens are optional for all methods, and only required if you need to force non-default precedence. Returning the value of the last expression seems reasonable to me (just like a UNIX shell). In Python, I'm bothered by the little inconsistencies. Why is str.len (or length, or size, or count, etc) not a method? Why len(str) instead? And Python has plenty of oddball syntax: significant whitespace, triple quotes?? You get used to it of course. Ruby and Python are about equally efficient -- if you're optimizing for code efficiency, both are bad choices. In many domains, that's not a critical metric, so we talk about developer efficiency. I'll argue that developers are more efficient when they are more happy, and for me that selects Ruby by a mile over Python. But I won't pretend that it's more than a matter of taste. :)
- wood-porch 4y agoI feel very similarly about Python vs. Ruby inconsistencies! I remember starting a job and used python for the first time coming from Ruby, and being extremely disappointed in the inconsistencies in the standard library and the sheer… lack of features in the Stdlib compared to Ruby. I’ve yet to use a language with such a magnificent stdlib and documentation. I main python nowadays, and I find the ecosystem and typing to be better than Ruby, but Ruby is the best language I’ve ever used for many reasons
- Turing_Machine 4y ago> And Python has plenty of oddball syntax: significant whitespace Yes. Especially this. The whitespace thing in and of itself has kept me from ever developing a fondness for Python. Clearly there are plenty of people who aren't bothered by it. De gustibus.
- Simran-B 4y agoSignificant whitespace is probably my favorite feature of Python, which might have to do with the German keyboard layout making it very cumbersome to enter curly braces.
- Simran-B 4y agoMaybe not oddball syntax, but rather syntax that doesn't make intuitive sense. With Python, only nested list comprehensions come to my mind that are a bit tricky to read. With Ruby, I often felt lost reading code and it was sometimes hard to figure out the name of a thing or search for a specific syntax, e.g. with a single character like @ - especially in the official reference documentation. But maybe it's on me for not learning Ruby properly first.
- dragonwriter 4y ago> I consider Ruby to be quite similar to Python. They are both dynamic, OO scripting languages, whose main implementation has a GIL, but beyond that, they aren’t all that similar. > However, it’s kind of like Python’s weird brother, Methods-with-self-in-args-list isn’t the “weird” one? > with optional parentheses for calls without arguments Parens are optional in Ruby on method calls and method definitions except where necessary to resolve ambiguity (including in the newer special single-line method definition syntax, its not a special syntax option for no-arg methods > auto-returning the result of the last expression Ruby is basically an expression-oriented language [0], everything returns a value, and a sequence of expressions returns the last expression in the sequence. Explicit “return” lets you short-circuit that. Python is a statement-oriented language, and statements don’t return things except an explicit return tells the function its in to return something. Both are common kinds of languages, just very different. Neither is “weird”.
- Simran-B 4y ago> Methods-with-self-in-args-list isn’t the “weird” one? I agree that it's uncommon, but I do like the clarity it adds compared to something like "this" which magically refers to the current instance. Hasn't C++ just added something like it with "deducing this"?