Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I would like to hear opinions from people who have used a language that compiles to php. One such language I know is Haxe. Other ones I've read about are Kira and Pharen.

How well do these languages integrate with PHP? Is it relatively easy to write a plug-in for a PHP CMS in them?

How mature are their implementations and tools?

Would you recommend them to someone who has to use a php cms but hates php?

share|improve this question
1  
HaXe is good. Atleast give it a go. I just installed it, and uploaded and tested my first PHP page in 9minutes (including time to download haxe), it's easy and there's a great community behind it with lots of docs –  J.T.S. Jan 13 '11 at 20:24
    
I have created pratphall.org which is a typed language that compiles to PHP. –  Chad Retz Mar 1 '13 at 22:34

5 Answers 5

I'm the creator of Pharen, which compiles a Lisp dialect to PHP. To answer your questions, it integrates pretty well with PHP. It's easy to include existing libraries call functions/use their objects.

As for maturity, there hasn't been any production use of Pharen code yet. While in terms of the language everything you'd want is there and working, things like deployment still need a little extra effort.

That said, if you do choose Pharen I'd be happy to help out however I can. Please let me know if you have any other questions!

share|improve this answer
    
Comment not answer. –  Josh K Jan 13 '11 at 16:51
6  
I answered the questions of how well it integrates with PHP and how mature it is. –  Scriptor Jan 13 '11 at 18:24
    
@Scriptor: With no other information then "I created it, it integrates well." –  Josh K Jan 13 '11 at 21:58
    
"It's easy to include existing libraries call functions/use their objects." Which should be enough for working with most external libraries, including plugin API's for a CMS. The original post wasn't too specific about what integration means. I also explained the state of its (lack of) maturity. –  Scriptor Jan 13 '11 at 22:02
    
Thank you for your answer and for your offer to help me. Is pharen comptabile with any other lisp? Does it have its own operators or does it just use the ones in php? For example, does the == in pharen behave the same way as in php? –  Kim Jan 14 '11 at 16:12

Josh K is right on some counts, it is better to know php in order to better target the php runtime. However, the main reason for this isn't that haxe is a bad compiler, but that php is such an "idiosyncratic" language.

Php has an incredible amount of functions in its base namespace. So, there's a lot of reserved keywords and special functions that you have to know about in order to prevent naming conflicts. Some people are fine with this, I think it's horrible language design. HaXe gets around this issue by creating it's own namespace in php.

Php automatically turns an integer to a float on overflow. This of course breaks strict typing that languages like HaXe rely on for type safety (and to enable simple things like fast hashing algorithms). I think this is another terrible language feature. Also, haXe can't help here, because this php behavior can't be changed.

So, there you go. I think haXe makes php better because it cleans up a few (perceived) language flaws for php. However, there are so many weird things about php, that you end up needing to learn it well in order to fix some of its idiosyncrasies.

All that being said, the haXe language is pretty amazing. It lets you organize your php code into better namespaces, has fairly sophisticated type system, has some conditional compilation options for handling php specific issues, and has a few nice documentation operations. For those reasons alone, it's not a bad choice to design a sophisticated library... even for something like php.

Relevant links:

php magic: http://haxe.org/doc/advanced/magic

(also look for "platform quirks" in the community section of the main haxe.org site)

share|improve this answer
    
Thanks for your answer. Did you have any issues calling php from haxe or vice versa? –  Kim Jan 17 '11 at 8:13
    
So PHP (dynamic language) has issues with haXe (depends on static typing)? Amazing! PHP is a slightly strange language, but given it's roots in Perl it is understandable. What you believe to be "horrible language features" and what is "standard dynamicism" seem to be quite similar. –  Josh K Jan 18 '11 at 14:11
1  
You can have static language features alongside dynamic runtime features. They're not mutually exclusive. HaXe uses the "Dynamic" Type indicator for this purpose. Namespace and math operations don't really have anything to do with language dynamicism. These are just quirks of php. –  jdonaldson Jan 18 '11 at 15:54

Horrible Garbage

I used haXe on the recommendation of someone and would never recommend that to anyone for any reason.

Cross compiling between languages leads to confusion, mistakes, and errors. It also makes debugging a monumental task.

Would you recommend them to someone who has to use a php cms but hates php?

No! I would recommend you either learn PHP properly or use a different CMS. Since it seems you don't have a choice in the CMS part the other option is to learn the language and deal with it.

How mature are their implementations and tools?

Young at best, unstable at worst. You won't find a lot of support for them.


It sounds like you have the job of writing something for a PHP application. Besides the obvious issues that your code would have to import existing PHP functions / objects to work, and the above mentioned junk, anyone else working on this is now going to have to learn your language to language compiler. Otherwise they are going to be messing with the flimsy "PHP" code that is the result. This also means that if they work on it you are going to have to reimplement those changes in your code, or risk loosing changes anyone else makes.

If you hate working with PHP, wait till you have to work with some of the code those languages output.


""Cross compiling between languages"

It leads to confusion, mistakes, and errors. When you write code that is getting translated into another language you are removing yourself from the initial source. What you write, and what get's generated is completely up to the compiler. Writing code to generate code does get confusing, you will make mistakes, and you will find errors you don't expect. I would not recommend you use them.

share|improve this answer
3  
Please try not to get too emotional about this and try not to make too many assumptions. What makes you think I didn't learn php "properly"? How else would I have come to hate it? The generated code is not an issue for me, as I don't wanna touch it. Debugging is not an issue, since I very rarely use a debugger. Other developers also aren't an issue, since most CMS plugins aren't big projects anyway. You make very broad claims about haxe. Can you please back them up with examples? It would be much appreciated. Also, how long ago did you use it? –  Kim Jan 13 '11 at 20:56
3  
So you are saying that the compiler creates buggy php code? That is one of those broad claims I would like you to back up with an example. Another broad claim is "Cross compiling between languages leads to confusion, mistakes, and errors." Please give examples for that. If you wanna discuss whether PHP is a language worth using, I am sure you will find thousands of people on the internet who will do that with you. I'm not one of them. –  Kim Jan 14 '11 at 7:19
7  
"Cross compiling between languages - It leads to confusion, mistakes, and errors". Strange, and here I was, thinking any compiler did just that - translating one language into another (like into assembly, C, JVM code...). –  foo Jan 14 '11 at 19:47
1  
Actually, being a professional programmer and having many languages/frameworks/APIs under my belt (java,c++,python,php,ruby,javascript,etc.), HaXe was a beacon of light for me. For the first time ever I encountered a language which I found had done things right, and which was "ok" on all sides. I'm unable to understand how someone can dislike it. For PHP, it's limited though. –  arnaud Mar 16 '12 at 9:51
1  
Fully agreed with most of terms (specially about haxe). But working with php using lisp syntax is really fun! So I want to be in such weird part of code just for fun. –  Heather Mar 16 '12 at 9:55

I've used numerous language translators, and in the end you always have to much around in the thing it is you're trying to avoid... So if you hate PHP, just wait until you have a really obscure issue that requires you to get neck-deep into it's bowels. Though, I must be a glutton, because I think targeting neko with haXe would be pretty cool.

share|improve this answer
    
All compilers are "language translators". Are you saying we should not use compilers? ;) Whether you have to "get neck-deep into its bowels" depends entirely on whether the compiler is doing its job well, which is exactly what I'm trying to find out. Judging from the answers here, I guess I will have to do my own investigation. –  Kim Jan 14 '11 at 19:42
    
I'd like to target Neko with haXe, but I don't want to depend on Apache's httpd. I like being able to have a choice on web servers. –  stesch Feb 6 '11 at 22:03

If it's to make a plugin for a PHP CMS, stay with PHP.

Although I use HaXe and finds it really really great, I do not recommend it in this case. It's simply too many indirections and the costs would be higher than the gains for just a small plugin.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.