
Ask HN: The best language for writing RESTful APIs? - ianseyer
I&#x27;ve used flask, rails, and padrino (sinatra).<p>Flask was my favorite but is hard to keep organized without much of a toolkit or recommended dev patterns baked in. I recognize that blueprints really help, but a consistent cross-project organization would be nice.<p>The transition to padrino was welcomed due to a lot of basic structure that is consistent in all projects, but unsustainable due to a functionally dead community (#sinatra has 25 people at max and nobody talking, #padrino has maybe 8).<p>Rails is far too much bloat to just be serving JSON (benchmarks show that sinatra is 4-8x faster...) and implies TOO strict a structure to development (also, being a python person...I don&#x27;t appreciate magic).<p>What do you recommend?
======
jakerella86
I'd agree that Node.js is pretty dang nice for RESTful APIs. The fully
asynchronous nature means really great throughput on the server, especially
when most of your processing time is spent in DB or file I/O (as is often the
case in APIs). As for disadvantages... I dunno. I guess if you don't really
know JS very well it could be difficult to get into, and good developers are
harder to find than in some other languages. But as a platform for APIs it's
pretty solid.

As for a guide... There's a guide for LoopBack specifically here:
[http://docs.strongloop.com/display/LB/Getting+started+with+L...](http://docs.strongloop.com/display/LB/Getting+started+with+LoopBack)
That framework was written specifically for writing REST APIs.

~~~
dpweb
Here's a minimal framework for NodeJS.
[https://github.com/digplan/rex](https://github.com/digplan/rex) I have read
some good things about other langs, but I'll usually use Node.

------
bjourne
> Rails is far too much bloat to just be serving JSON (benchmarks show that
> sinatra is 4-8x faster...)

Does it matter 1 bit? If you can't _demonstrate_ that it does, you might as
well choose the framework with the best mascot and Django's mascot is pretty
damn awesome.

~~~
hackerboos
Sinatra is faster but enjoy writing the boilerplate.

I'll have my Rails API up in half the time. Why worry about scaling before you
have to?

~~~
ianseyer
That sounds awfully like famous last words...

In addition, I would say the mentality of scalability when constructing
applications is part and parcel of the design ideology of ruby, but too often
far removed from its practice.

I see no reason to prefer Rails API. It is a reverse-frankenstein situation
whereby they had the monster, and started removing limbs...

------
brickcap
I would recommend openresty. A library that allows you to script nginx using a
lightweight,easy to learn language lua. You get all the advantages of nginx
(unmatched speed and resource efficiency) along with the ability to "inject"
lua code into it's event loop. Which should be a compelling enough reason for
you to give it at least some serious thought.

As far as organization of code is concerned openresty does not impose any
restrictions on you. But since it is just lua you can bundle you code into
modules. And then you can use those modules using "require" much like in node
js (though it is slightly different)

Also there is lapis[1] and sailor[2] if you are looking for something more
organized.

[1][https://github.com/leafo/lapis](https://github.com/leafo/lapis)
[2][https://github.com/Etiene/sailor](https://github.com/Etiene/sailor)

------
volgodark
What about PHP ? You may try Aisel, its uses clean object-oriented PHP
[https://github.com/ivanproskuryakov/Aisel](https://github.com/ivanproskuryakov/Aisel).

Aisel based on principles of REST architecture combines two different and
independent frameworks - Symfony2 with a robust PHP community and progressive
AngularJS.

------
treve
PHP is also a dependable, boring, but proven choice.

------
centrinoblue
node.js / LoopBack - super fast prototyping, flexible, open js/json

~~~
ianseyer
Also, care to explain some of the DISadvantages of using node for APIs?

~~~
angersock
So, the biggest thing that can't be worked around is that the number type in
Javascript doesn't support arbitrary-length integers. That means that you
can't blindly trust numeric IDs for resources (though it'll take you a while
to hit them)--instead, you'll have to do things like specify string versions
of those id's. Twitter ran into this, I believe, and it's something to be
aware of.

The other disadvantage of using Node is that the ecosystem is still not
completely agreed on what to use--for my 0.02USD, I'd look into HAPI +
Swagger.

Also, if you don't know about promises or generators, you're going to write
_really really_ ugly Node code. That said, it's pretty easy to pick up.

------
altsang
for _this_ specific use case? Node.js using LoopBack.io. I/O platform with a
framework that was specifically designed for this use case, built on top of
Express to save you time.

------
pcx
You haven't used Django Rest Framework yet! I am 90% confident you will love
it ;).

------
thamizharasu
Java with JAX-RS api (Jersey framework) is my choice. Very clean API

------
romanovcode
Easy answer. C# WebApi

------
bradhe
golang is my goto.

