` Ruby vs Python why I like Ruby More

Ruby vs Python why I like Ruby More

I’m a student like most of you I was taught to code in C/C++ in college and like each one of you after getting to know how to code a bit. I jumped into the immense sea of programming languages, libraries, etc. And that was the time I was introduced to the scripting languages like python, ruby etc. and most probably ruby and python are most popular. And I fall in love with both of these languages as I was able to do the task in fewer lines of code and quickly.

Why I started with python and how i feel about it :

So I was googling new languages and I surprised by the love python gets from people and the community. And thought to give python a try

First Impression:

Don’t get me wrong i love python too but this article is why i liked ruby more than my beloved python

I used some quick starter for python. And I can’t describe how much I was loving to code in python. Everything was requiring less lines of codes to do more things. Then suddenly……..

It was W@F . Why?

I was unable to figure the syntax, before you start judging me and curse me in the comments. I was able to get the basic syntax of python and I loved as it was easier to read fun to apply. But the problem started when I started with loops and function And I was like

How to end this @#@#@#@ code block of the loop or function

And it took some time and frustration and Google search to know that block of code are marked by an indentation. Seriously? That’s what I asked myself.

if pwd == 'pass123':
    print('Logging in....')
    print('Incorrect password.')

print('You are logged in')

I was like wow, And I really hated this methodology. But in ruby I can simply close my function/condition/loop block using end command

if	pwd == 'pass123'
  puts 'Logging in.....'
  puts 'Incorrect password'

It can be seen how I can clearly know where my code block ended and in python I was scratching my head sometimes because of it.

Things I Like About Ruby More

  • The first thing I noticed when I jumped into ruby was that I was not wasting my time type casting. Don’t know why while coding in python I was just wasting my time typecasting, but it’s not the case with ruby.

  • Ruby is magical, I love how I can do complex tasks with fewer lines of code easily. When I need to things to do fast and making some scripts to do some basic tasks

  • Now I kept the best thing for last

    #### Flexibility:

​ I just love how much magical and flexible ruby is there are many ways to do the same task as you like to do:

From loops to condition myself gets a wide range of choices to use for scripting and for some people it may be painful, but I love this approach of ruby it makes coding more enjoyable as we can code how we like to do so.

For condition I can use either

# i can use unless to evaluate false conditon instead of using != 

There are wide range of loops too

while conditional [do]
end while conditional
  until conditional [do]
end until conditional

These are things i love about ruby

At last I love python too, but ruby is way too magical to fall in love with.

Also Read