5 ms·
"...next language choice was clear: Python, which seems to fit my style better than Ruby" Just out of curiosity, why would someone believe this? The syntax of
by jenius 14y ago
"...next language choice was clear: Python, which seems to fit my style better than Ruby"
Just out of curiosity, why would someone believe this? The syntax of python and ruby are nearly identical, but ruby has more tools and support for web-based projects. For someone looking to develop for the web, ruby is pretty clearly a better choice. And this is not knocking python at all, I really enjoy them both and there are many other things python has more community support for - don't get me wrong.
To support what I'm saying about the syntax, check out this comparison: http://hyperpolyglot.org/scripting http://hyperpolyglot.org/scripting - they are super similar, if anything ruby is a tiiiny bit more elegant.
- seanl 14y agoHaving done substantive work in both, the most significant difference that for me favours Python is that every module explicitly imports the names that are accessible within its namespace (barring use of 'from X import *' which is generally discouraged). In comparison I found it a real pain to track down definitions of specific names in a complex chain of 'require'd Ruby code.
- j_baker 14y agoFor someone looking to develop for the web, ruby is pretty clearly a better choice. For someone looking to troll while looking smart and insightful, this comment is pretty clearly a better choice. Python has a ton of web tools and lots of companies build web services in Python. Ruby is simply another choice, not a better or worse one.
- jerf 14y agoRuby and Python are nearly identical in syntax and basic functionality. But I like Python's community and philosophy better. If you agree there is a difference, then for some set of people, those differences will be the determining factor. Also, while fairly comparing the amount of "web stuff" that Ruby and Python have would be an effectively impossible task, the simple truth is that both ecosystems are abundantly full of stuff, to the point that which has "more" doesn't matter. You're not going to miss out on anything by going with Python, unless you drill down to a hyper-specific particular package you may need which only exists on one.
- IsaacL 14y agoJust by looking at a syntax table, the higher-level differences are not going to be enumerated. Just off the top of my head: - Ruby was always designed as an OO language, whereas Python OO was bolted on later. Ruby's object system is almost a straight transplant from Smalltalk and is very powerful. - Python lambdas can only be one liners. Ruby lambdas can be arbitrarily long. Guido doesn't really like FP - there's no tail recursion, either. - Ruby's metaprogramming capabilities are a bit more powerful (haven't really looked at Python in this regard, so don't quote me). - In fact, there are some pretty big syntax differences. Python requires brackets even for the print statement now, whereas Ruby lets you miss them out if it's unambiguous. Ruby has blocks. Python doesn't have "end\n end" sprinkled everywhere. The main philosophical differences are that Ruby is more powerful and implicit, wheras Python is stricter and explicit. When I say "powerful", by the way, I don't necessarily mean "good", just that it exposes more functionality to the user. Although I like Ruby a lot, I accept that on large projects Ruby's power (like that of Lisp or C) can be dangerous. Python has a lot going for it. You're right, they're still very similar in many ways. Maybe they're like Democrats or Republicans; up close, they're screamingly different, but from a distance they're almost alike.
- lucian1900 14y agoWhile I find Ruby to be nice overall, you're wrong on several points: - Whether or not Python was historically OO or not, everything in Python is now an object. Its love for protocols drives design like `str(foo)` (which calls `foo.__str__()`), not any particular deficiency in its object system - Python's lambdas are indeed limited, but one can easily use `def` and just name the function. Functions are first class, after all - Metaprogramming facilities are very similar in power. Neither language has macros. - Python tends insist on not duplicating things (i.e. both indentation and braces/end) and on not being ambiguous. There is another reason Python can't omit braces for function calls: without braces, they are references to the function. As a consequence, Python doesn't need things like .call() Overall, I haven't seen one language or the other to be more powerful.
- wilmoore 14y agoPersonally, I find that Python and Ruby are comparable as it relates to utility. I'd think it is fair to say that argument is a wash. It is Ruby's expressiveness that makes it my choice before Python: --- Ruby --- letters = ['a', 'b', 'c'] letters.map &:capitalize --- Python --- letters = ['a', 'b', 'c'] capitalize = lambda x: x.capitalize() map(capitalize, letters) --- PHP --- <?php $letters = ['a', 'b', 'c']; array_map('strtoupper', $letters); Of course, this is one example where PHP (5.4+) at least somewhat resembles Python. I think that is why some of the more experienced PHP developers tend to choose to go with Python as their PHP recovery language. Personally, I prefer "letters.map" (Ruby) over "map(...)" and "array_map(...)"; however, that is a personal style preference and has nothing to do with technical merit. And I still enjoy writing Python here and there. PHP is also still a necessity much of the time. That being said, there are a few edge cases that I've witnessed where Python actually reads better than Ruby; though, these cases are few.