I wonder if it is a good idea to create DLLs in C for using them in PHP for tasks that PHP cannot handle. Thank you.
Yes! It is a very good idea if: you really know that PHP doesn't have such functionality that you are implementing in shared library you know how to port that dynamic link library code later to other OS's (e.g. .so file on linux) - if required you know how to create PHP extension (even better) that can later be compiled for different platforms and different versions of PHP - check the bridging tool called SWIG that generates code that can be phpized - if required it is really a performance issue that you think C can play a great role in and boost your application speed your task is algorithmic and does huge calculations you need to do something very low level (i.e. OS level) that PHP doesn't support you are after real parallel processing and utilize the power of multi-core you know more to do in C than you know in PHP you know how to effectively utilize piece of of functionality you have in said DLL And No, if: you are not sure if same feature does already exist in PHP you do are not good at C you think you can waste memory you need to host application on Linux but you just know how to create MS Windows DLL I can go on and on with Yes and No, but my personal opinion is "Yes" because by doing this you will learn a lot of new things not only in PHP but in C as well while bridging. As I have more than 18+ years of experience in both the programming languages I can personally go with any either for web programming and/or desktop/server end programming, but mostly I prefer using C or C++ to build additional functional that certain scripting language doesn't support and/or is slow in (e.g. PHP, Python etc), but I search first and if I find it built-in within the language am scripting in I do not go for reinvention of wheel. Hope it helps. Stay well...
No? So if php cannot handle the task or efficiently handle it your answer is....no don't use C................................. Hmmmmmmmmm
No. My answer was "no" as in why the hell would you limit the solution to Windowsbased machines? If you need a DLL file to do something PHP can't do, then perhaps PHP wasn't the right choice to begin with.
Are you serious with that response? I'm sure there are several people at FaceBook, Google, Twitter, Ebay, and other huge companies that use multiple languages on their platform that would raise an eye brow to you.... But then again you know it all....
Guys! My request to you would be to show responsibility, you are educated, highly skilled, and valuable resource to this community, especially learners. You both have an opinion so do I, and we must respect each other's option. PoPSiCLe is not a newbie in programming, thus his opinion and stance does matter ofcourse so does our. Winning an argument in such a tone will not only demote the thread but leave bad impression on new comers and the community. Dear NetStar When facebook invented HIPHOP out of PHP (porting PHP code to standalone C++ based multi-threaded servers) the whole world saluted them, when google created GO language many said it might replace C language but ultimately google itself (much of it) returned to Python, and still google has a small number of developers using it's own language called GO. Neither PHP nor C is created by you or me, it is matter of fact (in this case) creating C based shared library for PHP might be waste of time if same functionality does exist in PHP; Did any amongst us asked the poster what exactly is the problem he/she is addressing? NO! So? PoPSiCLe is right at one point that the poster might have selected wrong programming language to solve the problem it was not meant for! And there is nothing wrong in that, he is right and I do agree. Just for instance: I would be a fool to use PHP for creating Disk fragmentation tool (I should only create interface) I would be a fool to use C to write a social networking web based application (using CGI) I would be a fool to create a Graphic manipulation GUI application in Python I would be a fool to create Desktop Publishing application using TCL TK I would be a fool to code data tidying application in javascript Multiple technologies are used when certain main technology is lacking features, but first let's ask the poster what exactly he is trying to accomplish; may be we have a solution for him Please! Stay well....
Learn to read, NetStar. What I said was that creating DLLs will limit you to run the solution on Windows-based servers, which is severly limiting your choices. Especially since there are already way better ways of interfacing with C than creating DLLs. However, interfacing with low-level interfaces from PHP, able to manipulate the system itself opens up a LOT of potential security problems. Even more so than "normal" PHP-code. So depending on what the IP wants to do, it might be prudent to use something else than PHP from the get-go.