Live data from Hacker News

PHPPHP: a PHP VM in PHP

github.com

21–30 of 52 posts

Re: PHPPHP: a PHP VM in PHP

#22

I'm the author of this library. I figured I'd answer a couple of questions as to why I wrote this. First, it was something that I always wanted to do. For no particular reason other than I wanted to do it. I knew it was possible, but possible and doing it are two very different things. Second, it was far easier than I thought. The time to the initial commit (basic working VM) was only about 6 hours of work. So it's n…

Serious achievement. Well done!

Re: PHPPHP: a PHP VM in PHP

#23
post #8

PHPPHP is well on its way to being a simple PHP command line debugger. To my knowledge there currently isn't a good tool for command line debugging on PHP.

phpsh[1] by Facebook is good. Ironically, it's written in Python. [1] http://www.phpsh.org/

[deleted]

Re: PHPPHP: a PHP VM in PHP

#24
post #19

I'm the author of this library. I figured I'd answer a couple of questions as to why I wrote this. First, it was something that I always wanted to do. For no particular reason other than I wanted to do it. I knew it was possible, but possible and doing it are two very different things. Second, it was far easier than I thought. The time to the initial commit (basic working VM) was only about 6 hours of work. So it's n…

With this brillant project, is it the end of nodejs hype ?

This has nothing to do with nodejs or any hype around it. Read the parent's comments on why he built this.

Re: PHPPHP: a PHP VM in PHP

#25

I'm surprised this wasn't done earlier. It's actually a quite common practice for a language to eventually write a compiler for it in said language; this is called bootstrapping a compiler [1], and makes the language "self-hosted". C is a notorious language in this case, and is the closest to the real chick-or-the-egg problem this is: how do you write a C compiler without a C compiler? C is often the lowest-level lan…

> how do you write a C compiler without a C compiler? C is often the lowest-level language compilers are written in, so in order to bootstrap a C compiler for a specific architecture / OS, you need to write the entire compiler in the target language (assembly).

Nope, you probably don't do that. You use a computer (host) where you already have a C compiler, and you compile the new compiler (which you wrote/ported). Then you run this new compiler, on the host, to generate executable code for the new architecture (target), i.e. cross-compile. You can use this cross-compiler to (again) compile your ported compiler, but to run on the target architecture. You end up with a native compiler for your new architecture.

Though, there is no essential need to have a native compiler for an architecture. For example, you can program an AVR microcontroller in C without running any C compilers on the AVR itself.

Re: PHPPHP: a PHP VM in PHP

#26
post #25

I'm surprised this wasn't done earlier. It's actually a quite common practice for a language to eventually write a compiler for it in said language; this is called bootstrapping a compiler [1], and makes the language "self-hosted". C is a notorious language in this case, and is the closest to the real chick-or-the-egg problem this is: how do you write a C compiler without a C compiler? C is often the lowest-level lan…

> how do you write a C compiler without a C compiler? C is often the lowest-level language compilers are written in, so in order to bootstrap a C compiler for a specific architecture / OS, you need to write the entire compiler in the target language (assembly). Nope, you probably don't do that. You use a computer (host) where you already have a C compiler, and you compile the new compiler (which you wrote/ported). Th…

> Nope, you probably don't do that. You use a computer (host) where you already have a C compiler, and you compile the new compiler (which you wrote/ported). Then you run this new compiler, on the host, to generate executable code for the new architecture (target), i.e. cross-compile. You can use this cross-compiler to (again) compile your ported compiler, but to run on the target architecture. You end up with a native compiler for your new architecture.

Ah, yes, I tried to explain exactly that in the last paragraph I wrote. Is what you're describing different from what I described there?

Re: PHPPHP: a PHP VM in PHP

#27
post #17

Uh, where's all the code? I'm guessing I'm missing something, but a lot of the classes in the lib/ folder invoke classes that I just can't find in the project. Are these external dependencies that weren't called out in the README, or is not all of the code in master actually functional yet?

Which classes are you specifically missing?

[deleted]

Re: PHPPHP: a PHP VM in PHP

#28
post #25

Earlier quoted context omitted.

> how do you write a C compiler without a C compiler? C is often the lowest-level language compilers are written in, so in order to bootstrap a C compiler for a specific architecture / OS, you need to write the entire compiler in the target language (assembly). Nope, you probably don't do that. You use a computer (host) where you already have a C compiler, and you compile the new compiler (which you wrote/ported). Th…

> Nope, you probably don't do that. You use a computer (host) where you already have a C compiler, and you compile the new compiler (which you wrote/ported). Then you run this new compiler, on the host, to generate executable code for the new architecture (target), i.e. cross-compile. You can use this cross-compiler to (again) compile your ported compiler, but to run on the target architecture. You end up with a nati…

Sorry, I missed that, was distracted by your not-really-correct statement above :)

Re: PHPPHP: a PHP VM in PHP

#29
post #28

Earlier quoted context omitted.

> Nope, you probably don't do that. You use a computer (host) where you already have a C compiler, and you compile the new compiler (which you wrote/ported). Then you run this new compiler, on the host, to generate executable code for the new architecture (target), i.e. cross-compile. You can use this cross-compiler to (again) compile your ported compiler, but to run on the target architecture. You end up with a nati…

Sorry, I missed that, was distracted by your not-really-correct statement above :)

My mistake. I was trying to illustrate the more theoretical problem of bootstrapping a compiler without a compiler, since I personally find that fascinating. These problems were really solved years ago, and their only place nowadays is in an educational context.
Post reply on HN