Ruby Me wrote:
And the most interesting point, which language can create a web
application with less code? (I am talking about the languges not the
frameworks).
Ruby cause of the high dynamic approach and a cleaner language design.
Ruby allows you to build DSLs (Rails is such a thing) to make things
shorter. You have to understand that the Ruby language itselfs can be
modified (not the whole language but parts).
A important thing is DRY, don’t repeat yourself. Ruby allows you to
write programs where you don’t have to double your code many times.
In many languages you can see, how people have to copy’n’paste code and
modifiy only small things. It’s not the way how to do this in ruby.
Yes, you can repeat yourself in Ruby, but you don’t have to as much as
in other languages.
I read the online documentation about ruby and thought: Great, this
people made concepts first and tried to repeat this concepts in every
piece of the language. So you have an very consistent language with less
pit falls.
One thing is: Everything is an object. Yes, it means, everything is an
object and you can use the pattern of an object everywhere.
Another thing is: Everything is dynamic. So you can change an object and
a class at runtime (a class is an object too but at a higher level), can
define new methods. Yes, the internals of the language are objects and
you can work with them like any other object.
This is simply GREAT. With this dynamic approach you can build your own
DSL.
And the third thing is very important: Every piece of code can be
handled as an object. So you can write methods, which expects code as a
argument. This is a very heavy used concept in Ruby and is called
“blocks” where the given code is the so called block.
You write for example an algorithm for traversing a data structure. And
you have code which can handle the or some elements of the structure. In
Ruby you can easily split this code into two parts. You should do this
because the two problems, knowledge about the data structure and
knowledge about the elements are complete independent from each other.
You could exchange the elements with other types of elements and you had
to traverse the data structure the same way.
Or you could use the elements somewhere else in another data structure.
So you should split the code and ruby supports you very well on that
task.
So you can write shorter, cleaner and less error prone code. And yes,
writing ruby code is much more fun than writing PHP. You can feel the
support for abstraction. On the other side writing PHP code feels like
walking through a shelter. You feel thick walls everywhere. The language
controls you very hard.
Regards
Oli