Which has better packages, Python or PHP?

Answered in Quora

Q: Which has better packages, Python or PHP?

It depends on the target utility. In the Python world, the most common package installer is pip; the PHP world didn’t settle on a dominant format/installation for packages until composer, and that was relatively recently (last 4 years).

The reason for this is because PHP is a language almost exclusively designed for websites, and the economy of the open-source world has found that a dedicated application, instead of a framework or library could serve the bulk of most commercial needs. For instance, a single application, WordPress, four years ago (2014) accounted for nearly 20% of all websites and 50% of all blogs. There is little need package management when a single download and install (or a single click during ISP/hosting account creation or visit to site like Bitnami) can set up everything a typical website might need, fully under your control, with its own package infrastructure (plugin and theme ecosystem) where the underlying language (PHP) is pretty much irrelevant to the user.

Other languages like Ruby (with gems) or Go (import) or Javascript (with npm) which matured later and are more general purpose had a more robust package management and installation system. PHP Composer, in fact, is most modeled on npm.

Python, like Perl, predates these languages, but its general purpose demanded package management early in its development. However, because of this, pip takes less advantage of web conventions that npm does. Python has the added headache of version compatibility with its core runtime. Still pip is perfectly workable and relatively seamless and easy to use.

So which has better packages? The answer is it depends on the domain. In nearly any language you can find an adequate package for any of your needs, but overall you will find the packages are higher quality, more up-to-date, and sometimes just better overall in the domain the language seems to target well.

In my opinion, packages for data science/AI/ML applications, Python packages are second to none. As a PHP expert, I wouldn’t even bother looking in Composer for them and would instead find a PHP extension that binded to a dedicated engine optimized for the problem area or write a dedicated solution/web service in Python/flask and call it from PHP. If, for some crazy reason, I needed to do this entirely within PHP, I would search for the best solution in Python and see if someone has a port for that in PHP.

I would expect the same in DevOps for Python, but right now that space, like blogging (WordPress), seems to have dedicated solutions where a domain-specific language has abstracted one from the language-specific package management solution. For instance, in the configuration management space the top four applications are: Puppet, Chef, Ansible, and SaltStack. Of those four, I believe only one (Chef) exposes the underlying language (Ruby), and it does this to the DevOps engineer no more than WordPress exposes PHP to a blogger.

For server-side web-based packages, I feel PHP and Composer are going to have a solution for any problem PHP itself is capable of solving. That is a restricted set, however, as more and more work for web applications is being done on the client-side in Javascript and there is already an adequate toolchain for that (as well as a package management system in npm). Other web-based languages will probably have adequate solutions in this space with decreasing order/quality: Ruby (on Rails), Javascript (NodeJS), Python, Go, Perl, Java… The web problem is now pretty discovered at this point so there is less a need to adopt the bleeding edge in the web problem.

NaNoWriMo 2016

Ever since Marie wanted to learn to program in 2009, I’ve wanted to write a book to help her. But I never could get started.

The National Novel Writing Month is November every year for just this purpose: to motivate people to put 50,000 words on paper (about the size of the novel, Slaughterhouse-Five), editor be damned.

I first heard about it in 2007, when I started using Scrivener, but dismissed it because the requirement that a novel be fiction. I only just found about NaNo Rebels, which allows you to customize the “50,000 words” into nearly any other creative exercise, including non-fiction. So yesterday, this was born:

NaNoWriMo 2016 Participant Badge

Nowadays, I use Ulysses. I simply created a group in the software and set a 50,000 word goal and started typing away!

NaNoWriMo 2016 Day 2

Goal setting on my iPad.

I don’t know if I can finish since it’s about a good sized blog article each and every day. We’ll see how it goes. So far it’s been a bit strange writing a book. For instance, I can’t use my WordPress shortcode macros lest I ruin the word count.

Periodically, I’ll dump the output to my blog, which you can track here. Wish me luck!

If you want to buddy up, I’m “tychay” there.

I come to bury PHP, not to praise it?

(I received an answer request from someone on Quora for this question. At the time of my writing, there were only two answers, both that boiled down to “use Python.” While I feel I was asked to balance out that with some PHP cheerleading, I can’t bring myself to do that. Nor, can I hop on the bandwagon.)

Between PHP and Python which is better for a startup?

My answer reads like a Zen koan: it depends on the nature of the problem; it doesn’t really matter. It becomes the nature for future problems; that makes it matter.

Continue reading an to see that the koan does actually make sense after the jump

Why do Python programmers hate PHP?

Why do Python programmers hate PHP?

I saw a colleague answer this question and thought I’d give a go:

Are sure it’s just Python programmers? I think that relatively speaking Ruby developers and Java developers hate on PHP more (and Perl and Javascript developers less).

From a software language design perspective, the PHP language is an ugly hack. One of the creators of Java said that when he thinks of PHP his heart goes dark (showing a complete black slide in his presentation for emphasis). The more structured the language (and Java and Python certainly are), the more offensive this ugliness is. (Ruby gets this view not from the language but for being the home of a lot of programmers who were trained in Java in school and for Ruby on Rails being a popular framework in the webspace already crowded out by PHP.)

However, there are t-shirts out there of me saying back in 2006, “PHP is a ball of nails, but when you throw it at a wall, it sticks” and that still applies today—it’s ugly, true; but it works. If anything, the language is far more ubiquitous on the web now than then, though that’s mostly due to the popularity of applications written in PHP such as WordPress and Facebook rather than any success in the language itself. The language has proved remarkably successful due to its adaptability and limited focus on what problems it tries to solve.

I imagine that this popularity-in-spite-of-aesthetic-beauty is offensive to those working in the web who think themselves above the direct, simple, and crass. That reality may sit so ill with some people that they feel the need to disparage PHP which becomes an object of their derision and the villain in their story. It’s only natural for a cohort in the minority to feel that way toward a market leader: Apple Macintosh users used to act like that toward Windows PCs, Windows Phone users act this way toward iOS and Android, etc.

The irony is that PHP is a market leader in only one tiny aspect of the programming market: the server-side, non-event-driven web. It has no footprint in the client-side web, none in application space or even the mobile app space, no recognized products in non-web tools and applications; and is just a rounding error in the DevOps space (to pick just one area where Python seems dominant/ascendant). It even makes no pretension to be a programming language to facilitate learning programming (another area Python is better suited to). Since all these areas are growing as the niche PHP represents is static, I find it ironic people still wage language-religious jihad against PHP.

That’s like hating on a horseshoe monopoly after the automobile has been invented.

And I say this as someone who has programmed PHP for 16 years and gives keynote speeches in the language.

On being a beginner (again)

Compiled from three separate discussions on IRC, twitter, and in person:

“Whatcha do with your time these days? Learning Rails? 😈”

I did pick up Objective-C again after an aborted attempt at learning Swift. Mostly I’m trying to catch up on the javascript frameworks that have come out since I stopped coding. Right now it’s AngularJS—I figure I can jury-rig React into it if performance becomes an issue.

On the non-programming side, I’ve been messing with Ansible because I just got tired of doing things by hand—and I never needed to learn this because I’ve always had operations engineers working with me.

The ripping on Rails thing is over with me because there’s no point in arguing over how to solve a solved problem—today, the web problem is the easy part. What I find strange is people still feel the need to defend Ruby on Rails. I mean who the fuck cares what your middle layer code is written in when everything is an API to something written in Javascript?

“I don’t like that everything is an API to something in Javascript. As a user, the Web feels slower and flakier than it used to.”

I don’t like that everything on the front-end is pushed toward a single-page application. The reason for this is that the DOM-based model of front-end javascript (e.g. jQuery) gets so taxing when the application gets big because you’re bolting feature-on-feature, library-on-library to get it to work as smoothly as you envision. At a certain point, a true MV(VM) javascript framework (e.g. AngularJS) gives you much more because it abstracts all that in a consistent manner.

As soon as you buy into one of these, you’re invested into a huge initial javascript payload which causes you to not want the user to leave the page to unload anything, which then forces you into an API-based model with HTML partials and a client-side route/sitemap and more crap in the payload until you have a single-page application.

And then pretty soon your website is like Flickr where I swear every tenth click I’ve got to reload the page because the UI became non-responsive and I’m deciding to open the app in my iPhone just to do something without that frustration. How fucked up is that?

But then I look at Bootstrap and I figure, I’d rather have a SPA than everything looking like it was designed by some Apple-loving hipster (and this coming from a person who has used and loved Apple products longer than they’ve been alive).

“I’ve always enjoyed your talks and lamented that you didn’t remain on the PHP speaking circuit.”

Maybe I’ll start speaking when I have something to say. Like I’ve said before, PHP solves the “web problem” very well, but the web-problem is not a hard problem anymore.

Remember, it’s been four years since I’ve done any UI programming so everything is new to me. Basically, I’m a newbie, and I don’t think anyone wants to hear from someone who doesn’t know what they’re talking about.

But I did notice this from managing engineers: the worst problem a coder can get into is fear of having to start over. You get good at what you’re good at and when things pass you by, you feel the need to protect what you have because its what you know.

That’s how I feel about Ruby on Rails and that’s how I feel about me and PHP.

So, I’m a beginner again.

Pork Tocino

If you live in The Richmond, you know that B*Star Bar is like eating at Burma Superstar but without the line.

