
Rails API is coming to Rails 5 - colinbartlett
https://github.com/rails/rails/pull/19832
======
steveklabnik
Context: [https://rubygems.org/gems/rails-
api](https://rubygems.org/gems/rails-api)

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.

~~~
mparramon
Why was it pulled before release?

~~~
steveklabnik
It's been a very long time, so I don't remember the specifics, to be honest.

------
jfaucett
IMHO this is nice code, nothing against the devs, but I just don't see why its
getting added. As someone who has built lots of rails apis, I don't really see
any benefit other than perhaps speeding up bootstrapping. But as is, right now
its incredibly easy in rails to require the action-X packages you want and
setup middleware how you like it. Maybe I'm missing something though...

~~~
steveklabnik
There's a lengthy explanation here: [https://github.com/rails-api/rails-
api#why-use-rails-for-jso...](https://github.com/rails-api/rails-api#why-use-
rails-for-json-apis)

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.

~~~
catshirt
this justifies the library's existence but does not justify it's inclusion
upstream.

~~~
1qaz2wsx3edc
Because Rails has become bloatware and has been since they lost sight of the
future of the web and stagnated on innovating...

------
scott_o
This provides some more context: [http://wyeworks.com/blog/2015/4/20/rails-
api-is-going-to-be-...](http://wyeworks.com/blog/2015/4/20/rails-api-is-going-
to-be-included-in-rails-5/)

------
ludicast
I love this. I find that Rails-API sometimes does/needs some screwy stuff
because it has to be 2nd class citizen. This promotion of it is great news
because it will obviously be kept in sync way better.

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".

------
grandalf
There is also sinatra, which has had a stable API for years.

~~~
ad_hominem
Not really:
[https://twitter.com/maccaw/status/576437511729221632](https://twitter.com/maccaw/status/576437511729221632)

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.

~~~
pjonesdotca
Actually a good testing suite fixes that issue. It's probably the most bogus
"issue" strong type addicts bring up.

~~~
jallmann
The only thing better than having tests is not needing tests. That's what a
robust type system gives you.

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.

~~~
erokar
You might want to watch this talk for some data on this subject:
[https://vimeo.com/74354480](https://vimeo.com/74354480)

"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."

~~~
ssmoot
As someone who worked with Ruby since ~1.8.1, has written a ridiculous amount
of OSS Ruby and now works mostly in Scala, this is the exact opposite of my
experience.

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.

~~~
grandalf
What's your thought on something like contracts or facebook's flow (for js) ?

------
wiremine
Like the concept, but the name is confusing. I get it is coming from a
separate gem, but hopefully it is renamed to convey what the intent is.

------
ksec
I dont have time for the Video, has anyone written a post on what's coming in
Rails 5 yet? ( Apart from Rails API )

------
andyl
What is the best Rails solution for javascript modules and package management
these days??

~~~
kennethtransier
I'm a huge fan of [https://rails-assets.org/](https://rails-assets.org/).
Requests components from the Bower registry and packages them as gems.

