Hacker News new | ask | show | jobs
by faraaz98 1316 days ago
Great post! I feel like Ruby can make a comeback if a lot more people use it for more than just Rails
6 comments

I really, really like Ruby-the-language, and prefer it over python. I don't love that it's joined at the hip with Rails.

compared to Python, Ruby has:

  - first-class symbols (yes python has sys.intern but it would take a PEP giving them a pithy syntax to make them usable, plus python has 25 years of stdlib and libraries using "strings" or enums for constants instead of :symbols)
  - procs/blocks and better-than-python lambdas
  - "open classes" / monkey-patching of builtins (for better or for worse)
  - trivial metaprogramming with method_missing (for better or for worse)
some of these make fun one-off projects easier or faster, some of them would be less welcome in large, mature codebases.
So I'm a Ruby fan and I largely agree with you. I started dicking around with Stable Diffusion recently and was almost immediately reminded of so many things I dislike about Python.

But just to be a bit contrary:

- I don't see a huge value in symbols. In Ruby they are literally just static strings which means they use memory you'll never get back – potentially important if you're e.g. parsing something large into a hash and symbolizing the keys. If you have to put a non-alphanumeric character in a symbol you still need to use quotes.

- Procs, blocks, and lambdas – yes.

- Metaprogramming and monkey patching? dfjasdjldfjkdfjlkfdjldfoh4houfhufl. A double edged sword at best and 100% not something I'd want to see in a larger codebase. Javascript folks largely learned this lesson with the shift from Prototype to jQuery. You can do some really neat-o things but they're almost always unintuitive to the uninitiated.

I think monkey patching is a nice tool to have. I once had to deal with a vendor provided gem that assumed the product was configured in a specific way (it was not) deep in an internal method. Patching that one method was all I needed to do to get it working.
exactly. And when writing a test suite, I monkey-patch at will, which makes it sooo much easier to have self-contained tests without side effects or complicated dependencies.
You can dynamically create symbols and expect them to be garbage collected as of Ruby 2.2. They only become "immortal" if you use them to define a method, instance variable, or constant. So the common use case of hash keys is fine. One important advantage of symbols versus strings is that Symbol#== is constant time.
Ah hah, you've discovered how long it's been since I've thought about Ruby performance.

  One important advantage of symbols versus strings is that Symbol#== is constant time.
At that point though why not use integer constants?
syntactic sugar- you don't have to pre-declare them or worry about conflicting values. And occasionally the symbol.to_s method is useful in logging or whatnot. That's pretty much it.
> A double edged sword at best and 100% not something I'd want to see in a larger codebase.

the real footgun is dependencies that monkey patch things you don't know about / don't expect, and then the order you require those dependencies becomes important. augughghhhhh I hate that part.

Monkey patching I agree with but IMO it's unfair to lump metaprogramming into that same bucket.
The ruby proc passing style seems so ergonomic in curly paren style languages that I just can't understand my I haven't seen it anywhere else.
Haven't used Ruby in years, the one thing I miss in Ruby is decorators.
Don’t call it a comeback—Ruby hasn’t gone anywhere.

I get it that the hype around Ruby and Rails has—thankfully—subsided but Ruby is even better today than it was then.

It's much better today.

Sure when it was hype a decade ago you'd get lots of flashy tools and library every other days, but a large part of it was really wonky.

Now that the dust settled, the tools that remain largely used are much higher quality.

That and it's still by far the language backing the most startups that made it big.

Ruby gets results.

> backing the most startups that made it big [10 years ago]

This is not the case today. And most of those startups also had to then migrate to Go/Java/etc. to scale.

There's an argument to be had that they would not have been successful enough to need to scale without the speed of development provided by Ruby.
Yep, also a lot just migrated some components to more suitable languages but the for the most part remained Ruby.

You can scale anything if architected right.

You can't make languages fast and fun to write in if they aren't that to begin with. There's a lot to be said for dev morale and productivity.

