Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Ask HN: The best language for writing RESTful APIs?
10 points by ianseyer on June 16, 2015 | hide | past | favorite | 21 comments
I've used flask, rails, and padrino (sinatra).

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.

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

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't appreciate magic).

What do you recommend?



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... That framework was written specifically for writing REST APIs.


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


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


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?


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


What? I legitimately did not understand what you just said.

Django, similarly to rails, has far too much bloat and is tediously layed out. An entire rant aside, Django is becoming increasingly unpythonic and more rubylike, imo.


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 [2]https://github.com/Etiene/sailor


What about PHP ? You may try Aisel, its uses clean object-oriented PHP 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.


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


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


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


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.


understanding asynchronous coding in JavaScript - e.g. callback hell, flow control, it's the tradeoff to efficient and scalable processing


having never used node, could you point me to a good tutorial/guide on using the two in tandem?


Might want to poke around here for tutorials geared at devs coming from other languages: https://strongloop.com/node-js/node-js-get-started-java-php-...



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.


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


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


Easy answer. C# WebApi


golang is my goto.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: