Live data from Hacker News

Django and Postgres for the Busy Rails Developer

andyatkinson.com

21–30 of 127 posts

Re: Django and Postgres for the Busy Rails Developer

#21
I worked significantly in both Django and Rails, and I found the most magical part of rails is its ORM (ActiveRecord). I find both SQLAlchemy and DjangoORM both more awkward and less natural to use, both for the query side and the relationship definition side.

Once the data is loaded into memory, everything else is just syntax.

At this point, I only reach for python as a web application if I need to build something that has AI / ML features. Rails apps I've built in the past that needed to call a local model resulted in having to create a python inference microservice, which kinda sucks.

Re: Django and Postgres for the Busy Rails Developer

#22
post #13

Earlier quoted context omitted.

The whole appeal of Django is that you can just swap in a different templating engine / syntax if you prefer. And you can add a DB and let there be managed by some other system. Same goes for extending manage.py I’ve worked on Django projects big and small and generally the speed are which we could deliver even on strange edge cases impressed.

You can do that with Rails too. The difference is that Rails defaults are very good.

The Rails dev says that Rails defaults are very good and so says the Django dev about the Django defaults.

The Django ORM is loved by tens, maybe hundreds of thousands of Python devs globally, and while I could raise concerns about it (for example, the async experimental capabilities fucking suck, and the core dev team is extremely slow to innovate on them on the basis that that's not "the Django way"), I've never heard anyone but a Rails dev complain that it's "too verbose".

People love it so much that they'll do atrocities like import it into Jupyter notebooks or simple scripts that should otherwise have no business in bringing in those type of dependencies. I should know because when I've felt creative and a bit naughty about doing those types of things I've found out - to my unmeasurable disappointment - that there were many other trailblazers before me to write gists, Medium articles, and almost everything every type of format short of an entire O'Reilly book on how to do it.

Re: Django and Postgres for the Busy Rails Developer

#23
post #7

Earlier quoted context omitted.

Python is used for much more than just web dev and Django, whereas Ruby seams to only be synonymous with Ruby on Rails. Do you think Rails is still worth using when investing in learning Python and Django has a much higher roi?

Majority of learning surface will come from framework and not the language, if you need Python elsewhere just learn that as well, but this shouldn't move framework choice much.

> Majority of learning surface will come from framework and not the language

Once you get past the beginner level in Django, you're going to pick up a ton of Python knowledge (standard dunder methods, MRO, standard lib, data type's im/mutability, package ecosystem, etc.) and muscle memory along the way. Django (for the most part) is just plain old Python data structures, classes, and functions that a decent Django dev will apart, reuse, override, repurpose, and add on to as they do more interesting things. Python is boring (in a good way), however it has a lot of surface area (std lib is massive) and intricacies that a Django dev will pick up along the way to becoming an intermediate/advanced dev. It would take someone coming in fresh to Python quite a while to catch up. Naturally, if the same person knew several languages, the ramp up would be quite a bit quicker.

Re: Django and Postgres for the Busy Rails Developer

#24
post #4

I'm working on a Rails and on a Django project for two different customers and I've been doing that for years now. I'd pick Rails over Django any time for every single feature. The absolute worst Django feature is the templating language. It seems to be designed to slow down developers to the like of old time Java web apps, almost mandatory templatetags et all. The query language is moderately bad, quite verbose (Mod…

A bit off topic, but whenever Rails and templating get brought up, I have to plug my absolute favorite project out there: Phlex https://beta.phlex.fun/ . It's like ViewComponents, but swap out the ERB for pure Ruby. It has been a joy to develop with. With the addition of Phlex::Kit, it has made building out a component library pretty easy too. RubyUI https://github.com/ruby-ui/ruby_ui does a great job of showing off…

Funnily enough I write most of my view components without a template these days, unless there's a load of markup.

I keep meaning to take a look at Phlex.

Re: Django and Postgres for the Busy Rails Developer

#25
post #4

I'm working on a Rails and on a Django project for two different customers and I've been doing that for years now. I'd pick Rails over Django any time for every single feature. The absolute worst Django feature is the templating language. It seems to be designed to slow down developers to the like of old time Java web apps, almost mandatory templatetags et all. The query language is moderately bad, quite verbose (Mod…

Funny you mention templating, its one key thing I'd change about Django, that... and maybe scaffolding, I'd crank it up drastically more. My ideal enhancement to Django would be something like how Microsoft made Razor into Blazor... A template engine that can run purely on the back-end or purely on the front-end, replacing any need to ever use JavaScript, you stick to your native programming tongue if you will.

I think of Django's templating system as a great tool for a previous era. I'm hopeful that PEP 750 [1] gets accepted and a modern ecosystem of template engines emerges in Python-land. For the moment, I tend to use in-python builders like htpy [2] when I want back-end Python code to generate some HTML.

[1] https://pep-previews--4124.org.readthedocs.build/pep-0750/

[2] https://htpy.dev

Re: Django and Postgres for the Busy Rails Developer

#26

> Migrations in Django > > The Django approach has noteworthy differences and a slightly different workflow My explanation of Django's approach to migrations would involve a lot more expletives. It is by far my least favorite thing about the framework. - Fields are not-null by default, the opposite of SQL itself - Field declarations use argument names that sound like the SQL equivalents (default, on delete cascade/re…

> The default value thing combined with not-null by default

It is interesting... I strongly feel the opposite after debugging far too many SQL queries where someone checked for an empty string but forgot to check for NULL. NULL by default is a SQL footgun IMO.

Re: Django and Postgres for the Busy Rails Developer

#27
post #4

I'm working on a Rails and on a Django project for two different customers and I've been doing that for years now. I'd pick Rails over Django any time for every single feature. The absolute worst Django feature is the templating language. It seems to be designed to slow down developers to the like of old time Java web apps, almost mandatory templatetags et all. The query language is moderately bad, quite verbose (Mod…

I've worked for many years with both frameworks. I have the opposite view, since I prefer the Django ecosystem and Python.

Rails has nice things, but overall, I prefer Django's approach and the language it uses.

Re: Django and Postgres for the Busy Rails Developer

#29
post #4

I'm working on a Rails and on a Django project for two different customers and I've been doing that for years now. I'd pick Rails over Django any time for every single feature. The absolute worst Django feature is the templating language. It seems to be designed to slow down developers to the like of old time Java web apps, almost mandatory templatetags et all. The query language is moderately bad, quite verbose (Mod…

Python is used for much more than just web dev and Django, whereas Ruby seams to only be synonymous with Ruby on Rails. Do you think Rails is still worth using when investing in learning Python and Django has a much higher roi?

Yes. You learn unique, transferable things from every language and framework; usually, techniques and perspectives, but also confidence and theory.

I’d also contest your statement that learning Python and Django have a “much higher ROI” - but, I don’t actually want to get into it.

Re: Django and Postgres for the Busy Rails Developer

#30

I have yet to see a software project where ActiveRecordish ORMs did not end up making the modelling of business processes and translation of use cases into code overly messy and complicated, Rails or Django.

The Rails apps I’ve worked with where there was an ORM mess (which yeah… is all of them) it’s extremely clear that the mess is the normal “too fast” software development mess. Sure, it’s worse because it’s the ORM (and/or sharp knives), but it’s also always been the case that I can clean it up with better use of Actuve Record.

Also, I’ve worked with some pretty gnarly pure-SQL systems that had essentially the same kinds of problems.

It’s all just variations on “saving hours of planning with months of work” kind of things.

Post reply on HN