5 ms·
Downvote away -- I know I deserve it, but I need to say this: Whenever I see a discussion of good software design principles given by a PHP programmer, with PH
by jessedhillon 14y ago
Downvote away -- I know I deserve it, but I need to say this:
Whenever I see a discussion of good software design principles given by a PHP programmer, with PHP examples, I roll my eyes and press Back.
Rightly or wrongly, the thought that goes through my head as a former PHP programmer (from versions 3 - 5.x, ending in ~2010) is something like, "if this person knew anything about well-designed software, they'd know enough to use a well-designed language."
- eamann 14y agoNope, I'll upvote :-) I started my career as a .Net developer and still work a great deal with .Net (primarily C#) code. I use PHP for work because that's what WordPress is built on and, without rewriting the platform that powers a huge chunk of the Internet, I have to use it. When in Rome ... And I never said singletons were a good software design principal - just that they have a place and a purpose (even if rarely).
- jessedhillon 14y agoRegarding specifically WP, which is how I made ends meet (and then more) for a number of years -- it's like crack, you hate it and you know you're better than this, but it's just makes life so easy if you don't resist. Not a perfect analogy, but what I'm trying to say is that, yes it's easy and you're fighting the uphill battle if you don't go with it. Plus, WP consulting can be very profitable, given how much of your code can be reused from project to project. But, I have to say, at this time the flaws of WP are so well-known, and the direction and style of the WP devs are such a known quantity, that we as users/devs know what it is and we know exactly how good/bad it's going to be. It's never going to be a well-designed MVC application, and it's probably never going to conform to good OOP design either. It will probably continue to look pretty nice on the backend, but remain really annoying to extend for anyone but the greenest noobs. And it will probably have a ton of features which seem like bloat to people who simply want a blog, and like cruft to people who want a full-fledged CMS. I think, after so many years, the cost of building a reusable system from scratch is starting to outweigh the benefit of just sticking with WP. One of the major pillars supporting WP's proliferation is the ease with which one can find hosting -- just upload your site, if it doesn't have push-button install already -- and I think the ease with which a Python or Ruby app can be deployed has now matched that. At least for a certain range of users.
- olleicua 14y agoI completely agree. Why has nobody made a WP replacement in rails yet?
- mikeschinkel 14y agoSee my reply to you about why above.
- jt2190 14y agoA statement like this doesn't help anyone. It doesn't help the productive PHP programmer get a better understanding of other (possibly better) tools that exist, what problems they solve, and how they can transition to those tools. It also doesn't help the person making the statement convey their expertise in the subject matter. Instead it looks like an easily dismissed statement about PHP, without any real attempt to prove it.
- olleicua 14y agoThe problems of PHP have been well documented here: http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/ http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-de... I think its relevant that PHP does object and classes in terrible backwards ways and, among other things, a singleton will necessarily be rather ugly in this context. Learning about singletons won't help anyone get a better understanding of other tools that exist. Learn Ruby or Python if you want to do web programming.
- jmathai 14y agoIt's like people in Ferraris yelling at people in Toyotas.
- olleicua 14y agoExcept if Ferraris were also really slow in addition to having bad gas mileage.
- jmathai 14y agoYou mixed up the references. But my point is that the argument is philosophical. And doesn't really matter. People are out building and shipping stuff in PHP, .NET, Ruby, Python, C and foobar. And it all works. And users don't care. If you believe all (heck most) PHP developers care that it's a fractal of bad design, then your view is way too narrow.
- 1010011010 14y ago
- olleicua 14y agoI had precisely the same reaction. I'm used to seeing singletons in the context of Java. The reasons to want a singleton pattern seems obvious to me but I would only describe it the way its classically described if I was using a crappy language like Java. In Ruby or Python you just call it class that never needs to be instantiated (and it looks way cleaner). Then I see we're talking about PHP and my reaction is if your doing something complex enough to need a singleton then why aren't you using a real language?
- mikeschinkel 14y agoIf they goal is to target the WordPress user base then the question of "why aren't you using a real language?" is moot.
- debacle 14y agoOkay. You want a piece of blog software. It has to have SEO plugins, Facebook integration, Twitter integration, fine grain editing controls, and requires approval for publishing. Oh, and the client only wants to spend $1500. What software are you going to use? Many PHP projects are driven by momentum. PHP is a language to get things done in, and I know plenty of incredible PHP programmers who use PHP because it has unparalleled adoption and a library of off-the-shelf OSS software that can't be rivaled by any other programming language. I'm pretty okay with people shitting on PHP, but shitting on PHP programmers is a completely different story. We use PHP because it gives us a leg up that no other programming language currently can. Unless you've only been a programmer for a few years, you'll understand the libraries matter more than the language when it comes to writing software. In that regard, and with regards to the OSS software written in PHP, it probably comes close to or beats CPAN.
- olleicua 14y agoRuby and Python are increasingly invalidating this argument. Python has some of the best diverse library support of any modern non-Java language. And for web stuff (which is basically all PHP does anyway) ruby is basically there. Yes we don't have an out of the box CMS aimed at the WP market yet but that just means someone needs to make it. I've worked with WP a lot and I understand why people do that and I don't disrespect them. I've also spent time staring at its guts and man they are gnarly. However if you're talking about designing new software (which is the situation you are in if you are talking about software design patterns like singleton) then choosing PHP because you are comfortable with it is a cop-out.
- mikeschinkel 14y agoIt's interesting that you mention this: "Yes we don't have an out of the box CMS aimed at the WP market yet but that just means someone needs to make it." I've got 3 "generations" of developer ecosystems under my belt[1][2][3] and from that experience I'd argue that the nature of PHP developers lends itself to creating a commonly-used CMS more than the nature of Ruby developers. I've seen the same thing happen in [1] and [2]. Ruby developers by nature are a lot more experienced and experienced developers like building great architectures and they tend not to be satisfied with "it works, but it's nowhere near perfect." So instead of a few CMSes we get many, and none get enough critical mass. In the PHP world ironically people are more focused on getting something to work even if it's not perfect because they don't even understand perfect. And they are more apt to use somebody else's im-perfect work. I'd argue that's one of the several reasons WordPress has managed to establish itself as the overwhelming marketshare lead for simple web CMS. And that reason is a necessary although by no means sufficient to explain WordPress' dominance. [1] Clipper for DOS [2] Visual Basic for Windows [3] WordPress for the web In summary Ruby is great for custom systems needed for SaaS but I highly doubt a single CMS will emerge to unseat PHP-based WordPress from it's throne. And end users don't give a crap what it's developed in or the superiority of it's technical architecture; all they care about is "Does it work for me." And PHP-based WordPress does.
- johnbellone 14y agoWhen I see WordPress I think this, but not PHP in general: haven't you used any frameworks? Unless you're KTLO who actually would build any web/service and not use a framework? There are plenty of good frameworks out there for PHP that allow you to write clean code. Most of them have only existed since PHP4+. I understand where you are coming from, but in reality when you're writing about software design language is generally a moot point.
- jasonlotito 14y ago> Downvote away -- I know I deserve it, but I need to say this I'm curious to know why you decided to post something that you knew should not be posted? If anything, it suggests that any advice or commentary you add is equally worthless because your standards are poor at best.
- jessedhillon 14y agoIt just says that I talk for reasons different than those the guideline authors would prefer to motivate people to comment. In this case I was having a specific emotional/rational reaction, which I was sure other people were also having, and wanted to start a discussion around that tangent. I'm not sure that your conclusion follows, either. How are my standards poor? And how would that render all advice and commentary worthless? Suppose -- to reduce your claim to absurdity -- that I had posted a proof that P == NP. It would have been totally irrelevant to the thread, but hardly worthless.
- mikeschinkel 14y agoFor some it's more important the market they are addressing than the language they are using. WordPress is written in PHP and has over 17% of the web at this point. If you want to address the WordPress market as the author of the referenced post does, there is no option to switch languages. "Use the right tool for the job," as so many developers like to say. For WordPress the right tool is PHP.