News for hackers. Stuff that matters.
Re:It's not Ruby that's slow, it's your database by drewbug01 on Tuesday November 08, 2022 @07:16PM (#33526032)
I think my favorite part is buried in footnote 5:

> Ironically, the performance issue becomes less articulated in this non-http, non-rails context, yet in these cases people generally dismiss ruby as option, for its performance-issues. Which, catch-22, is one of the reasons Ruby is hardly used outside of Rails (and/or Web).

It's a shame that most people only write Ruby in the context of Rails. It's a lovely language, and performant enough for a wide array of tasks. It can be startlingly elegant and exceedingly productive.

Of course, it's valid to talk about Ruby performance in the context of Rails, as the author does. However, it's gratifying to see a more detailed discussion on what Ruby folks mean when they say "your database is usually the bottleneck," and the author does a good job at examining different aspects.

(All that said: Rails is still a really good choice. So much of our work is just writing CRUD apps, and it's kinda boring. Rails makes it boring and easy, and it's a really good tradeoff.)

Re:It's not Ruby that's slow, it's your database by spoiler on Tuesday November 08, 2022 @08:04PM (#33526363)
> It's a shame that most people only write Ruby in the context of Rails

I fully agree with this! I used to use Rails for a few years (not professionally, FWIW), but didn't enjoy Rails that much. Even though, it's hands down the best "in class" framework, it beats anything in the JS or Python ecosystems (and claiming Django is anything close to Rails is just offensive to Rails).

But anyway, I've yet to find something that's as good as Ruby for daily scripts or task automation. Ruby is one of those few languages you can just read (I can't explain it well), and coming back to old Ruby code, the "wtf is going on here" moments are fairly scarce (sans code that touches metaprogramming/eigenclasses/DSLs, but even then it's more straightforward than in other languages). Lately I tend to just use Fish for most things (which are simple), but still reach for Ruby when the task is a bit more involved. Like, yeah there's Python, but I never liked Python. That's not to say Ruby isn't without any warts, but that's just... Technology, I guess lol.

Re:It's not Ruby that's slow, it's your database by drewbug01 on Tuesday November 08, 2022 @08:17PM (#33526490)
I don’t have some kind of grand, unified theory about this - but the people I know who genuinely enjoy Ruby on its merits seem to think about code differently. Not different-as-in-bad, but just… different. I too find it hard to explain.

> Ruby is one of those few languages you can just read

I think this has something to do with it, though. The stdlib has a lot of different ways to “say” the same thing (TIMTOWTDI, anyone?) and used well it can be quite legible. But some programmers I know find that really frustrating.

Maybe it has something to do with how one visually processes and reads code? How one might associate semantic meaning to things? I don’t know how, but it feels like there’s something interesting there to study.

Re:It's not Ruby that's slow, it's your database by KerrAvon on Tuesday November 08, 2022 @08:27PM (#33526579)
Yeah, there's a reason that _why the luck stiff was a Ruby person. Writing Ruby is (or can be) a more creative endeavor.

Some people really dislike the inability to recommend or see one unambiguous path to follow. These people are generally happier with Python.

Re:It's not Ruby that's slow, it's your database by ryantgtg on Tuesday November 08, 2022 @09:00PM (#33526763)
I agree. I’m not a professional developer, but I sometimes make bots/daily scripts, as well as scripts for work that are beyond Excel, and I always use ruby. My colleagues use python for similar work scripts, but to me they are painfully difficult to read and understand.
Re:It's not Ruby that's slow, it's your database by arkis22 on Tuesday November 08, 2022 @08:18PM (#33526501)
rails, postgres, PORO, and htmx is a monstrously productive stack
Re:It's not Ruby that's slow, it's your database by iamgopal on Tuesday November 08, 2022 @08:24PM (#33526555)
Any examples?
Re:It's not Ruby that's slow, it's your database by arkis22 on Tuesday November 08, 2022 @08:55PM (#33526737)
you're looking for what? my personal million dollar website or my billion dollar startup?
Re:It's not Ruby that's slow, it's your database by boredtofears on Wednesday November 09, 2022 @02:05AM (#33528326)
just any evidence to back up your argument
Re:It's not Ruby that's slow, it's your database by arkis22 on Wednesday November 09, 2022 @08:17PM (#33540871)
just my years of experience, sorry
Re:It's not Ruby that's slow, it's your database by ithrow on Tuesday November 08, 2022 @10:04PM (#33527099)
If you are one Rails, why not the hotwire stuff?
Re:It's not Ruby that's slow, it's your database by arkis22 on Wednesday November 09, 2022 @08:16PM (#33540856)
https://github.com/hotwired/hotwire-rails

