4 ms·
Can you give me an example of Python readability trumping Ruby?
by aditya 16y ago
Can you give me an example of Python readability trumping Ruby?
- samratjp 16y agoIt's simple, If I don't indent properly - I don't get to run my code in python. Yes, I know I can make my code look cleaner in Ruby, but I'm lazy. Call me shallow, but sometimes not having to type in blocks and "end" is kind of nice because of the inherent indentation constraint. And that indentation makes it easier to find lexical scope hierarchy easily too (at least for me). YMMV :-)
- rjprins 16y agoI think indenting and block syntax are absolutely trivial with any good editor.
- samratjp 16y agoYou missed my point. I am talking about the code being cleaner to look at in general.
- stcredzero 16y agoIt's just a trade-off. You get cleaner-looking code, which is much trickier to copy off a random web page. The latter might seem trivial, but it's not so simple. In an environment with ubiquitous browsers, many programmers start as copy-pasters. (Just as many of us of earlier generations started out in BASIC.) I'm not saying this is bad. It just is.
- wvoq 16y agoIf you're trying to copy a non-trivial amount of code from a web page, you're doing it wrong. In 2010, I think sharing code over the internet is a solved problem.
- stcredzero 16y agoNewbies often try to "do it wrong." I also wrote lots of really horrendous BASIC. It was a learning experience. If you think of tab-soup as a Python newbie right of passage, that's your prerogative.
- thezilch 16y agoThe programmers should hone their tools first, as they are going to be the most important part of their experience. For copy-pasting code, in vim -- surely other editors have similar, highlight the new code (and surrounding code) and hit "=" (equals) key.
- clyfe 16y agoExample: http://docs.python.org/reference/datamodel.html#basic-customization http://docs.python.org/reference/datamodel.html#basic-custom... vs http://www.brpreiss.com/books/opus8/html/page595.html http://www.brpreiss.com/books/opus8/html/page595.html
- Raphael_Amiard 16y agoI don't know if that's tongue in cheek, but as a mainly python programmer i find ruby much more clear regarding operator overloading.
- prog 16y agoI have to agree. I am also mainly a Python programmer who had dabbled a bit in Ruby, but in the above examples, Ruby is definitely nicer. I mentioned some of the reasons I stuck with Python here: http://news.ycombinator.com/item?id=1941594 http://news.ycombinator.com/item?id=1941594 Where _language_ is concerned, I think Ruby is every bit as nice as Python if not nicer.
- alextgordon 16y agoI think the point of Python's horrible syntax is to make operator overloading so painful that you're less likely to abuse it (cough C++ cough Haskell). Either that or Guido really likes underscores.
- Daishiman 16y agoIt's part of the point. The idea being that when you're doing operator overloading or metaclass hacking there's a simple, easy visual guide.