5 ms·
Worth it to learn Ruby if you already know Python and NodeJS ? I find Ruby fascinating yet difficult.
by 999900000999 3y ago
Worth it to learn Ruby if you already know Python and NodeJS ?
I find Ruby fascinating yet difficult.
- jitl 3y agoI think Ruby is much better at shell script like tasks and interactive / exploratory programming for system tasks compared to Python or Node. Use it as “better bash” or “better Perl” and it’s worth it. I primarily work in a Typescript codebase, but regularly reach for it as a tool to wrangle log data, semi-structured text, or do regex rewrites of a bunch of files. Ruby is also very fun, probably the most fun language I’ve used regularly. That makes it its own reward.
- callc 3y agoThis is very intriguing, could you please elaborate? I have been looking for a better bash for scripting stuff without all the bash and sh-isms and gotchas.
- ignurant 3y agoSome of the most enlightening books I’ve read when I was first learning Ruby were Text Processing in Ruby, and Building Awesome Command Line Apps in Ruby 2. They each reveal certain features and perspectives that work towards this end, such as text parsing moves, Ruby flags to help you build shell 1-liners you can pipe against, and features with stdio beyond just printing to stdout. Then add in something like Pry or Irb, where you are able to build castles in your sandbox. Most of my data exploration happens in Pry. A final book I’ll toss out is Data Science at the Command Line, in particular the first 40 or so pages. They highlight the amount of tooling that exists that’s just python shell scripts posing as bins. (Ruby of course has every bit of the same potential.) I had always been aware of this, but I found the way it was presented to be very inspirational, and largely transformed how I work with data. A good practical example I use regularly is: I have a project set up that keeps connection strings for ten or so SQL Server DBs that I regularly interact with. I have constants defined to expedite connections. The [Sequel library](https://sequel.jeremyevans.net/ https://sequel.jeremyevans.net/) is absolutely delightful to use. I have a `bin/console` file that sets up a pry session hooking up the default environment and tools I like to work with. Now it’s very easy to find tables with certain names, schemas, containing certain data, certain sprocs, mass update definitions across our entire system. ``` # Something failed, and not everything loaded as you expected # explore explore explore… db::CompetitorPricing.tables db::CompetitorPricing.tables.grep(/^pricing_/) latest = DB::CompetitorPricing.tables.grep(/^pricing_/).map {|table| [table, table.max(:create_ts)} latest = latest.sort_by(&:last) # serialize to csv, or json, or perhaps copy the data into excel: Clipboard.copy latest.map{ _1.join("\t")}.join("\n") ``` Just like with work in the shell, you have a really easy time iteratively exploring the problem and building up your answer. The ability to serialize your data you’ve found, and keep your favorite tools in your pocket feels extremely productive. And of course, all of this can be written in ruby 1-liner shell scripts, or more complex shell scripts to pipe in and out of other tools if desired.
- eddieroger 3y agoIf you're productive in Node or Python, then learning Ruby would just be educational in that it's something else to use. Personally, I've found Ruby to be a great language in which I can be productive quickly, which is why I stick with it, but I've written Ruby code off and on for the last 15 years in various forms of production code. I think it's great to learn, but I wouldn't switch to it (or anything) if you're already productive elsewhere.
- lp4vn 3y agoI worked with ruby, ruby in rails(RoR) more specifically, a bit more than ten years ago(2011-2013). At that time it was already the afterglow of RoR, the framework for web development that had come to life in 2005 and raged between 2007 and 2009. The latest-technology-addicted crowd was jumping into the boat of node.js, that was crazy fast compared to anything done RoR, and API oriented development with angularjs. In 2013 RoR already showed its age as the standard ways of doing things with it was still the monolithic way and the framework was not transitioning very well to the new paradigm of frontend/backend development. This introduction about a framework built with ruby and not ruby itself was necessary because even today, I would guess that 95% of all development with ruby is RoR applications. It's my understanding that ruby rose to prominence mostly because of ruby on rails, now that RoR is in a downward trend I think ruby will follow the same trend until it's reduced to a small community of enthusiasts in the same way that happened to perl. As for the language itself I can't think of a single reason to opt for ruby over python or typescript. Ruby doesn't do anything better both in terms of language or platform than its already better established competitors.
- gls2ro 3y agoRuby and Ruby on Rails are not in a downward trend. There were maybe some year where the interest was decreased but in the last 2 years a lot of things happened: Ruby has a lot new features, Rails 7 is out and comes with a new approach to web apps like for example Horwire with the just released Turbo 8. And there is a lot more: new conferences, new books and new gems. (Shameless plug: I curate a newsletter called Short Ruby that covers news from Ruby world every week). Maybe Ruby is not at the level where is was in 2007-2009 but it is also NOT in a downward trend.
- lp4vn 3y ago>Maybe Ruby is not at the level where is was in 2007-2009 but it is also NOT in a downward trend. It's not only that ruby and ruby on rails are trending down, this has been the case for at least 10 years. https://berk.es/2022/03/08/the-waning-of-ruby-and-rails/ https://berk.es/2022/03/08/the-waning-of-ruby-and-rails/ This is only an article, but you will find the same point of view in many other places. The decline of ruby and RoR is obvious for anyone doing web development. Python is only getting stronger, Typescript the same, not to mention the statically typed competitors like Java with Spring Boot. I wouldn't doubt that even languages like Go and Rust might surpass ruby soon in web development because as general purpose languages they are already more relevant. I'm a former RoR developer and I took off the keywords ruby and ruby on rails from my curriculum because for me professionally it makes no sense to invest time in them.
- burlesona 3y agoRuby is basically a less popular but more elegant Python. It’s a solid general purpose language, but especially good at shell scripting, data munging, etc. If you’re fluent in Node and Python it should be quite easy to learn. The downside is it’s not going to do anything fundamentally new for you coming from those languages. The upside is mostly aesthetic, Ruby offers and encourages really beautiful ways of expressing code, and it’s neat to experience that.
- nerdponx 3y agoHaving tried to use Ruby for text processing specifically, I'm not sure I agree it beats Python at that particular task. Maybe I'm just used to the Python way of doing things, but I found it difficult to work with the lack of first-class functions and iterators/generators, as well as the general iteration protocol.
- weaksauce 3y ago> lack of first-class functions and iterators/generators, as well as the general iteration protocol can you elaborate on what you miss here? ruby has a robust enumerable suite of methods so i'm curious what you found lacking
- dragonwriter 3y ago> but I found it difficult to work with the lack of first-class functions and iterators/generators, as well as the general iteration protocol. Ruby has iterators/generators. It doesn't have first-class functions because it doesn't have functions at all, but blocks/procs serve the same purposes.
- xdennis 3y agoI don't know Ruby, but it kinda sounds like Ruby just calls first-class functions blocks.
- thelibrarian 3y ago
- xivusr 3y agoI’d genuinely love to hear more about what you find difficult about Ruby coming from a heavier Python or NodeJS background. For me, coming from more of a Ruby background, I found Python and Node to not be too hard to understand, and my only nitpick would be on how eggs/packages were managed and dealing with dependancies. In particular, Python dependancies compared to Ruby dependancies were more challenging initially for me. I’ve grown to appreciate Python indents and find it nice to read, but that was also annoying at first.
- tjpnz 3y agoNot op but compared with Python it's heavier in the syntax department. You would have an easier time going in the other direction and encounter less situations where you have to stop and think about what to use in which situation while learning.
- deleted 3y ago[deleted]
- block_dagger 3y agoUse Rubocop to give you hints about improving your code as you learn. It' s a wonderful linter and teacher!
- ufmace 3y agoDepends on what you're looking to get from it. The most interesting part IMO is how it's so similar to Python along many categories, but also so different. Biggest example is how Ruby just loves Blocks. They're all over the place in the std lib, tons of syntax sugar for them, and countless DSLs built around them. All the standard functional stuff is there in the std lib and has been from very early on, so doing functional-style stuff is really smooth and reads well. In Python, you can technically do most of the same stuff, but it all seems a lot more awkward to write and to read (though maybe just my opinion from doing Ruby first). Python has lambdas, but it doesn't seem to like them much for more than trivial things. But instead functions are first-class everywhere.
- hello_moto 3y agoOnly if you want to build web-app that fit Rails. I wouldn't use NodeJS to build web-app that fits Rails. NodeJS ecosystem feels like building on a house of cards though.
- 999900000999 3y agoNodeJS is probably my strongest language. But it's horribly unstable, the sheer amount of legacy code is overwhelming. Python feels alot cleaner, but I wouldn't pick it over Node for web UI automation or Rest API testing.
- hello_moto 3y agoThe biggest problem with NodeJS ecosystem is the type of crowd that gets excited over NodeJS: JS developers, some web folks. NodeJS does not attract the kind of people who build ElasticSearch, Kafka, Hadoop, Spring Framework, etc so the quality of the libraries reflected of that the Web Developers crowd: the short-term Do-ers (need it today, let's build it, and let's move on to the next interesting stuff).