开发者

Is it possible to create PHP extensions in Haskell?

开发者 https://www.devze.com 2023-03-06 17:27 出处:网络
Is it possible to create PHP extensions开发者_JAVA技巧 with Haskell? Usually PHP extensions are written using C. Is using Haskell FFI to provide functionality for a stub C extension possible (or even

Is it possible to create PHP extensions开发者_JAVA技巧 with Haskell?

Usually PHP extensions are written using C. Is using Haskell FFI to provide functionality for a stub C extension possible (or even a good idea)?

What are the caveats to such an approach? Does Zend perform some magic in the background that would disrupt such a scheme?


You can certainly do this, though I'm not sure anyone has tried. Haskell interoperates with C via its FFI mechanism, and you can certainly:

  • Call Haskell from C

so if you can call C from PHP, and that C calls Haskell, you're in business.


Why would you want to do this? Faster, safer, simple code for your core algorithms or safety-critical code, perhaps. Or to take advantage of say, a parallel or multicore server backend via Haskell.


Yes, its possible. Just make sure you wrap everything and translate arguments between php -> c -> haskell and the way back correctly.

0

精彩评论

暂无评论...
验证码 换一张
取 消