In Python you dont' have to type 'end', just kidding although for some reason it reminds me of VB for this reason. I wish it didn't but it does. Why have an end be anymore than 1 character on a serious note, that is lots of keystrokes extra not needed. But more seriously Python is a growth like Javascript. It has grown and adapted to every change it has been required because it has a very rapid iteration time and is…
Ask HN: Why Python over Ruby?
81–90 of 198 posts
Re: Ask HN: Why Python over Ruby?
#82At my job I use Python because, well, at some point before I arrived one of the senior developers went on a jihad against Perl. :-)
I've read stuff about Ruby and while some things about the language intrigue me, it seems that any application you can build with Ruby can also be built with Python. If I'm going to learn another programming language in my Copious Free Time, I want to learn something really different from what I already know, not something that has pretty much the same features with different syntax and libraries. So Python wins by inertia.
Re: Ask HN: Why Python over Ruby?
#83Earlier quoted context omitted.
...strange ad-hoc combination of other languages. I call bullshit, sir. Ruby is objectively less strange and more consistent than Python. Some has to do with the fact that Python is older - hence has more baggage to carry. A lot of it, though, just has to do with poor/missing design choices. Specifics? - ruby 'block' passing convention is much cleaner and more powerful than python's 'for'/iterators. - python's global…
Quoting an article on the topic: Having ploughed through several tutorials, I did not find Ruby particularly "elegant", or its syntax particularly obvious. Much of it seemed ad hoc, thrown together, in particular when there were several different ways of doing something, and it seemed to be the philosophy of the language to provide all of them. I did not find its constructs as intuitive and natural as claimed, trying…
Firstly starting with my_string['foo'] = 'bar', this is a syntax that is used a lot in Ruby for anytime that you wish to recover a subset of a collection - you can use it with a Dir object for example to recover a subset of directories/files, or in the case of a hash, to recover the object stored at the key. The thing is that you need to think about it as being a subset operator, rather than an index operator.
The exclamation point at the end of a method name has no syntactic meaning - it is simply a naming convention used by the standard libraries to indicate when the method mutates the object or not. Same same for method names ending with a question mark, it's just a convention to indicate that the response will be a boolean.
As for the whole "5" * 2 vs. 2 * "5", I must admit to not understanding where you're coming from. I don't see how you could expect any other kind of behaviour from an object orientated language. Personally I don't like over-riding arithmetic operators for non-number types, for precisely this reason, but hey, some people like it, so why not?
Integers converting to strings? I think every language has that no? I mean there's always something like: sprintf(myStringPtr, "%d", myInteger); or cout etc etc
By making this a standard method on all classes (to_s), Ruby makes it really easy to dump a class to a serial format, which is very useful for debugging, as an example.
I get the impression that you simply didn't spend enough time with Ruby to come to understand its idioms, in which case, you're not really in a position to effectively criticise the language...
Re: Ask HN: Why Python over Ruby?
#84Earlier quoted context omitted.
...strange ad-hoc combination of other languages. I call bullshit, sir. Ruby is objectively less strange and more consistent than Python. Some has to do with the fact that Python is older - hence has more baggage to carry. A lot of it, though, just has to do with poor/missing design choices. Specifics? - ruby 'block' passing convention is much cleaner and more powerful than python's 'for'/iterators. - python's global…
Quoting an article on the topic: Having ploughed through several tutorials, I did not find Ruby particularly "elegant", or its syntax particularly obvious. Much of it seemed ad hoc, thrown together, in particular when there were several different ways of doing something, and it seemed to be the philosophy of the language to provide all of them. I did not find its constructs as intuitive and natural as claimed, trying…
You're calling a method on a string, so you got the string doubled. Seems to make sense to me.
Obviously in this case the order of the arguments matter.
Re: Ask HN: Why Python over Ruby?
#85Earlier quoted context omitted.
... a community rife with arrogant children It's difficult to accept your rational argument when you include stuff like this.
Why is that? It can easily be proven. I'm not trying to suggest that everyone who uses Ruby is an arrogant child as I even have friends who certainly don't fit that bill, but when you have an especially abrasive attitude like that within a community, it only takes a minority to sour the majority. And while it certainly isn't a fault of the language , it definitely influences it usage for some people.
That's a decision you make for yourself, not an absolute truth.
Re: Ask HN: Why Python over Ruby?
#86I like Ruby (culturally) more than Python. Python has NumPy/SciPy/and friends, so I use Python. This, I feel, is a strong point for most who are using a scripting language to do scientific work.
Also what kind of work are you doing?
Re: Ask HN: Why Python over Ruby?
#87Re: Ask HN: Why Python over Ruby?
#88I hate Python's neglect (by Zed Shaw): http://www.zedshaw.com/blog/2009-05-29.html
Ruby seems to be so much more "symmetric", Python feels like a hack on top of dictionary to me.
Re: Ask HN: Why Python over Ruby?
#891. Get latest OpenSolaris. 2. Install latest SunStudio 3. download latest source of Python (3.1) and Ruby (1.9.1). 4. Try to build them with CC=/opt/SUNWspro/bin/cc" CFLAGS="-m64" 5. See the results. Run make test for ruby.
Re: Ask HN: Why Python over Ruby?
#90Earlier quoted context omitted.
Ruby's syntax is flexible: for i in 3..6 do puts i end
Very flexible. Once you learn what the sytnax means the implementation of blocks and iterators is one of the best parts of the language. 3.upto(6){ |x| puts x } I don't think the uniqueness of a language is any reason not to learn it. To be honest that sounds lazy. PS I'm not a Ruby zealot, and Python is a great language
Zen of Python: "There should be one-- and preferably only one --obvious way to do it."
Sure, there are other ways to do it in Python, but it'd be frowned upon to use something like 3.upto(6) rather than a standard range() that everyone is used to. Readability matters.