News for hackers. Stuff that matters.
Re:Django 2.0 released by whalesalad on Saturday December 02, 2017 @11:08AM (#15832471)
I’d posit that a simple crud app would take an order of magnitude less time with Rails. I’ve been a Django developer since 0.96 and have built dozens of apps with it. After transitioning to Rails, it’s hard to justify the use unless you’re in an evironment that absolutely must use Python.
Re:Django 2.0 released by fulafel on Saturday December 02, 2017 @12:08PM (#15832804)
Interesting. What would you say is the biggest reason for this >10x development speed difference?
Re:Django 2.0 released by whalesalad on Saturday December 02, 2017 @12:31PM (#15832940)
Django forces you to declare everything. Lots of manual boilerplate. Example, you must define every bit of a model in order for it to work. Rails is the opposite. ActiveRecord will ‘just work’ with the database. You can run rails on an existing db for example if it follows what are widely used conventions such as lowercase model name is the table, foreign keys are foo_id, etc...

This is where people fear the “magic” of things like pluralization of models to table name and introspection... but it’s all just code! You can read it and look at it and understand it. No magic here. Just convenience and a smaller mental model as an end developer.

Also... resources as a first clsss citizen is the biggest reason and the reason it defeats Django for this use case. You define ‘resources’ in your routing layer instead of just routes that map to a function. This allows you represent multiple crud actions with a single controller and even nest them, all with a few lines of code. Then you get access control for free on your sub resource, knowing you’ve already passed the parent checks and have that context.

Example: /users/:id/photos/:id

In this case, my Photos controller will already know who the user is (and if they can view these photos) based on work that the parent did. It’s single responsibility principle. You can even have a top level photos resource devoid of the user context and support both cases with minimal effort.

Yes, you can do these things in Django. But it’s not designed to make these things composable and seamless. I’d argue it’s not REST-friendly. Don’t even get me started on Django Rest Framework which is a massive beast in and of itself.

You get all of that out if the box on Rails. You can stand up extremely robust and ergonomic API’s with so little code you’ll feel like your cheating.

I should probably write a blog post.

Re:Django 2.0 released by knivets on Saturday December 02, 2017 @01:00PM (#15833097)
Rails is definitely more convenient to prototype, but the magic issue is real. You never know where a variable or a function comes from by reading the source -- you'd need to run a debugger to do that (in Python you can just follow the import statements). The overall Rails architecture feels convoluted and unnecessary complicated (Railties, Engines etc). I also dislike the fact that there is no single source of truth for data in Rails. You have schema.rb, but you can't edit that directly, it is generated by running `rails db:migrate`, so one might say that migration files are a single source of truth, which is inconvenient: I need to generate a migration, then edit the migration file to add any modifications not supported by generator script and finally add accessor and validators in model file. In Django we have a model definition as a single source of truth (data model, validations). Also, once I've created (or updated) a model definition, I run `manage.py makemigrations` and all necessary migrations (which capture the current data model state + what's necessary to do to perform a database migration automatically) are created automatically. I also like the fact that in Django data integrity is enforced by default.

Though, when it comes to prototyping, I think Rails is a much more convenient option. In Rails I can launch a working CRUD app with authentication in 10 minutes, literally. In Django I have to manually create directory structure, manually specify each route mapping, create and program controllers (views), etc. Django doesn't even have a built-in authentication templates, only controllers (views), so I end up writing this boilerplate over and over again. The other thing is that the authentication requires a username and password, which feels kind of clumsy, when every other authentication relies on email and it is not very trivial to modify that (built-in admin dashboard relies on built-in authentication for example).

Re:Django 2.0 released by ubernostrum on Sunday December 03, 2017 @02:01AM (#15836390)
Example, you must define every bit of a model in order for it to work. Rails is the opposite. ActiveRecord will ‘just work’ with the database

Someone still had to create that database with those tables in it. It didn't magically pop out of the aether. Your complaint, then, is not "you must define every bit", but with where you do it, since you have to define things no matter what.

And if you have an existing database you'd like to use with Django, 'manage.py inspectdb' will reverse-engineer a set of model definitions from it.

Re:Django 2.0 released by bmelton on Saturday December 02, 2017 @04:42PM (#15834252)
> you must define every bit of a model in order for it to work. Rails is the opposite. ActiveRecord will ‘just work’ with the database.

If you have an existing database, sure, Rails is preferred. If you're starting from scratch, the Django definitions can create the tables for you. If you do have existing tables though, you can use inspectDB to have Django create the models for you.

Re:Django 2.0 released by ralmidani on Saturday December 02, 2017 @08:02PM (#15835364)
I enjoy having a well-structured framework that saves me time and does not need to be spoon-fed. But I have a theory that no programmer ever died from writing an import statement.
Re:Django 2.0 released by collinmanderson on Saturday December 02, 2017 @12:39PM (#15832978)
Have you tried Django’s inspectdb?
Re:Django 2.0 released by mjfisher on Saturday December 02, 2017 @06:39PM (#15834986)
Just wanted to anecdotally affirm whalesalad's experiences with my own. I desperately wanted to like Django more than Rails (I just really appreciate python as a language), but I find projects much quicker to build in Rails. It really is the convention-over-configuration magic that makes the difference. There's less to do in Rails to add commonly used web/crud functionality - but it's much less explicit and relies on you getting all the conventions correct. Rails is really the only framework that I've found fairly hard to learn, simply because you have to memorize the conventions to know e.g. where to pluralize and what magic helper methods will have been auto-generated. It should be noted I've never worked on a large Django project - I suspect once a site's data structure and main functionality has been nailed down and you get a larger team involved, Python and Django's 'explicit is better than implicit' design philosophy will start to provide increases in efficiency.
Re:Django 2.0 released by jrumbut on Saturday December 02, 2017 @10:01PM (#15835726)
I feel like you can tell a good rails developer by finding who thought it was hard to learn. There really is a lot you need to know under the magic, and if you can learn to create compatible magic in your own code the framework becomes incredibly extensible.

My Rails projects have always been the ones that felt the most done on their initial release. That extra time not typing and configuring goes into caching, validation, UX, and making nice solutions to project specific problems that fit nicely and don't become pain points as time goes on. All these things that can feel shortchanged in other projects get more of the polish they need sooner.

Re:Django 2.0 released by cschneid on Saturday December 02, 2017 @11:56PM (#15836031)
I've worked on a handful of large to very-large Rails apps, and I find that after a certain level of size, you're dealing with a Ruby code base that happens to have Rails as the way it is presented. Rails' implicit functions are either obvious because you use them often, or just not relevant, since you're deep in plain Ruby objects implementing your business logic.
Re:Django 2.0 released by _arvin on Saturday December 02, 2017 @11:10AM (#15832489)
Python - Django

Ruby - Rails

PHP - Laravel

all nice choices

Re:Django 2.0 released by blunte on Saturday December 02, 2017 @11:45AM (#15832689)
And if you don't mind the learning curve (which will make you a better thinker!), I would add

Elixir - Phoenix

I wish there was a complete Clojure - ???

Re:Django 2.0 released by enraged_camel on Saturday December 02, 2017 @06:03PM (#15834756)
Elixir with Phoenix is phenomenal. An absolute joy to use.

Elixir itself is an excellent language that leveraged the strengths of the Erlang VM, and Phoenix is like a massively improved, blazing fast and reliable version of Rails.

Re:Django 2.0 released by guftagu on Sunday December 03, 2017 @01:24AM (#15836275)
I'd wait for the ecosystem to mature before building a business app with Phoenix. You never know what taken for granted library is missing in Elixir, and it's going to be damn hard to hire a developer experienced with Phoenix. Everyone on your team will be slow and will be making a steady stream of mistakes as they learn the framework
Re:Django 2.0 released by blunte on Sunday December 03, 2017 @03:27PM (#15839387)
I think Phoenix (and Elixir) is mature enough already to use in production. I've made pretty good, bordering on oracle-like :) predictions about directions in technology over more years than I care to think about; so I'm confident that Phoenix is only going to grow in use and positive attention.

It will be the logical successor to Rails. It already is.

That said, I use a good mix of Elixir+Phoenix and old-school cron launched Python utility scripts, and that works nicely. Anything that's difficult (probably because I am still a newb) in Elixir I can easily do out of band with a Python script.

But your point about difficult to hire experienced people is the reason for my reply. This is the mentality that is ruining IT and development. Yes, having someone with hands on experience in all of your tools is nice - a rare luxury in fact. But it's really not necessary. I would be quite happy to have someone that has willingly built something in Rails, Django, and Nodejs with an "Oh I can learn that" attitude. Especially if you come from a modern MVC framework, Phoenix itself is easy. Elixir is the part that requires some real effort, imo.

Re:Django 2.0 released by KingMob on Saturday December 02, 2017 @07:35PM (#15835243)
Closest is probably Luminus, but it's really just a Leiningen build tool that can pull in your choice of libs to stitch together. It's good, and speeds up Clojure web dev, but is in no ways a framework by itself.
Re:Django 2.0 released by baby on Saturday December 02, 2017 @11:33AM (#15832616)
Agree, note that Laravel was heavily influenced by RoR.

I personally find that Laravel is less heavy than Django which is way less heavy than RoR. I would never use RoR for small projects.

Re:Django 2.0 released by CraneWorm on Saturday December 02, 2017 @01:41PM (#15833263)
Scala - Play
Re:Django 2.0 released by BlackMonday on Saturday December 02, 2017 @05:29PM (#15834547)
I'm not sure about that. Compared to Django, RoR and Laravel it's not opinionated enough. No resources like RoR and Laravel, no buil-in database mapping, no built-in authorization etc.

btw: what do you use for the database access? Slick, Quill, Doobie, ScalikeJDBC, Anorm, Squeryl, jOOQ, Relate, Activate or something else? There seem to be gazillions of sql libraries for scala (although the big three and most relevant are probably Slick, Quill and Doobie).

And what do you use for Authorization? Something custom build? If I look at Laravel there are quite a few maintained authorization libs with ~1000 stars on youtube (even more if we count unmaintained), for play there is not really much (deadbolt, play4j and t2v/play2-auth, I don't count Silhouette since the lib is mainly about authentication).

Re:Django 2.0 released by mundanevoice on Saturday December 02, 2017 @12:14PM (#15832837)
How about performance? Bugs that might come up due to the implicit nature of Rails? Just curious, since you have seen both sides.
Re:Django 2.0 released by whalesalad on Saturday December 02, 2017 @12:25PM (#15832905)
The implicit “magic” thing isn’t a real thing. It’s a fallacy. I have not come across real world problems like this.
Re:Django 2.0 released by mundanevoice on Saturday December 02, 2017 @12:32PM (#15832950)
Well. I disagree that it is not a real thing. For better debugging, you need to know more what's behind the scenes. Personally, I have seen some of my colleagues struggling to find the cause or better architect the thing because most of the decision has been hidden/taken by the framework. Not saying, it's true for all Rails dev but for some beginners, it really bites them.
Re:Django 2.0 released by whalesalad on Saturday December 02, 2017 @12:36PM (#15832964)
Sure but there is magic everywhere. You trade convenience for the risk of not knowing the underlying mechanism in action. The inverse is long boilerplate code, setting up multiple services and factories and fooWidget stuff just to do a simple thing. It’s more clear, yes, but is it always better?

Rhetorical question by the way... just food for thought. There is a balance. I happen to love the convention rails imposes and the “magic” it offers. That being said, there isn’t anything about it that I consider wizardry or don’t understand. It’s just ruby.

Re:Django 2.0 released by mundanevoice on Saturday December 02, 2017 @12:43PM (#15832999)
> The inverse is long boilerplate code, setting up multiple services and factories and fooWidget stuff just to do a simple thing

Are you not talking about Java here? ;)

Clearer code makes it easier to reason and hence easier debugging. Correct me if I am wrong.

Also, it really depends on person to person on how they write the code. Django does not mean big boilerplate nor does Rails.

My main question was on performance. How do they stack up next to each other? Python3 with Django is really working well these days. You can also check out the performance improvement on Instagram because of it. https://thenewstack.io/instagram-makes-smooth-move-python-3/

Re:Django 2.0 released by odonnellryan on Saturday December 02, 2017 @10:15PM (#15835764)
I can get a fairly feature-complete Python up with Flask + Flask Admin, within a few weeks. 1-4 weeks I'd say is a good timeframe. Have done this multiple times. How does Rails stack up there? Not trying to enter a pissing contest .... I agree that Django is not faster than Flask for simple business crud apps.