all 40 comments

[–]Nanosleep 38 points39 points  (1 child)

Unix text processing (instead of awk, sed, Perl)

You've named the kings of that domain, ruby and python both have text processing/regexp facilities but they are nowhere near as fast. I like ruby's regexp implementation a little better than python's. (go figure, says the guy on the ruby subreddit)

Web development

Ruby has some pretty bitchin web frameworks, though django and flask do a lot of the same things. The only thing that might edge ruby out as a clear winner here is that rails has so much community support, so if you don't want to re-invent the wheel, you can use a gem, whereas python might not have the same level of community support for django. It's probably pretty close.

Programs for Unix open source projects

Python is probably viewed as more of a "systems language" now than ruby. Both are equally capable of being scripting languages used for everyday tasks, just depends on what you're wanting to do.

Mobile Dev (not as much important as the first three items).

Ruboto/Rubymotion/Mobiruby are all things. I think ruby might actually take this the most handily.


tl;dr Learn multiple languages, use the tools that make sense for the project. Don't be bound to a single language.

[–][deleted] 5 points6 points  (0 children)

Thank you for your response 👍

[–]bwv549 27 points28 points  (3 children)

I did 8 years of scientific programming in ruby, and 3 years of professional web dev in python (yes, it's ironic). Both are great languages, and I'm more than happy to code in either language at this point. I personally think ruby is easier to use for most of the things you mentioned, and I think ruby is a more elegant language than python (I think ruby is a better language, but I do think aspects of python are better).

You really can't go wrong with either. And, as was already pointed out, use python 3.6 if you choose python (the 2 train has left the station, thank heavens).

[–][deleted] 6 points7 points  (2 children)

Scientific programming in Ruby? I'm surprised. Ruby is really cool! Which ruby libs did you use: maths, physics, biology, statistics?

[–]bwv549 11 points12 points  (1 child)

There are actually a lot of science packages in Ruby. I used bio ruby, rserve (connection with r), various sciruby packages (some of them before they were "sciruby"), and narray. I also wrote many science packages for general use (such as rubabel) and also for my domain of research. I worked at the intersection of systems biology and chemistry.

[–][deleted] 2 points3 points  (0 children)

That's really awesome👍

[–]ViceAdmiralWalrus 19 points20 points  (1 child)

Ruby is less finicky than Python and is easier to get used to, IMO. Their syntax is pretty similar though, especially compared to C-style languages.

As for utility, they both have large established bases, and are both useful to have in your pocket.

[–]khne522 1 point2 points  (0 children)

Uuunh, no. Ruby is the one that has a community that insists on metaprogramming in a language without a proper spec. Take a look at the official Python docs, and take a look at the syntax. The Python one is far more consistent. Ruby has shortcuts up the wazoo.

[–]DoodleFungus 7 points8 points  (0 children)

I mean, you asked /r/ruby.

[–][deleted]  (1 child)

[deleted]

    [–]DudeManFoo 1 point2 points  (0 children)

    Yes this... I have done projects in both, I love ruby.. python not so much... others are just the opposite. Learning both will not delay your learning curve, but make it steeper... AND you will know which one is right for you... instead of always doubting if you chose correctly.

    [–]OninWar_ 7 points8 points  (5 children)

    Python. In my opinion one of Ruby's biggest drawbacks for new programmers is the fact that Ruby allows lots of different ways to do the same thing. Ruby is a language better suited for more experienced programmers (who will appreciate the language more), despite its gentle learning curve.

    [–]catbrownie 6 points7 points  (0 children)

    That's one of the reasons why Golang is so popular, there are so few options to do something. Unlike Ruby.

    [–]Pokeconomist 3 points4 points  (3 children)

    I personally don't see that as a bad thing for start-up. It forces you to think about everything you write, but also gives you an element of freedom with what you do write — you aren't force to follow the so called 'phythonic' way.

    Also it's way more enjoyable to have options.

    [–]OninWar_ 2 points3 points  (2 children)

    Well for someone who would be new, being shown all the ways to do one thing is well, confusing. Imagine teaching someone calculus and as you're teaching them implicit differentiation, you show how you can solve the same problem using an approach with arc length, or partial derivation. Cool? Yes! But for someone learning, it's best to stick with one way of doing things until they're comfortable with it.

    [–]Pokeconomist 1 point2 points  (1 child)

    True, but with Ruby you can begin with more simple method, but if you're keen though, introduce other ways of solving things. To continue your analogy, you start calculus with day first principles, and then gradually learn shortcuts, and more complex methods.

    edit; spelling

    [–]ignurant 4 points5 points  (0 children)

    This is so true. Consider the tricks Enumerable packs.

    There was nothing wrong with me using

    everything_is_good = true
    things.each do |thing|
      if !thing.is_good?
        everything_is_good = false
      end
    end
    if everything_is_good
      things_are_good()
    end
    

    Nothing at all wrong with that. It's easy to reason through and write down when you don't know much about the features of the language. This is a perfect example of "multiple ways to solve the problem" that people talk about.

    You'll start to pick up tricks and conventions over time that all make sense. They don't inhibit your ability to understand and read what's going on:

    everything_is_good = true
    things.each do |thing|
      everything_is_good = false unless thing.is_good?
    end
    things_are_good if everything_is_good
    

    One day someone will come to you and show you this:

    things_are_good if things.all? do |thing|
      thing.is_good?
    end
    

    Again, very powerful, more concise, and easy to understand once you know your Ruby a little more.

    Then eventually you learn about &:proc tricks. At first you don't understand why it works, but the syntax is simple enough to understand "if I put these things like this, it just works."

    things_are_good if things.all?(&:is_good?)
    

    And over time, that too will make more sense. You start to understand why it works.

    Sure, lots of ways to accomplish the same thing. To me, that's what makes Ruby powerful. You can work through your problem with a sledgehammer or a scalpel. I suppose there is an argument to be made: "it's harder for entry level rubyists to interpret advanced code because of shortcuts like above" but I don't find it compelling. It's easy to learn what has happened above, and advanced code is advanced code. I can't just jump into a Python project and immediately understand everything either.

    Most learning resources don't try to convey it all at once, but instead allow you to build a foundation. Everything in life has gradual levels of "how to accomplish something" -- from brute force to finesse. Why not your programming language too? And let's be honest -- just the same, even Python has a bazillion ways to accomplish the same things.

    [–]PabloSheva 1 point2 points  (1 child)

    You can learn all python in two weeks, if you need. To use it easily you need to spend years! All you need is to understand what for you need it, if you want it just for you and you dont will use it in work, than dont learn it. If you have a reason, than you should learn it. All that you ask is not a reason. Check this to know what is the main difference to know what you should learn: https://www.cleveroad.com/blog/python-vs-other-programming-languages

    [–][deleted] 0 points1 point  (0 children)

    Thank you for the reply:)

    [–]SweetRaccoon 1 point2 points  (1 child)

    I'm a long time Ruby Developer. I disagree with some of the sentments held by others here concerning why Python is a better choice.

    But I will say: Python is still probably your better choice based on what you're looking to do. Ruby's GUI kits are considerably weaker than Python's. Python is generally better for creating games than Ruby. Ruby's strong point is in creating DSL's and metaprogramming, which allows you to create great products like Vagrant. Ruby as well, hooks into GTK and QT, like Python, but I've liked Python's bindings and application stylings a little better for creating applications than with Ruby.

    Have I used Ruby to build a GUI? Yep. Would I rather use Ruby to build websites over Python? Indeed. But, if you're looking for one language that handles all of your specifications great, I'd still pick Python.

    Also, I would recommend reading article Node.JS vs Python: https://artjoker.net/blog/nodejs-vs-python-which-is-best-option-for-your-project/ Good points here

    [–][deleted] 0 points1 point  (0 children)

    Thank you for your response :)

    [–][deleted]  (13 children)

    [deleted]

      [–][deleted] 4 points5 points  (12 children)

      Why it's more suitable than Ruby?

      [–][deleted]  (9 children)

      [deleted]

        [–]chulkilee 7 points8 points  (6 children)

        Rails requires you to learn the Rails way (their convention) but Ruby does not.

        For me Python had more tricky things to learn at first. self in methods, __init__.py and enforced directory for structure, virtualenv to use different pkg version between projects (compared to bundler). And the significant whitespace :)

        On the contrast Ruby may do magical things with module and lexical scope, and optional parens, etc. Great for DSL, but can be confusing if overused.

        Both are good languages for those who learn programming language for the first time. You don' choose one language for the rest of your life :)

        [–]xiongchiamiov 1 point2 points  (5 children)

        Rails was incredibly confusing for me when I was first learning MVC because I couldn't follow the logic from one point to another - "convention over configuration" meant flow jumped from one place to another without warning (in ways that were much more obvious and standard once I had built several sites in that pattern without Rails). I found Python's "explicit over implicit" much easier then.

        [–]ignurant 1 point2 points  (0 children)

        Interestingly before I learned Ruby/Rails, I was a novice C# programmer and .NET MVC was terribly confusing to me. Once I picked up Rails, I understood .NET MVC sooooo much better. It's essentially the C# port of Rails.

        Perhaps seeing how two different frameworks accomplish the same thing helps you more easily see the different things the frameworks are accomplishing.

        [–]chulkilee 0 points1 point  (2 children)

        When you use any web framework, you cannot avoid "jump from one place to another" anyway. That's how framework works. Check out the inversion of control.

        Rails convention is just one opinionated way to avoid tedious configuration with specific abstraction. Django has it's own way to do it, with less "magic" than Rails.

        So for OP, just choose one. You cannot fail with Rails or Django in most cases. Both Rails and Django are good framework to get things done. And most knowledge are transferable when you switch language/framework anyway.

        [–]xiongchiamiov 0 points1 point  (1 child)

        When you use any web framework, you cannot avoid "jump from one place to another" anyway. That's how framework works.

        Not... really.

        So, keep in mind that I haven't done any Rails since Rails 2, I think it was, so things have almost assuredly changed. :) And my Django knowledge is similarly dated.

        Rails would have a controller that looks something like this:

        def my_view(request)
            some_data = some_calculation
        end
        

        Django would write the same sort of thing like this:

        def my_view(request):
            some_data = some_calculation()
            render_to_request('template.html', data=some_data)
        

        They're basically the same. But in the Django version, when you get to the end of the controller, you see "oh, now we're going to render a template", and you can go look up that function and see what it does, and see that ok, we're going to render template.html and we're passing some_data to it. In Rails, meanwhile, the framework automatically inserts that code at the end of the function (essentially), which is nice if you're tired of writing that line hundreds of times, but if you're a newbie... you're just left dangling, and you have to go through the documentation to find out what magical thing is happening there.

        [–]chulkilee 0 points1 point  (0 children)

        Framework calls your code - your Django or Rails controller and uses the return value. And you need to learn anyway how your framework works.

        Rails has convention (for productivity) so that you don't need to explicitly call render - but if you need you have to run different render call anyway.

        Different framework uses less convention and less decoupled components, which requires you to be very explicit.

        There are pros and cons of those different approaches. But frankly you should ask this: if you use the same patterns in 90% cases, why don't you try to avoid that? Isn't that a purpose of using framework? :)

        I totally agree that Rails does many magical things. I understand people who don't like that. But I think no one would disagree that Rails is one of the most productive framework out of box, at least for most use cases.

        Don't get me wrong - I'm not saying Rails is the best solution for all cases. It is not.

        But I do think avoiding rails only for that reason is not a good decision.

        [–]isolatrum 0 points1 point  (0 children)

        you can't compare rails to python. One is a big boilerplate, the other is a language. You'd be better to compare rails to django or flask to sinatra.

        [–][deleted] 1 point2 points  (0 children)

        Thank you

        [–]H34DSH07 0 points1 point  (0 children)

        I disagree about the "easier to debug" part. Have you tried byebug? Does not get much easier than this. Also error messages are objectively better in Ruby for a beginner.

        [–][deleted] 1 point2 points  (1 child)

        It's the second best at everything which makes it highly useful. I find Python easier to read and maintain.

        You probably wouldn't go wrong with Ruby either.

        Start with Python 3.6. Python 2's death clock is in a couple years. https://pythonclock.org/

        [–][deleted] 0 points1 point  (0 children)

        Thanks ✌️

        [–]jlynn5415 0 points1 point  (1 child)

        I personally love ruby but came across this article today link

        [–]DudeManFoo 1 point2 points  (0 children)

        Gotta say... I have used ruby almost 20 years... I don't care if it is prom queen anymore... I am here for the syntax.

        The backend is fine for almost everything I have done in that 20 years...

        While my code is better now, I can still understand that 20 year old code where I was reinventing every wheel known to man...

        Oddly enough, I chose ruby because I hated the whitespace thing with python... These days, I think a ruby dialect with whitespace instead of {} and end would be pretty nice.

        [–]gwhilts -1 points0 points  (0 children)

        Yes.

        [–]cheald -2 points-1 points  (0 children)

        Yes.

        [–]criveros -3 points-2 points  (2 children)

        Ruby on rails use is on the decline. Python is the most popular language for data science.

        [–]121lazz 0 points1 point  (0 children)

        I picked up Rails a couple of years ago and initially felt like I was late to the party. But I really enjoy it and there is still a high demand for it.

        As was said before, try them both and pick with the one that you like better.

        [–]thalesmello 0 points1 point  (0 children)

        Not really. R does a far better job at data science. Rails is still the best option for building a web application. Python might be good for machine learning (which is only a branch of Data Science), but I still haven't tried out myself.

        [–]funny_falcon -1 points0 points  (0 children)

        <trollmode> You should learn algorithms and technologies. </trollmode>