This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Could node.js replace Ruby on Rails completely in the future?
I'm doing bad in understanding the sense of node.js. I understand what it does regarding IO etc., but is it for example a Ruby on Rails replacement? Can I do the same database operations etc.? What about authentication?
what kind of web or other applications get build on basis of node.js?
is it for example a ruby on rails replacement?
IMHO RoR has much longer history/experience/functionality for website development. Node.js itself is a lightweight (low level) framework from which you can take off to build various types of server-side applications (not just web oriented). One of its main advantages is in wide spectrum of modules provided by community of open source developers.
Can i do the same database operations etc.?
Yes, just find the right module for your type of database.
What about authentication?
Modules like connect offers built-in authentication functionality.
Node.js is a totally separate technology to Ruby on Rails, built on a different technology stack. In its current state it's not a replacement for Rails, and certainly not a drop-in replacement
AIUI Node.js is a bit more low-level than that, in particular it has no support for typical high level web development (MVC model, db integration, etc). Look at it as a javascripty basis to write networking software on (including web frameworks).
There are some web frameworks out there built on Node.js. The only one I know is geddy.
Node.JS is to Javascript as EventMachine is to Ruby (and Twisted to Python). It's something completely different from Rails.
To illustrate: the Thin webserver that is often used to serve Rails application was built using EventMachine. So you would need a complete web framework on top of Node.JS to make it a Rails replacement.
You are comparing apples and pears.
Ruby on Rails is a MVC Framework to build websites.
Nodejs is a framework to build evented I/O operations.
You can build a port of RoR on top of nodejs if you want.
Related
I am interesting in some manual/tutorial which I could not find.
What is a lifecycle of Ruby Web application? Ruby is a scripting language. Same as PHP. But as I heard, Ruby is precompiled before running. So the questions are:
when precompilation is done?
how precompilation is working for different files and classes?
what is a lifetime of precompiled code?
how route is passed to ruby application from apache/nginx (example could be made based on sinatra)?
maybe there is a tutorial on how to make own simple web framework, or web page without any web frameworks, but with pure ruby.
where is session object located?
etc.
Every manual contains only information on how to use some framework, but how it is working internally, nothing is describing this.
Thank you.
Ruby is "interpreted" just as PHP is, but this is also a form of compilation. What you might be confusing is that Ruby on Rails and Sinatra, as with most Ruby-based frameworks, are hosted as persistent processes. PHP tends to be interpreted for each request, though accelerators and web server modules do reduce the overhead of this process significantly.
I wouldn't suggest trying to make your own framework as this is a non-trivial task and even as an academic exercise would be of limited value. It's best to study something like Sinatra to see how that's implemented in order to learn more than to start from scratch.
Rails is quite well documented. If you have a specific question about a component of the framework that can't be answered by simply reading the source code, which is usually fairly well organized, you can post that here.
Up to now I've always used PHP with or without a framework but a month ago I decided to start something new: Ruby and Rails, I found them quite easy and similar to PHP and some PHP frameworks in how they works but using a simpler syntax and many other advantages.
Some days ago I started reading about Node.js, Node.js vs Rails, "why node.js is better"...
I'm a bit confused but my objective is to learn something modern that will not become obsolete in a few months so:
What are the main differences between Rails/Ruby and Node.js and a framework based on it like Express.js (except that one is written in JS and the other in Ruby)?
What are the main advantages/disadvantages of using Node.js and framework based on it instead of a Ruby based solution like Rails?
Thanks!
There aren't enough differences between Node.js and Rails for it to practically matter.
A lot of what Node.js can do can be pulled off in Rails with things like EventMachine and Pusher. So unless you are really familiar with Rails' limitations, and know you'll be pushing the boundaries, you'd be hard pressed to make something a seasoned Rails developer couldn't do.
Having built apps in Node and Express I can say that they alone aren't enough to make a sexy application. They can seem just as old and stale if you don't have an outstanding frontend UI to facilitate the backend possibilities. Instead of comparing backend servers, I think the real future of doing amazing things is in front-end JavaScript frameworks like Backbone.js that use Express/Rails/Node.js on the backend.
I have chosen to go in the direction of Backbone.js with Rails as my backend API server. Because it's so easy to rapidly create a very nice RESTful backend server in Rails. Rails also makes working with CoffeeScript and precompiling/organizing Backbone code a breeze. There are already decent Backbone.js gems out there for Rails.
The Rails core is also able to acknowledge and embrace the fact that frontend JS MVCs are logically a good next step, and they have been working to strengthen the bond between the two. For those same reasons they have also worked to make Rails an even better API server so that it can work with frontend JS easier. Node.js and Express aren't putting as much effort to coordinate with frontend JavaScript MVCs as the Rails community is.
Being good with a JavaScript frontend MVC and Rails as a backend makes you also great for both worlds in terms of getting a job. You will easily be able to hop onto a Node.js project and add value to that team with your superior frontend experience, and you can also roll with the punches on a Ruby on Rails team and add value to them as well.
As official Node.js website explains it:
Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.
On the other hand Ruby on Rails official website says:
Ruby on Rails is an open-source web framework that's optimized for programmer happiness and sustainable productivity. It lets you write beautiful code by favoring convention over configuration.
Given this I guess that it is more appropriate to compare Ruby and Node.js, but even this is not quite right given that Ruby is programming language and Node.js is NOT. You could probably compare JavaScript with Ruby but I guess that is not what you meant to ask with this question :)
So, for me, key point in understanding what Node.js truly tries to accomplish is well described on Node.js about page. Key Node.js idea (for me) is described in this sentences:
Node is similar in design to and influenced by systems like Ruby's Event Machine or Python's Twisted. Node takes the event model a bit further—it presents the event loop as a language construct instead of as a library. In other systems there is always a blocking call to start the event-loop. Typically one defines behavior through callbacks at the beginning of a script and at the end starts a server through a blocking call like EventMachine::run(). In Node there is no such start-the-event-loop call. Node simply enters the event loop after executing the input script. Node exits the event loop when there are no more callbacks to perform. This behavior is like browser javascript—the event loop is hidden from the user.
What this should enable you, is that you should be able to easily write highly concurrent programs without even thinking about concurrency using JavaScript syntax and callback functions as basic concurrent runnable units.
Your fear that either Rails or Node.js will be gone in a week is unfounded. Rails has a large community and will be around for a very long time even though currently (early 2012) it's getting a bit of hate thrown its way. Node.js is just getting started and has so much attention I don't think it will have any problems getting to the Rails level some day.
That said I've been evaluating Node.js and Rails as options for a project and the reasons I choose Node.js over Rails are:
"The Rails Way" - In my (admittedly limited) experience with Rails it really seems like you either do it the Rails way or you are going to be in for a world of pain. A big part of the Rails way is to use the ActiveRecord model. The advantage of this is that there are a lot of gems that work with your code happily because they know you'll be using ActiveRecord. The disadvantage is you are mixing your data access & model. I am not a fan of this idea so the Rails way for me still seems a bit.. off.
JavaScript is a key part of client side web development and the idea of using it on the client and server is interesting. I'm not super strong at JavaScript and I can't imagine a better way to get better then to have to use it everywhere.
My project has real time communication needs which while I'm sure can be done in Rails there seems to be quite a bit of positive mention on Nodes ability to handle this with socket.io being the front runner option.
At the end of the day no matter which you choose you will have a great time & learn a ton of new stuff that will change how you write code. If you're not on a big time crunch I'd recommend building a small project management tool in both and see which you prefer.
Either way.. Good Luck!
2 things - performance & productivity.
Performance (more details here)
(source: jslang.info)
Productivity (how fast you can build that app)
Ruby on Rails is specialized and highly productive tool for creating so called Web 1.0 and Web 2.0 applications (99% of internet sites are such apps). In my subjective judgement and experience in this area Rails about 2-4 times more productive than node.js or express.js.
For Web 3.0 apps (realtime things, client-side MVC, etc.) this isn't true, RoR doesn't keep its advantage there.
So choice depends on use case and priorities.
I know a lot more about Node.js than I do about Ruby. That being said, Ruby is much more widely adopted. It is currently a very hot skill to have in the work place. Some may argue with me on this but I think that Node.js is still "under development" and will be for a little bit longer. It has a lot of promise but just hasn't been adopted by many companies and projects yet.
Background: I have a java library that is accessed by many developers - usually via java. However, a few devs hope to access this via a Ruby API. I am gravitating in the direction of Jruby in order to implement a Java-Ruby API.
Questions:
My main concern is that these developers will not be able to utilize the API in their current, Ruby on Rails development framework; but instead will have to operate within Jruby's rails environment. Is this going to be the case?
Perhaps I'm missing a connection between Jruby and Ruby on Rails. But it seems that you can either work in Rails, or work in Jruby's rails - are these technically two different development environments?
I would really appreciate any light someone could shed on this..
Edit: Forcing developers (actually clients to be more specific) to make large changes to their projects in order to accomodate for this API is not really an option. So, if their Rails apps would have to be converted to Jruby on Rails apps, then perhaps someone could offer yet another alternative for me (other than Jruby)?
First, I should mention that Ruby on Rails is simply Ruby code, and the same code can run in the JRuby environment (on the JVM) or the MRI (written in C) runtime.
However, only JRuby can load Java classes and use a Java API. Asking your clients to switch their deployment environment to JRuby may not be feasible, but if you can set up a service in Java that speaks XML or JSON then they will be able to easily use it from Rails.
You might find the answers to a similar question helpful. Depending on your application it may be possible to seamlessly port your RoR app to run on JRuby subject to the caveats noted in that answer. But you'd want to be sure that the benefits of doing so balanced the effort and potential risks.
Alternatively you might consider making these Java library facilities available to your MRI Rails app as an internal web service (which could be Rails or Sinatra or similar) built on JRuby. That's way you would decouple the elements and de-risk the project. If you subsequently were comfortable with that working you might then consider collapsing them back together, all under JRuby-on-Rails if that made sense.
UPDATE: Adding more detail at questioners request
As I'm not familiar with what your application or Java libraries do this will be somewhat abstract but I trust you can fill in the blanks to suit your needs.
It seems that full porting of your Rails apps to run on Jruby is not feasible. Fine. So one idea would be to expose your Java library as a web service (e.g. RESTful) to your RoR application. Let's call this thing JLS. In this case it would run as a Java or Jruby network service, listening for requests, call into the library and send back responses (general waving of hands here but you get the idea).
Depending on what your developers are more comfortable with you can create JLS in Java running a Servlet container maybe. Or you could develop JLS in Ruby, running on Jruby (binding to your Java library) and use a framework like Rails or Sinatra to implement it.
On the RoR side, assuming you've made JLS RESTful (and I don't know if that's even appropriate in your case), you can use the ActiveResource facility for communicating with JLS.
In summary the RoR app and JLS run in separate memory spaces (maybe even different hosts). Each can be developed somewhat independently (with RESTful interface agreement of course) and your RoR app does not need to be disrupted or put at risk.
This suggested option comes with tons of small print but I hope you get the general idea.
Days ago I read something like "Ruby on Rails is for web applications, Django is for standard webpages". Is that true?
I have to decide in the next weeks if I go with Ruby on Rails or Django for an university project. It will be an email marketing software.
What do you advise me to use?
This is mainly because of their heritage - Rails was originally used for web applications like Basecamp, while Django was used to build newspaper/magazine sites.
I would say both have long since outgrown their original purposes however.
No that is not true, but however, Django has the built-in Admin back-end making it a great starting point for a CMS or something similar. Django is still very capable for creating complete web applications!
I presume this is:
Ruby on Rails (i.e. the Rails framework, using Ruby as the programming language)
vs
Django (i.e. the Django web framework, using Python as the programming language)
Both of these frameworks are Model View Controller (MVC) frameworks, so they are both capable of web applications and web pages.
Therefore, your decision is really "Python or Ruby".
Both Ruby and Python are object-oriented languages and are easy to get into... they both have quick-start guides here:
http://www.ruby-lang.org/en/documentation/quickstart/
http://wiki.python.org/moin/BeginnersGuide
I think Ruby has the edge in terms of simple documentation and ease of use - as long as you are happy to abide by the rules that the language enforces (which aren't necessarily a bad thing by the way).
Both frameworks are great for what you're trying to do and Ruby and Python are similar in a lot of ways. My suggestion would be to skim through the online documentation for each and go with what feels best for you.
First, you need to answer 2 questions:
Do you prefer Python or Ruby?
Do you need a minimalistic framework, or a more complete one?
As a minimalistic framework in Python, take a look at web.py.
Both are great frameworks.
The question is.. Do you prefer (or feel more comfortable, or know better) 'Python' or 'Ruby'?
Once you have the answer to this question you also have the answer to the original one.
You can use either framework to create almost any web application imaginable.
If you have no language preference, and you don't have a preference for their different design patterns (Django is nearly not as strict MVC as Rails), then think about the different Python and Ruby libraries/apis out there that could be useful for your project.
Go with whichever language supports those libraries/apis that help you the most.
In my experience, Rails developers are more likely to work in small, funded startups. Django seems to be the preferred environment for independent consultants building websites for small businesses. If you're picking a language to gain experience, you might keep this in mind.
You'll be spending most of your time configuring, learning the tools, frameworks, and environments. The language itself (Ruby or Python) will not be a big hurdle for you.
Also - Rails is really nice to develop with on a Mac. I don't know about Django tools.
Are there any important features in Rails or Django which do not exist in the other framework?
Is there anything important missing - for an enterprise web app - in either one?
This question is not intended to be argumentative - I am trying to make an informed technology decison for an upcoming project. Two of the concerns I have, with regard to choosing one of these frameworks, are:
Integration with external systems (Java, .Net, SAP, etc)
Reporting - would there be any difficulties producing sophisticated reports/charts (financial) using either framework. This would require multi-table joins, custom sorting, pagination (w/ajax) and printing for different devices.
Django on Jython is running nicely so Java integration shouldn't be a problem.
In terms of integration in general don't forget that Django is also Python so you have the massive support of the standard library plus all the other mature well supported Python projects out there. Integrating 3rd party Python code into Django projects is usually trivial.
At the risk of getting evangelical I would list the following Django killer features:
The admin
The documentation
Python ;-)
Django also has GeoDjango. The NY Times chose Django over Ruby for their Represent project for easy mapping support:
"We built Represent with Django, the Python web framework. Although we do most of our work with Ruby on Rails, we chose Django for this project so we could use GeoDjango, an add-on that supports geometry fields and extends the ORM to allow spatial queries."
My experience/opinion is that Rails is much more flexible and has a more diverse ecosystem and is developing faster while Django is more stable, slower changing, better documented.
Rails has a huge advantage for integration with other systems via JRuby. You can give rails access to the entire Java ecosystem and run it on the JVM.
Django might be able to take advantage of .Net via IronPython (I don't know anything about this other than that IronPython exists - while IronRuby is only on the way but not here yet)