Which? Apart from the twitter case, which was ages ago and largely overblown, there's no case that I can remember of ditching ruby for tech X because "for scale". There are lots of examples of companies using other tech rather than ruby, but usually for different reasons (python ML tooling, go for some performance bottleneck, Java for hiring).
Twitch, LinkedIn, Soundcloud, Grab, Parse, and Deliveroo. GitHub and Stripe are both transitioning off.

I.e https://news.ycombinator.com/item?id=20349004

"I worked at Twitch from 2014 to 2018... No more Ruby on Rails because no good way was found to scale it organizationally; almost everything is now Go"

I love that Ruby’s main goal is developer happiness. I feel like Matz has really delivered on that promise, even after 30 years.
Ruby never went away. It just used to have an extreme amount of hype and now is a mature and, dare I say, slightly "boring" language.
With Python being so much more common, Ruby would have to have something really remarkable in order to do that. Does it?
Ruby is the closest thing to Aspect Oriented Programming that I’ve seen. Primary driver of the reason the Gem ecosystem is so good.
But is it better enough to warrant a switch? Python has multiple inheritance (enabling “mixin” classes), metaclasses and decorators, all of which can be used to solve the problems which AOP aims to solve. Not to mention numerous modules to make AOP easy, if that is what you want. Again, it might be easier in Ruby, but is it easier enough?
I’ve read a few Python books and dove into it. All I can say is that I enjoy programming with Ruby. I keep coming back to it despite multiple other languages.

I love Elixir as a language but I still find myself coming back to Ruby frequently.

Python exists, but there’s nothing about the language that makes me want to use it. Quite the opposite. I find myself avoiding it whenever possible.

As a prominent Python dev told me, “It’s the okayest language out there.”

Could u tell me more details the "opposite" things here in details ?
By far the biggest thing for me is package/environment management. All of the tools I've used just suck. Pip, virtualenv, conda. For me, at least, getting started with anything non-trivial in Python involves grinding my teeth and slogging through whatever unpleasantries. Recently I've run into problems where some stuff seems to not work between different minor versions of Python 3. Ruby is generally easier and more portable – that a large subset of Python folks have standardized on a model / management tool like Conda that's not portable is something I can't say anything civil about. I can't think of any other language that's done something so boneheaded.

Beyond that Python is opinionated. In a lot of ways this is an improvement over e.g. Perl. However enjoyment is largely predicated on liking the opinions, if you don't it's not fun. For instance I wanted to write a multi-line lambda recently (mostly to make it easier to read). With Ruby and Rust I can do this pretty easily. With Python? No dice. Sure, there are good reasons to not make a lambda a multi-line ordeal but sometimes I just want to.

The things that attracted me to Python were:

1. “One way of doing everything”

2. Had a “Rails like” framework with Django

3. If I wanted to dip my toes in an AI library it would be a good choice

4. Access to a lot of system level libraries.

These all fell apart for me after getting into it.

1. As the other commenter suggested, there’s not even one clear way to handle package management. It’s a mess. In other languages, I’ve never had a good development experience with Docker because native is usually so much smoother, but with Python native is a bit of a mess with everyone recommending different tooling. This was compounded because I got into it during the last year of Python 2 so library segmentation was a bit of an added problem.

2. I’m hugely opposed to the way Django handles database changes compared to standard Rails migrations. This is personal preference.

3. I never had time to get into it, but figured if I ever did I’d setup something more dedicated for it. Plus Elixir released so much tooling around this space that I’d probably just go that route anyway.

4. I haven’t found anything system level that I need that I can’t get from Ruby or just calling directly from the command line.

Those were the biggest items.

It’s just not for me. I say that knowing full well that there are plenty of people who don’t like Ruby.

Unfortunately no. There's been a sight increase in interest ever since Ruby 3 but something else is needed for a spark
See, Rails is the one thing that I have never actually used Ruby for despite using it for a decade. Ruby is a fantastic language for systems automation, gluing things together and CLI apps.