1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Using C "from" PHP

Discussion in 'PHP' started by Chetan Tudor, May 12, 2016.

  1. #1
    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.
     
    Chetan Tudor, May 12, 2016 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    No.
     
    PoPSiCLe, May 12, 2016 IP
  3. Chetan Tudor

    Chetan Tudor Greenhorn

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    6
    #3
    Why ? Just tell me the points, I will study them by myself.
     
    Chetan Tudor, May 12, 2016 IP
  4. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #4
    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...
     
    Vooler, May 12, 2016 IP
    ThePHPMaster likes this.
  5. Chetan Tudor

    Chetan Tudor Greenhorn

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    6
    #5
    Thank you.
     
    Chetan Tudor, May 12, 2016 IP
  6. NetStar

    NetStar Notable Member

    Messages:
    2,471
    Likes Received:
    541
    Best Answers:
    21
    Trophy Points:
    245
    #6
    No?

    So if php cannot handle the task or efficiently handle it your answer is....no don't use C................................. Hmmmmmmmmm
     
    NetStar, May 12, 2016 IP
  7. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #7
    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.
     
    PoPSiCLe, May 13, 2016 IP
  8. NetStar

    NetStar Notable Member

    Messages:
    2,471
    Likes Received:
    541
    Best Answers:
    21
    Trophy Points:
    245
    #8
    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....
     
    NetStar, May 14, 2016 IP
  9. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #9
    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....
     
    Vooler, May 15, 2016 IP
    PoPSiCLe likes this.
  10. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #10
    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.
     
    PoPSiCLe, May 15, 2016 IP
  11. NetStar

    NetStar Notable Member

    Messages:
    2,471
    Likes Received:
    541
    Best Answers:
    21
    Trophy Points:
    245
    #11
    My mistake. I thought you simply said..."No."
     
    NetStar, May 21, 2016 IP
  12. Chetan Tudor

    Chetan Tudor Greenhorn

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    6
    #12
    Thanks, to all of you !
     
    Chetan Tudor, Jun 9, 2016 IP