Live data from Hacker News

Pharen: A lisp that compiles to PHP

scriptor.github.com

1–10 of 43 posts

Re: Pharen: A lisp that compiles to PHP

#2
Hi everyone, I'm the creator of Pharen. Feel free to ask me questions or remind me why this is a terrible idea. :)

Yes there are a lot of issues with cross-language compilers. That said, Coffeescript: http://coffeescript.org, which compiles its own language to Javascript has had a lot of success and is being used in production. So it's at least possible to use languages like this.

The extra layer of abstraction is a big hurdle. When debugging you have to find the source of the problem in the PHP, though ideally after that you can just find the matching Pharen code and go from there. One of the things on my todo list is to have at least a rough line-to-line tracker built, so that it could at least tell you the general location a problem happened, if not the exact line.

Translating docs and example code for existing libraries into Pharen is a bigger issue, I think. Mainly because Pharen emphasizes a functional style of coding while most PHP code assumes you are doing things imperatively. This is something Clojure has to deal with in terms of Java interop so again it shouldn't be too hard to get around.

In terms of efficiency there is tail recursion optimization (converts a recursive function to having a while loop at the end) and a persistent sequence library in the works that would make functional looping through a list about as fast as imperative iteration. More aggressive optimizations might come in the future.

If you're interested, feel free to contribute: http://scriptor.github.com/pharen/contribute.html. If you use IRC you can come hang out (or berate me personally) on #pharen on Freenode. Any suggestions or ideas are welcome.

Re: Pharen: A lisp that compiles to PHP

#3
post #2

Hi everyone, I'm the creator of Pharen. Feel free to ask me questions or remind me why this is a terrible idea. :) Yes there are a lot of issues with cross-language compilers. That said, Coffeescript: http://coffeescript.org , which compiles its own language to Javascript has had a lot of success and is being used in production. So it's at least possible to use languages like this. The extra layer of abstraction is a…

What is it for?

Re: Pharen: A lisp that compiles to PHP

#4
post #3
post #2

Hi everyone, I'm the creator of Pharen. Feel free to ask me questions or remind me why this is a terrible idea. :) Yes there are a lot of issues with cross-language compilers. That said, Coffeescript: http://coffeescript.org , which compiles its own language to Javascript has had a lot of success and is being used in production. So it's at least possible to use languages like this. The extra layer of abstraction is a…

What is it for?

Originally, for fun!

It gives you a chance to use Lisp's syntax and mentality if you're stuck with PHP on the backend. Moreover, you have features like macros and lexical scope, which can be useful.

Re: Pharen: A lisp that compiles to PHP

#6
This actually doesn't suck. I was expecting something much much worse, but I was pleasantly surprised. If the author just focuses on a few primitives and how to make them as efficient as possible (i.e. closure efficiency, tail-calls, macros, efficient list representation, etc), if he just gets those right, others can always use it as a target and develop more comfortable lisp substrates on top of it.

Cheers!

Re: Pharen: A lisp that compiles to PHP

#8
post #5

Is the intended user a Lisp programmer forced to work on a php code base...or a Lisp programmer looking to take advantage of some of php's native server scripting features?

Both really, since interop with PHP is pretty easy so you can use those native features in a lispy way.

Re: Pharen: A lisp that compiles to PHP

#9
post #7
post #5

Is the intended user a Lisp programmer forced to work on a php code base...or a Lisp programmer looking to take advantage of some of php's native server scripting features?

HAH! I think, strictly, the former. (I actually laughed out loud at this :_)

Fair enough. I've never programmed in lisp. I just assumed that lisp didn't have native server abstractions like $_REQUEST - and that Pharen may expose those.
Post reply on HN