Hacker News new | ask | show | jobs
by realusername 1645 days ago
Better ORM and better migration? That has to be a joke, that's the weak point of the framework...

Yeah there's less magic I give you that, but also because it does much less.

Also for me the Python packages are a minus, they are usually not tested very well and it's very easy to burn yourself when migrating (good luck finding some equivalent of rspec)

3 comments

> Better ORM and better migration? That has to be a joke, that's the weak point of the framework...

That was probably only true 6–10 years ago. Migrations are a solved problem in Django and I can only think of one very obscure query that I couldn't get done in the ORM and had to drop into raw SQL. Aggregations, annotations and other query expressions in general have lifted the ORM to a truly strong position

I've made a full project about 2 years ago with Django, unless things are improved since then or I'm too inexperienced with the framework it still does not compare to activerecord.

Where are my scopes? Where's the equivalent of strong_migrations? The equivalent of db_consistency? Where are delegate attributes? Concerns? Arel?

The ORM isn't bad I'll admit that but some complex features are tedious.

Last time I used Rails was like 8 years ago so I'm not up to date on the changes to their ORM but when it comes to django the ORM is pretty top notch, especially when it comes to Postgres support.

I've never used rspec but it sounds like pytest and hypothesis would do the job. In ruby there's no hope for pytorch / tensorflow / ray / numba.

Django I knew had pretty weak testing tools compared to Ruby/Rails mostly because the culture was no there. It was way harder to find a Rails App with had little to no tests. Quite a contrary in Django world.

Rails is a Web Framework. I don't understand the point about ML. Those categories are totally different. I guess it might be a tiny plus, but not very practical. Going this route one might conclude that game studios should build Websites in C++?

Because most machine learning models are still deployed behind a web server? For ranking, filtering, recommenders, visual search / nearest neighbor search, NLP, image recognition and etc python is a great first choice.
> I've never used rspec but it sounds like pytest and hypothesis would do the job

Sorry it really does not, having factorybot + rspec + rspec-mocks really is a super power when it comes in testing.

The issue is that most of the time I land on a django project, it has really poor testing whereas most of the time I land on a Rails project, it has very close to complete testing. The reason is that the tests are more tedious to write.

And this culture trickles down to your dependencies as well. Anything you install with rails is almost guaranteed to have the upmost quality of testing.

Testing django with pytest is super easy (ex: https://dev.to/sherlockcodes/pytest-with-django-rest-framewo...)
It's nowhere near as equivalent, where's the behavior testing? Where is stuff like allow_any_instance_of(...).to receive(...).and_return(...)? What about shared examples? How can you patch globally the current time? Where are partial matchers like an_object_having_attributes? What about automatic db rollbacks?

Have a look on the examples here https://github.com/rspec/rspec-mocks

Andrew Kane wrote gems similar to popular ML libraries which are wrappers around C code: https://ankane.org/new-ml-gems

pytorch: https://github.com/ankane/torch.rb Tensorflow: https://github.com/ankane/tensorflow-ruby

> Migrations are a solved problem in Django

Still, no information how they are better than the migrations in Rails?

They are automatically generated from the model. It presents some warts etc, but works pretty well. It basically does require some hooks to ensure that developers don't work on the same migration at once, but not a big deal.