Live data from Hacker News

PHP is worth learning and using

bulletproofphp.dev

241–250 of 468 posts

Re: PHP is worth learning and using

#241
| php is fast.

https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

it's faster than python, but my grandma is too and she died in 1993. However, function calls are extremely slow. If you would bench something like a naieve fibonacci implementation (or ackermann's function) you would be surprised.

Re: PHP is worth learning and using

#242

Hey if you don't like PHP please don't use it. I 'd hate to bring the culture of tiny packages, fake compilers, transpilers and weekly trends to PHP. Personally I use php because it works well and fast and still supports my 10 year old websites, not because it's cool.

Oh well we are about to break most of said 10 year old web sites.

Particularly, PHP 8.1 has some changes that low key force people to update, such as the use of return types when extending a built-in classes (https://php.watch/versions/8.1/internal-method-return-types).

Re: PHP is worth learning and using

#243

Hmmm... Most points in this article are shouting "yeah we have those too!!" but it didn't give any convincing arguments why I (or anybody who doesn't already know PHP) would like to learn and use PHP over other decent modern languages and ecosystems, which happen to have those points as well.

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.

> even if the language is truly terrible.

PHP already has caught up to others with 5.6, these days PHP 8 doesn't lack anything found in other major languages.

What is still confusing is the standard library, but only for people who never worked with C/C++ before - as most of the native PHP standard library actually originates as a verbatim copy of the C/C++ libraries.

Re: PHP is worth learning and using

#244

Earlier quoted context omitted.

Php has developed a lot in a decade. Lots of new good things in php7/php8. The typecasting is way better than before, but it still allows you to be more "dynamic" if you want to.

$x = [1,null,'xxxx', collect([])]; gettype($x) is "array". you can annotate a type as being an `array`. How does that help me exactly?

[deleted]

Re: PHP is worth learning and using

#245
post #61

I have used PHP for years. Like it. Have accomplished some nice things with it. Think it's evolved nicely in recent years. Feel it's a great tool for particular problems. Will continue to use it. Will always be open to alternatives. Will never understand why some people find that so offensive and will tell you that you mustn't use it or imply that you are ignorant or stupid for using it.

For people of a certain age and job history, the worst code they've ever inherited was written in PHP. I think JS can be worse. There are things that are possible with dynamic languages that are literally impossible with static ones. So think of PHP less as a "bad language" and more of a code smell.

I don't think any JS code can be worse than old PHP code. I've had to deal with legacy software written with PHP4. I was to port it to PHP7 since it was not compatible with PHP5.4+. The code used "register globals", meaning that variables were created on the fly from the parameters in the URL, the POST form data, and the cookies.

Requesting `index.php?something=X` implied `$something = "X";` in the global scope at the beginning of "index.php". And since the global scope was not limited to a file, tracing a variable through files and side effects was a nightmare. Even understanding the code intent was often hard!

Before PHP7, there were many elements of the language that were meant to simplify its usage, but had awful consequences in many cases. Even more because it bent the PHP community toward a quick and dirty process. "Magic quotes", the automatic escaping was one of those abominations. For any request input (e.g. POST form data), it added backslashes before single quotes. It was meant to protect data automatically in case it was inserted into a SQL request... It granted no security gain in this context, and was a mess for any other use.

Re: PHP is worth learning and using

#246
post #229

Earlier quoted context omitted.

Same here in Switzerland. And other than working on actual modern PHP these jobs are usually maintaining old software with weird custom scripting languages like typoscript xsml ... I'd consider a PHP job, but only if they quarantee they don't have any of those legacy maintaining things lying around.

> I'd consider a PHP job, but only if they quarantee they don't have any of those legacy maintaining things lying around. I see your point, but there is lots of legacy code (in any language) laying around and making shit tons of money for their owners - hence the need to maintain these systems.

I love maintaining old rails projects. No worries with that, MVC is making it easy to work with any project done by someone who knows the language. The language allows and encourages updating as well. It can be fun even.

PHP had no common way to do anything for a long time and you still see it from people writing PHP today.

Re: PHP is worth learning and using

#247

Earlier quoted context omitted.

IDK what is a good salary in US/Canada, I live in European Union. My salary as WordPress developer is more than 4,5k USD/month and I see job offers with 8k USD as well (still for WP developers, this is my specialization and I know this field the most; I expect for better recognized PHP fields like modern frameworks like Laravel it could be more) And yes, 4,5k USD/month is massively good salary for Europe. On the othe…

I also live in the EU, and 4,5k is not a massively good salary for a programmer in my country (Denmark). This is usually what a junior is paid.

Is the 4,5k before or after tax?

Re: PHP is worth learning and using

#248
post #163

Most arguments against PHP miss the point. You know why you should use PHP? Because it's fun and you can get something running much quicker than figuring out the Elixir, Ruby, Rust, whatever ecosystem and paradigm. Maybe PHP is not so good at WebSockets or async worker threads, but most projects don't need that. There's no shame in doing long polling, users can't tell the difference anyway! PHP shines when you're try…

I used to believe this, but... But that's just not true. All the things you mentioned are a yum/apt/nix/pacman/ install away on Linux, and probably as simple to install on macOS. I'm sure Windows has installers for these, too. So, it's no harder to develop in them than it is in PHP. You could argue it's cheaper because you don't have to pay for a shared hosting provider to host your files. However that's a bit moot s…

Your comment on file uploads in PHP reminded me of the remote code execution via automatic file metadata parsing vulnerability built into PHP that happened a couple years ago.

Re: PHP is worth learning and using

#249

Earlier quoted context omitted.

That ship has sailed a long time ago (or you're just playing around and most languages will have a REPL nowadays) Modern PHP wears a business suit and wants to buddy the "big boys" (Java/C#) of the world. You'll have deployment pipelines, strong push towards classic OOP, strict type checking etc. I personally think ruby for instance is leaner in its dev process in most real world projects.

OP is correct, you still can develop like this with PHP, and no the ship has not sailed for many. You can have deployment pipelines etc, but if you like, you can still develop the ancient way - it still works.

Well I can still develop like this in ASP.NET if I wanted to and probably and many other languages/frameworks too, so it's not exactly unique.

Re: PHP is worth learning and using

#250
post #246

Earlier quoted context omitted.

> I'd consider a PHP job, but only if they quarantee they don't have any of those legacy maintaining things lying around. I see your point, but there is lots of legacy code (in any language) laying around and making shit tons of money for their owners - hence the need to maintain these systems.

I love maintaining old rails projects. No worries with that, MVC is making it easy to work with any project done by someone who knows the language. The language allows and encourages updating as well. It can be fun even. PHP had no common way to do anything for a long time and you still see it from people writing PHP today.

My point was more that if there's money being made with some chunk of code, a sensible product owner would allow a modern refactor or even a rewrite in the same language to not endanger the long term success of said app.
Post reply on HN