You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: readme.md
+11-10Lines changed: 11 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -63,7 +63,7 @@ This is what is known as the [Zen of Python](http://www.python.org/dev/peps/pep-
63
63
4. Complex is better than complicated.
64
64
5. Readability counts.
65
65
66
-
Essentially, Pythonists value code readability and productivity over all else.
66
+
Essentially, Pythonists value code readability and productivity over all else.
67
67
68
68
> Check out [this](http://stackoverflow.com/questions/228181/the-zen-of-python) StackOverflow question to see examples of all the guidelines in use. Highly recommended read!
69
69
@@ -79,20 +79,20 @@ While Python values one main way of solving a problem, Ruby - influenced by Perl
79
79
80
80
*Ruby inherited the Perl philosophy of having more than one way to do the same thing. I inherited that philosophy from Larry Wall, who is my hero actually. I want to make Ruby users free. I want to give them the freedom to choose. People are different. People choose different criteria. But if there is a better way among many alternatives, I want to encourage that way by making it comfortable. So that’s what I’ve tried to do. Maybe Python code is a bit more readable. Everyone can write the same style of Python code, so it can be easier to read, maybe. But the difference from one person to the next is so big, providing only one way is little help even if you’re using Python, I think. I’d rather provide many ways if it’s possible, but encourage or guide users to choose a better way if it’s possible.*
With more freedom and less syntactical rules, many Rubyists believe that Ruby is a much more elegant language - and it is. But you can also often see messy code (especially from beginners) that can be difficult for other developers to read. For example, you can put multiple statements on one line. This can look good and be readable, depending on how it's coded - or it can be a mess.
86
+
With more freedom and less syntactical rules, many Rubyists believe that Ruby is a much more elegant language - and it is. But you can also often see messy code (especially from beginners) that can be difficult for other developers to read. For example, you can put multiple statements on one line. This can look good and be readable, depending on how it's coded - or it can be a mess.
87
87
88
88
Let's compare some code. The following snippets of code are for solving the Fibonacci sequence:
89
89
90
90
*Ruby:*
91
91
92
92
```ruby
93
93
deffib(n)
94
-
n <=2?1 : fib(n-2) + fib(n-1)
95
-
end
94
+
n <=2?1 : fib(n-2) + fib(n-1)
95
+
end
96
96
```
97
97
98
98
*Python:*
@@ -153,7 +153,7 @@ As you can imagine, there are many more differences that just the syntax and phi
153
153
154
154
#### Learning Curve
155
155
156
-
Without a doubt, Python is much easier to learn because of how the language is structured - and how **explicit** it is. One can literally become proficient in two to three months. Ruby takes much longer to learn due to its flexibility. Beneath the elegant surface, there's a lot of magic happening. It takes a while to grasp exactly what is happening. It can take upwards of six months to become proficient in Ruby.
156
+
Without a doubt, Python is much easier to learn because of how the language is structured - and how **explicit** it is. One can literally become proficient in two to three months. Ruby takes much longer to learn due to its flexibility. Beneath the elegant surface, there's a lot of magic happening. It takes a while to grasp exactly what is happening. It can take upwards of six months to become proficient in Ruby.
157
157
158
158
You can see just how explicit Python is based on this example:
159
159
@@ -169,7 +169,7 @@ require 'twitter'
169
169
twit =Twitter.new
170
170
```
171
171
172
-
In the first example (Python), we are importing the `Twitter()` class from the `twitter` library, while in the latter example (Ruby), we are simply importing the `twitter` library, giving us access to the entire library, not just the `Twitter()` class. So you can see that in Python, you import only what you need, nothing else.
172
+
In the first example (Python), we are importing the `Twitter()` class from the `twitter` library, while in the latter example (Ruby), we are simply importing the `twitter` library, giving us access to the entire library, not just the `Twitter()` class. So you can see that in Python, you import only what you need, nothing else.
print"Hi, {}. I'm thinking of a number from 1 and 20.".format(name)
234
+
print"Hi, {}. I'm thinking of a number from 1 and 20.".format(name)
235
235
236
236
while guesses <6:
237
237
@@ -262,7 +262,7 @@ guesses = 0
262
262
puts'Hello! What is your name?'
263
263
name =gets.chomp.to_s
264
264
265
-
puts"Hi, #{name}. I'm thinking of a number between 1 and 20."
265
+
puts"Hi, #{name}. I'm thinking of a number between 1 and 20."
266
266
267
267
while guesses <6
268
268
@@ -291,7 +291,7 @@ What are the syntactical differences? Is the Python code Pythonic? Is the Ruby c
291
291
292
292
### Conclusion
293
293
294
-
As you can tell, there's not too many differences in the languages themselves. Yes, Python values **readability**, **one method of doing things**, and being **explicit** - but these are minor differences. It's more about the end goal. What are you trying to accomplish? My advice: Try both languages. See which language you like better, then learn that one. After that, learn the other.
294
+
As you can tell, there's not too many differences in the languages themselves. Yes, Python values **readability**, **one method of doing things**, and being **explicit** - but these are minor differences. It's more about the end goal. What are you trying to accomplish? My advice: Try both languages. See which language you like better, then learn that one. After that, learn the other.
295
295
296
296
Always, always, ALWAYS remember that no language can do it *all*. In other words, all languages have their positives and negatives
297
297
@@ -302,4 +302,5 @@ Cheers!
302
302
1.[Why I push for Python](http://lorenabarba.com/blog/why-i-push-for-python/)
303
303
2.[4 Reasons Why You Should Learn Ruby As Your First Programming Language](http://www.skilledup.com/learn/programming/4-reasons-learn-ruby-first-programming-language/)
304
304
3.[How do Python and Ruby compare?](http://www.quora.com/How-do-Python-and-Ruby-compare/answer/Fabio-Akita?share=1)
305
+
4.[Why Python is a Great First Language](http://blog.trinket.io/why-python/)
0 commit comments