Live data from Hacker News

I Like PHP

beust.com

141–150 of 269 posts

Re: I Like PHP

#141

Earlier quoted context omitted.

Here is some PHP code: $x = "0"; if(!$x){ echo "0 is false"; } If you understand why it's crazy that PHP prints "0 is false" when you execute that, you're probably better off jumping ship now. If you don't, you'll probably appreciate the low barrier to entry for PHP more than any benefit you'd gain.

I understand the standpoint of people thinking it's crazy. But javascript does the same thing, does it not? I thought this is what the triple equals is for?

Yes Javascript does it too, and it's considered one of its top warts for the same reason. The tl;dr version is: always use triple equals, never double.

Re: I Like PHP

#142

Earlier quoted context omitted.

Python's got excellent documentation, both official and third party.

Python itself does, but the third party modules (which do most of the heavy lifting) generally don't. See: Twisted.

Twisted has semi-decent documentation, see

http://twistedmatrix.com/documents/current/api/twisted.html

http://twistedmatrix.com/documents/current/core/howto/index....

http://twistedmatrix.com/trac/wiki/Documentation

It's not as comprehensive and shiny as the core Python docs, but along with the tutorials and examples, it's actually pretty decent.

Re: I Like PHP

#143

Earlier quoted context omitted.

Do yourself a favor. Never ever use wordpress as an example of a quality PHP application. Please look at the source code, the open source wordpress is a monstrous hack that has no clear architecture, has a terrible system of hooks that plugin authors regularly abuse and doesn't scale unless you write your own hack of plugin to override the db handler so you can do things like r/w splitting or sharding.

Any suggestions for PHP applications whose source code can be presented as an example of what TO do instead of what NOT to do?

https://github.com/symfony/symfony

http://flow3.typo3.org/download/ This is still in alpha but has good source code regardless.

Re: I Like PHP

#144

Earlier quoted context omitted.

Do yourself a favor. Never ever use wordpress as an example of a quality PHP application. Please look at the source code, the open source wordpress is a monstrous hack that has no clear architecture, has a terrible system of hooks that plugin authors regularly abuse and doesn't scale unless you write your own hack of plugin to override the db handler so you can do things like r/w splitting or sharding.

Any suggestions for PHP applications whose source code can be presented as an example of what TO do instead of what NOT to do?

Symfony2

Re: I Like PHP

#145
post #115

Earlier quoted context omitted.

I don't think you really mean "object orientation" so much as "a byzantine object hierarchy" (stereotypically associated with Java, of course). To me, Ruby's object-oriented string functions are a lot easier to keep track of than PHP's: x.length vs strlen($x) x.gsub('foo', 'bar') vs str_replace('foo', 'bar', $x) x.strip vs trim($x) x.upcase vs strtoupper($x) All four of the PHP functions use a different form: strX, s…

Python takes a different tactic, and has a non-object-oriented len() method What do you mean? In Python len() is just a standard protocol for getting the length of something, but len() itself is calling obj.__len__() if it is defined. You can even override or replace it in an object instance, returning whatever you want. You can argue that these protocols are a bad idea, or maybe a useless one since Ruby does just fi…

I meant it only in the superficial sense, that the call of len() is called as len(foo), not foo.len().

I guess this is another example of why using the term "object-oriented" at all can be unhelpful, as it may mean so many different things to different people depending on the particular situation.

Re: I Like PHP

#146

There's a regular stream of "defending PHP" posts but they all seem to miss the point. No one bashes PHP because it can't do these things, or that it isn't easy. People bash PHP because there are objectively better languages and platforms out there and objectively bad decisions made by those guiding the PHP language. If you want to defend PHP in any meaningful way then you can't just list things that can be done easi…

> If you want to defend PHP in any meaningful way then you can't just list things that can be done easily in almost every semi-modern web ecosystem Did you ever read Python's documentation? Or Ruby's? Or Java's? Show me one popular web programming language which has a full page, up to date, with examples and user comments and version incompatibility info, per function . Of course, it's just one point and I otherwise…

User comments don't belong in documentation.

Re: I Like PHP

#147
post #78

Earlier quoted context omitted.

Don't forget being able to do this from within the interpreter: >>> print abs.__doc__ abs(number) -> number Return the absolute value of the argument. >>> print xrange.__doc__ xrange([start,] stop[, step]) -> xrange object Like range(), but instead of returning a list, returns an object that generates the numbers in the range on demand. For looping, this is slightly faster than range() and more memory efficient.

Or from ipython, even better: In [1]: abs? Type: builtin_function_or_method Base Class: String Form: Namespace: Python builtin Docstring: abs(number) -> number Return the absolute value of the argument.

And:

    In [1]: import json
    
    In [2]: json.dumps??
    Type:       function
    Base Class: 
    String Form:
    Namespace:  Interactive
    File:       /usr/local/Cellar/python/2.7.2/lib/python2.7/json/__init__.py
    Definition: json.dumps(obj, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=None, separators=None, encoding='utf-8', default=None, **kw)
    Source:
    def dumps(obj, skipkeys=False, ensure_ascii=True, check_circular=True,
            allow_nan=True, cls=None, indent=None, separators=None,
            encoding='utf-8', default=None, **kw):
        """ [snip (excellent) docstring] """
        # cached encoder
        if (not skipkeys and ensure_ascii and
            check_circular and allow_nan and
            cls is None and indent is None and separators is None and
            encoding == 'utf-8' and default is None and not kw):
            return _default_encoder.encode(obj)
    #snip rest of func

Re: I Like PHP

#148
post #55
post #17

One of the reasons I like PHP is that it still lets you get to a lower level of coding. Many of the newer languages and frameworks that have become popular in the past couple of years abstract things such as database connectivity away (Django is a good example of this) and it makes it difficult to optimize queries effectively without hacking onto the framework.

Wow, It's pretty apparent that there are a lot of young programmers here on HN. I was just stating my opinion and I got downvoted because I talked bad about your precious frameworks.

Comments, Item 8: http://ycombinator.com/newsguidelines.html

Re: I Like PHP

#149
post #118

Earlier quoted context omitted.

In production, or just your dev environment?

You technically can compile ASP pages on the fly in production but it's bad practice, just like making changes directly to production is bad practice. The whole blog post is pretty much a great write up of how not to manage a website.

He was talking about small sites, in which case a deploy script, etc. is probably more trouble than it's worth.

Re: I Like PHP

#150

Earlier quoted context omitted.

> If you want to defend PHP in any meaningful way then you can't just list things that can be done easily in almost every semi-modern web ecosystem Did you ever read Python's documentation? Or Ruby's? Or Java's? Show me one popular web programming language which has a full page, up to date, with examples and user comments and version incompatibility info, per function . Of course, it's just one point and I otherwise…

Everyone is mentioning Python, but also check C# and .NET Fx and ASP.NET MVC. For example: http://msdn.microsoft.com/en-us/library/w4hkze5k.aspx or http://msdn.microsoft.com/en-us/library/system.object.member... You get the syntax (including VB, C++, and F# where availalbe), remarks, examples, version information, platforms, comments, and related content.

What used to drive me especially nuts about MSDN documentation (when I used to write C#) is that they seem to change the URL scheme every year or so, just so that every reference to anything breaks every single time you try to look at it.

I mean, just look at that first URL!

Post reply on HN