简体   繁体   中英

Rails or node.js for Restful API

I have an existing website written in ASP.net, I have recently switched to Mac full time (With Windows in Boot Camp), and need to write a public API for accessing my website's MySQL data. I primarily want to use the API to allow building an iOS application.

I am interested in learning either Ruby on Rails or Node.js, I haven't used either of them yet.

Which language would be better for me to learn?

Rails is a relatively mature web framework based in Ruby and is designed for handling object-mapped data persistence in a relational database backend.

Node.js is much newer on the scene , and unlike Rails, is a more bare-bones package that allows for server-side Javascript applications thanks to a pretty tight HTTP(S) API. Node applications are by nature event-driven , which may or may not be ideal for your application.

Since it seems that you'll need data-persistence (you mentioned accessing MySQL data...), Rails might be easier to get started with, as it comes packaged with all the things you need in this respect and is designed to facilitate this sort of application.

If you you don't really need relational data persistence, Node is probably a better bet as it stays out of your way and lets you decide how to handle things. It's important to note that Node is a much more bare-bones "framework" than Rails -- if you want something slightly higher-level but still lighter than Rails that runs on Node, express is good place to start.

Still, if you want to try Node (I will confess: it's a lot of fun!), it's totally possible to access MySQL in a nice, event-driven (non-blocking) way . Here are two modules that will be helpful:

Neither is a language; they're frameworks. There is no "better", there may be a "more suitable" (probably not in this case).

Which would you prefer to develop in, Ruby (Rails), or JavaScript (node.js)?

Would you like to transfer that knowledge to a different job without rampup time (Rails)?

Would you like to learn something a bit more esoteric, event-driven (node.js)? (Ruby has Event Machine, but IMO node.js takes it a bit further.)

So this new application is just a middle man between your ASP.NET thing and your other clients.

In that case, totally use node. Node is great at being networking glue. Node scales great with IO bound applications (ie being a network middleman).

If you're going to use node then you probably want to look at express to make it easier.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM