Live data from Hacker News

How to build a search engine with Ruby on Rails

blog.testdouble.com

51–60 of 65 posts

Re: How to build a search engine with Ruby on Rails

#51
post #20
post #2

This is a bit off topic but I wanted to say I’m really glad there are still people out there hacking on some ruby + Postgres projects and writing about it. I feel that ruby is an excellent language and dread the demise of it.

Some of the most interesting projects I stumble on as part of the public sector digitalisation in EU are made in Ruby on Rails (Southern Europe, especially Spain/Portugal), PHP (all of EU) and Python (Eastern Europe). Having recently switched most of our internal development from C# to Python and Powershell I get it. I can’t imagine not building small web apps in Python and I imagine PHP and RnR are exactly the same…

>Having recently switched most of our internal development from C# to Python and Powershell I get it.

How was the move from C# to Python?

Re: How to build a search engine with Ruby on Rails

#53
Great article. By the way, ActiveRecord's #merge is golden, and I'm under the impression it's not as mainstream as it should be.

I use it extensively to avoid duplicating scope code.

For instance:

class Listing

   scope :active, -> { where("expired_at > ?", Date.current).where.not(suspended: true) }
end

class User

  has_many :listings
end

So instead of doing this (which is terrible):

user.joins(:listings).distinct.where("listings.expired_at > ? AND listings.suspended != FALSE", Date.current)

You can simply:

user.joins(:listings).distinct.merge(Listing.active)

Rails docs are amazing, but #merge doesn't get enough love. Maybe I'll issue a pull request to improve it with some examples like this and the ones from the article.

Re: How to build a search engine with Ruby on Rails

#54
post #46
post #23

Earlier quoted context omitted.

Rails doesn't scale? Github's the largest code repository site in the world. Stripe's one of the largest fintech sites in the world. Shopify is one of the largest ecommerce sites in the world. There's also Airbnb, TripAdvisor, many others that are huge. Also, you can write shitty, slow code in any language. You can make too many calls to the DB in any language. You can also scale to Google size in any language. Pytho…

Github does make it work, but you can see there's a tradeoff for that. Like in this blog post: https://github.blog/2020-08-25-upgrading-github-to-ruby-2-7/ You see mentions of 70 second application boot times. Also interesting is the reference that a future upgrade to Ruby 3.x might increase performance by a factor of 3. That would mean they are leaving quite a lot on the table right now. Basically, yes, they make it…

Ruby 3 being 3x faster is based on a video game emulation benchmark. Rails sites won't see anything like that. The ruby team chose a really specific benchmark to target and it's frustrating that it's not communicated well, leading to understandable misunderstandings.

Re: How to build a search engine with Ruby on Rails

#55
post #20
post #2

This is a bit off topic but I wanted to say I’m really glad there are still people out there hacking on some ruby + Postgres projects and writing about it. I feel that ruby is an excellent language and dread the demise of it.

Some of the most interesting projects I stumble on as part of the public sector digitalisation in EU are made in Ruby on Rails (Southern Europe, especially Spain/Portugal), PHP (all of EU) and Python (Eastern Europe). Having recently switched most of our internal development from C# to Python and Powershell I get it. I can’t imagine not building small web apps in Python and I imagine PHP and RnR are exactly the same…

First one that comes to my mind is Decidim (https://github.com/decidim/decidim, https://decidim.org/)

Re: How to build a search engine with Ruby on Rails

#56
post #46

Earlier quoted context omitted.

Github does make it work, but you can see there's a tradeoff for that. Like in this blog post: https://github.blog/2020-08-25-upgrading-github-to-ruby-2-7/ You see mentions of 70 second application boot times. Also interesting is the reference that a future upgrade to Ruby 3.x might increase performance by a factor of 3. That would mean they are leaving quite a lot on the table right now. Basically, yes, they make it…

Ruby 3 being 3x faster is based on a video game emulation benchmark. Rails sites won't see anything like that. The ruby team chose a really specific benchmark to target and it's frustrating that it's not communicated well, leading to understandable misunderstandings.

Somewhat interesting then, that Github cites the 3x without that context.

Re: How to build a search engine with Ruby on Rails

#57
post #6

Earlier quoted context omitted.

How is it demised? Shopify, Stripe and many new YC startups use it.

Rails hasn't had any interesting updates since version 4, and arguably introduced a few regressions IMHO (I'm looking at you, active storage and action cable) Ruby hasn't evolved much either. Rails only scales so far and then scaling gets really challenging, obviously the named companies have figured it out, but its not easy. For example, rails due to the high coupling between models and the database, rspec test get…

