Live data from Hacker News

Taking PHP Seriously

slack.engineering

341–350 of 673 posts

Re: Taking PHP Seriously

#341

Earlier quoted context omitted.

> The language is not beautiful, it is full of signature and func naming inconsistencies [1] it inherited from C. It was consistent with the thing it inherited most of it's syntax from so that makes it inconsistent? > The devs are ultra-conservative and stubborn to cause BC even at major version bumps (like the forever-incorrect ternary associativity [2][3]) You shouldn't be judging the way operators work in one lang…

> It was consistent with the thing it inherited most of it's syntax from so that makes it inconsistent? It is also internally inconsistent in so many ways. Half the array functions take arrays as the first arg, the other half the last. explode and implode have different argument order requirements (one is strict, the other works either way). Functions have a grab-bag of errors from returning null to false to 0 to str…

C++ is a C-like language but C++ muddies up the difference between some operators due to operator overloading. This is an inconsistency.

Do you support that? No one will ever be able to convince me that ">" make sense to be read and write.

Re: Taking PHP Seriously

#342

Earlier quoted context omitted.

You can have the same mentality in many languages that suck less than PHP, though. Python, for example, tends to get out of your way and just let you write your algorithm. Go, as well. Or various JVM languages, particularly Java 8 and Kotlin. The one thing you want to avoid are communities that argue about "the best" way to do things. Even then, you can use the fruits of their labors, as long as they're willing to pa…

I do think certain languages are more conducive to the "just write it quick" mindset. I find it easier to enter this mindset when I write a bash script.

I find this interesting because I feel that is true and if it is true, then there must be some definable reason for it. So what is it? I have this with Perl, PHP, Bash, C(!), Lua and pure (browser) JS with Jquery (not npm, CSS and HTML though => those keep me from even starting something when I think too long about them).

I would think I like Lua & C to just write it quick because they are so limited; I remember their syntax, core functions and core libs, so I can, without internet or documentation, write things in it immediately.

I'm not sure why those others give me that feeling; probably because it's easy to just start instead of having to set up dev environments etc. Most is already on your computer and they are forgiving (a bit too much I agree) about sloppy coding.

It would be interesting to try to dive into details of why the brain finds some languages more conductive to 'just write it quick' and try to mix that with languages which do not have that feeling at all.

Re: Taking PHP Seriously

#343
Every programming language is a tool. As such it isn't good if used for the wrong job. PHP is amazing for simple services that don't need much aside from database/filesystem access. I love PDO and wish more languages had such a first-class database access implementation.

I wish more people gave PHP a chance and didn't just keep bagging on it. There are problems with the standard libs, but nothing that isn't bearable. Grab an IDE and it's not an issue.

Re: Taking PHP Seriously

#344

Sorry to sound so dramatic but I don't know how to put this in better words: After reading this thread, is there even a proper way to measure how good a language is (trade-offs, benefits down the road)? Having done web stuff in PHP and Python I think both are terrible. So, how would a programmer trying to avoid his own biases and anecdotes find what tools are right for each job? Maybe I didn't "liked" PHP and Python…

There's no easy answer to this, but books like CTM [1] give an overview of the programming languages landscape. They can come in handy when evaluating language designs.

[1] https://www.amazon.com/Concepts-Techniques-Models-Computer-P...

Re: Taking PHP Seriously

#345
post #74

I find the virtues quite uncompelling, take for example >First, state. Every web request starts from a completely blank slate. Except for, you know, when you don't want to reinitialize everything everytime someone makes a new request. There are tons of things that you only need to run once. >I claim that PHP’s simpler “think; edit; reload the page” cycle makes developers more productive. Over the course of a long and…

> Except for, you know, when you don't want to reinitialize everything everytime someone makes a new request. There are tons of things that you only need to run once. I mean, you're not reinitializing it, and it's not exactly slow. And when your application starts scaling across many instances, many zones, many servers, you can have more faith that each request runs independently and there are no runaway processes to…

>when your application starts scaling across many instances, many zones, many servers, you can have more faith that each request runs independently and there are no runaway processes to worry about on a single one of your random servers somewhere

It's just as easy to scale with other languages, you would keep the data that needs to be persisted in a DB. The benefit comes from things that does not need to be persisted, like resource pooling, memoization, config loading etc.

> > where I'd almost have to visit every branch of code when I alter something because of it's many weird behaviours

>Write a method, write tests for that method

Exactly, I need to write tests for things that are trivially verifiable by a compiler. And I'm not just talking about type coercion (which is a bad thing), but also missing function parameters, wrong parameters, missing initialization of variables etc etc. These are runtime errors and you either have to write tests to catch them (hence visit very code block) or manually try and reach them.

Some IDEs, like PHPStorm, can you get pretty far though.

>Low barrier to entry gets you a lot of crummy projects

As someone else mentioned in another comment, 1% of PHP projects succeeding is still a lot more than 20% of Haskell projects.

>PHP is a lot easier to manage and maintain in production

Except for when you need to scale. Varnish, memcache, php-fpm, redis, what-have-you are basically mandatory for a PHP site to really run performant, adding quite an overhead to any production setup you'll get into.

Re: Taking PHP Seriously

#346
post #301
post #74

I find the virtues quite uncompelling, take for example >First, state. Every web request starts from a completely blank slate. Except for, you know, when you don't want to reinitialize everything everytime someone makes a new request. There are tons of things that you only need to run once. >I claim that PHP’s simpler “think; edit; reload the page” cycle makes developers more productive. Over the course of a long and…

Refactoring without a proper tool is like shooting at your own feet.

Indeed, which is why it's nice to have a compiler catching things that you would have to write tests to catch in PHP.

Re: Taking PHP Seriously

#347

Earlier quoted context omitted.

I know you're making a parody, but I think I agree with your parody. I mean, essentially all you're saying is "startup success is largely uncorrelated with the programming language used to implement those startups' products". That seems like not at all an unreasonable position. (It's not, by the way, equivalent to the statement "choice of language doesn't matter".)

Ooh. Mind, I agree with you, but given the Holy Documents Handed Down By Our Lord and Savior, Paul Graham, HN... might not be the safest place to say it. Edit: so, I'm clearly getting a lot of downs on this... maybe sarcasm in reference to PG was going a bit too far. Oh well. I'm not deleting or editing any of it, because that's sort of dishonest.

Sarcasm in general pisses people off, doubt it's anything Paul graham specific

Re: Taking PHP Seriously

#348
post #323
post #16

I work on PHP at my day job (in a public company), before this, I came from Ruby, and .NET before that. I'm convinced the reason so many successful projects use PHP, is not because of any inherent nature of the language. I think it's the people who use it. They just don't care. A successful project needs to be started by someone that cares just enough, but not too much. If you're programming in PHP, you're not runnin…

> It's a garbage language, and you know it. But it allows you to get something up and running, so dang quick. PHP didn't succeed because of the "language" part. It succeeded because it was limited and focussed to just being a tool to write small web-apps in a short time. It did one thing and did it better than anything else of the same era (I built CGI apps in C, Perl and Python before discovering PHP). It was just f…

I'd argue it succeeded because it didn't require you to run a server. All those cpanel lamp ISPs mean sign in and upload code.

All other solutions, java, .net, node, python, Haskell, etc require you to run and maintain your own servers. A minor exception for CGI based solutions but those were all too heavy.

Re: Taking PHP Seriously

#349

Earlier quoted context omitted.

I'll offer an alternate hypothesis. Some companies are succeeding in spite of php. There are many, many users of php, and we'd expect that there would be considerable variance, with some users doing awful (no traction, buggy sites, etc) and some hitting home runs (facebook). Because it's such a popular language, it will have users across this entire spectrum. It's easy to cherry-pick the winners and miss all of the t…

It would be an outlier company indeed who held an 'all hands on deck' meeting and said, "We're succeeding in spite of PHP everyone!" Only engineers care about programming languages. Seriously. That's it. No one else cares about them. I work in a large public university alongside a revolving door of student interns who are always 19. In 10+ years of work, I've still yet to meet the person who talked about their favour…

Doesn't it stand to reason that the people that actually know how things work under the hood are the people that care about such things.

You could say the same thing about cars people don't care about what sort of engine is under the hood or how it works they just want to go places! It doesn't then follow that all cars are the same and you are just as well getting any one of the millions of cars or even any one of the models out there.

Re: Taking PHP Seriously

#350
post #45

Love the memes: "PHP is garbage language!", "PHP is a shitty language!" That is the antiquated view of course. The old days. Now with Laravel and PHP7 it is a pleasure to use. I'd go further. Working in Laravel is BETTER than ROR IMHO.

Have you used Rails in production? Just curious.
Post reply on HN