News for hackers. Stuff that matters.
Re:Running GitHub on Rails 6.0 by sellingwebsite on Monday September 09, 2019 @03:27PM (#20921454)
My comment on one of the previous discussions:

I don't want to start a flame war here, but I think Rails (and gem ecosystem in general) is a better choice than Django, at least for SaaS apps.

These are all my personal opinions, take it with a grain of salt. Having said that, here we go:

* Authentication - it is a pain if you'd like to deviate from the standard Django User model (using username to login instead of an email). I don't like Devise either.

* Asset pipeline, even though it is not updated anymore (sprockets) and partially replaced by the webpacker, is still better in Rails

* Configuration spread across multiple files, by environment, instead of a single config.py file

* Sidekiq has a better API compared to Celery. Also, Celery's default broker is RabbitMQ, not Redis. It is really hard to find managed RabbitMQ hosting, for Redis there are plenty

* Mailer previews, small but quite useful utility

* Better security by default: Rails comes pre-configured with a bunch of security headers[0].

* Testing - Minitest and Capybara is just a joy to work with.

* I prefer ActiveRecord over Django ORM

* Rails isn't afraid to deprecate things and move forward. This isn't the case with Django, which is big on backwards compatibility. I don't like it, since it puts into a disadvantage folks who are starting new projects. Different strokes for different folks, I suppose

I could go on and on, but I remember struggling a lot with Django/Celery when building a SaaS app. I decided to switch to Rails and haven't looked back (Rails has its warts as well). YMMV

[0] https://guides.rubyonrails.org/security.html#default-headers

EDIT: Added last point about backwards compatibility

Re:Running GitHub on Rails 6.0 by yowlingcat on Monday September 09, 2019 @04:10PM (#20921925)
I can't argue about your preferences here, but these seem to be subjective preferences or complaints about warts.

In terms of feature and ecosystem surface, there is one area where I think Django is a clear winner: Django Admin. It is a very mature part of the framework and there is a large ecosystem around it. Compared to how useful that is for standing up an MVP SaaS (especially in anything remotely enterprisey), I would find it difficult to consider Rails if I ever envisioned needing admin.

For what it's worth though, I think that Django and Rails are both exceptional choices and in terms of ergonomics, best in class. I wouldn't have complaints about the framework to coming into a project using either one.

Re:Running GitHub on Rails 6.0 by pfranz on Monday September 09, 2019 @05:05PM (#20922474)
I don't do webdev, but have primarily used Python for 10+ years. I've dabbled in both Rails and Django and agree with the parent's points. I would have stated them myself, but it was probably 5 years ago and it sounds like not much has changed. The arguments might be subjective, but they all ring true to me.

I thought Django Admin was cool when I first set it up, but as soon as I hit a few of the issues the parent mentioned, Admin broke or became irrelevant.

Re:Running GitHub on Rails 6.0 by TylerE on Monday September 09, 2019 @08:11PM (#20923915)
Django Admin is one of those things where it makes it easy to get 90% of the way there, which is sexy in a short demo, but the last 10% murders you.
Re:Running GitHub on Rails 6.0 by pmontra on Tuesday September 10, 2019 @01:22AM (#20925240)
I agree that having admin baked in is very convenient for simple CRUD, which saves the time to query the database. For every other criticism of Django compared to Rails I agree with whoever posted them. Still, to address another debated technology, Django is far better than any JavaScript backend I saw.
Re:Running GitHub on Rails 6.0 by tyre on Monday September 09, 2019 @04:15PM (#20921969)
Having never used Django Admin, how would you compare to Rails Admin and Active Admin?
Re:Running GitHub on Rails 6.0 by freehunter on Monday September 09, 2019 @04:38PM (#20922214)
The only comparison I can do is that Django Admin is built-in out of the box, so I use it on every Django project. Rails/Active Admin is not built-in out of the box so I've never used it and always built my own admin page.

It's super weird because Rails is known for convention over configuration and includes default packages for basically everything you might need EXCEPT auth and admin. Meanwhile Django removes a lot of the magic of Rails and lets you do it yourself, except for bundling auth and admin into the core product.

Re:Running GitHub on Rails 6.0 by BOBOTWINSTON on Monday September 09, 2019 @06:01PM (#20922962)
I used ActiveAdmin a lot when I started and it always gave me a headache. From what I have seen of Django Admin (admittedly not a lot) it looks very similar?

I have found that at least for my users, admin type functionality and views generally require a lot of custom work that is not easily turned into convention. About 4 years ago I stopped using Active Admin completely and just started using Ransack + Kaminari gems on their own. I have been a much happier with the way that pattern has worked out.

Re:Running GitHub on Rails 6.0 by yowlingcat on Tuesday September 10, 2019 @09:56AM (#20928216)
It really depends on the specific use case. It's possible to arrive at a point where you'd get more mileage out of using something like react-admin and custom API views. But, until you arrive at that point, something like Django Admin or Active Admin can get you quite far.
Re:Running GitHub on Rails 6.0 by acejam on Tuesday September 10, 2019 @11:40AM (#20929400)
I've used Active Admin in previous projects, but eventually got tired of it. As of late I've been using administrate with pretty good success: https://github.com/thoughtbot/administrate
Re:Running GitHub on Rails 6.0 by tyre on Monday September 09, 2019 @04:13PM (#20921947)
ActiveRecord is the best ORM I've ever used, in any language, and I don't know of an engineer I've worked with who disagrees, regardless of their preferred stack. Using `merge` on two queries still blows my mind. I've been using SQLAlchemy lately and it's a daily reminder of just how many things AR got right.

Rails has its downsides (helloooooo memory usage!) but for getting up and running fast and having a full toolkit available to get the basics done, it's a pretty amazing project.

Re:Running GitHub on Rails 6.0 by RussianCow on Monday September 09, 2019 @05:55PM (#20922914)
SQLAlchemy is far superior to ActiveRecord if you already know SQL and write fairly complex queries. Once you get past a certain point, figuring out how to write or optimize a query in AR (or, to be fair, most other ORMs) tends to involve hunting down some obscure Rails-specific incantations, whereas SA maps pretty nicely onto SQL and doesn't try to offer as high of a level of abstraction. I've also found that it's easier to shoot yourself in the foot with ActiveRecord, performance-wise (though this has gotten much better over time).

The downside of SQLAlchemy is that it's less pleasant to use for simpler queries/tasks, so which ORM is better depends on the project. I've worked on codebases that never crossed that threshold, and ActiveRecord gave a consistently great developer experience. YMMV.

Re:Running GitHub on Rails 6.0 by faitswulff on Monday September 09, 2019 @08:31PM (#20924037)
Is SQLAlchemy about equivalent to Arel in Ruby, then?
Re:Running GitHub on Rails 6.0 by masklinn on Tuesday September 10, 2019 @02:08AM (#20925486)
ARel is very roughly equivalent to SQLAlchemy Core[0], though I'd expect less complete and polished but I really don't know much of ARel.

[0] https://docs.sqlalchemy.org/en/13/core/tutorial.html

Re:Running GitHub on Rails 6.0 by cortesoft on Monday September 09, 2019 @04:16PM (#20921979)
In fairness I haven't used ActiveRecord in a few years, but I really love the Sequel ORM for ruby over my previous experience with ActiveRecord. I feel like ActiveRecord can be a bit too magic for some of the more complicated things I have to do with my models.
Re:Running GitHub on Rails 6.0 by tsotpsstt on Monday September 09, 2019 @05:14PM (#20922551)
+1 for Sequel. I've decided to try Sequel instead of AR for new project 3 years ago. Never looked back, feels like a breath of fresh air. Hope it will gain more recognition in the Ruby community.
Re:Running GitHub on Rails 6.0 by pg_bot on Monday September 09, 2019 @04:20PM (#20922012)
I used to hold this opinion until I started using elixir's ecto library. However, I still do hold ActiveRecord in high regard.
Re:Running GitHub on Rails 6.0 by tyre on Monday September 09, 2019 @04:45PM (#20922286)
I love ecto as well. I love pure SQL and interfacing closer to raw data. Phoenix/Ecto is where I'd gravitate starting a new project (we used it in production at our startup) for many reasons including the simplicity of deployments.

For people getting started with engineering, AR is a nice wrapping/mapping of SQL => object oriented models. There's a mix of productivity, approachability, and feature set that puts AR ahead, for me, as a general use ORM.

I would agree, though, with a strong and experienced engineering team Ecto and Elixir are quite nice.

Re:Running GitHub on Rails 6.0 by dnautics on Monday September 09, 2019 @04:47PM (#20922308)
If nothing else ecto doesn't autopluralize. I suppose I have a small mind, but that always got under my skin.
Re:Running GitHub on Rails 6.0 by cglace on Monday September 09, 2019 @04:48PM (#20922313)
I've never found it hard to do anything with sqlalchemy and we write some pretty complex queries. Do you have any examples?
Re:Running GitHub on Rails 6.0 by steveklabnik on Monday September 09, 2019 @04:35PM (#20922180)
It's been a few years since I've been involved in Ruby and Rails, but back then, there was a lot of controvery over AR. Not because of the quality, which has generally been excellent, but over the pattern itself; see the pushback against "fat models" and towards "service objects" for this kind of debate.
Re:Running GitHub on Rails 6.0 by flukus on Monday September 09, 2019 @08:10PM (#20923906)
> ActiveRecord is the best ORM I've ever used, in any language, and I don't know of an engineer I've worked with who disagrees

Maybe it's morphed into a more general ORM in the 10+ years since I've touched it, but the active record pattern breaks down very quickly once you get beyond basic CRUD apps.

Re:Running GitHub on Rails 6.0 by SiliconAlley on Tuesday September 10, 2019 @12:47AM (#20925111)
I have worked extensively in both frameworks and would add to this:

* Django has comparatively limited I18n and localization faculties compared to Rails (with Django’s i18n built atop gettext, which I always found kind of brittle with .po files/string-based keys)

* No intelligent/efficient class reloading in development. The whole development server just restarts when you make changes

* No reloader for the shell (horrible for developer ergonomics - you can't just type "reload!", you have to restart the shell to pull in any change)

* Caching faculties in Django are much more limited - no template digests (to make template fragment caching much more robust)

* ActiveSupport has also always been a god-send for productivity. It may seem small but things like “Array#to_sentence” and the time functions (i.e. 1.day.ago) are incredibly useful.

* No default assumption of multiple environments (no default development/testing/production configuration files, environment detection, etc). This is pretty ridiculous for a web application framework.

* No built in credential encryption (makes keeping a team in-sync with keys for integrations a comparative pain)

* Dependency management is much more challenging in Python. The de-facto virtualenv + requirements.txt combo is lossy (no dependency graph) and awkward compared to bundler. There are other solutions here but something so foundational shouldn’t be so hard.

Django was the first web application framework I learned and I still work with it professionally from time to time (as recently as ~2 months ago). I am just a bit stunned by how much it has fallen behind in terms of its broad state of maturity, community/ecosystem, productivity, etc.

Re:Running GitHub on Rails 6.0 by batiste on Tuesday September 10, 2019 @03:23AM (#20925846)
For once a fair criticism of Django by someone who seems to know the framework well.

I don't quite share the same experience with i18n though. I always found Django statical code analysis to extract translation keys to be superior in many ways to other translation systems. It is giving useful context that are stored in the PO files and good translation tools use them. I also never had any issue with string based keys. You can chose an english based key or an abstract whatever you prefer.

Some of the annoyance you mentioned, that I agree completely, are more of a language issue like: reloader, or dependency management.

For multiple environments there is a very simple pattern you can put in place using an environment variable and conditional imports. something like:

  from settings.base import *
  
  if env == 'prod':
    from settings.prod import *
Re:Running GitHub on Rails 6.0 by e12e on Tuesday September 10, 2019 @04:29PM (#20933314)
A bit funny (sad) about the dependencies - zope, the early web application server - brought much to python (eg: eggs) - and essentially worked more like bundler + Gemfile/Gemfile.lock - with its zc.buildout dep (and more) manager. And like with ruby/rails, it could be difficult to get it to converge on "known good sets" of dependencies.

Take a look at this dated doc for zope 4 - anyone who's had to fight with bundler should see some similarities - good and bad i think:

https://docs.plone.org/4/en/old-reference-manuals/buildout/b...

You can still use it today, too (but you probably don't want to):

http://www.buildout.org/en/latest/

Re:Running GitHub on Rails 6.0 by steve_adams_86 on Monday September 09, 2019 @04:04PM (#20921872)
I recently got up to speed with a rails app remarkably quickly and I agree with all of these points. I found testing wasn't really a joy, but it was less painful than any experience I've had in the python or PHP world. Mailer previews are actually very cool, too. It's not a game changer but I liked having it and it came in handy.

ActiveRecord was also surprisingly slick. I'd previously mostly used Doctrine and over the years I've mostly come to dislike it. AR was fine though and had some features I liked quite a bit. Scopes are really neat. Like any ORM though there are plenty of double edged swords all over.

I'm actually keen to work with Ruby more since working on that project. Rails is really nice, even if it's a lot different from how I'm used to working. It felt very productive.

Re:Running GitHub on Rails 6.0 by correlator on Monday September 09, 2019 @04:27PM (#20922083)
Rails is a business tool. It allows developers to move quickly to build and iterate rapidly on the business vision.

This means a lot of interesting engineering work and optimizations are out of your hands. Some people think that's a bad thing, I think it's a great thing. Depends on your goals.

Re:Running GitHub on Rails 6.0 by belak on Monday September 09, 2019 @04:18PM (#20921993)
For me, I prefer Django, but I haven't used Rails in a number of years. In general I prefer Python over Ruby because it's more explicit and less magic, but Ruby definitely has its conveniences.

That being said, I am not a Ruby developer, I am a Python developer, so I'll try to address these points as best I can from the other side of the equation.

* Authentication - this is fairly simple to address. It's a fairly easy-to-use pluggable backend. It's not very hard to write a system to replace the default which would let you log in using other credentials. Also, a few years ago you couldn't replace the default User model - that has since been changed.

* Asset pipeline - fair point, but I prefer to keep my assets separate from the backend if possible - my current work project has a backend API in django with a separate frontend repo with all the JS/CSS

* Configuration - the best solution for this I've found is django-environ[0]. Alternatively, the built-in `DJANGO_SETTINGS_FILE` environment variable lets you specify a different base config file.

* Sidekiq/Celery - The API, I'll give you, however it's fairly easy to configure Celery to use Redis

* Mailer previews - I've used mailhog[1] before. This gives you a local mailbox to test with and will be closer to your final configuration anyway.

* Better security - possibly by default, but I haven't had any issues with django-rest-framework in the past

* Testing - pytest with pytest-django is also great to work with.

* Django ORM vs ActiveRecord - I don't have a ton of experience with ActiveRecord but I like the Django ORM. There's also SQLAlchemy, but it's a bit odd to rip that out of django if you don't need to.

I like Django because it's solid out of the box, but still provides a way to extend the core to be as flexible as you want. I assume it's possible to do this with Rails, but that's not my area of expertise.

I do appreciate you outlining things you like better as opposed to just saying "Django is terrible". I'll definitely have to try Rails again and see what I think of it now.

[0] https://github.com/joke2k/django-environ

[1] https://github.com/mailhog/MailHog

Re:Running GitHub on Rails 6.0 by yagodragon on Monday September 09, 2019 @03:50PM (#20921731)
Is rails really that good? I feel so confused and paralyzed trying to find a modern backend framework. I've almost settled to Python+Django because it enforces good practices,has great tools like Django Rest Framework and Python is a language with huge application field. On the other hand, laravel and rails have so strong communities and feel more modern (for example, integration with front end frameworks). Django just seems left behind. So the question boils down to this: Should I invest my time learning django in 2019?
Re:Running GitHub on Rails 6.0 by clairity on Monday September 09, 2019 @04:13PM (#20921946)
rather than the framework (which largely have parity, as far as i can tell), the big decision factor in my mind is between (1) how joyful it is to code in ruby vs (2) the power of statistical/machine learning libraries in python.

if you don't have complicated statistical/machine learning needs, i'd recommend ruby on rails every time. it's so fast to get started and productive. and the language is performant enough to get you to initial success (at which point you can choose to spend money to attain greater performance).

Re:Running GitHub on Rails 6.0 by batiste on Wednesday September 11, 2019 @04:19AM (#20937702)
If you do not know Ruby, it is neither easy nor fast. You have to learn a brand new language and Ruby is quite a departure from C-like languages that most people are familiar with. Then you have to learn Rails and its conventions.

It is a huge mountain of work you have ahead yourself if you are a newbie in both domains.

Sure you might be able to slap together a simple CRUD app following a tutorial but truly knowing what you are doing will take months, if not years. It is a huge investment.

Re:Running GitHub on Rails 6.0 by weaksauce on Monday September 09, 2019 @04:23PM (#20922049)
rails is a good technology that is more mature and boringish now. it's a solid choice to choose to learn. you can also go down the javascript route that changes faster than a more mature technology. realistically a lot of the concepts from any of them will be fairly transferable.
Re:Running GitHub on Rails 6.0 by onlyrealcuzzo on Monday September 09, 2019 @04:11PM (#20921926)
Rails is really that good. I'm a dinosaur in web development (I think). I've used everything popular for a decent swath of time: Microsoft's MVC, Java Apps Framework at Google, Django, Drupal & Joomla in PHP, Elixir/Phoenix, Express, and Rails.

When I first came across Ruby -- and particular Rails -- I loathed it. Ruby's syntax allows you to get pretty creative, and jumping into Rails + Rspec is like jumping into a Perl repo that's been managed by 3 different people over ten years. There's all kind of things that -- because the syntax is so loose -- it's not clear what's going on. It doesn't help (in my opinion) that Ruby's own style guide almost encourages this: dropping the "()" from functions that take no arguments; Eiminating "{}" around certain hashes passed into functions; The "!" marker having a seemingly different meaning in almost every library, etc...

When you're new to Rails and Rspec, it's easy to have no idea what's going on.

That being said, you can prototype an entire business in a few days Rails. It is that easy. It's incredibly polished. It's opinionated in mostly right ways, and all of its libraries are, too -- which means you don't often find people doing crazy shit (except Devise, everyone is always doing something crazy with Devise).

As much as I hated Rspec with a passion, I do feel like it's the best testing frameworks I've ever come across. It lets you be SUPER expressive about what you're testing.

I go against the Ruby & Rspec style guides on a few things, but I feel like no other combination let's you write code that's so expressive.

And, finally, anything you want to do in Rails has a library built in that does it very well. And unlike in -- say JavaScript for example -- there aren't ten libraries to pick from. There is a clear winner, and I think that's good for the community.

Also, almost every major API you can imagine has a Rails Gem so that it plays nicely with the framework.

Don't get me wrong, I loved Django and I still think it's a great framework. My love for Python, Elixir, and Kotlin are strong.

Ruby & Rails are by no means perfect, but I do feel like it's a very clear winner if you're starting a new web business. The number of companies I've seen flounder because they wanted an App + a website + (obviously) backend business logic... and all of that in one language, in one code base -- it's impressive. I've seen a lot of Rails businesses fail. But despite what people warn about scaling, I've never seen a Rails-based company fail because of Rails. Plenty have flourished -- Shoppify, GitHub, AirBNB, etc...

I could go on and on about the advantages WRT hiring, too. Don't even get me started...

Re:Running GitHub on Rails 6.0 by frizkie on Monday September 09, 2019 @04:47PM (#20922310)
As a full-time Ruby developer I absolutely loathe code which drops the parentheses from method definitions that have arguments.
Re:Running GitHub on Rails 6.0 by sudhirj on Tuesday September 10, 2019 @02:11AM (#20925502)
Have you tried Rubocop? It automatically reformats code according to an opinionated style guide (which I think aligns with your opinion).
Re:Running GitHub on Rails 6.0 by chillfox on Monday September 09, 2019 @10:26PM (#20924578)
interesting, I find that the fewer parentheses and squiggly brackets the easier the code is to read.
Re:Running GitHub on Rails 6.0 by philwelch on Monday September 09, 2019 @09:33PM (#20924362)
It kind of depends on what you need. If you need to deliver working code in a hurry and either agree with or can live with the opinions assumed by Rails, go for it. I find a lot of what is in Rails somewhat overweight and unnecessary, and I’ve never see a Rails app age well. But in that respect I’m comparing Rails more to something like Flask than Django.
Re:Running GitHub on Rails 6.0 by leklund on Tuesday September 10, 2019 @01:35AM (#20925303)
“and I’ve never see a Rails app age well.”

Seems like this describes any app in any language I’ve ever worked on. Certainly Rails apps are more prone to this phenomenon because of the low barrier entry. Having worked with apps that have grown from Rails 2 through 5 (and soon 6) it’s quite possible to build Rails apps that “age well”.

Case in point for a Rails app that can age well is GitHub. When they launched in 2008 they were probably using Rails 2.0.2 (best guess based on release notes).

Re:Running GitHub on Rails 6.0 by philwelch on Tuesday September 10, 2019 @04:40AM (#20926213)
To be fair, I've never seen GitHub's codebase. In fact, I'm not entirely sure if it's even still the same "Rails app", or if they've moved to a microservice architecture or something.
Re:Running GitHub on Rails 6.0 by pwelch on Tuesday September 10, 2019 @10:46AM (#20928804)
Not sure what microservice architecture has to do with it. You can have microservices that are Rails apps. :)
Re:Running GitHub on Rails 6.0 by philwelch on Tuesday September 10, 2019 @04:50PM (#20933563)
Yes but if you change architectures, you will have replaced much of your original codebsae.
Re:Running GitHub on Rails 6.0 by pwelch on Tuesday September 10, 2019 @10:51AM (#20928856)
Agreed, any application regardless of language or framework can age poorly. I've seen some pretty solid "long running" Rails applications that were just maintained well.
Re:Running GitHub on Rails 6.0 by sellingwebsite on Monday September 09, 2019 @04:10PM (#20921922)
ça dépend.

I am only familiar with Django and Rails, can't comment about Laravel.

If you are building a basic CRUD app, definitely stick with Rails. If you are doing some kind of CMS or need machine learning pipeline, go with Python.

A warning about Ruby/Rails: some folks have moved on to shinier languages/frameworks and as a result there are lots of unmaintained gems (gems are 3rd party libraries in the Ruby world) out there. For instance, I needed a curl wrapper written in Ruby. Nothing worked for me so I ended up forking Ethon [0]. I am hesitant to send PRs, since I doubt that they will get merged. Now I am maintaining two codebases at once. I will probably rewrite it from scratch at some time.

A warning about Python/Django: dependency management is kind of a mess [1]. See linked discussions [2][3][4][5].

[0] https://github.com/typhoeus/ethon

[1] https://xkcd.com/1987/ (Add pipenv and poetry to the mix)

[2] https://news.ycombinator.com/item?id=20672436

[3] https://news.ycombinator.com/item?id=18612590

[4] https://news.ycombinator.com/item?id=17607083

[5] https://news.ycombinator.com/item?id=13459740

Re:Running GitHub on Rails 6.0 by Scarbutt on Monday September 09, 2019 @10:39PM (#20924634)
For instance, I needed a curl wrapper written in Ruby. Nothing worked for me

Curious, why didn't something like faraday worked for you?

Re:Running GitHub on Rails 6.0 by sellingwebsite on Tuesday September 10, 2019 @02:16AM (#20925537)
Faraday is a wrapper around several libraries, no? I needed more features that these libraries could offer, namely HTTP/2 support, brotli compression, timings for the requests (namelookup time, tls handshake time, connect time, etc..). Faraday and Net:HTTP is fine if you're doing simple HTTP requests.
Re:Running GitHub on Rails 6.0 by xvilka on Monday September 09, 2019 @04:26PM (#20922075)
I would recommend to consider using Go instead. Statically typed, native-fast, easily deployed. Everything that both Python and Ruby lack.
Re:Running GitHub on Rails 6.0 by StreamBright on Monday September 09, 2019 @04:56PM (#20922394)
Go's static typing is a bit old school. If you want a statically typed (yet flexible and powerful), native-fast, easily deployed environment, I would go for Rust. As of today it brings everything to the table that you need for reliable web services. The performance and memory safety are the biggest selling points for me.
Re:Running GitHub on Rails 6.0 by xvilka on Monday September 09, 2019 @05:06PM (#20922482)
I like Rust and use it often, but the learning curve is steep. Go can be learned in a week.
Re:Running GitHub on Rails 6.0 by StreamBright on Tuesday September 10, 2019 @03:09AM (#20925775)
But it pays off. With do you can spend more time on chasing data corruption bugs with Rust you spend more time (initially) on learning it.
Re:Running GitHub on Rails 6.0 by m_ke on Monday September 09, 2019 @04:06PM (#20921894)
1. Changing the base user model is not that hard if you're starting a new project. It took us a few hours to make that change.

2. Nothing is stopping you from using multiple files for config. We use a config module with a separate file for DB, caching, DRF and etc.

3. Testing with pytest is pretty nice too.

Django rest framework is what makes Django great these days.

Re:Running GitHub on Rails 6.0 by jamestimmins on Monday September 09, 2019 @04:26PM (#20922081)
I'm curious why it took a few hours to swap out the base user model? Unless I'm missing something, it's fairly simple to extend the AbstractUser class with a custom user model, and then assign `Settings.AUTH_USER_MODEL = 'CustomUser`.

That said, everything is easy once you know how to do it. If this was the first time you've done this or there was research involved, it definitely makes sense that it would take longer!

I'm mostly asking bc I'm curious if you came upon a level of complexity that I simply haven't encountered.

Re:Running GitHub on Rails 6.0 by m_ke on Monday September 09, 2019 @04:38PM (#20922220)
We made some heavy modifications to the user model to allow for authentication with a few different types of identifiers, including composite keys. Django expects you to set a single USERNAME_FIELD but we had to support more than one and that required changes to the auth system. By default it also didn't work with UUIDs as usernames so that took a bit of time to fix.
Re:Running GitHub on Rails 6.0 by sellingwebsite on Monday September 09, 2019 @04:13PM (#20921942)
You have just proven my points. Sure you could do it yourself, but defaults matter. A lot.
Re:Running GitHub on Rails 6.0 by tidepod12 on Monday September 09, 2019 @04:29PM (#20922106)
I don't see how your points were proven. The 'defaults' you're talking about take a grand total of ~10 minutes tops to change, and actually can come by 'default' if you use one of the available Django templates that are popular.

Your complaints are valid from a subjective perspective, but if your bar for something being "a pain" is really "took longer than 10 minutes", I can't imagine how you function as a software engineer as even in Rails there are many things that will take longer to do.

Re:Running GitHub on Rails 6.0 by sellingwebsite on Monday September 09, 2019 @04:37PM (#20922199)
How about "I was struggling for days with Django which lead to a minor burn-out and as a result I lost several weeks of my time"?

That's when I decided to pick up Rails tutorial and it was probably one of the best tech-related decisions I made in my businesses.

I shouldn't use cookiecutter templates, plugins, scripts to make working with the software tolerable. It should just work and get out of my way. Well, at least when doing a greenfield development.

Take a look: https://rubyonrails.org/doctrine/

Re:Running GitHub on Rails 6.0 by tidepod12 on Monday September 09, 2019 @04:39PM (#20922235)
It took me about 5 seconds of googling to find a Django tutorial that describes how to change the user auth model and make the change in less than 10 minutes.

In comparison, I too could waste my entire weekend tinkering with something in Rails, but I instead choose to do things the right way and look up a tutorial to explain how to do it easily, which it sounds like you did with Rails. Why you didn't do this with Django instead of wasting weeks, I dunno.

Again, if you prefer rails for subjective reasons that's fine. But blaming Django for being "too much of a pain" just because it sounds like you chose to do things the difficult way is pretty unfair.

Re:Running GitHub on Rails 6.0 by yowlingcat on Monday September 09, 2019 @07:18PM (#20923569)
If you were struggling for days with Django, I really wonder how you'd handle writing line of business logic for paying customers, which is orders of magnitude more difficult than picking one framework among several that have feature parity. This could be a place for you to improve as an engineer rather than being proof of a framework being bad or "burning" you.
Re:Running GitHub on Rails 6.0 by m_ke on Monday September 09, 2019 @04:22PM (#20922041)
The defaults in Django work fine for most people. I've used rails before and it's a great framework but python has a much better ecosystem, especially if you're doing anything machine learning ralated.
Re:Running GitHub on Rails 6.0 by myalphabet on Monday September 09, 2019 @04:46PM (#20922299)
Why does every thread about Rails on HN devolve into a thread bashing Django? Do Rails users have some kind of "little brother complex" compared to Django?

Every Django thread on HN usually involves a healthy amount of discussion about the pros/cons of Django, and it's really helpful. You would expect that Rails threads have a discussion about the pros/cons of Rails, right? Except instead, every Rails thread also turns into a discussion about the pros/cons of Django.

If Rails is so good then why do its users feel they have to constantly defend itself against non-existent attackers?

Re:Running GitHub on Rails 6.0 by dymk on Monday September 09, 2019 @05:35PM (#20922713)
Note that you didn't actually defend Django, but just complained that a user pointed out a bunch of flaws of Django compared to Rails.

Ironically, the OP you're replying to is much more substantive than your own attack.

Re:Running GitHub on Rails 6.0 by RussianCow on Monday September 09, 2019 @06:00PM (#20922950)
I don't know why you think the author was trying to defend Django or "attack" Rails? It seems to me that they were simply trying to point out the ridiculousness of Rails threads always devolving into "Rails vs Django" flame wars.
Re:Running GitHub on Rails 6.0 by dymk on Monday September 09, 2019 @06:09PM (#20923024)
“Discuss pros and cons” is not a flame war; attacking people for civilly discussing something is a flame war.
Re:Running GitHub on Rails 6.0 by sanderjd on Monday September 09, 2019 @07:23PM (#20923604)
Totally, and that would make a ton of sense on a "I think Rails is better than Django" article or something like that, but on an article purely about Rails, this whole thread about Django reads like a non-sequitur. I was surprised to see this as the top comment, because it seemed totally unrelated to anything in the article. If you go to the article and ctrl-f for "django" you come up empty. So the pushback seemed reasonable to me.
Re:Running GitHub on Rails 6.0 by RussianCow on Monday September 09, 2019 @06:42PM (#20923291)
Maybe I'm missing something, but I don't see the comment you're responding to as an "attack" at all. They're pointing out that the OP is "civilly discussing something" that's irrelevant to the topic of the thread, and that this seems to happen in every thread about Rails (which I have also noticed).
Re:Running GitHub on Rails 6.0 by sellingwebsite on Monday September 09, 2019 @05:03PM (#20922462)
Because I've got burnt by Django in the past. If you do some search on the HN and elsewhere on the difference between two, the common answer that you'll find is that they are similar and it doesn't matter which one do you pick (given that you are not proficient with any of them). I don't agree with that premise and decided to make a case here.

So if you are ever in a position to pick between Django and Rails for CRUD-y SaaS app, go with Rails. You can't go wrong with that.

Re:Running GitHub on Rails 6.0 by arshbot on Monday September 09, 2019 @05:09PM (#20922509)
Understandable sure, but why bring up Django on a post about upgrading to Rails 6.0 a week after 6.0 was released?
Re:Running GitHub on Rails 6.0 by sellingwebsite on Monday September 09, 2019 @05:25PM (#20922627)
Because I too followed the common advice and started with Django (I only knew Python back then). Well, I hated it and got burnt out as a result. So, despite the conventional wisdom, I decided to change my stack from Django/Python/Celery to Rails/Ruby/Sidekiq and I am very glad I made the leap.

I have seen both sides of it, that's why I decided to vent it out.

P.S. Don't get me wrong, I have tons of respect for people doing open source and don't want to badmouth Django folks. But in my limited experience, it just wasn't a great experience.

Re:Running GitHub on Rails 6.0 by sanderjd on Monday September 09, 2019 @07:25PM (#20923613)
This is all fair enough - you're entitled to your opinions developed through your experiences - but it's just not relevant to this article. Just because you got burned by Django does not mean it makes sense to pop into any thread about Rails and talk about how you got burned by Django. That's not what this article is about!
Re:Running GitHub on Rails 6.0 by dymk on Monday September 09, 2019 @05:39PM (#20922748)
Because Rails and Django are two competing web frameworks which are majorly directly comparable, and it's good to know the pros and cons between each one.

Not everybody is an expert on both, so it's nice to see concrete lists like the one posted above.

Re:Running GitHub on Rails 6.0 by yowlingcat on Monday September 09, 2019 @07:13PM (#20923542)
Unless there's more you didn't explain, you weren't burned by Django -- at most you were lightly singed by your own expectations. Everything you've described is more a matter of "I liked this one more than that one" -- things that are so minor or inconsequential to the actual hard work in building a SaaS app so as to be rounding errors. On the other hand, you haven't described a single area where feature parity is lacking, so it comes down to a matter of opinion and taste.
Re:Running GitHub on Rails 6.0 by ratww on Monday September 09, 2019 @07:36PM (#20923701)
Some people perceive Rails as being in decline. That makes a lot of people in the Rails community act defensively.

I think it boils down to people only being experts in Rails and fearful of having to change to other tech.

I used to get the same kind of answer when comparing Rails to other tech such as Node or Sinatra.

Re:Running GitHub on Rails 6.0 by chaostheory on Monday September 09, 2019 @07:20PM (#20923584)
He's not wrong, but you have a point. imo the reason I don't like Django as much is that there's not one way to do one thing like with python ie it's not convention over configuration. That said, it's still a good, mature framework and unlike Rails, upgrades aren't going to break your app (even though migration in Rails is easy as long as you do it often). Also it's nice to have a dominant framework in Python. Just wish it had the same philosophy as Python.
Re:Running GitHub on Rails 6.0 by drspacemonkey on Monday September 09, 2019 @05:02PM (#20922449)
>I don't like Devise either

I've got my complaints about Devise, but I'll take those pains any day of the week over the alternative nightmare of "built in-house" authentication.

At this point, if somebody doesn't want to use Devise in a project I'm working on, they better have a _really_ good explanation. To me, it's like suggesting setting the building on fire.

Re:Running GitHub on Rails 6.0 by debaserab2 on Monday September 09, 2019 @06:35PM (#20923228)
I've found the "out of the box one stop auth" packages rarely deliver the experience that product managers / UX people have planned for. You're usually stuck with whatever workflow the library decides for things like forgot password, password expiration policies, 2fa, login methods, etc.

There are very legitimate reasons why your SaaS app might want a nuanced workflow for these things.

Re:Running GitHub on Rails 6.0 by joshmn on Monday September 09, 2019 @06:54PM (#20923383)
> I've found the "out of the box one stop auth" packages rarely deliver the experience that product managers / UX people have planned for. You're usually stuck with whatever workflow the library decides for things like forgot password, password expiration policies, 2fa, login methods, etc.

It's pretty effortless to override and/or completely rewrite the views/flow with something like Devise.

Re:Running GitHub on Rails 6.0 by debaserab2 on Monday September 09, 2019 @07:48PM (#20923770)
Overriding is simple when it's changing a view. I've found the exact opposite to be true if it's anything regarding the actual workflow. If you're trying to change the workflow, you're probably already in an edge case and you're usually dealing with documentation that isn't terribly comprehensive or updated and rarely relates to the change you are trying to make. You're usually stuck reading the library internals carefully and scouring Stack Overflow for other people who have attempted to make the same change (often only to find unanswered question).

Every time I've ended up in this scenario I've wished that I had just built from scratch in the first place.

Re:Running GitHub on Rails 6.0 by joshmn on Tuesday September 10, 2019 @04:40PM (#20933464)
What sort of workflow are you trying to achieve? Devise is effectively `User.create(email: params[:user][:email], password: params[:user][:password])`
Re:Running GitHub on Rails 6.0 by debaserab2 on Tuesday September 10, 2019 @06:47PM (#20934686)
Here's a good example of something I worked on recently that I highly doubt is simple to implement with an out of the box solution. I could be wrong - I have no idea if Devise can do it or how hard it would be (it wasn't considered because the auth handling was already implemented):

You have a multi-tenant SaaS application that needs to support the following:

* Accounts may have different password, lockout, and expiration policies.

* There's a generic "login" button on the marketing site that 50%+ of our users use. This generic login page must implement all account specific constraints (probably via a 2-step login form)

* Some customers have SSO. For some customers, using SSO is optional. For others, it is required.

* Owners of accounts have a limited impersonation feature that allows them to see only certain parts of information in eyes of one of their account members

Re:Running GitHub on Rails 6.0 by drspacemonkey on Wednesday September 11, 2019 @01:12PM (#20942415)
* Accounts may have different password, lockout, and expiration policies.

I've had to do that with Devise. It was easy enough to fork the `devise-security` plugin and modify the configuration settings to handle lambdas. The lambdas were then set to pull the config values from the user's account configuration.

* There's a generic "login" button on the marketing site that 50%+ of our users use. This generic login page must implement all account specific constraints (probably via a 2-step login form)

That's super easy.

* Some customers have SSO. For some customers, using SSO is optional. For others, it is required.

I'm in the process of adding exactly this to my project's Devise configuration right now. It's a little tricky, but only because our previous attempt at SSO was very strangely done (and I now understand why so many users complained about not being able to log in).

* Owners of accounts have a limited impersonation feature that allows them to see only certain parts of information in eyes of one of their account members

User permissions are outside the scope of Devise, since it just handles authentication. But the Pretender plugin makes user impersonation dead simple.

Re:Running GitHub on Rails 6.0 by freetonik on Tuesday September 10, 2019 @04:15PM (#20933165)
>I've found the "out of the box one stop auth" packages rarely deliver the experience that product managers / UX people have planned for.

I’d love to see more pushback from devs on this. So many products nowadays provide an “experience” for auth which makes things unnecessarily difficult. Not showing login and password fields on a single page, ambiguous 3rd party auth rules, weird account linking logic, etc.

Re:Running GitHub on Rails 6.0 by sellingwebsite on Monday September 09, 2019 @05:08PM (#20922505)
Custom built auth isn't as scary as you make it to be. I have done it myself and would do it in the future. You just have to be cognizant of what you're doing (i.e. simply copying Hartl's or Railscasts' tutorial won't suffice; see session fixation attacks).

If I were to bring in 3rd party gem for auth, I'd have gone with Sorcery rather than Devise.

Re:Running GitHub on Rails 6.0 by dymk on Monday September 09, 2019 @05:43PM (#20922782)
> Custom built auth isn't as scary as you make it to be

> You just have to be cognizant of what you're doing

These two ideas are incompatible with each other.

Re:Running GitHub on Rails 6.0 by headmelted on Monday September 09, 2019 @07:20PM (#20923582)
I would have phrased it differently, but I see the parent's point.

You don't roll your own security. You just don't do it. There are far too many variables that you can screw up, and anything you come up with isn't realistically going to go through nearly as much battle-testing as a ready-made solution (either upfront or on an ongoing basis).

> Custom built auth isn't as scary as you make it to be

Custom-built auth should be scary. Anyone who's worked on the security story for a popular framework will tell you that.

If you're not scared by it I'd have to assume you're either not seeing large swathes of the problem space or you're a genius.

Re:Running GitHub on Rails 6.0 by debaserab2 on Monday September 09, 2019 @08:10PM (#20923910)
But everyone rolls their own security. Security isn't a feature of the application, it's a characteristic of every piece of code, workflow, and practice your dev team implements. I know this sounds like a platitude, but if you treat security like something that you should only let the experts handle, you may end up not paying attention to the security properties that end up in your control.

Don't write your own crypto. That's great advice. The idea that everyone's auth needs are so standard they fit for every app just hasn't been realistic in my experience.

Re:Running GitHub on Rails 6.0 by sellingwebsite on Tuesday September 10, 2019 @02:20AM (#20925556)
I should have phrased it differently.

Yes, you don't roll your own security. You use powerful primitives provided by Ruby and Rails, such as bcrypt, has_secure_password/has_secure_token, encrypted sessions, secure httponly cookies with prefixes + samesite attrbiute all served over TLS 1.2+, with HSTS and CSP

Re:Running GitHub on Rails 6.0 by ratww on Monday September 09, 2019 @07:44PM (#20923741)
I'd argue that Auth itself isn't hard per se, but it involves hard things that you shouldn't roll your own, notably cryptography and session handling.

But those are things that people normally delegate to either libraries (crypto) or the framework itself (session handling).

Of course, there's lots of places one can screw up, such as sending non-expirable password reset tokens, revealing private information and membership status via F2A/reset tokens. But those are the kinds of screw-ups that can happen in other parts of the website too.

That said, Devise is one of the few things that I don't completely dislike about Rails.

Re:Running GitHub on Rails 6.0 by mushufasa on Monday September 09, 2019 @09:33PM (#20924361)
> * Authentication - it is a pain if you'd like to deviate from the standard Django User model (using username to login instead of an email).

It's not so hard, you just define a custom user class -- plenty of SO snippets if you're lazy. Though I agree that it would be better if common user schemes like email login were supported out of the box.

>* Better security by default: Rails comes pre-configured with a bunch of security headers[0].

Django has security headers also https://docs.djangoproject.com/en/2.2/topics/security/

> * Sidekiq has a better API compared to Celery. Also, Celery's default broker is RabbitMQ, not Redis. It is really hard to find managed RabbitMQ hosting, for Redis there are plenty

There are several on Heroku, including with free plans. https://elements.heroku.com/addons/cloudamqp . I agree that Celery has a bit of a learning curve (e.g. heartbeat, concurrency, etc.). The project is improving, and python overall is getting better at async.

> Django, which is big on backwards compatibility.

Version 2.0 breaks code from 1.11, which happened in 2017.

> I decided to switch to Rails and haven't looked back

Maybe Django improved since you last looked, and could merit another try :).

> I don't want to start a flame war

Nor do I. Both cake and pie are good. The ability to weave in the rest of the python ecosystem (e.g. pandas, keras) makes Django attractive to me for many projects.

Re:Running GitHub on Rails 6.0 by cdcarter on Monday September 09, 2019 @09:27PM (#20924316)
For what it’s worth/to prevent too much FUD about something as important as secure by default, Django has fantastic security header defaults out of the box too. https://docs.djangoproject.com/en/2.2/ref/middleware/#module...
Re:Running GitHub on Rails 6.0 by tptacek on Monday September 09, 2019 @08:36PM (#20924061)
No, I don't think many application security people would agree with you that Rails is more secure out of the box or in common configurations than Django. I don't think it matters much; the differences are probably marginal.

(I've shipped Rails applications and would probably not myself ever pick Django for a new project. Obviously, I do more security work than application development work).

Re:Running GitHub on Rails 6.0 by conroy on Monday September 09, 2019 @09:02PM (#20924190)
If you wanted to avoid a flame war, you wouldn't have posted in the first place. Why bring up Django when the linked post is about upgrading a Rails code base to 6.0?
Re:Running GitHub on Rails 6.0 by diegojromero on Monday September 09, 2019 @05:47PM (#20922825)
Could you expand on why do you prefer ActiveRecord over Django ORM?

When I started with Rails I was so frustrated with ActiveRecord that I develop some of the Django QuerySet API as a gem[0].

[0] https://github.com/diegojromerolopez/babik

Re:Running GitHub on Rails 6.0 by malloryerik on Monday September 09, 2019 @11:54PM (#20924908)
What's the real-time / reactive story looking like for Rails these days? Should one choose Rails for new real-time apps?
Re:Running GitHub on Rails 6.0 by sprite on Tuesday September 10, 2019 @01:32AM (#20925290)
This might be outdated but should give you some idea at least https://dockyard.com/blog/2016/08/09/phoenix-channels-vs-rai...
Re:Running GitHub on Rails 6.0 by ljm on Monday September 09, 2019 @06:19PM (#20923103)
Rails gets background processing emphatically wrong.

Rails does a lot of things right, but ActiveJob and everything built upon it (including the abuse of Redis) is a travesty.

The entire concept of serialising code and re-evaluating it (which is what these libraries do) is a joke.

Your job payload should be pure data but Rails ensures that it is code.

And you should builds the workers that consume it.

Re:Running GitHub on Rails 6.0 by dymk on Monday September 09, 2019 @07:02PM (#20923449)
Job payloads are certainly not code; they're exposed to the developer as basically blobs of JSON, and the code lives in a "job handler" which is certainly itself not serialized.
Re:Running GitHub on Rails 6.0 by gwright on Monday September 09, 2019 @07:15PM (#20923553)
> Your job payload should be pure data but Rails ensures that it is code.

Doesn't sound right to me. ActiveJob just serializes the arguments to the job. The job runners spins up the rails environment (i.e. the code) and deserialize the arguments before executing the job.

There is no code serialization as far as I can tell.

Re:Running GitHub on Rails 6.0 by steveklabnik on Monday September 09, 2019 @06:20PM (#20923117)
This comment would be much better if you explained why you think so, even at a high level.