Man, is calling ActiveStorage a regression ever spot on. Wish we'd never have used it and stuck with Paperclip.

ActiveJob was Rails4, so I can see where you're coming from there, but ActionMailbox from Rails6 has been a huge win for us. However Webpack has been a disaster. And then the odd evolution of Turbolinks and Stimulus in parallel.

With Rails7 rolling back Webpack and uniting Turbolinks and Stimulus under Hotwire, ActiveStorage finally getting to a good place, and ActiveRecord getting more and more niceities between 4 and 7, then factor in Ruby3's nice perf improvements, I'd say Rails is actually in a much more interesting place than it has ever been. The road from 3 to 7 has been rocky for sure, but for the first time in awhile I'm actually excited to spin up a new Rails project.

Re: How to build a search engine with Ruby on Rails

#58
post #41
post #6

Earlier quoted context omitted.

Rails hasn't had any interesting updates since version 4, and arguably introduced a few regressions IMHO (I'm looking at you, active storage and action cable) Ruby hasn't evolved much either. Rails only scales so far and then scaling gets really challenging, obviously the named companies have figured it out, but its not easy. For example, rails due to the high coupling between models and the database, rspec test get…

You don't know what you are talking about. Every Rails release from 4 adds a ton of new stuff, bug fixes to the framework. ActiveStorage is great addition - storing files on AWS now takes 30 minutes at most to setup. You don't need to use external gems for the same functionality now. Labeling it as a regression is nonsense as Rails before didn't have the functionality at all. Ruby also evolved a ton since Rails 4. Ju…

ActiveStorgae was launched half-baked. Downloading files on the back end was missing from 5 and not introduced until 6. This seriously burned us as we had to put off implementing a ton of what should be easy reporting features until we could get around to upgrading from 5 to 6. Rails strategy of bundling everything together was a huge problem. With Rails7 it looks like ActiveStorage has finally reached parity with Paperclip, so while its nice that there's a built-in option, fundamentally we're still back to where we were years ago, as its not like it took longer than 30 minutes to setup Paperclip either.

Re: How to build a search engine with Ruby on Rails

#59
post #53

Great article. By the way, ActiveRecord's #merge is golden, and I'm under the impression it's not as mainstream as it should be. I use it extensively to avoid duplicating scope code. For instance: class Listing scope :active, -> { where("expired_at > ?", Date.current).where.not(suspended: true) } end class User has_many :listings end So instead of doing this (which is terrible): user.joins(:listings).distinct.where("…

that’s one of those little niggles i’ve had about rails that gets solved so neatly eventually. i started with rails 3 (#merge is a rails 4 addition) so i didn’t know about #merge for a while (#or was another nice addition), and was doing a lot of that ugly chaining in the beginning. same with js - with the move to frontend without webpacker and node, i’m eager to try out rails 7 alpha to see what the dev ergonomics are like now.

Re: How to build a search engine with Ruby on Rails

#60

Earlier quoted context omitted.

Exactly, I only started maybe a month ago and incredibly simple to get into.

Ironically, I think that's part of the reason it became trendy to hate on Ruby and Rails: they make it really easy to do things, which means they also make it really easy to do ill-advised things. But that's not really the fault of the lanaguage or the framework - writing good and maintainable code is a skill you need to work at and develop over time, no matter what language you're using.

It's not so different to the same kind of elitism that gives, say, PHP or JS a bad rap.

They just happen to be successful, and popular.

I don't think the trope of Ruby being old and boring is such a bad thing either, it just means it's stabilised and has a strong ecosystem that requires little to no effort to get set up. And it still gets a lot of love with every Christmas release adding something desirable and new.

I also think it will require some immense innovation or paradigm shift to unseat Ruby/Rails as a de-facto framework for rapid web prototyping. I would still kick off a project with Rails in favour of trying to early-adopt some new approach to development.

Post reply on HN