Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The single most reason why a language X (it's python for me today) wins my heart is not because it's extra fancy or anything but the times when it gets out of my way to let me think about the problem and then everything else seems clearer. I write a lot in both Python and Ruby, but the days when I have to dig into my old code, Python readability trumps over Ruby's (or anything else for that matter).


the times when it gets out of my way to let me think about the problem and then everything else seems clearer.

There are two different ways languages accomplish this.

Smalltalk and Lisp accomplish this through odd-looking minimal syntaxes. The code may not look like anything familiar (outside of longish intention-revealing names) but there are so few syntactic rules to process that a smart person should be able to master them in a few days or weeks at most. (Despite the lack of familiar operator precedence for arithmetic operations.)

Python and Ruby accomplish this by having moderate amounts of syntax. (Ruby has about 3X more syntax than Python, but you can ignore much of Ruby syntax for general purpose programming and leave it in the "sysadmin toolshed.") However, the moderate amounts of syntax are designed to closely resemble pseudocode your professor used to scrawl on the chalkboard. Hence, the language can stay out of the way while you focus on the problem domain.

On the other end of the spectrum are languages that expose everything. C, C++, and Assembly are like this. Everything is available in raw form or as powerful and arcane tools. The beginner might be a little lost, but the rewards to the virtuoso are tremendous.

This is an oversimplification, of course. Python and Ruby also give the power-programmer access to powerful, arcane, and easily-abused tools. It's also quite possible to write very clean pseudocode-resembling code in C or C++. (See the Taligent coding standards.) The difference is really only in design-focus of the languages. (Smalltalk as another example. Smalltalk was designed to be simple to the complete novice -- as in a grade school aged kid. This is why it's minimalist, yet manages to look odd to the hard-core Unix geek.)


Can you give me an example of Python readability trumping Ruby?


It'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 :-)


I think indenting and block syntax are absolutely trivial with any good editor.


You missed my point. I am talking about the code being cleaner to look at in general.


It'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.


The 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.


If 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.


Newbies 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.



I don't know if that's tongue in cheek, but as a mainly python programmer i find ruby much more clear regarding operator overloading.


I 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

Where _language_ is concerned, I think Ruby is every bit as nice as Python if not nicer.


I 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.


It'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.


I find python revolting to look at. I find Pyhton web frameworks confounding to work with. I find PHP to be the most enjoyable language to write web based applications in. PHP just never enters into the discussion of languages but all of it's shortcomings are peripheral to the experience of actually writing code. Minor version upgrades often break things being my biggest gripe.

To folk claiming PHP is to programming what white bread is to a healthy colon, I say that you are the inferior programmer for not being able to love it.

My claim is this: PHP (and most certainly Perl) are to web application development what paint is to painting.

Web application frameworks written in Ruby and Python are to web programming what paint by numbers is to painting.


You're missing my point - a great language (whatever it may be for one's choice) doesn't get in the way of thinking clearly. If that's PHP for you, that's great.

I never mentioned any context of web in my statement. Au contraire, python's greatest strength is in its vast number of libraries for non-web stuff as well (though it can handle a lot of web stuff very easily). I find python's vast science and math packages to be very handy.


Not sure how that post ended up in reply to yours. I meant to add it as a comment on the article.


Why are people down voting this comment? Seems vindictive.


Your paint by number analogy doesn't really apply.

PHP, or Python, or Perl, as a language are to web applications what paint is to painting. CakePHP, or Symfony, or Rails, or Django is to web applications what paint + scaffolding + tarpaulins + masking tape + ladders is to painting.

Yes, you can build a ladder in the programming language you like, or you can just import one (or, in many cases, not have to) with a framework. They both still use paint, and I completely disagree with the assertion that a framework tells you where or what kind of paint to put -- it just puts you closer to the walls, and makes the application of said paint a little easier.

For the record, I personally consider an application framework more like a Wagner spray painter, or something more like that, but I think that's more dependent on the framework itself. Yes, there are constraints with frameworks, but there are significant advantages to speed of development.

As for the whole PHP vs Python, I'm completely ignoring, since you seem to be conflating PHP vs 'application frameworks in other languages' instead of PHP vs 'another language', which is unfair at best, and ill-informed at worst. For what it's worth, I'd put either Ruby or Python up as a general purpose language above PHP any day of the week, and PHP is the language I learned to program on (and still like, despite its unpopularity.)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: