Live data from Hacker News

PHP is worth learning and using

bulletproofphp.dev

361–370 of 468 posts

Re: PHP is worth learning and using

#361
post #313
post #258

You guys think a hell of a lot about your hammers It's a tool, use it or don't. Why do we have this weird slap fight every 2 months? It's so weird

I haven't commented on this thread until now (I left PHP so many years ago, I have nothing to add) but are you suggesting to never discuss with other peers about the available tools for the job? Could you be more specific on your proposal?

No, I'm not suggesting that. I am suggesting that the same conversation happens over and over again

"PHP is good now!" "No it isn't!" "That was PHP 4!" "array and string functions" "abstract it with a framework" "PHP is slow" "It isn't" "it is look benchmarks nobody will ever need"

See y'all in 2 months haha

Re: PHP is worth learning and using

#362
post #287

Earlier quoted context omitted.

My favorite thing about PHP is the execution model. Every single request is brand new and runs the whole program start to finish. IMO that's extremely powerful in its simplicity and while you can get it in other languages, it feels like like a "core competency" for PHP (just like how async code is easier in javascript than in python, because JS kind of had it from day 1)

I see this as the opposite and find it adds quite a load of complexity and prevent to do some form of optimization in an app that has its own server. It adds its load of complexity on how to run the apps itself, you need an external server, apps often requiring some customization of the server that will run it (either mod-php or php-fpm). It means that parts of our app settings lives outside of the app, it also make…

PHP does have it's own built-in server as well, although it is not really meant for production use.

Global PHP configuration options have become less important over time, with resource limits and extensions being most of what has to be configured now.

Re: PHP is worth learning and using

#363

Earlier quoted context omitted.

The best part of PHP is the development model. You copy some files to a server, and load the page. That's it. It is really hard to beat how easy it is to iterate, even if the language is truly terrible.

I don't see how that makes the development cycle any better. I can just edit a file, press save, and it compiles and tests run automatically. If I'm doing something in interpreted languages, the code updates in memory. Furthermore if I'm working with JS/TS, hot reloading even makes it so I don't even need to refresh the page. I can even inject code into arbitrary places with the debugger (as if I'm editing the source…

Javascript has come a long way, but I think there's still a different.

With PHP, you install the toolchain, save a file and the page becomes available.

With JS/TS, you install the toolchain, and then enter a complicated process of yarn/npm incantations in the command line to get the project working right. The manual may say "yarn add typescript" but in practice there's always more setup and configuration to be done before it works well.

For "real" projects, there's not that much of a difference between yarn and composer. For getting started, though, the process is a lot more involved.

Another problem is that running Javascript on the backend is almost completely different from normal frontend development. If you want to store state, you end up using the same (or even worse, a similar) programming language with completely different contexts and available libraries and methods. You can't document.createElement in the backend to tell the user that an operation succeeded or failed, even though that's what you'd do if you were working on a frontend file.

With PHP, you can't do frontend, so whenever you write frontend code, you can't get confused. In my opinion, this makes learning PHP backend dev a lot easier. It's only natural that you choose to continue working in the language you've started you development career in. You can see that by the fact that there are still people who swear by VB.NET, despite everything.

The JS ecosystem does have the advantage of coming with a debugger, but PHP users can get the same by hooking their PHP install into the PHPStorm debugger. I think it doesn't matter much which language you use at that point, it's just a tooling preference.

All in all, I think both languages have their uses. If PHP really was as bad as people say it is, it would've died out already.

Re: PHP is worth learning and using

#365
post #298

Earlier quoted context omitted.

A lot of people 10+ years ago were building websites by interpreting PHP and using the output as HTML. The language (at the time) seemed to encourage this. I agree that PHP is not a framework, but it seemed to have some opinion on how HTML was to be generated, which most languages don’t have. Also rails is 7 years older than Laravel, so my point still stands that PHP was behind the curve.

If your standard is rails then literally everything in every language before rails was "behind the curve". Currently PHP has frameworks that have caught rails, but Ruby's perf is still garbage.

Django was released shortly after Rails. Ruby and Python developers _needed_ to build something like Rails and Django because those languages didn’t promote the same type of script-as-html pattern that PHP did. Had more thought gone in to serving websites, PHP might enjoy more popularity today. PHP had the first mover advantage after all, but frameworks built in other languages were purely better in almost all categories.

Re: PHP is worth learning and using

#366
post #352

I really don't understand all the PHP dismissal on HN. As a language it has continued to evolve in meaningful ways, especially with the latest releases. Companies like Facebook are built on PHP (yes, they extended with Hack, but most of the benefits are available in PHP 8 now without the downsides). Coming from a C background, I found PHP easy to step into as many of of the underlying libraries and common functions a…

One thing I've noticed is people who code in PHP for work or projects don't bother to come on here and try and defend the language. It's underrepresented, but maybe the groupthink ship against PHP has sailed here a long time ago, they don't bother. Or perhaps, more likely, they are too busy creating.

While I primarily program in python these days I have two major open source PHP projects (millions of downloads each). I was also part of the standards group that tried to modernize some aspects of PHP (to various degrees of success).

In general I would never bring them up on this site. It's just not worth my time or effort. I've even gone so far as to ask people who have posted my blog posts here to take them down. Hacker News has one of the worst groupthink cases in tech, where if you speak against various core beliefs you get absolutely hammered with trolls both on the site and off of it. Having a reasonable discussion about the pros and cons of PHP is just not something this site is capable of supporting.

Re: PHP is worth learning and using

#368

Earlier quoted context omitted.

This argument may have worked in the years before Heroku (or Docker even) but it’s really outdated in 2021. Then you have the myriad of static site hosts that also take 2 clicks to host something without even having to write any code.

You must have not worked with small non-profits with zero technical expertise and zero budget for hiring a consultant/permanent paid staff. Heroku is overcomplicated, and Docker/static sites (or the command line/running a server of any kind) might as well be alien technology. Some orgs know just that little.

I don't see how PHP fits into your example either.

Who is writing the code in the first place? They're uploading existing code to a shared host through FTP but then who wrote the code? Is it a prepackaged Wordpress? But then Wordpess hosts already exist.

If the developer is giving them a zip to upload, why can't the developer handle the deployment as well?

You moved the goalposts so far that the example doesn't make any sense anymore.

Re: PHP is worth learning and using

#370
post #336

I'll be honest. I really don't like PHP. However when I was running a coding workshop, very frequently people would ask: "How do I make a web page talk to a database?" I'd say: Well, you know that HTML file? Rename it to become a PHP file and you're almost there! As pretty much all cheap hosting already offers support for PHP (and MySQL for that matter) this would almost always work. I would love to be able to do thi…

You hit the nail on the head, this is exactly why I fell in love with PHP. I learnt it back in the PHP4 days, and it just seemed like the perfectly straightforward way to do web.

In a similar fashion, I abstracted away the database connection, query and returning of results into one lazy-inited function, so talking to the database really was just like

  
I worked a lot with other languages, none feeling as natural to me as this one, aside from Ruby.
Post reply on HN