cover wrote:
why i should choose rails instead of php or jsp ? (no flame, it's only a curiosity...i wan't learn a web language, but i've to choose one). When use rails, jsp or php ?
To write a web program, you must often write lots of code in several languages, running in several layers. To get anything done, for example, you must add a variable in SQL to your database, then add it again to your business layer, then add it again to your HTML. And nowadays you might add it _again_, to your Ajax!
Classical web frameworks are often "smart HTML", where you template your HTML and put logic inside <% %> tags, or similar. But the problem arises _what_ logic to put there. You don't want SQL statements, but that's usually the easiest thing to write. A web framework should make the easiest statements also the most logically correct ones.
Rails simplifies this using a powerful principle:
Rails shortens the distance between any two points
If you need a variable in your SQL and your HTML, you just add it in those two places. Rails takes care of...
- migrating the database to the new schema - upgrade the live data in that database (!) - add the variable to all your data objects - copy the variable from database into the objects without _any_ SQL - transport the variable into the HTML layer
So when you make a change, you typically tweak only a few locations, and this makes you feel like the distance between those layers is very short.
If you don't configure Rails, it will try to guess, and it will often guess correctly. All data tables should have a key called 'id', for example. You shouldn't want to use any other key name, but if you want to (or if you want _no_ key), you can still configure Rails to support this. And because Rails shortens the distances between two points, Rails itself can almost always express things once and only once. You don't need to write similar code in many different places just to get anything done. Classical web frameworks still often require that.
Oh, and Rails fully supports something called "Test Driven Development", which is a system to make most bugs disappear without any debugging. That's common in standalone applications these days, but extremely rare in web applications. Rails makes it easy the same way it makes good application designs easy:
- present the variable to the test cases for testing - provide sample data in the variable for tests
This is just the tip of the ice-berg. These features make Rails extremely rapid to work with. The hardest of Rails development is often easier than the easiest of classical web development.