Re: What's wrong the __autoload()?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/12/08, Zoltán Németh <znemeth@xxxxxxxxxxxxxx> wrote:
> ok, I admit I don't have experience with Ruby but I have experience with
>  php. and I don't have experience with Ruby because I read some manuals
>  and example codes and whatnot and I just could not get to like it at
>  all.

That's a lot different from your previous blanket statement of "Ruby
as a language just plain sucks".  I hate you less now that I know a
bit more about you, see how that works?

> it's just so strange and different from anything I know (php, c,
>  java) -

Ruby has a lot of functional language influence.  Once you use it you
really start to like how much shorter your iterative loops are for
example.  The first two developers I worked with using Ruby also knew
ML and Scheme.  One of them suggested I go study Scheme so I would
appreciate Ruby more.  I did so for several weeks and now I do.  Ruby
provides everything from the procedural world we're currently used to
seeing in PHP, C, and Java, but it also adds functional style that
makes for some utterly beautiful, compact code.

> and I could not find out any good reasons for most of the
>  differences...

And you won't until you use it in practice more than once.  But that's
true of most any language.  I worked in Python by day for the better
part of last year and man was it fun seeing other ideas for how to do
things.

> e.g. how come function definitions are between 'def' and
>  'end'?

def is shorter than PHP's "function" qualifier?  I give up.  'end' is
optionally replacable with '}',  as is 'do' and '{' but you probably
didn't ever get to that page in the Ruby book you read.

> I just don't like it and it's a matter of taste,

In my experience "matter of taste" usually equates to "resistance to
learning", but call it what you will.

> so there is no
>  need to argue about it more... :)

There's always reason to argue the features of a given language.  For
example you may need to try and convince me at some point that Zombie
is a great language:

http://www.dangermouse.net/esoteric/zombie.html

Or not.

>  however that's not about the framework, I admit that Rails had several
>  new and useful concepts, and I know that the framework I currently use
>  took a lot of ideas from there.

Those other frameworks can never be as powerful as Rails because they
aren't written in something as meta-capable as Ruby.  Can you do this
in PHP?

class Foo
end

f = Foo.new

class Foo
  Resource.find( :all ).each do |r|
    res = r.name.downcase
    define_method( "op_cost_#{ res }".to_sym ) do
      self.properties.inject( 0 ){ |c,p| c + p.send( "op_cost_#{ res }" ) }
    end
  end
end

cost = f.op_cost_wheat

No you can't.  PHP doesn't support adding methods to classes at
runtime, nor does it support adding methods to instantiated objects of
those classes at runtime.  And that's just one example.  These sort of
OO advantages exist throughout Ruby.

You don't love these features because you don't know they exist.  You
don't know they exist because you haven't given the language more than
a few minutes of your time.  Running through some silly little 5
minute Rails scaffolding tutorial will in no way teach you the real
power that exists in Ruby.


-- 
Greg Donald
http://destiney.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux