Live data from Hacker News

Pharen: A lisp that compiles to PHP

scriptor.github.com

11–20 of 43 posts

Re: Pharen: A lisp that compiles to PHP

#12

Hey Scriptor, neat project! What are the major differences between Pharen and Lisphp? (covered here:) http://news.ycombinator.com/item?id=1488160

The big one is that Lisphp is an interpreter while Pharen is a compiler. Lisphp takes source code and just runs it, which means that it's lisp code running on Lisphp, which in turn is running on the PHP interpreter.

Pharen generates regular PHP source files that you can then throw wherever PHP works.

Re: Pharen: A lisp that compiles to PHP

#13

Hey Scriptor, neat project! What are the major differences between Pharen and Lisphp? (covered here:) http://news.ycombinator.com/item?id=1488160

The big one is that Lisphp is an interpreter while Pharen is a compiler. Lisphp takes source code and just runs it, which means that it's lisp code running on Lisphp, which in turn is running on the PHP interpreter. Pharen generates regular PHP source files that you can then throw wherever PHP works.

How do they compare performance wise? I've tried some 'toy' lisp programs in Lisphp and was pretty disappointed at the speed, does Pharen fare better in this respect?

Re: Pharen: A lisp that compiles to PHP

#14
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…

Does this only work on the newest version of PHP? Compilation of closures, I presume, requires that PHP support closures, right?

Re: Pharen: A lisp that compiles to PHP

#15
post #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!

Thanks Mahmud :)

Efficient sequences are what I'm working on right now, particularly trying to make persistent versions of the major data structures in PHP.

Tail calls are another thing, though with PHP 5.3's gotos they could be done (who'd have thought that feature would ever be useful?) Could you elaborate on how I could improve efficiency for macros?

Re: Pharen: A lisp that compiles to PHP

#16

Earlier quoted context omitted.

The big one is that Lisphp is an interpreter while Pharen is a compiler. Lisphp takes source code and just runs it, which means that it's lisp code running on Lisphp, which in turn is running on the PHP interpreter. Pharen generates regular PHP source files that you can then throw wherever PHP works.

How do they compare performance wise? I've tried some 'toy' lisp programs in Lisphp and was pretty disappointed at the speed, does Pharen fare better in this respect?

I haven't done any real benchmarks, but theoretically Pharen would have at least the same order of magnitude performance as regular PHP. The main things slowing it down is the memory overhead needed for using lexical scope.

Re: Pharen: A lisp that compiles to PHP

#17
post #14
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…

Does this only work on the newest version of PHP? Compilation of closures, I presume, requires that PHP support closures, right?

Nope, it should work for PHP 5.2 as well. Closures are implemented using a static member on a class that handles all the lexically scoped variables, not PHP 5.3's native closures.

Re: Pharen: A lisp that compiles to PHP

#18
post #14

Earlier quoted context omitted.

Does this only work on the newest version of PHP? Compilation of closures, I presume, requires that PHP support closures, right?

Nope, it should work for PHP 5.2 as well. Closures are implemented using a static member on a class that handles all the lexically scoped variables, not PHP 5.3's native closures.

ok, that is killer. awesome work!

Re: Pharen: A lisp that compiles to PHP

#19
post #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!

Thanks Mahmud :) Efficient sequences are what I'm working on right now, particularly trying to make persistent versions of the major data structures in PHP. Tail calls are another thing, though with PHP 5.3's gotos they could be done (who'd have thought that feature would ever be useful?) Could you elaborate on how I could improve efficiency for macros?

Macros don't need to be efficient, only accurate :-) Don't sweat hygiene too much, just implement GENSYM and you should be fine.
Post reply on HN