News for hackers. Stuff that matters.
Re:In Defence of WordPress by girvo on Thursday May 14, 2015 @10:04PM (#9548594)
I like PHP.

Right, yes, I know, that makes me crazy, but modern PHP is a fine language. HHVM, Hack, Composer, Packagist, the PSR standards: all of that comes together for a nice development workflow. PHP's shared-nothing architecture by default makes horizontal scaling an exercise in simplicity.

But: I don't like WordPress. Yes, it can autoupdate -- and that's certainly better than how things were prior, however WordPress' core code is horrendous. There's a reason why security issues are consistently found.

The bigger issue is the sorry state of most plugins; the bulk of vulnerabilities that end in compromise of WordPress sites are not from the core itself, but the plugins. An autoupdater for those certainly exists, but it doesn't help you if the people writing the plugins to begin with have no clue how to write not-insecure software.

These days, I avoid WordPress like the plague. When I do have to work with it, I've dragged it kicking and screaming into 2015: It lives in a Docker container, is fully 12-factor, completely managed through Composer (including Wordpress' core itself) and all code that I write for it is proper unit tested, PSR-4 autoloaded namespaced classes; this allows me to avoid crappily written plugins and rely on battle-tested libraries instead.

If and when it gets compromised, I can restore the Docker image within seconds, or lock it down as straight HTML by exporting it as a static site temporarily. WordPress can be decent if forced to be, but it's a lot of work and I'd much rather use something that doesn't have so much cruft clogging it up.

I mean heck; you still can't run the latest version of WP on anything other than MySQL, despite technically having a DBAL. Absolutely crazy, considering we have Doctrine or Propel!

