5 ms·
I'v been thinking about using Php lately. I come from a C# background, so I was poking around to see what I would be missing or gaining from Php. Why haven't th
by DonnyV 15y ago
I'v been thinking about using Php lately. I come from a C# background, so I was poking around to see what I would be missing or gaining from Php. Why haven't they added a compiled option yet? I know you can use http://phpcompiler.org http://phpcompiler.org compiler to do it but why hasn't it just been added to the project? The speed increase is well worth it. Also I noticed Php doesn't have generics or Template classes. I use these a lot in my C# libraries. Anyone know if thats going to be added anytime soon? I do like that its used everywhere. Also looking for a good MVC framework for Php like Asp.net MVC.
UPDATE
Can you please stop down voting. I'm not hating on Php, read my other comments below.
- darklajid 15y agoDidn't downvote you, but 1) You're hijacking the thread with something unrelated and better suited for some online research or sites like SO 2) According to your questions you're not investigating PHP, you're looking for C# in disguise/in another set of clothes.
- DonnyV 15y agoYeah your probably right about asking this here. I was hoping for some Php experts maybe to point me in the right direction. I'm not trying to hate on Php just want to learn an open source framework or language that has similar features to C#. I really don't want to learn Java because I think thats a dead language. I'd rather use Mono but they don't have very good support for asp.net mvc.
- seanp2k2 15y agoCheck out HipHop which transforms PHP into C++ then compiles that using G++ https://github.com/facebook/hiphop-php#readme https://github.com/facebook/hiphop-php#readme This is what Facebook uses. That aside, PHP is plenty fast as long as you avoid Zend and design your apps correctly for what you're doing. Lots of bad stuff out there giving PHP a bad name, like Magento.
- mgkimsal 15y agoHave a look at some jvm-based languages/frameworks. Grails/Groovy, and Rails with JRuby may be interesting to you. Both Groovy and JRuby have strong metaprogramming aspects, which may be of interest. Heck, even Play! might change your mind about Java. In the PHP world, there's a huge number of choices/options out there, and finding something that fits your style can be a challenge (because, until you know your style, you don't know what fits). http://www.reddit.com/r/php http://www.reddit.com/r/php would probably be a good place to ask these questions too.
- phpnode 15y agoI too wish php had a widely supported compiler, but in reality it's not something that most projects require. The overhead of interpreting php is a lot lower than e.g. making a single db call. Also, in the most common usage scenarios, PHP processes only live for the time it takes to deal with each request, so how do you approach that if you're compiling your code? Keep spinning up new processes or rewrite your application code? Regarding MVC frameworks, try Yii - http://www.yiiframework.com http://www.yiiframework.com
- DonnyV 15y agoThese speed charts are why I would compile Php. http://naspinski.net/post/AspNet-vs-php--speed-comparison.aspx http://naspinski.net/post/AspNet-vs-php--speed-comparison.as... It seems worth it too me. Thanks for the Yii link.
- phpnode 15y agothose charts don't say whether APC is enabled, which leads me to suspect that it isn't. APC is an opcode cache that greatly enhances php performance, no one runs a high traffic website without using APC
- DonnyV 15y agoDid not know about APC...nice. Does APC just compile it after the first time and save it in memory? Can you use APC to create a packaged compiled file?
- zombielifestyle 15y agobytecode caches (like APC) store the bytecode on the fly in memory. you can't create somthing like a "binary" file. edit: at least they're not intended to create "binaries". you can probably mess around with APC and make php look and behave like a compiled language. but you won't gain any notable speed improvements beyond the on the fly caching. edit2: you can store php projects in a jar like file, caller phar. http://php.net/phar http://php.net/phar
- Pedrom 15y agoPHP is not strongly typed as C# so it doesn't need generics or templates or better said it wouldn't make much difference on performance unless it would be compiled (which is not the case on the standard). I don't think that an official compiler is planned but HipHop (http://en.wikipedia.org/wiki/HipHop_for_PHP http://en.wikipedia.org/wiki/HipHop_for_PHP) might change that in the future. There are plenty of MVC Frameworks for PHP you can try with SilverStripe or CakePHP.
- corford 15y agoAlthough I don't use it I have heard the symfony2 is one of the better MVC frameworks out there. The same people have also made quite a nice templating language called twig that you may also want to look at (http://twig.sensiolabs.org/ http://twig.sensiolabs.org/).
- Udo 15y agoWhile it's a good idea to look around what language A could borrow from language B once in a while, it's important to not fall into the trap of imitating B at all costs in A. In this specific case, I don't think it's a good idea to do C#/ASP.Net in PHP and vice versa. Most PHP hosting environments do have a compile-once-run-many-times paradigm by virtue of opcode caching. The advantage over a typical Java or .NET app server is that you can change files and they get automatically recompiled on the fly. So for all intents and purposes, PHP is usually running a piece of in-memory compiled bytecode. There are many MVC frameworks for PHP, for any interpretation of "MVC" you might want. I'm sure you can find one that's closely modeled after ASP.net, but again I'm not sure this is a productive undertaking in principle.
- deleted 15y ago[deleted]