Breakfast plate with pork tocino, garlic fried rice topped with two eggs cooked over easy. Spoon in foreground
Pork Tocino with Garlic Fried Rice
B*Star Bar, The Richmond, San Francisco, California, United States

Sony DSC-RX1
0.013 sec (1/80) @ f/4.5, iso400, 35 mm

My favorite brunch dish there is the Pork Tocino. Grilled jerk pork over a bed of garlic fried rice and cherry tomatoes, topped with scallions and balsamic vinegar.

Since Marie loves their Huevos Racheros, I end up ordering this dish a lot. The only times I don’t is when we bring a guest, then I suggest they get it and I order something else.

Continue reading about some WordPress plugin notes after the jump

FYWP #257-262: wpautop and shortcodes/oEmbed do not play nice at all

It occurs to me that wpautop() is the register_globals of WordPress—a feature that was instrumental for its growth and popularity, but really needs to DIAF. They should rename the function wppeepee() because it finds a way to pee pee on your content at the most inopportune moments, causing unending headaches in your code.

For those of you who don’t know, wpautop can be seen as nl2br() on steriods, or (as I prefer to call it) a poor man’s Markdown. It’s been in WordPress for almost forever, and it’s hard to imagine writing a blog post without it, even if it’s a Really Bad Idea™.

Continue reading about the interaction of wpautop, shortcodes and oEmbed after the jump

I'm speaking again!

After a couple year hiatus, I thought it’d be nice to start speaking again — the disconnect of basically stopping speaking at open source conferences when I started working at two companies producing some of the world’s largest open-source products ([WordPress][] and [Wikipedia][]) was becoming too much.

I decided to apply this year. Luckily, [Northeast PHP Conference][nephp] forgot to check the The Great Offensive PHP Speaker Blacklist™, and accepted my talk!

The talk will be: [Ten Evil Things: Features Engineering at Wikipedia][10 evil things]. Now with 30% less swear words, but don’t worry, it’ll still be fun. 😀

When registering, belatedly, I noticed they had an interesting preferences page, I thought I’d share my answers with you

[WordPress]: http://wordpress.org “WordPress: Blog Tool, Publishing Platform, and CMS”
[Wikipedia]: http://en.wikipedia.org “Wikipedia: The free encyclopedia”
[nephp]: http://www.northeastphp.org “Northeast PHP Conference 2013”
[10 evil things]: http://www.northeastphp.org/talks/view/156/Ten-Evil-Things-Features-Engineering-at-Wikipedia “Ten Evil Things: Features Engineering at Wikipedia—Northeast PHP Conference”

Continue reading my answers to their questions after the jump

Enterprise job recruiting

> Hi Terrence,
>
> I am following up on previous emails and calls. I am doing some research on PHP. I understand that you are focused on [canonical model](http://en.wikipedia.org/wiki/Canonical_Model) management, [SOA](http://en.wikipedia.org/wiki/Service-oriented_architecture) or [ESB](http://en.wikipedia.org/wiki/Enterprise_service_bus) initiatives. Do you have 10 minutes for a quick call tomorrow afternoon?
>
> The [redacted] platform enables rapid service design, construction, and management all from a Canonical Model. This enables the following:
> 1) Your services are managed in our repository aligned to all of your business capabilities
> 2) Impact analysis on how a change from a provider system ([Logical Model](http://en.wikipedia.org/wiki/Logical_data_model)) can impact the Canonical and other services
> 3) Rapidly propagate the changes to the impacted services
> 3) Rules based [version management control](http://en.wikipedia.org/wiki/Version_control)
> 4) Mapping provider systems to the canonical model reduces the number of mappings required by over 99% for a complex integration projects.
>
> I know this is a busy time of year. If someone else is better suited for this discussion, can you please refer me to them?

I understood every third word.

The other day, I sat through a presentation from from an enterprise consultant, they had an 8 category scrum chart just for feature choice and a 10 category one for development. The former had categories like: “paths to insight” -> “validation” -> “harvesting”, so I spent most of my time imagining what would happen if people were story cards that ended up dying due to being harvested at the end of validation due to improper paths to insight.

Maybe if they spent less time throwing verbiage and more time doing, [Enterprise](http://terrychay.com/article/php-enterprise-scalability.shtml) [wouldn’t](http://terrychay.com/article/php-pro-con.shtml) [be such](http://terrychay.com/article/php-enterprise-myths.shtml) [a joke](http://terrychay.com/article/enterprise-scalability.shtml).

22 categories? **This** is agile?

My theory is that someone with [Wernicke’s aphasia](https://en.wikipedia.org/wiki/Wernicke%27s_encephalopathy) would make [a killing in Enterprise software development](http://www.youtube.com/results?search_query=wernicke%27s+aphasia).