More than a versus (it's more striking) I would really like to know what things they have in common and how they differ, what their main advantages are compared to the other and of course their opinion of them. One point to take into account is because they believe that python is more used in AI and Machine learning developments.
Should I learn Ruby or Python?
Unix text processing (instead of awk, sed, Perl)
You've named the kings of that domain, ruby and python both have text processing/regexp facilities but they are nowhere near as fast. I like ruby's regexp implementation a little better than python's. (go figure, says the guy on the ruby subreddit)
Web development
Ruby has some pretty bitchin web frameworks, though django and flask do a lot of the same things. The only thing that might edge ruby out as a clear winner here is that rails has so much community support, so if you don't want to re-invent the wheel, you can use a gem, whereas python might not have the same level of community support for django. It's probably pretty close.
Programs for Unix open source projects
Python is probably viewed as more of a "systems language" now than ruby. Both are equally capable of being scripting languages used for everyday tasks, just depends on what you're wanting to do.
Mobile Dev (not as much important as the first three items).
Ruboto/Rubymotion/Mobiruby are all things. I think ruby might actually take this the most handily.
tl;dr Learn multiple languages, use the tools that make sense for the project. Don't be bound to a single language.
More on reddit.comWhat makes Python more popular than Ruby?
Ruby or Python for a first language? (no experience)
I think Ruby is better for learning.
Everything is an object™
clearly demarcating the end of a logical block with end, rather than whitespace is much easier to follow for beginners.
Documentation for Ruby is much more readable
What does Ruby have that Python doesn't, and vice versa? - Stack Overflow
Is Ruby better than Python?
Which is easier, Ruby or Python?
Can you use Ruby and Python together?
Videos
Hi I want to learn an all-purpose scripting language which I can use in:
-
Unix text processing (instead of awk, sed, Perl)
-
Web development
-
Programs for Unix open source projects
-
Mobile Dev (not as much important as the first three items).
So, Ruby or Python?
Unix text processing (instead of awk, sed, Perl)
You've named the kings of that domain, ruby and python both have text processing/regexp facilities but they are nowhere near as fast. I like ruby's regexp implementation a little better than python's. (go figure, says the guy on the ruby subreddit)
Web development
Ruby has some pretty bitchin web frameworks, though django and flask do a lot of the same things. The only thing that might edge ruby out as a clear winner here is that rails has so much community support, so if you don't want to re-invent the wheel, you can use a gem, whereas python might not have the same level of community support for django. It's probably pretty close.
Programs for Unix open source projects
Python is probably viewed as more of a "systems language" now than ruby. Both are equally capable of being scripting languages used for everyday tasks, just depends on what you're wanting to do.
Mobile Dev (not as much important as the first three items).
Ruboto/Rubymotion/Mobiruby are all things. I think ruby might actually take this the most handily.
tl;dr Learn multiple languages, use the tools that make sense for the project. Don't be bound to a single language.
I did 8 years of scientific programming in ruby, and 3 years of professional web dev in python (yes, it's ironic). Both are great languages, and I'm more than happy to code in either language at this point. I personally think ruby is easier to use for most of the things you mentioned, and I think ruby is a more elegant language than python (I think ruby is a better language, but I do think aspects of python are better).
You really can't go wrong with either. And, as was already pointed out, use python 3.6 if you choose python (the 2 train has left the station, thank heavens).
Hi folks, as a web engineer I've been coding for quite a lot in Ruby and Python and have an obvious question since that both languages are often compared to each other: why is Ruby not as popular as Python outside of the web? In my opinion obvious Ruby's advantages are as follows: object model is sane, neat and intuitive compared to Python's magic methods based duck typing, descriptors, metaclasses and imperative std; blocks are an absolute killer-feature; no Unicode hell; metaprogramming is easy to use; pip literally can't be compared to gems + bundler which can be found in almost all projects. The only advantages I can see in Python is list/dictionary comprehensions, and some low-level features buffer protocol.
Hey so as the title say, I'm really interested in becoming a DigitalNomad and learning how to programme, obviously this is not a viable career untill I'm confident with the language I learn. Just wondering what you guys think would be the best language for a person like me with no experience, I hear both are the easiest languages to learn (not to say they are not hard) If you could tell me some pros and cons of each language and what sort of work i would be looking at with each language (freelance & office) thanks, and sorry if this is not the place to ask!
I think Ruby is better for learning.
Everything is an object™
clearly demarcating the end of a logical block with end, rather than whitespace is much easier to follow for beginners.
Documentation for Ruby is much more readable
Depends what you want to do, most Ruby people do web dev (e.g. apps's backend and websites), and python devs do a lot of data crunching and some web dev.
Personally I use Python sometimes for small things I can't do with ruby (mitmproxy, machine learning, etc.) but I try to send the data back to some ruby code as fast as possible :D.
Ruby has the concepts of blocks, which are essentially syntactic sugar around a section of code; they are a way to create closures and pass them to another method which may or may not use the block. A block can be invoked later on through a yield statement.
For example, a simple definition of an each method on Array might be something like:
class Array
def each
for i in self
yield(i) # If a block has been passed, control will be passed here.
end
end
end
Then you can invoke this like so:
# Add five to each element.
[1, 2, 3, 4].each{ |e| puts e + 5 }
> [6, 7, 8, 9]
Python has anonymous functions/closures/lambdas, but it doesn't quite have blocks since it's missing some of the useful syntactic sugar. However, there's at least one way to get it in an ad-hoc fashion. See, for example, here.
Python Example
Functions are first-class variables in Python. You can declare a function, pass it around as an object, and overwrite it:
def func(): print "hello"
def another_func(f): f()
another_func(func)
def func2(): print "goodbye"
func = func2
This is a fundamental feature of modern scripting languages. JavaScript and Lua do this, too. Ruby doesn't treat functions this way; naming a function calls it.
Of course, there are ways to do these things in Ruby, but they're not first-class operations. For example, you can wrap a function with Proc.new to treat it as a variable--but then it's no longer a function; it's an object with a "call" method.
Ruby's functions aren't first-class objects
Ruby functions aren't first-class objects. Functions must be wrapped in an object to pass them around; the resulting object can't be treated like a function. Functions can't be assigned in a first-class manner; instead, a function in its container object must be called to modify them.
def func; p "Hello" end
def another_func(f); method(f)[] end
another_func(:func) # => "Hello"
def func2; print "Goodbye!"
self.class.send(:define_method, :func, method(:func2))
func # => "Goodbye!"
method(:func).owner # => Object
func # => "Goodbye!"
self.func # => "Goodbye!"