deprecated. they use stimulus and its worse obfuscated JS than htmx IMO

Re:It's not Ruby that's slow, it's your database by Lio on Wednesday November 09, 2022 @03:35AM (#33528814)
Personal opinion, if I was going to use htmx with a PORO backend I'd probably go for Roda[1] and Sequel.

If it was going to be read heavy I think I'd also pair that with SQLite for low latency and cheaper deployments.

If I didn't know exactly how requirements are likely to change over time I'd probably go with with Rails, Postgres[2], Redis and Hotwire. You can go a long way with that and a small team.

1. https://roda.jeremyevans.net/index.html

Re:It's not Ruby that's slow, it's your database by aaron_m04 on Wednesday November 09, 2022 @12:27PM (#33534883)
What is PORO?
Re:It's not Ruby that's slow, it's your database by arkis22 on Wednesday November 09, 2022 @07:13PM (#33540234)
plain old ruby object. basically you take your truth from the database and you plug it into an object that takes the data and functionally produces a data output that you feed to your view.
Re:It's not Ruby that's slow, it's your database by boredtofears on Wednesday November 09, 2022 @02:03AM (#33528313)
I'm gonna play devil's advocate here: Ruby sucks in large codebases where conventions aren't well defined (unlike Rails, which has well understood concepts and abstractions).

Having no ability to do any kind of static analysis means a large legacy codebase will contain giant rabbit holes for you to fall into any and everywhere you look -- unless, of course, the architect(s) responsible for the codebase thought very carefully about this and limited the number of abstractions. If they didn't, you're left stepping through all the metaprogramming and one-off abstraction implementations.

Obviously, my experience is anecdotal, but I've decided my current job is the last Ruby job I'll take. I don't see any reason to pick Ruby over Typescript if you're not using a popular framework. Types save an incredible amount of time when you're ramping up.

Re:It's not Ruby that's slow, it's your database by ngc248 on Wednesday November 09, 2022 @02:26AM (#33528416)
You are exactly right and the pitfalls you talk about are common to all dynamically typed languages.
Re:It's not Ruby that's slow, it's your database by heurisko on Wednesday November 09, 2022 @03:41AM (#33528845)
Which is why some dynamically typed languages, like PHP, are moving towards types.
Re:It's not Ruby that's slow, it's your database by Lio on Wednesday November 09, 2022 @03:05AM (#33528632)
> Having no ability to do any kind of static analysis

Wouldn't Sorbet count as static analysis? It even supports gradual typing specifically for legacy codebases.

https://sorbet.org/docs/gradual

Re:It's not Ruby that's slow, it's your database by cntainer on Wednesday November 09, 2022 @03:35AM (#33528816)
> Ruby sucks in large codebases where conventions aren't well defined

The community is working to improve the outside-Rails ecosystem with efforts like dry-rb or ROM. So you can find plenty of useful non-Rails conventions if you look for them, but if you're doing typical web stuff it is hard to compete with the productivity monster that Rails has become.

> I don't see any reason to pick Ruby over Typescript if you're not using a popular framework. Types save an incredible amount of time when you're ramping up.

I guess RBS and Sorbet are trying to cover this point. I don't know how well they scratch that particular itch of yours as I haven't worked with Ruby for quite some time.

Re:It's not Ruby that's slow, it's your database by Tainnor on Wednesday November 09, 2022 @04:37AM (#33529215)
> dry-rb or ROM

When I was still doing Ruby, dry-rb was one of the projects I was excited about, but it didn't ever seem to gain a lot of momentum, and in my experience, Ruby means Rails (or at the very least something like Sinatra + gems originating from Rails) in almost all companies.

I was also left wondering, at some point, why solnica didn't just abandon Ruby for a statically typed functional programming language, as that seemed where he was headed with his efforts. It's what I ended up doing, at least.

Re:It's not Ruby that's slow, it's your database by berkes on Wednesday November 09, 2022 @06:25AM (#33529977)
I think the issue is with, what GP calls "boring CRUD".

This is where Rails truly shines! It's a near perfect fit. But that means anything that isn't a CRUD-setup, but e.g. command or event driven, or leaning on (complex) domain-logic or heavy in workflows, it lacks.

It lacks features to deal with it. It lacks structure to isolate a domain-model. It makes it easy to spread logic all over, but hard to put that logic in a bounded context. It is all about HTTP, when that really should be a detail in many apps. It is all about the database (as I write in my article "Rails is all about The Sacred Dictating Database") which should really be a boring detail.

"Large codebases" often fall in this category of nog being very cruddy. And therefore probably should eschew Rails. I won't choose it for these cases.