Phalanger: PHP .NET compiler revealed
- Posted: Mar 16, 2005 at 3:12 PM
- 52,646 Views
- 28 Comments
Loading User Information from Channel 9
Something went wrong getting user information from Channel 9
Loading User Information from MSDN
Something went wrong getting user information from MSDN
Loading Visual Studio Achievements
Something went wrong getting the Visual Studio Achievements
Right click “Save as…”
Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation,
please create a new thread in our Forums,
or
Contact Us and let us know.
Follow the Discussion
Oops, something didn't work.
What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in. You need to be signed in to Channel 9 to use this feature.What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in and view them all on your notifications page.sign up for email notifications?
Did those guys also make it possible to create PHP files in Visual Studio.net (with statement completion, intellimenus)?
I thought Zend was a compiler of sorts but I guess it interprets the bytecode it generates (like early JVMs) so it's still not as fast as a CLR based system.
I like the way people approach the CLR with "I wondered if it was possible to for it to run a dynamic language" - I've seen that from the developers of quite a few different projects before. Of course it's possible for the CLR to run any language at some level as it is a turing-complete machine even in verifyable mode. To run a dynamic langauge just means the compiler just has to throw out a lot more instructions to handle things like late binding and run-time type conversions. OK, the CLR isn't ideally suited to all langauges which means a langauge-specific runtime like most LISP implementation use would be faster, but the possibility to target the CLR is there for any language.
Compiling it to managed means that you can interoperate with other managed languages really naturally. So, you can take a PHP project and add new "modules" to it that you write in, say, C#, then import the C# dll into your Phalanger project, and compile.
So, it's more than just performance (not to mention security), but, you are right, it was kind of a "let's see if we can do this" kind of thing (which many school projects are, initially) and they did! Smart kids (well, they look like kids to me).
C
Check out their site and ask them questions and give them feedback!
EDIT: From the authors' site:
Our integration introduces the PHP language into the VS.NET in a specific project type supporting syntax highlighting and compilation. PHP files are compiled to .NET Framework executables and can be executed and even traced from the VS.NET environment using the generated debug information.
To make script development and debugging more comfortable, the IntelliSense support for PHP projects and direct PHP variable insight may be added in future versions but this is not a priority for the current project. The VS.NET integration is rather some kind of add-on to the Phalanger.
C
Stephen
C
?
There is also another project called IronPHP which is still in the early stages.
Looks like cool stuff though, can't wait to see the video at lunchtime.
Just wanted to add that it's not just Tomas and me who worked on Phalanger - the impression you might get watching the video. Our team consists of six people (all of us are students) and I would like to name the other four that could not attend the Whidbey Compiler Lab. It's:
Jan Benda
Martin Maly
Pavel Novak
Vaclav Novak
No, it's not related to neither of these projects.
As one of that guys who you are speaking about here
We made a simple integration to VS2003. It includes syntax highlighting, syntax checking, a simple PHP project where files can be stored and which can be compiled (by F5) and debugged (experimental feature that sometimes doesn't work well). IntelliSense and code completion and other cool features of VS are not supported yet. We are working on integration to Whidbey which is much easier to program because it can be written in C#. Nonetheless, we focus more to the compiler and run-time than to the integration to VS.
Cool. It is quite an impressive feat even so.
One thing I would ask, was the fact that you could get the source code to PHP and therefore how it worked internally a factor in your choice of PHP over any other scripting language? I guess I am looking for some sort of Open Source helped us to do what we wanted sort of statement
No it isn't yet. As I have written in the previous post a simple debugging is available nowadays. Debugging of web applications doesn't work now. We know that it would be very useful so we are planing to do it in our new integration package targeting Whidbey and maybe we will upgrade also VS2003 package.
We plan to migrate to .NET Framework 2.0 soon which will enable us also to bring Phalanger to Mono. Why? Because we use MC++ for parser implementation (there is no Bison implementation which produces C# code as far as we know - if you know about some which works perfectly let us know, please). And MC++ compiler is not avaiable on Mono yet. We will rewrite our parser to C++/CLI producing pure IL which will, we hope, enable Phalanger managed binaries to be working on Mono (I think there is also a support for ASP.NET on Mono). Of course, native extensions shipped with PHP will not work there. Only those extension which we implement (or someone else does - anybody can add his or her functionality to Phalanger clas library).
We had to browse through the sources of PHP quite often, but only because of the lack of documentation. If PHP had some kind of language specification, the Zend API was well documented and so on, we would have never felt a need for the sources. So yes, Open Source helped us, but we would probably prefer closed source + good documentation instead.
I believe the Mono guys ported Jay (Java sort of bison which uses same syntax) to produce CS and written in CS. Unfortunately it is GPL.
As far as I know, the ZPS (and other accelerators) are rather some kind of cache. They keep an internal representation of the code in memory, so they do not have to go through the parsing stage when the page is requested again. Actually it might be viewed as a bytecode but it's still interpreted.
Yes. The challenge is to identify which dynamic features are really dynamic (and also the contexts in which they are dynamic) and devise sophisticated optimizations. For example, if you only use reflection and compile every function invocation as a call to Type.InvokeMember, you would end up with a very slow code.
Phalanger guys "You take the code that you wrote for original php. You compile it and you dont have to edit a single line, It Just Works"
Ok this was a pure troll 
So if this small grp of students achieved this, what prevents VB6 guys doing the same
As they mention, there will be some additional stuff to be done should you want to call a .NET method that takes generic type from PHP..
So essentially it is quite understandable why having pure VB6 in .NET just doesn't make that much sense.
This from someone who's done a lot of VBA coding recently. And C#...
Ay...
Anyway,phalanger is really cool.what's IBM and ZEND thinking about?
I would suggest to give this compiler free also for comercial use. It seems that this is importamt :O)
It already is. See the license http://php-compiler.net/License.htm.
What an outstanding video and project, well done.
Everything I have seen and tested tonight (just the basics) it has worked like a charm. Tomorrow I am going to attempt porting an old application that is still running on a production server.
One negative thing I did notice though is the lack of the ability to call any .NET function straight from Phalanger. Although I know you do not want to change the php syntax, it should be considered as an option. From my point of view I think it is important that Phalanger runs unmodified php but it is not important that php runs unmodified Phalanger.
Also another treasured feature of .NET is output caching for web pages and especially user controls and I would LOVE to see a similar form caching available for Phalanger.
Once again, great work guys.
Hi!
Thanks. Well, there are some bugs. We will release a bug fix in a couple of days. So maybe it will be better for you to wait until then.
You are absolutely right. We know about this limitation and we plan to enable that. Grammar needn't to be changed to do that. But it's a lot of work so it will take some time.
For now, there is a workaround. You can add your own PHP functions written in C# (a kind of mediators) to class library as you will see if you download source code of the Phalanger Class Library. There is an opportunity to add assemblies of your own to the class library assembly set provided they follow the same code style as the Class Library. The process of extending class library is not well documented now, however we work in the doc.
We will consider this suggestion. Thanks.
Remove this comment
Remove this thread
close