Live data from Hacker News

PHP 7 Virtual Machine

nikic.github.io

111–120 of 128 posts

Re: PHP 7 Virtual Machine

#111
post #100

Earlier quoted context omitted.

I'm pretty sure a substantial part of PHP's reputation is the nightmare code produced by PHP developers.

And that goes right into the whole "badly designed language" trope as well. Essentially, anything written in PHP prior to version 5 (and especially prior to version 4) should be considered suspect. I'm a long time PHP developer (well, was until recently - my current position is in the javascript/nodejs stack arena), and have been using it since the v3 days (so not there from the beginning, but close enough). There we…

Nail, meet hammer with claws on both sides.

It's entirely, 100% possible to write good, clean, tested, maintainable code in PHP. But most people working with PHP, for whatever reason (and I'm sure there are many reasons), simply don't bother.

I suppose the same can be said of all languages, but PHP devs are the worst offenders IME.

Re: PHP 7 Virtual Machine

#112
post #86
post #36

Earlier quoted context omitted.

Honestly. I think its main problem is it's not hipster enough. It's too popular. I bet if you made it difficult to use (for most people), added features that make certain aspects a nightmare to scale and gave it a weird name then it would do well here. Obviously don't let anyone know about the origin... say you built it at a series of obscure coding bootcamps.

On the contrary, I dislike PHP because I find it so difficult: its bad documentation, its badly designed standard API, the many badly designed and badly documented frameworks to replace the badly designed API, and the core language that goes out of its way to let buggy code through all combine to make writing medium-sized and above programs extremely difficult. Supposedly it's better now. I'm skeptical.

The docs are great--its the API that is badly designed in my opinion. It's not very intuitive or memorable. Take a look at string functions[1] for example. `count_chars` vs `strlen` and the list goes on.

[1]: http://php.net/manual/en/ref.strings.php

Re: PHP 7 Virtual Machine

#114
post #99

Earlier quoted context omitted.

Uh. You do realize that Mediawiki, powering nearly all wiki systems including Wikipedia, is written in PHP. Or Facebook, they were able to go with PHP for iirc 500 M users? PHP is in any case a better choice, performance-wise, than Python or, god forbid, Java.

Facebook built their own PHP-to-C++ compiler ( https://en.wikipedia.org/wiki/HipHop_for_PHP ) and later a JIT compiler/VM ( https://en.wikipedia.org/wiki/HipHop_Virtual_Machine ), with a custom, typed version of PHP ( https://en.wikipedia.org/wiki/Hack_(programming_language) ). All just to make PHP a little faster. I think you are making my case.

HH transpilation was introduced in 2010. Depending on when exactly you look in 2010, FB had between 350-600M active users (https://www.yahoo.com/news/number-active-users-facebook-over...).

Many websites don't ever get to 350M users, so it's safe to say that plain PHP will satisfy your startup for a long time. Also, PHP7 is pretty much on par with HHVM in real-world scenarios: https://kinsta.com/blog/the-definitive-php-7-final-version-h...

Re: PHP 7 Virtual Machine

#115

Earlier quoted context omitted.

It has come a long way. My last job was at a big PHP shop, which had a heavy focus on doing PHP The Right Way. The result was a fairly decent, maintainable codebase. I came to really appreciate the flexibility and ability to just "make things work" that PHP has, while finally having a proper development environment with real dependency management and IDE support.

Do you have any pointers to the recommended Right Way to do modern PHP? I'd be interested to explore it; I have a number of places where I want to add tiny bits of interactivity to otherwise static web pages, and this totally seems to be what PHP does best.

O'Reilly's "Modern PHP" (270 pages) is a fantastic introduction to the new way of doing PHP.

Re: PHP 7 Virtual Machine

#116
post #99

Earlier quoted context omitted.

Facebook built their own PHP-to-C++ compiler ( https://en.wikipedia.org/wiki/HipHop_for_PHP ) and later a JIT compiler/VM ( https://en.wikipedia.org/wiki/HipHop_Virtual_Machine ), with a custom, typed version of PHP ( https://en.wikipedia.org/wiki/Hack_(programming_language) ). All just to make PHP a little faster. I think you are making my case.

HH transpilation was introduced in 2010. Depending on when exactly you look in 2010, FB had between 350-600M active users ( https://www.yahoo.com/news/number-active-users-facebook-over... ). Many websites don't ever get to 350M users, so it's safe to say that plain PHP will satisfy your startup for a long time. Also, PHP7 is pretty much on par with HHVM in real-world scenarios: https://kinsta.com/blog/the-definitive-…

And the vast majority of websites never get 5000 concurrent users either. Your planned load obviously dictates the language as much as anything else.

Re: PHP 7 Virtual Machine

#117
post #54

Earlier quoted context omitted.

The fault in your argumentation is comparing a language (PHP) to a framework (Django, Jinja, Rails). Your argument is valid too for any PHP framework, it's hard to do XSS in laravel, symfony or zend framework.

You would have a point the frameworks you provided had that kind of protection by default (or if you could at least enable it project-wide), and if PHP development were mostly done on them, instead of wordpress and drupal. Besides, there's more to security than SQL injections and XSS. The PHP tooling is overflowing with bad practices.

Take a look again. Each of those Frameworks is using a template engine which is escaping any ouput by default. If you do not need escaping, you have to opt-out for single outputs.

Re: PHP 7 Virtual Machine

#118
post #82
post #69

Earlier quoted context omitted.

Most languages let you cut corners and code in a sloppy way. This is not limited to PHP. I think anyone can show anecdotes to support "coding in [language you don't like] is bad". Replace "unsafe" with "non-performant" and go back to early Rails days and you'll have plenty of examples where naive framework implementation led to programmers shooting themselves in the foot with the "easy way" in a different context.. L…

> Most languages let you cut corners and code in a sloppy way. This is not limited to PHP. Completely true, but for years PHP made it extraordinarily easy to shoot yourself in the foot right out of the box. register_globals for example... http://php.net/manual/en/security.globals.php

Deprecated 9 years ago.

Re: PHP 7 Virtual Machine

#119
post #6

It's always pleasant to see PHP occasionally get a positive moment in the limelight on HN. It's oft scorned yet powers a very large chunk of the web. With the work done on 7 it's also one of the fastest scripting languages around and deserves a little more credit if I'm honest.

It has come a long way. My last job was at a big PHP shop, which had a heavy focus on doing PHP The Right Way. The result was a fairly decent, maintainable codebase. I came to really appreciate the flexibility and ability to just "make things work" that PHP has, while finally having a proper development environment with real dependency management and IDE support.

What was your IDE of choice at that shop?

Re: PHP 7 Virtual Machine

#120
post #119

Earlier quoted context omitted.

It has come a long way. My last job was at a big PHP shop, which had a heavy focus on doing PHP The Right Way. The result was a fairly decent, maintainable codebase. I came to really appreciate the flexibility and ability to just "make things work" that PHP has, while finally having a proper development environment with real dependency management and IDE support.

What was your IDE of choice at that shop?

I think PHPStorm from JetBrains is the IDE of choice of most PHP devs using IDEs at this point. They completely own the market, and rightfully so (I'm still stuck on Sublime Text myself, but wouldn't consider any other IDE than PHPStorm if I were to use one).
Post reply on HN