It is very confusing for developers to decide which framework is best for their projects and choosing which one to learn can be a real challenge facing newbies to modern frameworks. After working in three ( django, laravel and rails - otherwise known as ruby on rails) frameworks, I am comparing these great frameworks on the basic of their motto, ease of learning, performance, strength & weakness of libraries and templates, support, future scope, job chances, cost and maintenance. If you don’t know what frameworks are then read this post Introduction to Frameworks
NOTE: The people who like their own framework are criticising the weakness of their favorite framework. I cannot help this because fact is fact. Each framework has some advantages along with some disadvantages.
Programming language: Programming language: The first major difference between these frameworks is that django is in python, laravel is in PHP and rails is in ruby. If you are going to use any of these frameworks then you will have to learn it's language. So due to this restriction many developers choose the frameworks which matches with their language knowledge. It is not hard to switch from one language to another but it does take some time. If you are confused about languages then here is the comparison of these languages - PYTHON vs PHP vs RUBY.
Motto: All of these frameworks are MVC frameworks and the motto of all these frameworks is ‘don’t repeat yourself‘, i.e. reusability and portability. These all are free, open source projects.
Also see CMS vs MVC frameworks.
The people who raise the point that django is MTV rather than MVC, please read this article. Django is much MTV but it is MVC because the framework itself handles the controllers.
Websites: Some well-known sites that use Django include Pinterest, Instagram, Mozilla, The Washington Times, Disqus, the Public Broadcasting Service,and Bitbucket. Laravel is a new framework with an initial release in June 2011. After its release it became very famous. Some website in laravel are Deltanet Travel, Sublimity, Neighborhood Lender, Sendity and MyRank. Rails is a great framework and some of the top websites using rails are Twitter, Shopify, SoundCloud, Heroku, Github, Bloomberg and Hulu.
2) Ease of learning:
Although all three have great community and official documents, learning django and laravel is much easier than rails. The offline docs for django makes it the easiest. If you are from a PHP background then you can learn laravel within just two to three weeks. The official docs are here: django docs, laravel docs and rails docs. Here is django offline pdf.
Security: All three have great security if the developer doesn’t make any mistakes. Django has middlewares, rails has active records and laravel has HTTP Middleware. All three also provide csrf tokens for forms. There is no big security difference in these frameworks. It all depends on the experience of programmer.
UPDATE: I noticed some readers point out that programmers are humans and they will make mistakes. In response to that, I will say that django is the most secure and laravel is the most unsecure. Read this article for django security. Here is the Rails security guide. And here is the laravel security guide. I will again state that there is no framework which is fully secure because framework developers as well as hackers are also humans. You can increase security but cannot make it 100% secure. If you write code very carefully then all frameworks are same for you in terms of security.
Speed: As all frameworks are written properly, speed depends on the programming languages. Django is fastest due to python and laravel is slowest due to PHP.
Time require to make app: If you have a perfect understanding of the framework then making an application in rails is fastest because it provides many shortcuts and you have to write much less code. On other hand, laravel is slowest and does not provide such a strong library. If the project is complex then the time difference between django and rails applications is much less because of python syntax which is comfortable to follow and less confusing. In the case of laravel you have to write much more code which may cause some confusion and there will be a greater tendency for errors.
4) Strength & Weakness of library:
Common things in all frameworks:
- All are MVC (django is also called MTV but just the name is changed, the concept is same).
- All frameworks focus on readability and simplicity of code and files distribution.
- All do auto queries for databases. We do not have to write database queries directly.
- All automatically build tables in database from models.
- All frameworks have easy and secure routing system. The webpages are rendered dynamically.
- All have their own template systems and each template system is rich of filters and predefined functions. There is only difference in the syntax. See blade template in laravel.
- These all are flexible and portable with other modern technologies.
Django has very powerful library with following features:
- The built in admin section, decorators and view classes are the strength of django
- The auto generated forms for models with validation makes is very easy
- A caching framework which can use any of several cache methods.
- Support for middleware classes which can intervene at various stages of request processing and carry out custom functions.
- An internal dispatcher system which allows components of an application to communicate events to each other via pre-defined signals.
- An internationalization system, including translations of Django's own components into a variety of languages.
- A serialization system which can produce and read XML and/or JSON representations of Django model instances.
- An interface to Python's built in unit test framework.
- An extensible authentication system.
- The dynamic administrative interface.
- Tools for generating RSS and Atom syndication feeds.
- A sites framework that allows one Django installation to run multiple websites, each with their own content and applications.
- Tools for generating Google Sitemaps.
- Built-in mitigation for cross-site request forgery, cross-site scripting, SQL injection, password cracking and other typical web attacks, most of them turned on by default.
- A framework for creating GIS applications.
Laravel's libraries are not as strong as django and rails but are sufficient for making any kind of website.
Also see Laravel framework architecture.
- Bundles and composer provide number of bundle modular packaging system and dependencies.
- Routing - The easiest to mange and abstract way of routing. It just makes everything hassle free and the abstraction provided takes out each and every complexity
- Eloquent ORM support - Another service provided to abstract and automate the model part. Relationships and mapping of database with our application with a simple convention over configuration technique
- Migrations - A way to version our database scripts in much elegant manner. No need to keep all the checks on migrations. A team working on a project can just pull the given migration and all is set and ready to go.
- Queue management - To abstract the unnecessary tasks and get them queued behind the scenes and make user response time much faster.
- Inhouse support for Redis. It can also be extended to memcached.
- Dependency Injection - Easy testing and automating dependency loading
- Artisan - Making command line apps in a moment
Learn laravel using laravel 5 tutorials.
- Ruby on Rails includes tools that make common development tasks easier "out-of-the-box", such as scaffolding that can automatically construct some of the models and views needed for a basic website. Also included are WEBrick, a simple Ruby web server that is distributed with Ruby, and Rake, a build system, distributed as a gem. Together with Ruby on Rails, these tools provide a basic development environment.
- Active record: It plays a major role in rails applications. It is more magical than Eloquent ORM in laravel and models in django.
- Shortcuts: Those people who come from other programming languages or frameworks consider it to be a magical framework due to a lot of shortcuts. Most of the things are predefined and you have to write only a few lines of code to make a complex application.
- Auto routing: Some of the common functions on database table like create, edit and show are automatically defined. It means that we do not have to spend any time on simple work and we can spend longer on the complex parts of the project.
- Command line: A lot of things can be done by command line like using rake. Rake is Ruby Make, a standalone Ruby utility that replaces the Unix utility 'make', and uses a 'Rakefile' and .rake files to build up a list of tasks. In Rails, Rake is used for common administration tasks, especially sophisticated ones that build off of each other.
- The ActiveModelHelper module contains helper methods for quickly creating forms from objects that follow Active Model conventions, starting with Active Record models.
5) Hosting Services:
You can run any application on a VPS or dedicated hosting service. Here are some links to some websites which allow you to host your project for free or on their shared hosting plans.
Some of the websites which host the django projects are WebFaction, PythonAnywhere, Heroku, Digital Ocean, Bulehost, Dreamhost, Arvixe and Google App Engine. Here is comparison of the last four of these hosting services Cheap Django Hosting.
6) Other Criteria:
All three are good frameworks so future scope, job chances, cost and maintenance are almost the same. Rails has some advantage over django and laravel in terms of jobs, although laravel is growing very rapidly.
You can take any of these frameworks according to your programming language and experience. If you are here to decide which one you should learn then my preference is for rails. It is hard to learn but very comfortable during application making. If you want some easy stuff with a lot of features then choose django. The python syntax and its models make it an amazing choice. Django will take time but it is not harder than rails. And last if you are from PHP background or want to learn very fast then choose laravel.