Sorry if this is a stupid question. I have looked through beginners guides about how to use Ruby. But I am still confused on what Ruby can do that PHP can't. Should I only use Ruby? Should I use PHP and Ruby? I am confused.![]()
Thanks for your help.
| SitePoint Sponsor |



Sorry if this is a stupid question. I have looked through beginners guides about how to use Ruby. But I am still confused on what Ruby can do that PHP can't. Should I only use Ruby? Should I use PHP and Ruby? I am confused.![]()
Thanks for your help.
For the phrase "Bethesda home architect", my clients
websites occupy 6 of the first 8 results
on the 1st page of Google. My Secret SEO Strategy Revealed




Ruby can do pretty much the same things as PHP, the difference is the amount of effort you have to put in.
If you mean Ruby on Rails and not Ruby in general, well, there are also quite a few MVC-frameworks written in PHP out there. If you mean Ruby in general I guess it comes down to two things: (1) Which language you like more (for whatever reason) and (2) if there are any libraries you want to use.
When it comes to libraries Ruby has some advantages to PHP thanks to namespaces support and so on, but this is only relevant if you want to use those features. PHP on the other hand has the advantage, that if you just want to have a small site it's probably easier to find a cheap host that gives you PHP support than Ruby on Rails support.
Just try both and then take what fits your needs and what you enjoyed more ;-)
Take a look at enumerable module. It makes iterating through collections a snap. It's like the difference between the following in php:
for($i = 0; $i < $arr.length; $i++)
foreach($arr as $value)
The latter doesn't seem like you're saving much effort but it helps keep you in flow as you're programming. Likewise, the enumerable methods handles the repetitive parts of the transversal so you can focus on the differences that make a difference.
# Returns [1, 2]
[1, 2, 7, 8].select {|i| i < 5 }
# Returns [7, 8]
[1, 2, 7, 8].select {|i| i > 5 }
This is basically it. A lot of lower-level actions (i.e. looping through collections and returning a single value) can be done with less effort on your part as a programmer in Ruby over PHP.
I also think Ruby's standard library/functions are more organized and consistent than PHP but some people don't agree with me![]()




A language is built from 3 things:
1) the primitive operations
2) the means of combination
3) the means of abstraction
You can build combinations from primitives. Say your primitives are foo and bar. You can combine them like this:
This is a combination. The means of combination in many languages is parameter passing and sequencing (execute some functions in a sequence):Code:foo(bar(4))
With abstraction you can give names to combinations, like this:Code:baz(3); foo(5)
Ruby is not very much like PHP qua primitive operations. The means of combination & abstraction (functions, classes) are very much the same, but Ruby has blocks (I won't mention continuations), which add some (minor) power.Code:def xyz(n) foo(bar(n)) end def zyx(n) baz(n); foo(n) end
Regular expressions are very different:
- primitives: literal characters, numbers, etc. "a", "1", "%", etc.
- means of combination:
1) 2 literals next to each other "aa", "12"
2) or: "a|b", "34|576"
n) some other things
- abstraction: there is no abstraction in regular expressions, you cannot gives names to combinations to reuse them.
It's interesting to look at languages (e.g. CSS, SQL) because you'll see that most popular general purpose languages only differ in the primitives.




Generally, all programming languages targeted to the same platform (like Internet/web) can be made to do all the same things. There is nothing really "magical" that one language can do that others cannot. It's all about implementation and personal preference. Some languages make it easier to do specific tasks, and others may require a little more work to get there. But as a general principle, all programming languages for a specific platform (like Internet/Web) can be built to achieve the same end result.
Stackbox CMS - Full edit-on-page drag-and-drop CMS
Autoridge - Vehicle information & maintenance part numbers
Twitter | Blog | Online Javascript Compressor



Ok I understand a bit better now. I just think Ruby is over-hyped.
For the phrase "Bethesda home architect", my clients
websites occupy 6 of the first 8 results
on the 1st page of Google. My Secret SEO Strategy Revealed
Everything that is hyped is overhyped IMO![]()
Ruby's biggest advantage is that it doesn't suck™.


Bookmarks