On 14-10-2020 03:41, Larry Garfield wrote:
> This sounds like a fantastic idea.  The inline-run capability of Go and 
> Rust's documentation is a huge win.  Writing good sample code for the 
> documentation would be an interesting challenge, but it's the sort of thing 
> that can be done over time.

I second this. However, then we should also make sure that the example
code actually works, and on which PHP versions. As soon as examples can
be run right from the documentation pages, the examples will be run far
more frequently than they are now, simply because it is so much easier
to do. Broken examples will cause more disappointing experiences.

I don't know if example code is currently tested automatically. If not,
adding a sandbox for running them may also offer an opportunity for
automatic testing.

Besides experimenting with example code, a sandbox may also be used to
expose runtime information. Think of generated opcodes, the JIT compiled
assembly, the AST.

At some point I can imagine adding a documentation page about
performance, optimization and JIT. That page could enable users to see
how an example code snippet is compiled, optimized and how type
inference is done. Change the code, change opcache settings and see what
happens. It is interesting to toy around with and it helps to get more
exposure to some impressive developments of recent years.

> The interesting question would be how to configure it to ensure it doesn't 
> become a security issue.  We'd probably need to lock down the environment's 
> ini settings *hard* to make sure it can't do any outgoing communication at 
> all.

Trying to lock things down will also limit the example code that can be
run. And we run the risk of overlooking things. Maybe we could learn
from other languages, how they set up their sandbox environments.

> If we need hosting for that, I work for a hosting company and we're happy to 
> help.

I think we all highly appreciate that offer.

Regards,
Dik Takken

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to