Re: PHP Extensions: C or C++?

From: Date: Thu, 26 Jul 2001 21:47:44 +0000
Subject: Re: PHP Extensions: C or C++?
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-61104@lists.php.net to get a copy of this message
J Smith wrote: > > I have a few PHP extensions that I'd be willing to share but I've never > done this sort of thing before. I wrote a few extensions for work, and my > company sees no problem in donating them to the open source world and to > the PHP project, but I'm curious about something: > > Are extensions for PHP required to be coded in C, or will C++ do? I'm a C++ > guy myself, and since PHP is largely written in C, does this cause a huge > problem? If there's enough interest in any of my extensions, I'd consider a > re-write from C++ to C, but I don't want to do that if I don't have to. > > The only extension really ready for prime-time right now is a rather simple > Porter stemmer, written in ANSI/ISO C++ using things like the standard C++ > string library and such. It's a simple extension that we're using to make > the search engine we're building a bit easier to manage. Any future > extensions are going to be focused on making search engines easier to > implement in PHP. (We're building a search engine that uses PHP.) Which search engine is this? > Any interest in that sort of thing? And if so, C or C++? Your interface to PHP is C. This won't change in a while, so if you want to write an extension in C++, it will end up as a mix of C and C++. If you can make it work, great. But I think you're going to run into a lot of hassle. For example, when you want to return a string from a PHP function that you've built with the standard C++ string library, you have to do additional conversions for every single string value. Unless you save a lot of time from using C++ components you've already written and such, there is great potential for wasting both a lot of time and cpu this way. :-) - Stig

« previous php.dev (#61104) next »