Python vs Ruby: Which is best for web development?

Đã đăng vào - Cập Nhật Lần Cuối vào

Python and Ruby are really popular coding languages. You’ll see them popping up in the back end of all sorts of sites, including Twitter (Ruby), Google (Python) and Facebook (Python) – check out some others here! They’re serious heavy-hitters, and they have quite a lot in common. It’s when you take a closer look that the differences come out, and it’s really one of philosophy. Each language has a very distinct way of solving problems, and these differences should affect whether you choose them for coding your own website, web app or program.

Ready to dive in?

Back to basics:

Python has been a player for a long time, since well before it was used for any web development. Introduced in the early 90s, it was originally designed to use to make prototypes, which could then be ‘translated’ into another coding language, C++, for scale. Ruby came a little later, in the mid 90s, and it became popular because it was used in the web development space and has grown along with it.

The words of each language’s users help to put it in context: they call Python ‘readable’ and ‘clear’; they call Ruby ‘elegant’. It’s not that Ruby is necessarily harder to use – people often say it’s an easy one to learn – but they have very different goals.

Python:

When it comes to Python, the aim is clarity and readability. It takes a very direct approach, and there should be one optimal solution to any given problem when you’re using Python. You could sum it up in the following way:

Beautiful is better than ugly.

Explicit is better than implicit.

Simple is better than complex.

Complex is better than complicated.

That’s actually from a Python user, Tim Peters – you can read the rest here!

Accordingly, Python has a simple syntax, which is easy to remember. Everything about it is meaningful: if you look at Python code, it has white space which gives it a definite shape as you look at it. That shape spells out exactly how the resulting app works, once you know what you’re looking at.

When it comes to the Python community, you’re looking at people who typically use Linux, who work in science and math-based jobs, possibly in academia. It’s a very stable language and a stable community, which attracts all kinds of people to it.

Ruby:

Ruby is different because it focuses on “human-language” programming. Python is a machine-based language, while Ruby is meant to be comprehensible up front. Unlike Python, Ruby lets you do the same thing in any number of ways.

Ever heard of the principle of least astonishment? "If a necessary feature has a high astonishment factor, it may be necessary to redesign the feature."

If there’s a central philosophy of Ruby, it’s that principle – and what that means is that it’s meant to behave the way you’d expect it to. It’s as if you were speaking to a person: if you told them to smile and instead they wrote out the word ‘smile’ on a piece of paper, that would violate the principle of astonishment. If that person were running on Ruby, so to speak, they would simply curve up the corners of their mouth and produce the usual human smile expression!

The problem with all this is that there are a lot of similar or even duplicate features, which can get confusing.

Ruby has a newer and possibly more diverse community than Python, a community which tends to focus on innovating and pushing Ruby to do new things. Unfortunately, that does mean it breaks a bit more often than Python.

The bottom line:

For web development, both Python and Ruby have powerful frameworks which are well understood – Django for Python, and on Rails for Ruby. The result is that if you’re just looking for a language which can do what you’re looking for, either is perfect for web development.

Which you actually choose will probably depend on how you prefer to think. Ruby’s got the flexibility and the room for innovation, while Python offers stability and an older user-base to offer advice. You probably already know which one you’d prefer to use from the descriptions above!

Đã đăng 28 tháng 6, 2017

Nicole Walters

Transcriptionist - Proofreader - Writer

I carefully choose projects I know I have the time, expertise and interest in completing. When I make a bid, I have already scheduled the work I could do for you. I currently work for the transcription company, Global Lingo, on a freelance basis, and I have previously worked for Dr Crockett of Dewsbury Hospital. I have a wide range of experience in transcription, research, writing and data entry ...

Bài Viết Tiếp Theo

12 Ideas to Improve Your Website UX in Under 2 Hours