Live data from Hacker News

Pharen: A lisp that compiles to PHP

scriptor.github.com

21–30 of 43 posts

Re: Pharen: A lisp that compiles to PHP

#21
post #20

Is this modeled after any particular Lisp? It looks a little bit like Clojure.

I'd say it's closer to Clojure than others lisps, but there are still some differences. For example, no keywords (:foo, :bar, etc.) and lists are not functions of their members. This can get a little confusing with Pharen's array access syntax:

    (:some-list 1)
Here, some-list is just a variable while the : prefix tells Pharen that you are trying to index into it.

Re: Pharen: A lisp that compiles to PHP

#22
From reading the examples this looks awesome, I'll give it a try tomorrow at the office. Is there a way to expand macros only and not do the compile-to-php step?

My current project involves generating php from a declarative definition and this could be just the right tool for the job! Maybe it will make switching to common lisp a lot easier once I learned enough of it :D

Re: Pharen: A lisp that compiles to PHP

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

> 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.

You could always just add the S-Expression that became the php code as a comment. From there it should be trivial to find it in the Pharen code.

Re: Pharen: A lisp that compiles to PHP

#27
post #9
post #7

Earlier quoted context omitted.

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.

While no or few lisps have that sort of thing baked in natively, they mostly have libraries that expose it, which is arguably better in any case.

Re: Pharen: A lisp that compiles to PHP

#28
post #4
post #3

Earlier quoted context omitted.

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.

Fun is good.

I just wondered if it had been built for a specific project and if so what problems it was trying to solve.

It's funny - I've spent the past few years thinking about high-level languages that would compile down to lisp. Recently I've seen a number that go the other way.

Re: Pharen: A lisp that compiles to PHP

#29
post #26

I pretty much like the partial such as (map (* 2) [1 2 3]). Do you plan on adding something like (map (/ _ 2) [1 2 3]) like Arc or a #(.. % ..) clojure equivalent?

Possibly, it might have a use in some web framework ideas I have (such as designate a series of actions to perform on something like input data).

Re: Pharen: A lisp that compiles to PHP

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

This is really cool and for the most part the syntax seems to make sense.

One thing I don't understand is why there is special unnatural-looking syntax for dictionaries. It is inconsistent that comma=whitespace everywhere else. Perhaps something like:

(array "a"=>1 "b"=>2)

Note that this currently compiles to array("a", =>1, "b", =>2)

Post reply on HN