Live data from Hacker News

PHP 7 Virtual Machine

nikic.github.io

101–110 of 128 posts

Re: PHP 7 Virtual Machine

#101
post #67

Earlier quoted context omitted.

what would be a good hardware spec and server configuration to have 5000 users do long polling with a php backend?

If you care about performance and traffic, perhaps php isn't where you should start anyway.

Yes, of course there are easy to use and much better programming languages for that - I just really wanted to read some "real-life" recommendations from that guy that mentioned "php" and "long-polling" in the same sentence.

[Maybe it was just a joke and I did not get it... or I did get it but did not identify it as a joke... however... I would like to see some beef...]

Re: PHP 7 Virtual Machine

#102
post #21

Earlier quoted context omitted.

> PHP iirc can't even be used as a websocket server True, if you run it behind a web server like 99.999% of all users. If you run it as a cli script, you can implement pretty much anything. I saw a ftp server once. Crazy. Still, even on a normal web server, php can do long polling perfectly fine, which is often enough. > being able to write program flows without dozens of promises is a breeze It is a breeze with asyn…

> If you run it as a cli script, you can implement pretty much anything. I saw a ftp server once. Crazy. Yeah, I implemented a simple ircd once. Funny days... but I don't know of any library/framework that could help you with the websocket protocol level, and I'm too old for writing my own ;)

Websocket is actually not that complicated. A couple of headers to upgrade the request from HTTP to websocket, then framing of each payload.

But you could use something like websocketd, which spawns a process of your chioce for each client and pipes the websocket to stdin and vice versa.

https://github.com/joewalnes/websocketd

Each PHP process looks like it takes about 5 MB of ram on my laptop, so probably not the best method for 5000+ concurrent users if you use PHP, but still.

Re: PHP 7 Virtual Machine

#103
post #21

Earlier quoted context omitted.

> PHP iirc can't even be used as a websocket server True, if you run it behind a web server like 99.999% of all users. If you run it as a cli script, you can implement pretty much anything. I saw a ftp server once. Crazy. Still, even on a normal web server, php can do long polling perfectly fine, which is often enough. > being able to write program flows without dozens of promises is a breeze It is a breeze with asyn…

> If you run it as a cli script, you can implement pretty much anything. I saw a ftp server once. Crazy. Yeah, I implemented a simple ircd once. Funny days... but I don't know of any library/framework that could help you with the websocket protocol level, and I'm too old for writing my own ;)

> I don't know of any library/framework that could help you with the websocket protocol level

FYI - http://socketo.me/

Re: PHP 7 Virtual Machine

#104
post #75
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.

I think that's unfair, the reason PHP has a bad reputation is not because of silly hipsters. It's because for a long time it was a terribly designed language. It was a laughing stock for a good reason. The whole "hobby-grade templating language turned general purpose with complete disregard to how programing languages are designed" thing. Now I'm willing to believe that it's improved a lot since then, but it's got a…

I haven't touched PHP in years, but I am hearing it's supporting stricter type checking, which is promising.

Re: PHP 7 Virtual Machine

#105
That the smart branches optimization requires a workaround in the IR codegen concerns me a bit. It makes sense in a HW context, like MIPS branch delay slots, but not really here. There could be a flag in the branch instruction that disables the optimization at least.

Re: PHP 7 Virtual Machine

#106

Earlier quoted context omitted.

