Rails API is coming to Rails 5
github.com
github.com
This gem was created because this feature was going to be in Rails a few years back, but was pulled out by DHH before release. But, as you can see, he's cool with it now.
EDIT: sorry, I mis-read your post. This is just "Why Rails and not Sinatra," not "this is easy enough to do on its own, why bother."
I wasn't directly involved in the decision, so I cant' tell you, to be honest.
I don't think this is a huge deal, but it will definitely be nice to have official support for this configuration.
Regardless, SPAs are fast becoming the best way to develop and this sort of thing (rather than the bandaid of turbolinks) gives me a lot of hope for the future of rails. I can even see rails eventually replacing views with a presenter layer (though something like that would probably wait for 6).
Reminds me of what someone once said about America: "they always do the right thing, after exhausting all other possibilities".
If you want true stability you probably have to switch to a language with a stronger type system. That Sinatra bug proves that even small codebases can suffer from basic type errors.
Type systems don't eliminate all testing, but they do eliminate a large swath of possible errors that need to be tested for, like the one that has (had?) been afflicting Sinatra.
"Some programming language theorists would have us believe that the one true path to working systems lies in powerful and expressive type systems which allow us to encode rich constraints into programs at the time they are created. If these academic computer scientists would get out more, they would soon discover an increasing incidence of software developed in languages such a Python, Ruby and Clojure which use dynamic, albeit strong, type systems. They would probably be surprised to find that much of this software—in spite of their well-founded type-theoretic hubris—actually works, and is indeed reliable out of all proportion to their expectations."
YMMV, but I've never seen the Ruby project that didn't suffer from stupid bugs even the most basic type system would have caught.
One of the biggest advantage of type-systems for me is that they don't suffer from No True Scotsman. If you don't have a test that covered this bug, people are happy to tell you you're doing it wrong. The type-system doesn't have that problem. It doesn't "rot". It expresses only what you tell it to. It enforces maintenance and rigor in a way that tests, as non-integral code, fundamentally can't.
But that's just my opinion man.
Anyway, I'm no PL theorist, only a schlub that's a better programmer because of ML. Yeah yeah, sample size of one...
I've written lots of useful stuff in Python and Ruby, but I've also sunk lots of time into tests that I would have preferred not to need to write.
You could see this move towards JSON APIs way back in 2012 as I suggested here: http://paulbjensen.co.uk/posts/2012/07/11/thoughts-on-rails-....
Some poo-pooed the notion, but you can clearly see that the popularity of realtime frameworks and the way that apps are built client-side heavy is pulling Rails in this direction.
Performance is still the key factor here, and I suspect that's half the reason why you've got some people who espoused Ruby in the past now playing with other languages beginning with Ru, but that have a much less friendly syntax compared to Ruby.
Some welcome changes though nonetheless, especially on the WebSockets front.
I've down API dev in Rails too, but it really feels like killing a fly with a hammer sometimes. And as I shift strongly to microservices (thanks Docker!), I want my API code to be as minimalist as possible. Grape/Sequel feels simple, which is good.
Would love to see a few examples
> I've down API dev in Rails too, but it really feels like killing a fly with a hammer sometimes
More like creating a few extra layers of abstraction to confuse the fly.