Live data from Hacker News

PHP: The Right Way

phptherightway.com

131–140 of 233 posts

Re: PHP: The Right Way

#131
post #74

Earlier quoted context omitted.

I was thinking more of: #include int main() { int arr[10] = {1,2,3,4,5,6,7,8,9,0}, *ptr; for(int i = 10; i>=0; i--) { ptr = &arr[i]; printf("%d\n", *ptr); } printf("%d\n", *ptr); }

Sure, but you defined ptr outside of the loop. Who defined $object outside of the loop in the PHP example? Also note that, in C, you have to explicitly dereference pointers: ptr = 42; You should get a warning from your compiler if you try that. PHP effectively goes ahead and changes it to: *ptr = 42; Perl requires you to explicitly dereference references as well: @array = ('c', 'c++', 'java', 'perl'); $item = \$array…

WTF. Sometimes I wonder if I'm being unfairly prejudiced by not learning PHP myself and making my own decision about it but things like this make me change my mind.

Re: PHP: The Right Way

#132
I think in order to prove PHP's worth we'll need to collectively redevelop a modern PHP webapp cookbook. I'd like to see something like that myself. I still enjoy writing PHP (partly due to nostalgia) despite it's wealth of flaws.

Re: PHP: The Right Way

#133
post #125

Earlier quoted context omitted.

We get it, man. PHP sucks, you're cool/smarter/better because you use something else, and you need to remind us all about it by jumping in every time the letters P-H-P are seen in sequence to let us all know how it sucks by retreading the same old lines used by the last fifty guys who said the same thing but to your credit you really tried to be clever about it. A good portion of why people like to mock PHP is due to…

> A good portion of why people like to mock PHP is due to the way people end up using the language rather than the language's ugly parts. Are you really going to trot out that old lie? Why not read this, instead? http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-de...

Are you really going to trot out that old link? I read that and have seen it linked a thousand times here. Go love or hate whatever you want but i've had enough with this php snobbery around here. The submission had absolutely positively nothing to do with php's merit or lack thereof but all the fuckin cool kids always seem to want to come troll any time they see php anywhere and remind us how dumb others are for using it, how bad it is, or how awesome they're hipster language choice is.

E-fuckin-nough! It's beyond irrelevant. It's trolling. No one has anything more to add on the discussion of php as a language. I know this because in the past 3 weeks there have been literally thousands of comments about it and at this point its all a bunch of repeats. You have to be living under a rock if you haven't seen this same "php suck. No it doesn't, it's awesome" discussion a billion times before. Get off it already.

Phptherightway.com is the topic at hand. It's awesome. I wish I had something like it when I learned php. Oh, and I use php. All the time. I'm not ashamed because I don't feel like I need to get into a dick measuring contest over my l337 skillz or whatever it is that gets people acting so snobby about php.

Re: PHP: The Right Way

#134
post #42
post #40

curl -s http://getcomposer.org/installer | php is creepy. Never ever run other people's code without at least giving it a glance.

RVM's installation is similar: https://rvm.io/rvm/install/ A far cry from the safer/verified "download this and check it's MD5 checksum" method that I'd prefer. Seriously, fixing package management so we can continuously integrate arbitrary code would be great. Getting arbitrary OS package creation to be almost as easy as pushing code to GitHub seems like a very worthy goal.

For the longest time the installation instructions for NPM were almost exactly the same. But its worse when PHP does it :)

Re: PHP: The Right Way

#135
post #6

Something to consider mentioning - there are some in PHP these days that take this sort of stuff a bit too far. Drives me nuts to see people writing classes to encapsulate a 3 column database result. So much overhead and boilerplate.

You should check out Java sometime.

The problem is not Java, but some types of architects that flourish in corporations, usually doing designs with endless numbers of abstractions, layer upon layer.

I've seen this happening in C, followed by C++, and now Java and C#.

They will do it regardless of the language being used.

Re: PHP: The Right Way

#136
post #80

The comments about namespace are somehow ironic: is it very common to find developers that know what classes are but not namespaces? The namespace concept is much simpler than class. Which makes me wonder: who is the target audience?

What I hate about namespaces in PHP is the separator they have chosen \.

Re: PHP: The Right Way

#137
post #40

curl -s http://getcomposer.org/installer | php is creepy. Never ever run other people's code without at least giving it a glance.

Yeah... only idiots "sudo aptitude install" without reading and building from source first!

You really can't tell the difference between blindly executing input from an insecure HTTP connection, and installing packages with a tool that verifies cryptographic signatures against known good keys shipped with your distro?

Mr. Cantor, I have added to the list of people to never hire I keep in my notebook.

Re: PHP: The Right Way

#138
post #9

I'm wondering why a specific code style is 'enforced' while it has nothing to do with interoperability. Libraries with different code styles can be used together without problems. It seems like they are using the PSR to declare they're own style as superior.

PSRs where decided based on the most common standards used by some of the biggest PHP projects around. It wasn't a single person setting a standard. PSRs are completely optional. However, you miss the point. The point of this isn't really to define all the options. Rather, it's to spell out best practices (and PSR-0 is really a best practice, and all about interoperability) that the community generally agrees with. B…

Im sorry but accepting underscores as a valid alternative to namespaces in 2012, is not a "best practice".

The whole concept of PSR-0 is ridiculous anyway, because PHP supports registering multiple class loaders. If a project wants to use a naming convention that won't work with standard spl_autoload(), they can register their own autoloader.

Re: PHP: The Right Way

#139
post #126

Earlier quoted context omitted.

They do. http://www.joelonsoftware.com/items/2006/08/01.html http://skilldrick.co.uk/2010/09/why-javascript-is-awesome/

Javascript is just Scheme with a C-like syntax and a limited number of bad design decisions (like automatic semicolon insertion and the == operator). PHP is a never-ending fountain of bad design decisions, because its core devs continue to make new ones.

What bad design decisions have been made in PHP in the last 5 years?

Re: PHP: The Right Way

#140
post #74

Earlier quoted context omitted.

I was thinking more of: #include int main() { int arr[10] = {1,2,3,4,5,6,7,8,9,0}, *ptr; for(int i = 10; i>=0; i--) { ptr = &arr[i]; printf("%d\n", *ptr); } printf("%d\n", *ptr); }

Sure, but you defined ptr outside of the loop. Who defined $object outside of the loop in the PHP example? Also note that, in C, you have to explicitly dereference pointers: ptr = 42; You should get a warning from your compiler if you try that. PHP effectively goes ahead and changes it to: *ptr = 42; Perl requires you to explicitly dereference references as well: @array = ('c', 'c++', 'java', 'perl'); $item = \$array…

You think PHP is weird because you don't understand references. Reference is not a pointer, PHP doesn't have pointers. Reference is variable binding. $a =& $b is not an assignment. It is a binding - it means $a and $b are now bound to the same variable/value.
Post reply on HN