I use PHP quite a bit outside of the web. I think tpetry was pointing out the difference between a language and a framework built on that language. (Replace language with whatever you think it is, it's still a subset just like Ruby on Rails is a subset of Ruby)

Sure you could separate PHP the language from PHP the processing instruction and PHP the standard lib. But PHP calls itself a "hypertext preprocessor" (it's in the name) and PHP's own intro (literally on page 1, sentence 1, cf. [1]) advertises web templating as its distinguishing feature. So I think it's fair to compare PHP against other HTML generators. [1]: http://php.net/manual/en/intro-whatis.php

So, regarding the parent, I was pointing to PHP being more of a language and less of a "web framework" which I don't believe you address at all. As for web templating and such

> PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML.

I would focus on the core statement of the sentence which is "is a widely-used open source general-purpose scripting language". Comparing PHP to other HTML generators (re re re? parent: Django, Jinja, Rails) leaves out the entire concept of "general-purpose scripting language" and only focuses on "embedded into HTML" which while a main feature isn't the whole of it.

Re: PHP 7 Virtual Machine

#107
post #79

Earlier quoted context omitted.

I would say it's unfair to compare a library to the basic PDO. If you want to compare apples to apples, try looking at Sequel versus Doctrine or some other third party SQL library. Just like any other template language (thinking of something like ColdFusion or ASP), of course one unescaped variable is going to be a headache. But you don't have to use it that way, and probably shouldn't. While PHP started as a templat…

I do not think it is an unfair comparison since Sequel has both basic parts on the same level as PDO, and then implements the more advanced features on top of these basic parts. The basic parts of Sequel has superior usability and safety to PDO. Sequel's right way: user = db['SELECT name FROM users WHERE id = ?', id].first Sequel's wrong way: user = db["SELECT name FROM users WHERE id = #{id}"].first PDO's right way:…

Okay, so instead of Doctrine, look at another library that has the basic parts and then the advanced parts. Here is one from a different library that is safe and "easy"

    $user = $db->find('user', 'first_name = ?', ['Name']);
> As you can see PDO is optimized for doing things easily the unsafe way while Sequel has the safe way as the normal way of running queries which is just as easy to use as the unsafe way.

PDO isn't "optimized" to do them the wrong way or the right way. Yes, it's less code to do it the wrong way, but that isn't a true definition of easier.

As for the escaping, I would expect Twig to escape things, it's want it's meant for (and the reason you use it instead of just vanilla PHP). And Rails is a subset of Ruby correct? So not a true comparison again.

Re: PHP 7 Virtual Machine

#108
post #79

Earlier quoted context omitted.

I do not think it is an unfair comparison since Sequel has both basic parts on the same level as PDO, and then implements the more advanced features on top of these basic parts. The basic parts of Sequel has superior usability and safety to PDO. Sequel's right way: user = db['SELECT name FROM users WHERE id = ?', id].first Sequel's wrong way: user = db["SELECT name FROM users WHERE id = #{id}"].first PDO's right way:…

Compare Sequel to EasyDB then: https://github.com/paragonie/easydb

Sure, I know there are good libraries for PHP, I mentioned Twig for example, but my issue is that the standard library of PHP is shitty and contains traps for beginners.

Re: PHP 7 Virtual Machine

#109
post #76

Earlier quoted context omitted.

> The default installation of PHP gives you a setup that parses HTTP requests and returns HTTP responses Correct me if I am wrong, but so does Node, Ruby, Python, etc... Sure it was built for the web, in simpler times, but everything has to start somewhere. Now days, PHP is a completely different beast. > Just not a very good one. An opinion if fine, but it seems like you are deriving this opinion from old experience…

> Correct me if I am wrong, but so does Node, Ruby, Python, etc. I think Node is also a framework, although there seems to be some controversy about this[1]. Ruby and Python give you standard libraries from which you can build a web server or templating engine or whatever, but it would be weird to say that made them Web Frameworks. Maybe things have changed, but last I knew PHP had a command line switch that tells it…

> I think Node is also a framework

I think we have different definitions of frameworks. So no point in arguing over that.

> Maybe things have changed, but last I knew PHP had a command line switch that tells it to not act like a web framework

I honestly don't even know about a command line switch. I just write my script and execute it with the CLI (php test.php)

> I am succumbing to someone-is-wrong-on-the-internet syndrome

Please tell me this has a name

> Although I can't resist asking - are you saying PHP is a good web framework? How does that fit with the idea that PHP is not a web framework?

Not sure you exact intent, but as far as PHP being a good language to write a web application in, sure, it can be. IMO, it depends on the application and use of the application.

Re: PHP 7 Virtual Machine

#110
post #108

Earlier quoted context omitted.

Compare Sequel to EasyDB then: https://github.com/paragonie/easydb

Sure, I know there are good libraries for PHP, I mentioned Twig for example, but my issue is that the standard library of PHP is shitty and contains traps for beginners.

Honest question, is Sequel a standard library for Ruby? I assumed it was something you had to install after you installed Ruby.
Post reply on HN