Live data from Hacker News

Taking PHP Seriously [pdf]

raw.github.com

151–155 of 155 posts

Re: Taking PHP Seriously [pdf]

#151
post #105

Earlier quoted context omitted.

Javascript, C and Java suck, yes. Show me something as bad as the OP in python3 and then maybe you'll have a point.

Even if Python 3's type conversion semantics has no dark corners, I still have a point. harshreality argued that, because PHP's implicit type conversion leads to weird behaviour, "PHP doesn't work. End of story." In that case, nearly every widely used language (with the possible exception of Python 3) "doesn't work. End of story." That's not a very interesting or useful story to tell.

Javascript, C and Java all "don't work", at least to the extent that I would never take a job writing them.

Re: Taking PHP Seriously [pdf]

#152
post #151

Earlier quoted context omitted.

Even if Python 3's type conversion semantics has no dark corners, I still have a point. harshreality argued that, because PHP's implicit type conversion leads to weird behaviour, "PHP doesn't work. End of story." In that case, nearly every widely used language (with the possible exception of Python 3) "doesn't work. End of story." That's not a very interesting or useful story to tell.

Javascript, C and Java all "don't work", at least to the extent that I would never take a job writing them.

Well, you're consistent.

As I said earlier, I agree that implicit type-conversion is evil. But if I refused to use flawed tools...

Re: Taking PHP Seriously [pdf]

#153
post #142
post #115

Earlier quoted context omitted.

PHP(.net) doesnt have strict typing ,but type hinting, which is not the same.

It does have strict typing with objects, but not literals. If I make a function meow(MyClass $meow) { } it will throw errors if anything other than a MyClass is given to it, including NULL.

You are wrong , it has type hinting , not strict type checking. You can alias types, there is no hard types in PHP except for arrays. Your function signature check the name of the object in the namespace , not it's type.

Re: Taking PHP Seriously [pdf]

#154
post #153
post #142

Earlier quoted context omitted.

It does have strict typing with objects, but not literals. If I make a function meow(MyClass $meow) { } it will throw errors if anything other than a MyClass is given to it, including NULL.

You are wrong , it has type hinting , not strict type checking. You can alias types, there is no hard types in PHP except for arrays. Your function signature check the name of the object in the namespace , not it's type.

function meow(MyClass $meow) { }

This will only accept an object that is_a MyClass. It can either implement an interface MyClass, extend an abstract MyClass, extend a regular class MyClass, or be the actual object MyClass.

Namespaces have nothing to do with this, other than you being able to use the "use" statement at the top to alias it.

Re: Taking PHP Seriously [pdf]

#155
post #100

I like the look of this "hack". It adds things to PHP that I missed from C# .. now if they will add Accessors syntax, that would be nice, especially for those that use Doctrine2. PHP is as professional of a language as the user. I found fun working with PHP, C#, (node)js, python and think each has its own way, quirks and benefits.

You can easily add something like accessors using traits. I cooked this up in 5 minutes: https://gist.github.com/jsebrech/6740010 You can do a lot with meta-programming in PHP. For example, you can write your own array type if you are so inclined and use it anywhere you would use an array. Here's an experimental library that showcases the meta-programming abilities: https://github.com/jsebrech/php-o

i can do something interesting with __set and __get , but i really just want it to be part of the language. Nice ideas in the meantime tho.
Post reply on HN