I like Rails, but to be fair, doesn't Rails also require a list of 30 random gems? Unless things have changed, authorization and authentication aren't even built-in, so people have to navigate random third party gems, and remember, you don't want CanCan, but you want the fork, CanCanCan. Again, I like Rails, and maybe it's still the nearest to an all-in-one framework, but I think somebody who took the next step and created a truly all-in-one framework would win big.
My current project:
$ grep -c ^gem Gemfile
75Perhaps the best example I can give for this difference is Devise, an authentication plugin for Rails. Have a look at the instructions for setting up Devise on Rails: https://github.com/plataformatec/devise#getting-started You just add the dependency and boom, you instantly get a database migration for storing authentication data in your database, automatic integration with Rails's email notification system, a single command you can run to generate all boilerplate files, and a single line of code you can add to your controllers to automatically enforce authentication for any particular action. With a similar authentication package in a Node application you'd most certainly have to set all that up manually.
my-MacBook-Pro:production-web-site me$ grep ^gem Gemfile | wc -l
74
I have mixed feelings about this. On the one hand, the framework isn't strongly coupled, tested as a whole, and opinionated like in Java and .NET land.On the other hand, overriding the "default" Rails behavior for e.g. logging or SAML is pretty easy as long as you can find a gem compatible with the versions of all your other gems. This can easily spiral into out of control technical debt where you're stuck using gems from 6 years ago out of fear you'll tug on one of them and bring the entire house of cards tumbling down, but I've consistently been surprised at how little effort has been required to do gem upgrades as long as they're planned carefully.
And while gems like CanCanCan are great, not every application needs them, and it's relatively straightforward to set up authorization logic directly for most simple cases (i.e. something like "users control their own things, admins control everything".
You're right in the sense that I've very rarely seen sizeable apps that are mostly "stock" Rails outside of things literally developed by Basecamp.
Other reasons I enjoy Rails:
- Scaffolds allow me to have CRUD support for any model I want with one command (combined with auth, I have Django's admin, more or less)
- JSON views without a third party library (surely this is pretty standard for a web framework in 2018 in most cases?)
Other reasons I don't enjoy Django so much:
- I can't think of an eloquent way to phrase this but Rails values my time. With Django I'm doing menial minutiae like creating a directory for my app's templates before it'll serve a page. Why? I know 'magic' is anathema to the Python community but context switches like this shouldn't be there when I'm trying to get an app up and running at speed
- I feel like it's stewardship is bordering on begrudging: Why are websockets (and JSON for that matter, but I've touched on that) not present in a 'kitchen-sink' web framework? I'm not sure why we're worrying about master/slave DB terminology [3] when there are axiomatically more pressing technical and adoption-related issues at hand.
Django is a fine web framework, and perhaps the best-in-breed for Python, but it feels miles behind where it should be at this point and I'm not really sure why.
[1] - https://github.com/plataformatec/devise
[2] - https://docs.djangoproject.com/en/2.1/releases/2.0/#mobile-f...
Django does have built in JSON support[1]. There's also Django Rest Framework[2], which while not built into the core, is well supported and hardly a burden to add.
And finally, Django's "scaffolding" functionality is built around its models. You define your model as a plain Python class inheriting from Django's model class, and then the various generic[3]/"scaffolding" views work by being told what model they're for, with the ability to override and extend whatever you want to.
[1]-https://docs.djangoproject.com/en/2.1/ref/request-response/#...
[2]-http://www.django-rest-framework.org/
[3]-https://docs.djangoproject.com/en/2.1/topics/class-based-vie...
In order to access a JSON endpoint in Django, I need to install DRF, integrate it with Django, configure it, edit my urls.py and perhaps set up a serialiser. I won't detail the procedure in your first link because I think you very well know that is simply a response object with a crude serialiser and a content header set. The inclusion of both misses the point, which is that in Rails, I would simply navigate to /model-name.json (so in fact, yes, it is absolutely a burden to go through that when you compare the two). That's it. No parsing. No route configuration. No concerning myself with edge-cases unless I'm doing something odd. Requirement satisfied, and I can sleep soundly knowing I'm not bequeathing some custom car-crash on whoever inherits my codebase. Debate aside, I wholeheartedly encourage you to try out this framework sometime - I've found going from Django to Rails to be an absolute joy to develop with.
Generic Views. Ah. Well that has its own set of problems. Why am I wading through the docs (or more accurately ccbv.co.uk because the actual docs are a verbose, time-sinking miasma; recall that in my previous comment, I am championing the development-velocity of Rails in contrast to Django) to discover which method from which class I need to override to implement the functionality I need? I can intuit a lot more now, after doing this for years, but why do I need this knowledge at all? It is the job of the framework to abstract and ameliorate bullshit. Corollary: why is it that every Django codebase I inherit has at some point converged on its natural state of 'car-crash' because of the combination of a bunch of rigid inheritance chains and my predecessors not putting in an escape hatch? At risk of being a bit of a zealot, MI is almost always an anti-pattern and I would prefer the flexibility afforded to me by composing things in the traditional fashion.
In Rails, I would build a model like this in my shell: `rails g scaffold Blog title:string content:text`. That's again, literally it. From that, I now have a Blog model with title and content, created and updated fields, controllers (or 'Views' in Django parlance for some reason) and both HTML and JSON views ('Templates', in Django-land), unit tests, assets for my asset pipeline (we don't have to run collect static btw - it seamlessly transitions into production because it was designed on the basis that people might actually be deploying their projects), my equivalent of urls.py has been updated to accommodate my new model and I have full CRUD functionality at this point. Genuinely, I implore you to try this framework. Django has come a long way since I first used it but it's nowhere near the level that modern frameworks like Phoenix [1] (you should give this a go too - the third party libs aren't quite there yet but it's a really well thought-out framework) are at, and I'm genuinely curious as to why.
I've seen my fair share of terrible Django and terrible Rails applications. Bad code can be written in any language and framework.
Don't get me wrong, Django definitely has its pain points, but I think it offers a very competitive alternative to Rails.
I definitely agree with you on Phoenix though! Elixir/Phoenix is my current stack of choice. I actually think they do a really great job of capturing the high points of both Rails and Django while also improving on the weak points of both as well. (For example, Phoenix offers a lot of the "magic" of Rails but it's all backed by explicit code that Phoenix generates while creating your project.)
You want a smooth progression of tooling that you can approach and slowly clarify ever-finer approaches to over time. The object model is the base of the pyramid, it's the thing you rely on when nothing else solves the problem, you know you can always invent a new kind of object hierarchy by refactoring to BasicObject, obliterating stdlib semantics with a veritable flamethrower. I've never put such a thing into production, because I know there's always less drastic ways to define, mold, shape, and extrude abstractions.
With less semantically-fluid languages, you wind up relying on the same few tricks over and over and over again, because they solve problems, albeit poorly and opaquely. This flows, again, from the underlying approach to typing. Python is dynamically typed, which keeps it from being totally unworkable any time you need to do something special or cross-cutting, which is absolutely a need in the web world, but it's structured enough to where you need to devote library-level amounts of thought into coming up with clean, semantic abstractions that are easily traversed, something Ruby just comes with out of the box.
They are.
Django Channels: https://www.djangoproject.com/weblog/2016/sep/09/channels-ad...
Stuff included in Rails I don't need:
* ORM
* Heavyweight controllers
* Server-side HTML templating
Stuff not included in Rails that I do need:
* Basic DB-level sanity checks, such as uniqueness constraints that actually work
* Any kind of real frontend framework
Stuff that I desperately want that Rails makes fundamentally impossible:
* Sane concurrency
* Not having to pull my hair out over random values in my codebase magically turning into "nil"
The best pattern for developing basic web applications that I've seen lately is basically:
* Use React for the UI. (If you prefer another front-end framework, I don't really want to fight about it, but React is pretty damn good.) Host your statics, well, statically.
* For your backend, use the simplest possible mechanism that receives HTTP requests and emits JSON. If you're married to Ruby, Sinatra does this. Flask does this. Node and Go and Java all have relatively simple mechanisms for this. The mechanism doesn't matter. Route HTTP requests to function; return JSON (or some HTTP response object that encapsulates your JSON) from function.
* For interacting with a relational database, use sprocs. SQL isn't hard; ActiveRecord is probably the best example of the Rails antipattern of, "make easy things easier, and hard things harder".
The learning curve isn't too bad.
I've been a Rails developer for quite some time and am picking up Elixir / Phoenix in my spare time while building a single side project. This is my first real attempt at picking up a functional language too.
The project I'm building is an ambitious project (users, accepting stripe / paypal payments, lots of data modeling, real time aspects, decent amount of logic I haven't implemented in other more familiar frameworks, etc.) but thanks to the community and open source projects to look at I'm making reasonable progress.
Of course I'm not as productive as I am in Rails but that's because I'm only putting in a few hours a week into this project (while learning Elixir / Phoenix as I go).
First I think a very large number of developers don't care for functional programming.
Then Phoenix is mainly run by only two persons, Chris McCord and José Valim (who also manages Elixir and Ecto). If I compare the pace of development and what you get out of the box with PHP/Symfony (I don't know RoR) it's quite clear that Phoenix is not there yet (without even speaking of the difference in ecosystem size).
Having said that I'm excited for Phoenix 1.4 https://github.com/phoenixframework/phoenix/milestone/17
I don't think that this is something I want in my project, I think I'll keep with .NET and Go even if I don't get the "competitive batteries-included all-in-one framework" packaged in.
(Well and there is always the issue that most larger RoR projects like to pull a lot of resources. And seriously the biggest three VMs on my host are an RoR application and the SQL Server which runs both MySQL and PG and the only node.js app I run)
When you know the framework well, however, I find one of Rails' strengths is that it massively decreases the time it takes to get familiar with a codebase. There's never a question of how a developer has organized their code, or configured logging (to take your example), because it's not a choice that Rails gives you - every project is going to work the same.
Usually you'd just create a custom logger[0] and tell Rails to use it[1]
[0] https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger....
[1] https://guides.rubyonrails.org/configuring.html#rails-genera...
Grepping can be a successful strategy, esp. when you know what you are looking for and you can search the database column in the code
Go with Ruby/Rails if you don't need the JIT/AOT compilers and high performace GC algorithms.
But it's missing scaffolding and stuff like that.
Another would be that sometimes a train is not the most practical transportation to travel a few blocks.
It also makes good use of what Typescript has to offer, which IMO is very much welcomed.
(Not that I'd consider an untyped ecosystem in the first place, especially one as fond of "magic" (e.g. monkeypatching) as rails. I have sympathy for just getting something working as quickly as possible, but there comes a point where you're storing up too much trouble even for the short term)
If the project's successful. The chance that most of what we're building with Rails hits the required escape velocity to require something other than Rails is a "Nice Problem".
For the vast majority of things people are building for the web, "CRUD+Auth+Billing" is all that's needed, maybe with a few API hooks into something more novel running on different infra.
If you then need it, then you can just build out a few more services with a few more API hooks, and then transition to a non-Rails stack as required.
It's great if you have unlimited resources to spend the time setting up the perfect tech base for a project for if it does eventually require scaling above what, Basecamp for example, can handle - but that seems like wasted resources for a great deal of orgs that don't have that level of backing.
Of course, if you truly need something novel, then it's a moot point, if you can't achieve what you need to with a stack, then just don't use it.
> For the vast majority of things people are building for the web, "CRUD+Auth+Billing" is all that's needed, maybe with a few API hooks into something more novel running on different infra.
> If you then need it, then you can just build out a few more services with a few more API hooks, and then transition to a non-Rails stack as required.
True as far as it goes. But if we're just talking about a prototype for validating product/market fit, with the intent to transition to a more maintainable stack as and when that becomes necessary, what's the problem with "list of 30 random npm packages" as a starting point?
We can argue it from both ends, but I see Rails as the middle ground, and allows you to go from MVP to $XXm ARR on the same stack. A hacky MVP with 30 npm packages doesn't have a clear path up the tree to grow without serious changes, and a custom architecture is useless if you don't get any users.
I see it as the opposite: it's clear which functions are the responsibility of which library, and it's easy to replace the ones that are becoming blockers and leave the ones that aren't. Whereas with Rails if you keep it monolithic then upgrades always become a huge pain point, but if you try to cut out pieces of it you're going against the grain.
(I used to love TurboGears nearly a decade ago, because you could use it like a monolithic framework to start with but it was explicitly a collection of standalone libraries underneath, and so once you started needing to do different things to individual pieces it was easy to. The modern web ecosystem could do with something like that, IMO (though personally I'm sticking to ScalaJS for the type safety))
The dude starting with rails will probably be done with the MVP before you decide _which_ 30 random npm packages to use.
I agree that that's what's going to happen in the short term, but var doesn't mean becoming dynamic; type inference doesn't compromise soundness at all. I think it's going to be much easier for sound type systems to get good-enough inference (indeed Hindley–Milner already offers "perfect" inference: you don't need to write any explicit types if you don't want to) than for dynamic languages to retrofit soundness. And while one can live with a few unsound constructs as long as it's locally clear when unsoundness is happening, as soon as you have pervasive soundness issues with action-at-a-distance your type system becomes almost useless.
Yes, I do.
Because it has allowed the community to develop a whole lot of well-integrated, batteries-included libraries that span the from the model layer to the frontend.
From a language perspective it's stable, fast, easy to deploy. Why wouldn't you choose to use it? For most it's not a difficult language to learn and start using.
The defaults of functions/methods in the standard library are often insecure.
if you want to write good PHP i can recommend following resources: https://paragonie.com/software Would use their stuff if i wrote PHP https://www.phptherightway.com https://phpdelusions.net even though the name sounds abrasive it is a good resource on dbaccess if you want to know specifics. It is from a guy with several SO gold badges.
I'm not some crazy fanboy but until someone can actually name a seriously competitive, batteries-included, all-in-one framework* which delivers everything, or even most of, what Rails does - it is very relevant and you ignore it to your serious disadvantage.
* your list of 30 random npm packages does not satisfy the requirement