Comparing PHP, Perl, Python and Ruby
71–80 of 92 posts
Re: Comparing PHP, Perl, Python and Ruby
#72This is a really great effort, but I noticed a handful of areas where the PHP example was off. I wonder if people with more experience with the other languages noticed the same thing for their language. Some examples: Null test: $var === null // omitted isset($var) // actually checks if $var exists and is not null (apparently-- I actually didn't know about the not null part) Undefined variable access: it's a notice.…
Re: Comparing PHP, Perl, Python and Ruby
#73Earlier quoted context omitted.
It also means you have to stumble upon Moose to start using objects in a reasonably sane way. The average new Perl programmer is not going to go looking for a library that does object-oriented behavior until it's too late. They'll probably have some crazy idea that the language should be doing OO for them. If you were to navigate a largish Perl codebase today, you'd encounter the old-school bless, Moose trickiness, a…
I'm not a Perl programmer, but I'm aware of Moose. It's frequently mentioned in beginner tutorials on how to do OO.
Re: Comparing PHP, Perl, Python and Ruby
#74Earlier quoted context omitted.
ruby will get you a job at twitter. I heard that twitter are moving from ruby to scala.
that was more then a year or two ago, they changed their mind in the meantime. they do have some cool software developed in scala I think.
Re: Comparing PHP, Perl, Python and Ruby
#75Earlier quoted context omitted.
my hosting is still on 5.2.17 and are in the "security testing" phase of 5.3.
I wonder what they mean by security testing? What exactly are they testing and how? BTW given that there's no security patches released for 5.2 anymore (while bugs are still being found and published of course) - their understanding of security is certainly unorthodox.
Re: Comparing PHP, Perl, Python and Ruby
#76"Passing by reference" section is wrong about Ruby (not sure about Python). Ruby passes everything by reference, it's only that integers are immutable so that the function can't alter them. Strings, though, are mutable: def foo s s.concat 'foo' end a = 'bar' foo a a # => "barfoo"
They both do "pass reference by value". Which is a big difference.
Re: Comparing PHP, Perl, Python and Ruby
#77"Passing by reference" section is wrong about Ruby (not sure about Python). Ruby passes everything by reference, it's only that integers are immutable so that the function can't alter them. Strings, though, are mutable: def foo s s.concat 'foo' end a = 'bar' foo a a # => "barfoo"
def foo s
s = 'foo'
end
a = 'bar'
foo a
puts a
# => bar
The assignment in the method doesn't change the object you "passed" in. Rather than passing by reference, think of Ruby as passing the value of a reference.For more examples and explanation, see http://khelll.com/blog/ruby/ruby-pass-by-value-or-by-referen...
Re: Comparing PHP, Perl, Python and Ruby
#78Re: Comparing PHP, Perl, Python and Ruby
#79"Passing by reference" section is wrong about Ruby (not sure about Python). Ruby passes everything by reference, it's only that integers are immutable so that the function can't alter them. Strings, though, are mutable: def foo s s.concat 'foo' end a = 'bar' foo a a # => "barfoo"
class Fixnum
alias :realplus :+
def + b
@a ||= 0
@a = @a.realplus(b)
self.realplus(@a)
end
end
The integer value itself is immutable, though.Of course all hell will break loose and adding instance variables in certain classes like Fixnum will be extra slow (as if there aren't enough other reasons not to), since MRI uses type-tagging for Fixnum, Symbol and a few others, and so since they're not "real" objects, if you do anything that requires one, it creates one that's stored in a hash table.
Re: Comparing PHP, Perl, Python and Ruby
#80Earlier quoted context omitted.
Nothing I love more than watching someone try way too hard to act "grizzled" and in the process make an idiot out of themselves. http://hyperpolyglot.org/
Was that in response to his exhortation to learn different languages, or do you actually believe that Perl and its self-proclaimed successors have any profound differences?