Re:In Defence of WordPress by PebblesHD on Thursday May 14, 2015 @10:06PM (#9548596)
Fear not, PHP when used appropriately can be fantastically useful. Pretty much every argument against it that I've read has centered around trying to do something it wasn't meant to do and not being very good at it. As a web scripting language, it works as advertised :-)
Re:In Defence of WordPress by imakesnowflakes on Friday May 15, 2015 @12:11AM (#9548904)
>PHP when used appropriately

'using php appropriately' involves keeping a large number of gotchas and weird behaviors in your head, when you are writing every single line of PHP.

Re:In Defence of WordPress by PebblesHD on Friday May 15, 2015 @12:21AM (#9548934)
It's almost identical to Java, C and pretty much every other language. What gotchas do you have to keep in mind?
Re:In Defence of WordPress by karmakaze on Friday May 15, 2015 @04:14PM (#9553369)
We just saw the broken hash equalities here for one.
Re:In Defence of WordPress by girvo on Friday May 15, 2015 @12:41AM (#9548973)
What's a language where that's not the case?
Re:In Defence of WordPress by pyre on Thursday May 14, 2015 @10:24PM (#9548654)
I've heard that it's not very good at the "web app" paradigm vs. the "cgi script" paradigm that it was created in. Is that really true?
Re:In Defence of WordPress by girvo on Thursday May 14, 2015 @10:28PM (#9548665)
Not in 2015 it's not! Front-controller pattern (single index.php, in the same way you'd have a single Python process that Nginx talks to) that hands off to something like Silex or Symfony or Laravel, and you have a beautiful base for a proper web application API layer -- autoloaded classes, proper dependency injection, and more.
Re:In Defence of WordPress by fsk on Thursday May 14, 2015 @10:45PM (#9548712)
I never liked the pattern of routing every single request through index.php. I prefer to let Apache do the routing for me, having a separate script for each task.

I also had a PITA debugging someone else's code with autoload magic. He didn't follow any pattern for what code was in which directory, and he reused class names so grep didn't work. Now where is that source file again? (In one particular abomination, he took a string from the database and included that source file.)

That's one nice thing about PHP. You can use PHP for a simple straightforward style, or for an abomination like zend.

Vanilla wordpress is good. I'm working on a project that has a custom framework that lives on top of WordPress, and I'm cursing the people who wrote it and my employer for outsourcing the WordPress project to them.

Re:In Defence of WordPress by vectorpush on Thursday May 14, 2015 @10:54PM (#9548748)
> He didn't follow any pattern for what code was in which directory, and he reused class names so grep didn't work. Now where is that source file again?

http://www.php-fig.org/psr/psr-4/

Re:In Defence of WordPress by fsk on Thursday May 14, 2015 @11:02PM (#9548764)
Nope, he didn't follow that, he had a bunch of exceptions coded in his autoload function.

He also had a bunch of functions where a function in one class nothing but call another function in another class. He also had way too many classes.

Re:In Defence of WordPress by girvo on Thursday May 14, 2015 @11:52PM (#9548858)
Right, but that's the problem.

You can quite easily make an abomination of a class hierarchy in Ruby, or Javascript, or even Python to some extent. If people don't follow best practices, then of course things will not work with other tools that expect your work to do so.

Also, I highly recommend XDebug with the Codebug[0] client -- if you're working with a crappy codebase and run into the issue of "what damned file is this?" it will solve that in a super nice way. It also gives you a full REPL in your working environment, pause execution and play around in the PHP side during your request :)

[0] http://codebugapp.com

Re:In Defence of WordPress by fsk on Friday May 15, 2015 @07:34PM (#9554317)
I'll look into Codebug. I haven't found a PHP editor I really like yet. I've been using dev-PHP and emacs. I'm using Netbeans at work and don't like it.

Oh nevermind, Mac only, forget it.

Re:In Defence of WordPress by PebblesHD on Thursday May 14, 2015 @11:34PM (#9548834)
well said. Personally I like the file based routing solution (Multiple scripts for individual tasks) where applicable, there are benefits to multi-function scripts but I like modularity. If i've already written a script to do X, why re-write it every time? Still All these points above and below are good.
Re:In Defence of WordPress by girvo on Friday May 15, 2015 @12:38AM (#9548969)
The key benefit to the front-controller architecture is that you can keep your code outside of the webroot, such that you can avoid misconfigurations causing security issues, and allowing for user uploads without exec permissions on the files in the uploads directory.

The other reason I like it is it gives me much more control over routing, versus relying on folder and file structures :)

Re:In Defence of WordPress by vectorpush on Thursday May 14, 2015 @10:53PM (#9548743)
I'm not really sure there is much of a difference between the two beyond routing (which the framework handles just like in all the other popular imperative scripting languages), in fact if anything I'd say PHP is more aligned with the "web app" paradigm since the canonical run-times are all intended to be paired up with an HTTP server, as opposed to most others which were designed as general purpose scripting languages. I don't think it makes much of a difference though.
Re:In Defence of WordPress by imakesnowflakes on Thursday May 14, 2015 @11:43PM (#9548845)
> modern PHP is a fine language.

I am sorry, but bolting on a ton of 'modern' features on a broken language does not make it not-broken. If it does anything, it is to put up an appearance of being modern, while remaining rotten on the inside, and hence all the more dangerous.

Remember, the most broken aspect of the language is also reason for it's very defining feature (No or very little learning required to get started). Hence one cannot hope that PHP will be fixed at some point in the future. Because fixing the language thus will actually involve killing it and designing it from the ground up, at which point you can just use Python 3.

And that is even considering that the PHP community is competent enough to identify the flaws of the language. But I think what happens inevitably is that, people who can really see how broken the language also see the hopelessness of the situation and immediately switch to something else or use it only to pay their bills.

If you think I am not familer with modern PHP, here is a tool I wrote some time back in php, for php programmers to deal with the pain of working with namespaces and also provide intelligent auto completion for editors like vim..

https://bitbucket.org/sras/cliche

Re:In Defence of WordPress by girvo on Friday May 15, 2015 @12:41AM (#9548972)
> If it does anything, it is to put up an appearance of being modern, while remaining rotten on the inside, and hence all the more dangerous.

But what's rotten that you have to use in the day-to-day? PHP still has it's quirks, sure, but when I write modern PHP nearly all of those melt away. Also, well done Cliche, that's pretty neat; there are some other implementations of this idea nowadays that do similar things and are very useful.[0]

One of the reasons I love HHVM is that Hack is basically PHP-the-good-parts-with-other-awesome-good-parts-added. Static analysis? No problem. Autocomplete? Built into the default tooling! Having to remember dirty array method parameter ordering? No need -- use Collections and use methods on the primitives!

[0] https://github.com/nikic/PHP-Parser

Re:In Defence of WordPress by 8ig8 on Thursday May 14, 2015 @10:55PM (#9548749)
Knowing about WordPress and the typical use case, what do you use instead?
Re:In Defence of WordPress by girvo on Thursday May 14, 2015 @11:55PM (#9548865)
That's the problem. For some clients, there simply isn't a decent alternative.

That said, if I was forced to choose a "user friendly" CMS, I'd go with Drupal 8 (when it's released). The reasoning? It still has the client-facing tooling that non techy users expect, but is built on top of the Symfony core, following all relevant standards.

It's a little while away though, unfortunately. Depending on the site, my answer nowadays is a Silex API for the data they want to work on, and a React + Flux front-end. That's too much work for a $2k site however; WordPress is so entrenched that any replacement needs to be able to answer the plugins question successfully to overtake it.

Re:In Defence of WordPress by cyri on Thursday May 14, 2015 @11:56PM (#9548867)
I'm using the blazing fast http://gohugo.io/ Hugo static site generator (written in GoLang 8-) )

And that plugin can help you with the migration: https://github.com/SchumacherFM/wordpress-to-hugo-exporter

Hugo is more for nerds than the average WordPress blogger.

Re:In Defence of WordPress by sluckxz on Thursday May 14, 2015 @11:26PM (#9548817)
Ghost is coming along very nicely. From what I have followed from their development I have seen very thoughtful developers from the start.

edit to add https://github.com/TryGhost/Ghost

Re:In Defence of WordPress by ceejayoz on Thursday May 14, 2015 @11:02PM (#9548765)
Most people would be fine with a static site generator like Jekyll and a third-party commenting system like Facebook or Disqus. As a bonus, it costs pennies to host such a thing on S3.
Re:In Defence of WordPress by 8ig8 on Thursday May 14, 2015 @11:08PM (#9548782)
I'm not necessarily here to defend WordPress, but, I agree, a compiled static site does make sense for the HN user's blog, but you're not typical. What about the neighborhood barbershop that needs a website and likes to self-publish blog articles a couple times a week? What's the best solution for them?
Re:In Defence of WordPress by ceejayoz on Friday May 15, 2015 @09:07AM (#9550286)
> What's the best solution for them?

I'd love to see a user-friendly GUI backed by Jekyll.

Re:In Defence of WordPress by jacques_chester on Thursday May 14, 2015 @11:08PM (#9548781)
> Most people

We in technology are not "most people".

Re:In Defence of WordPress by ceejayoz on Friday May 15, 2015 @09:08AM (#9550292)
Anyone who can manage a WordPress install should be able to get Jekyll working, but I'd like to see it get a user-friendly GUI that takes care of the grunt work.
Re:In Defence of WordPress by mikeschinkel on Thursday May 14, 2015 @11:59PM (#9548873)
+1
Re:In Defence of WordPress by JeremyMorgan on Friday May 15, 2015 @02:29AM (#9549183)
I'm with you. Though I'm a .Net developer by trade I spent years in the PHP trenches. C# and .Net provide better solutions in my opinion for the enterprise. But for shops with low funds and projects that needed to be done yesterday, PHP really shines.

It's not the language as much as it is the programmer. I've seen some very secure, well written programs in PHP.

Re:In Defence of WordPress by NDizzle on Thursday May 14, 2015 @11:23PM (#9548808)
I was wary of the Wordpress auto update changes starting with I think 3.8.

Right out of the gate they updated the $post object in a way that broke existing installations.

That was what got me off wpengine and off wordpress entirely. I was tired of the updates breaking existing functionality in a way that made me have to think about it.

Re:In Defence of WordPress by JonLim on Thursday May 14, 2015 @11:05PM (#9548771)
Honest question: for the rest of us who can't write our own blogging platforms but are able to roll out our own hosting for a blog, which one would you recommend?
Re:In Defence of WordPress by thesimon on Thursday May 14, 2015 @11:32PM (#9548830)
Not OP, but http://jekyllrb.com/ and ghost are both great.
Re:In Defence of WordPress by JonLim on Friday May 15, 2015 @12:27AM (#9548945)
I've been aware of Jekyll, but I never gave it any serious consideration. Maybe I should go ahead and do that now.

Thanks!

Re:In Defence of WordPress by dotBen on Thursday May 14, 2015 @11:32PM (#9548829)
WP Engine (http://WPEngine.com) laregly solves any of these lingering concerns, or makes them irrelevant. It is also relied on by many, many Fortune 500's through to YC Startups. (Disclosure, I'm a confounder but not actively involved in the company these days)
Re:In Defence of WordPress by JonLim on Friday May 15, 2015 @12:25AM (#9548939)
Very familiar with WP Engine! However, my question was more around what other platforms can I set up on the hosted space I already have, rather than paying for someone else to host my WordPress blog.

Thanks though!

Re:In Defence of WordPress by jcroll on Saturday May 16, 2015 @12:01PM (#9556561)
Are there any examples of someone trying to refactor Wordpress on the Symfony HttpKernel or basically moving Wordpress Core to some type of more modern architecture?
Re:In Defence of WordPress by pcunite on Thursday May 14, 2015 @10:54PM (#9548745)
giro, I agree, but what are the alternatives? I'm coding my own, personally.